Skip to main content

Processing Customer (CRECUST)

The CRECUST program is responsible for creating a new customer record in the banking system. This process involves several steps including initializing customer creation, deriving the current date and time, performing an asynchronous credit check, validating the date of birth, and finally writing the customer data to the VSAM file. The program ensures data integrity and accurate processing by performing these steps sequentially and handling any potential errors that may arise.

The flow starts with initializing the customer creation process, followed by deriving the current date and time to timestamp the transaction. Next, an asynchronous credit check is performed to ensure the customer's creditworthiness. If there are no errors, the program proceeds to validate the customer's date of birth. Finally, the customer data is written to the VSAM file, and the process is terminated safely.

Where is this program used?

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

Here is a high level diagram of the program:

Initialization and Setup


Initializing Customer Creation

First, the PREMIERE section starts the customer creation process by moving the SORTCODE to REQUIRED-SORT-CODE. This sets up the necessary sort code for the customer being created.

       PREMIERE SECTION.
P010.

MOVE SORTCODE TO REQUIRED-SORT-CODE.


Populating Date and Time

Next, the POPULATE-TIME-DATE section is performed to derive the current date and time. This ensures that the customer creation process has the correct timestamp.

           PERFORM POPULATE-TIME-DATE.



Executing POPULATE-TIME-DATE

The POPULATE-TIME-DATE section uses CICS commands to get the current time and format it. The ASKTIME command retrieves the current time and stores it in WS-U-TIME. The FORMATTIME command then formats this time into a readable date and time format, storing the date in WS-ORIG-DATE and the time in PROC-TRAN-TIME.

       POPULATE-TIME-DATE SECTION.
PTD010.

EXEC CICS ASKTIME
ABSTIME(WS-U-TIME)
END-EXEC.

EXEC CICS FORMATTIME
ABSTIME(WS-U-TIME)
DDMMYYYY(WS-ORIG-DATE)
TIME(PROC-TRAN-TIME OF PROCTRAN-AREA )
DATESEP
END-EXEC.

Date and Time Derivation


Derive Date and Time

First, the flow derives the current date and time by performing the POPULATE-TIME-DATE paragraph. This step is crucial for timestamping transactions and ensuring accurate logging and processing times.

      *    Derive the date and time
*

PERFORM POPULATE-TIME-DATE.


Perform Credit Check

Next, the flow moves to the CREDIT-CHECK paragraph. This section handles the asynchronous credit check process. It retrieves transaction IDs, initiates asynchronous transactions, and stores the results for later use. This ensures that the customer's credit information is accurately and efficiently processed.

       CREDIT-CHECK SECTION.
CC010.
*
* Carry out the Credit Check Asynchronously
*


*
* Retrieve the table of transaction IDs to use &
* initiate each Asynchronous transaction
*
MOVE 'CIPCREDCHANN ' TO WS-CHANNEL-NAME.
MOVE 0 TO WS-CHILD-ISSUED-CNT.

COMPUTE WS-PUT-CONT-LEN = LENGTH OF DFHCOMMAREA.

PERFORM VARYING WS-CC-CNT FROM 1 BY 1
UNTIL WS-CC-CNT > 5

*
* Use transactions OCR1 - OCR5

Interim Summary

So far, we saw the initialization and setup process, including the derivation of the current date and time and the execution of the credit check. Now, we will focus on the asynchronous credit check process and how the program handles potential errors during this step.

Asynchronous Credit Check


Performing Credit Check

First, the program performs the credit check by calling the CREDIT-CHECK paragraph.

           PERFORM CREDIT-CHECK.


Checking for Credit Check Error

Next, the program checks if there was an error during the credit check by evaluating if WS-CREDIT-CHECK-ERROR is 'Y'.

           IF WS-CREDIT-CHECK-ERROR = 'Y'


Handling Credit Check Error

If there is an error, the program sets the credit score to 0, formats the review date, sets the success flag to 'N', and assigns a failure code. It then displays error messages and exits the program by calling GET-ME-OUT-OF-HERE.

              MOVE 0 TO COMM-CREDIT-SCORE

STRING WS-ORIG-DATE-DD DELIMITED BY SIZE,
WS-ORIG-DATE-MM DELIMITED BY SIZE,
WS-ORIG-DATE-YYYY DELIMITED BY SIZE
INTO COMM-CS-REVIEW-DATE
END-STRING

MOVE 'N' TO COMM-SUCCESS
MOVE 'G' TO COMM-FAIL-CODE

DISPLAY 'WS-CREDIT-CHECK-ERROR = Y, '
' RESP='
WS-CICS-RESP ' RESP2=' WS-CICS-RESP2
DISPLAY ' Exiting CRECUST. COMMAREA='
DFHCOMMAREA


Exiting the Program

The GET-ME-OUT-OF-HERE section handles the program exit by executing a CICS RETURN command.

       GET-ME-OUT-OF-HERE SECTION.
GMOFH010.
*
* Finish
*
EXEC CICS RETURN
END-EXEC.

GMOFH999.
EXIT.


Performing Date of Birth Check

