Get Customer Record (INQCUST)
The INQCUST program is responsible for handling customer inquiries in the banking application. It checks the incoming customer number, retrieves customer information from the VSAM file, and returns the relevant customer data. The program ensures proper handling of abnormal terminations and initializes necessary variables to manage the inquiry process.
The INQCUST program starts by setting up abend handling to manage any abnormal terminations. It then initializes variables and checks the incoming customer number. If the number is all zeros or nines, it retrieves the last customer number in use or generates a random customer number. The program reads customer information from the VSAM file and, if successful, returns the customer data. Finally, it terminates the process.
Where is this program used?
This program is used multiple times in the codebase as represented in the following diagram:
Lets' zoom into the flow:
Setting Up Abend Handling
First, the program sets up abend handling using the EXEC CICS HANDLE ABEND
* Set up abend handling
*
EXEC CICS HANDLE ABEND
LABEL(ABEND-HANDLING)
END-EXEC.
Initializing Variables
Next, the program initializes several variables. INQCUST-INQ-SUCCESS
INQCUST-INQ-FAIL-CD
SORTCODE
INQCUST-CUSTNO
REQUIRED-SORT-CODE
REQUIRED-CUST-NUMBER
MOVE 'N' TO INQCUST-INQ-SUCCESS
MOVE '0' TO INQCUST-INQ-FAIL-CD
MOVE SORTCODE TO REQUIRED-SORT-CODE.
MOVE INQCUST-CUSTNO TO REQUIRED-CUST-NUMBER.
Checking Customer Number
The program checks if the incoming customer number is either all zeros or all nines. If it is, it performs the READ-CUSTOMER-NCS
REQUIRED-CUST-NUMBER
GET-ME-OUT-OF-HERE
* Is the incoming CUSTOMER number set to 0's, 9's or
* an actual value?
*
* If the incoming CUSTOMER number is 0's (random
* customer) or the incoming CUSTOMER number is 9's
* (the last valid CUSTOMER in use) then access the
* named counter server to get the last
* CUSTOMER-NUMBER in use.
*
IF INQCUST-CUSTNO = 0000000000 OR INQCUST-CUSTNO = 9999999999
PERFORM READ-CUSTOMER-NCS
D DISPLAY 'CUST NO RETURNED FROM NCS=' NCS-CUST-NO-VALUE
IF INQCUST-INQ-SUCCESS = 'Y'
MOVE NCS-CUST-NO-VALUE TO REQUIRED-CUST-NUMBER
ELSE
PERFORM GET-ME-OUT-OF-HERE
END-IF
END-IF.
Generating Random Customer Number
If the incoming customer number is all zeros, the program performs the GENERATE-RANDOM-CUSTOMER
REQUIRED-CUST-NUMBER
* For a random customer generate a CUSTOMER number
* randomly which is less than the highest CUSTOMER
* number that is currently in use.
*
IF INQCUST-CUSTNO = 0000000000
PERFORM GENERATE-RANDOM-CUSTOMER
MOVE RANDOM-CUSTOMER TO REQUIRED-CUST-NUMBER
END-IF.
Reading Customer Information
The program then performs the READ-CUSTOMER-VSAM
EXIT-VSAM-READ
* Get the customer information
*
PERFORM READ-CUSTOMER-VSAM
UNTIL EXIT-VSAM-READ = 'Y'.
Returning Customer Data
If the inquiry is successful, the program moves various pieces of customer data from OUTPUT-DATA
INQCUST
* Return the CUSTOMER data in the commarea.
*
IF INQCUST-INQ-SUCCESS = 'Y'
MOVE '0' TO INQCUST-INQ-FAIL-CD
MOVE CUSTOMER-EYECATCHER OF OUTPUT-DATA
TO INQCUST-EYE
MOVE CUSTOMER-SORTCODE OF OUTPUT-DATA
TO INQCUST-SCODE
MOVE CUSTOMER-NUMBER OF OUTPUT-DATA
TO INQCUST-CUSTNO
MOVE CUSTOMER-NAME OF OUTPUT-DATA
TO INQCUST-NAME
MOVE CUSTOMER-ADDRESS OF OUTPUT-DATA
TO INQCUST-ADDR
MOVE CUSTOMER-DATE-OF-BIRTH OF OUTPUT-DATA
TO INQCUST-DOB
MOVE CUSTOMER-CREDIT-SCORE OF OUTPUT-DATA
TO INQCUST-CREDIT-SCORE
MOVE CUSTOMER-CS-REVIEW-DATE OF OUTPUT-DATA
TO INQCUST-CS-REVIEW-DT
END-IF.
Terminating the Process
Finally, the program performs the GET-ME-OUT-OF-HERE
PERFORM GET-ME-OUT-OF-HERE.
READ-CUSTOMER-NCS
READ-CUSTOMER-NCS
The READ-CUSTOMER-NCS
GET-LAST-CUSTOMER-VSAM
NCS-CUST-NO-VALUE
READ-CUSTOMER-NCS SECTION.
RCN010.
*
* Retrieve the last CUSTOMER number in use
*
PERFORM GET-LAST-CUSTOMER-VSAM
IF INQCUST-INQ-SUCCESS = 'Y'
MOVE REQUIRED-CUST-NUMBER2 TO NCS-CUST-NO-VALUE
END-IF.
GET-ME-OUT-OF-HERE
GET-ME-OUT-OF-HERE
The GET-ME-OUT-OF-HERE
EXEC CICS RETURN
GET-ME-OUT-OF-HERE SECTION.
GMOFH010.
*
* Finish
*
EXEC CICS RETURN
END-EXEC.
READ-CUSTOMER-VSAM
READ-CUSTOMER-VSAM
The READ-CUSTOMER-VSAM
OUTPUT-DATA
CICS READ
EXIT-VSAM-READ
INQCUST-INQ-SUCCESS
READ-CUSTOMER-VSAM SECTION.
RCV010.
*
* Read the VSAM CUSTOMER file
*
INITIALIZE OUTPUT-DATA.
EXEC CICS READ FILE('CUSTOMER')
RIDFLD(CUSTOMER-KY)
INTO(OUTPUT-DATA)
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC.
*
* Check that the READ was successful. If it was
* exit this loop
*
IF WS-CICS-RESP = DFHRESP(NORMAL)
MOVE 'Y' TO EXIT-VSAM-READ
MOVE 'Y' TO INQCUST-INQ-SUCCESS
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human