Skip to main content

Updating Customer (UPDCUST)

The UPDCUST program is responsible for updating customer information in the banking system. It is used once in a flow starting from the BNK1DCS program. The program achieves its role by performing a series of steps including setting up data, validating customer titles, processing the update, and finalizing the transaction.

The UPDCUST program starts by setting up necessary data and clearing previous values. It then validates the customer's title against a list of acceptable titles. If the title is valid, it proceeds to update the customer information in the datastore. Finally, it completes the process by finalizing the transaction and returning control to CICS.

Where is this program used?

This program is used once, in a flow starting from BNK1DCS as represented in the following diagram:

Here is a high level diagram of the program:

Setups


Moving SORTCODE to COMM-SCODE

First, the SORTCODE is moved to COMM-SCODE to ensure that the communication sort code is set to the desired sort code.

           MOVE SORTCODE TO COMM-SCODE
DESIRED-SORT-CODE.


Clearing WS-UNSTR-TITLE

Next, spaces are moved to WS-UNSTR-TITLE to clear any previous values and prepare it for the new title.

           MOVE SPACES TO WS-UNSTR-TITLE.


Unstringing COMM-NAME

Then, the COMM-NAME is unstrung into WS-UNSTR-TITLE to extract the title from the customer's name.

           UNSTRING COMM-NAME DELIMITED BY SPACE
INTO WS-UNSTR-TITLE.


Evaluating WS-UNSTR-TITLE

Moving to the evaluation of WS-UNSTR-TITLE, the code checks if the title is valid by comparing it against a list of acceptable titles. If the title matches any of the valid titles, WS-TITLE-VALID is set to 'Y'. Otherwise, it is set to 'N'.

           EVALUATE WS-UNSTR-TITLE
WHEN 'Professor'
MOVE 'Y' TO WS-TITLE-VALID

WHEN 'Mr '
MOVE 'Y' TO WS-TITLE-VALID

WHEN 'Mrs '
MOVE 'Y' TO WS-TITLE-VALID

WHEN 'Miss '
MOVE 'Y' TO WS-TITLE-VALID

WHEN 'Ms '
MOVE 'Y' TO WS-TITLE-VALID

WHEN 'Dr '
MOVE 'Y' TO WS-TITLE-VALID

WHEN 'Drs '
MOVE 'Y' TO WS-TITLE-VALID


Handling Invalid Titles

If the title is not valid (WS-TITLE-VALID is 'N'), the code sets COMM-UPD-SUCCESS to 'N' and COMM-UPD-FAIL-CD to 'T', then exits the section.

           IF WS-TITLE-VALID = 'N'
MOVE 'N' TO COMM-UPD-SUCCESS
MOVE 'T' TO COMM-UPD-FAIL-CD
GOBACK
END-IF


Updating Customer Data

If the title is valid, the code performs the UPDATE-CUSTOMER-VSAM section to update the customer data in the datastore.

           PERFORM UPDATE-CUSTOMER-VSAM
*


Finalizing the Update

Finally, the code performs the GET-ME-OUT-OF-HERE section to complete the update process and exit the section.

           PERFORM GET-ME-OUT-OF-HERE.

Validation


Validating Customer Titles

First, the code initializes the variable WS-TITLE-VALID to a blank space. Then, it evaluates the variable WS-UNSTR-TITLE against a list of valid titles such as 'Professor', 'Mr', 'Mrs', 'Miss', 'Ms', 'Dr', 'Drs', 'Lord', 'Sir', 'Lady', and a blank space. If the title matches any of these, WS-TITLE-VALID is set to 'Y'. If none of these titles match, WS-TITLE-VALID is set to 'N'.

           MOVE ' ' TO WS-TITLE-VALID.

EVALUATE WS-UNSTR-TITLE
WHEN 'Professor'
MOVE 'Y' TO WS-TITLE-VALID

WHEN 'Mr '
MOVE 'Y' TO WS-TITLE-VALID

WHEN 'Mrs '
MOVE 'Y' TO WS-TITLE-VALID

WHEN 'Miss '
MOVE 'Y' TO WS-TITLE-VALID

WHEN 'Ms '
MOVE 'Y' TO WS-TITLE-VALID

WHEN 'Dr '
MOVE 'Y' TO WS-TITLE-VALID



Handling Invalid Titles

Next, the code checks if WS-TITLE-VALID is 'N'. If it is, it sets COMM-UPD-SUCCESS to 'N' and COMM-UPD-FAIL-CD to 'T', indicating that the update has failed due to an invalid title. The program then terminates the current operation with a GOBACK statement.

           IF WS-TITLE-VALID = 'N'
MOVE 'N' TO COMM-UPD-SUCCESS
MOVE 'T' TO COMM-UPD-FAIL-CD
GOBACK

Interim Summary

So far, we saw how the program handles the setup and validation of customer titles, including moving and unstringing data, and evaluating the validity of titles. Now, we will focus on the process and finalization steps, where the program updates the customer information and finalizes the transaction.

Process & Finalization


Update Customer Information

First, we perform the UPDATE-CUSTOMER-VSAM operation. This step updates the customer information in the VSAM datastore, ensuring that all the necessary customer details are correctly stored.

      *          Update the CUSTOMER datastore
*
PERFORM UPDATE-CUSTOMER-VSAM


Finalize Process

Next, we perform the GET-ME-OUT-OF-HERE operation. This step finalizes the process by executing a CICS RETURN command, which indicates the end of the transaction and returns control to CICS.

      *    The COMMAREA values have now been set so all we need to do
* is finish
*
PERFORM GET-ME-OUT-OF-HERE.


GET-ME-OUT-OF-HERE

The GET-ME-OUT-OF-HERE function executes a CICS RETURN command, which ends the current transaction and returns control to CICS. This is the final step in the process, ensuring that all operations are completed and the transaction is properly closed.

       GET-ME-OUT-OF-HERE SECTION.
GMOOH010.

EXEC CICS RETURN
END-EXEC.

GMOOH999.
EXIT.

 

This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human