If there is no credit check error, the program proceeds to perform a date of birth check by calling the DATE-OF-BIRTH-CHECK paragraph. This ensures the date of birth is valid and calculates the customer's age.

       DATE-OF-BIRTH-CHECK SECTION.
DOBC010.
*
* Ensure that the Date Of Birth is valid
*
IF COMM-BIRTH-YEAR < 1601
MOVE 'Y' TO WS-DATE-OF-BIRTH-ERROR
MOVE 'O' TO COMM-FAIL-CODE
GO TO DOBC999
END-IF.

MOVE COMM-BIRTH-YEAR TO CEEDAYS-YEAR.
MOVE COMM-BIRTH-MONTH TO CEEDAYS-MONTH.
MOVE COMM-BIRTH-DAY TO CEEDAYS-DAY.

CALL "CEEDAYS" USING DATE-OF-BIRTH-FOR-CEEDAYS
DATE-OF-BIRTH-FORMAT,
WS-DATE-OF-BIRTH-LILLIAN,
FC.

IF NOT CEE000 OF FC THEN

Date of Birth Check


Validate Date of Birth

First, the DATE-OF-BIRTH-CHECK paragraph is performed to validate the customer's date of birth.

           PERFORM DATE-OF-BIRTH-CHECK.


Check Date of Birth Error

Next, we check if WS-DATE-OF-BIRTH-ERROR is set to 'Y'. If it is, it indicates that there is an error with the date of birth. In this case, we set COMM-SUCCESS to 'N' and perform the GET-ME-OUT-OF-HERE paragraph to exit the process.

           IF WS-DATE-OF-BIRTH-ERROR = 'Y'

MOVE 'N' TO COMM-SUCCESS
PERFORM GET-ME-OUT-OF-HERE

END-IF.

Enqueuing, Updating, and Writing datastore


Enqueue Named Counter

First, we perform the ENQ-NAMED-COUNTER operation to lock the named counter for the customer. This ensures that no other process can update the counter simultaneously, maintaining data integrity.

           PERFORM ENQ-NAMED-COUNTER.


Update Named Counter Server

Next, we perform the UPD-NCS operation to get the next customer number from the named counter. This involves incrementing the counter and marking it as updated.

           PERFORM UPD-NCS.


Incrementing the Counter

Diving into the UPD-NCS function, we first increment the customer number counter by 1. Then, we perform the GET-LAST-CUSTOMER-VSAM operation to retrieve the last customer number and mark the counter as updated.

       UPD-NCS SECTION.
UN010.
*
* Update the Named Counter Server
*
MOVE 1 TO NCS-CUST-NO-INC.

PERFORM GET-LAST-CUSTOMER-VSAM

MOVE 'Y' TO NCS-UPDATED.

UN999.
EXIT.


Write Customer to VSAM

Then, we perform the WRITE-CUSTOMER-VSAM operation to write the new customer record to the VSAM file. This involves initializing the output data and populating it with the customer's details.

           PERFORM WRITE-CUSTOMER-VSAM.


Writing to VSAM

Going into the WRITE-CUSTOMER-VSAM function, we initialize the output data and populate it with the customer's details such as sort code, customer number, name, address, date of birth, credit score, and review date. We then write this data to the VSAM file and handle any potential errors.

       WRITE-CUSTOMER-VSAM SECTION.
WCV010.
*
* Write a record to the CUSTOMER VSAM file
*
INITIALIZE OUTPUT-DATA.

MOVE 'CUST' TO CUSTOMER-EYECATCHER.
MOVE SORTCODE TO CUSTOMER-SORTCODE.
MOVE NCS-CUST-NO-VALUE TO CUSTOMER-NUMBER.
MOVE COMM-NAME TO CUSTOMER-NAME.
MOVE COMM-ADDRESS TO CUSTOMER-ADDRESS.
MOVE COMM-DATE-OF-BIRTH TO CUSTOMER-DATE-OF-BIRTH.
MOVE COMM-CREDIT-SCORE TO CUSTOMER-CREDIT-SCORE.
MOVE COMM-CS-REVIEW-DATE TO CUSTOMER-CS-REVIEW-DATE.

COMPUTE WS-CUST-REC-LEN = LENGTH OF OUTPUT-DATA.

EXEC CICS WRITE
FILE('CUSTOMER')
FROM(OUTPUT-DATA)

Final Exit

This is the next section of the flow.


Start Termination Process

First, the termination process begins by performing the GET-ME-OUT-OF-HERE routine. This routine is responsible for cleaning up and safely exiting the customer record creation process.

           PERFORM GET-ME-OUT-OF-HERE.

P999.
EXIT.


Perform GET-ME-OUT-OF-HERE

Next, the GET-ME-OUT-OF-HERE routine is executed. This routine ensures that any necessary cleanup operations are performed, such as releasing resources or rolling back transactions, to maintain data integrity and system stability.

           PERFORM GET-ME-OUT-OF-HERE.

P999.
EXIT.


End Process

Finally, the process reaches the P999 label, which signifies the end of the termination process. At this point, the customer record creation process is fully terminated, and control is returned to the calling program or the next logical step in the application.

       P999.
EXIT.

 

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