Skip to main content

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 command. This ensures that any abnormal terminations are properly handled.

      *    Set up abend handling
*
EXEC CICS HANDLE ABEND
LABEL(ABEND-HANDLING)
END-EXEC.


Initializing Variables

Next, the program initializes several variables. INQCUST-INQ-SUCCESS is set to 'N' to indicate that the inquiry has not yet succeeded, and INQCUST-INQ-FAIL-CD is set to '0'. The SORTCODE and INQCUST-CUSTNO are moved to REQUIRED-SORT-CODE and REQUIRED-CUST-NUMBER respectively.

           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 paragraph to retrieve the last customer number in use. If the inquiry is successful, it moves the retrieved customer number to REQUIRED-CUST-NUMBER. Otherwise, it performs the GET-ME-OUT-OF-HERE paragraph to terminate the process.

      *    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 paragraph to generate a random customer number that is less than the highest customer number currently in use. The generated number is then moved to 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 paragraph in a loop until EXIT-VSAM-READ is set to 'Y'. This reads the customer information from the VSAM file.

      *          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 to the corresponding fields in INQCUST. This includes the customer eyecatcher, sort code, customer number, name, address, date of birth, credit score, and credit score review date.

      * 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 paragraph to terminate the process.

           PERFORM GET-ME-OUT-OF-HERE.



READ-CUSTOMER-NCS

The READ-CUSTOMER-NCS paragraph retrieves the last customer number in use by performing the GET-LAST-CUSTOMER-VSAM paragraph. If the inquiry is successful, it moves the retrieved customer number to 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

The GET-ME-OUT-OF-HERE paragraph simply executes the EXEC CICS RETURN command to finish the process.

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


READ-CUSTOMER-VSAM

The READ-CUSTOMER-VSAM paragraph reads the customer information from the VSAM file. It initializes the OUTPUT-DATA and performs a CICS READ command. If the read is successful, it sets EXIT-VSAM-READ and INQCUST-INQ-SUCCESS to 'Y'. If the read fails due to a system ID error, it retries up to 100 times. If the customer record is not found and the incoming customer number is all zeros, it generates a new random customer number and retries. If the customer record is not found and the incoming customer number is all nines, it retrieves the last customer number in use and retries. If the customer record is not found for any other reason, it initializes the output data and sets the failure code.

       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