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
SORTCODE
REQUIRED-SORT-CODE
PREMIERE SECTION.
P010.
MOVE SORTCODE TO REQUIRED-SORT-CODE.
Populating Date and Time
Next, the POPULATE-TIME-DATE
PERFORM POPULATE-TIME-DATE.
Executing POPULATE-TIME-DATE
POPULATE-TIME-DATE
The POPULATE-TIME-DATE
ASKTIME
WS-U-TIME
FORMATTIME
WS-ORIG-DATE
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
* Derive the date and time
*
PERFORM POPULATE-TIME-DATE.
Perform Credit Check
Next, the flow moves to the CREDIT-CHECK
IDs
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
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
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
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
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
PERFORM DATE-OF-BIRTH-CHECK.
Check Date of Birth Error
Next, we check if WS-DATE-OF-BIRTH-ERROR
COMM-SUCCESS
GET-ME-OUT-OF-HERE
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
PERFORM ENQ-NAMED-COUNTER.
Update Named Counter Server
Next, we perform the UPD-NCS
PERFORM UPD-NCS.
Incrementing the Counter
Diving into the UPD-NCS
GET-LAST-CUSTOMER-VSAM
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
PERFORM WRITE-CUSTOMER-VSAM.
Writing to VSAM
Going into the WRITE-CUSTOMER-VSAM
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
PERFORM GET-ME-OUT-OF-HERE.
P999.
EXIT.
Perform GET-ME-OUT-OF-HERE
GET-ME-OUT-OF-HERE
Next, the GET-ME-OUT-OF-HERE
PERFORM GET-ME-OUT-OF-HERE.
P999.
EXIT.
End Process
Finally, the process reaches the P999
P999.
EXIT.
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human