Skip to main content

Generating Credit Score (CRDTAGY3)

The CRDTAGY3 program is responsible for generating a credit score. This process involves setting up an initial delay, handling any errors that occur during the delay, retrieving and storing containers, and finally generating and assigning a random credit score.

The flow starts with setting up an initial delay to simulate wait time. If an error occurs during this delay, it is handled appropriately. The program then retrieves a container from a CICS channel, generates a random credit score, and stores the container data. Finally, the program assigns the generated credit score to the appropriate variable.

Here is a high level diagram of the program:

Setup and initial delay


Generating Delay

First, the program generates a random delay amount in seconds between 0 and 3. This delay is used to simulate a wait time in the application. The delay amount is computed using a random function seeded with the task number.

       PREMIERE SECTION.
A010.
*
* Generate a random number of seconds between 0 & 3.
* This is the delay amount in seconds.
*

MOVE 'CIPC ' TO WS-CONTAINER-NAME.
MOVE 'CIPCREDCHANN ' TO WS-CHANNEL-NAME.
MOVE EIBTASKN TO WS-SEED.

COMPUTE WS-DELAY-AMT = ((3 - 1)
* FUNCTION RANDOM(WS-SEED)) + 1.



Executing Delay

Next, the program executes the delay using the CICS DELAY command. The delay is for the number of seconds computed in the previous step. The response codes are stored in WS-CICS-RESP and WS-CICS-RESP2.

           EXEC CICS DELAY
FOR SECONDS(WS-DELAY-AMT)
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC.


Handling Delay Response

Then, the program checks if the response from the delay command is not normal. If the response is not normal, it initializes the abend information record, gets supplemental information, and links to the abend handler program. The POPULATE-TIME-DATE paragraph is performed to get the current date and time.

           IF WS-CICS-RESP NOT = DFHRESP(NORMAL)
*
* Preserve the RESP and RESP2, then set up the
* standard ABEND info before getting the applid,
* date/time etc. and linking to the Abend Handler
* program.
*
INITIALIZE ABNDINFO-REC
MOVE EIBRESP TO ABND-RESPCODE
MOVE EIBRESP2 TO ABND-RESP2CODE
*
* Get supplemental information
*
EXEC CICS ASSIGN APPLID(ABND-APPLID)
END-EXEC

MOVE EIBTASKN TO ABND-TASKNO-KEY
MOVE EIBTRNID TO ABND-TRANID

PERFORM POPULATE-TIME-DATE



Populating Time and Date

The POPULATE-TIME-DATE paragraph gets the current time and date using the CICS ASKTIME and FORMATTIME commands. This information is used to populate the abend information record.

       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(WS-TIME-NOW)
DATESEP
END-EXEC.

PTD999.
EXIT.

Error handling for delay failure


Initialize ABNDINFO-REC

First, the ABNDINFO-REC record is initialized to ensure all fields are set to their default values before any data is moved into them.

              INITIALIZE ABNDINFO-REC


Move EIBRESP to ABND-RESPCODE

Next, the response code from the EIBRESP field is moved to ABND-RESPCODE to preserve the response code for later use.

              MOVE EIBRESP    TO ABND-RESPCODE


Move EIBRESP2 to ABND-RESP2CODE

Then, the secondary response code from the EIBRESP2 field is moved to ABND-RESP2CODE to preserve the secondary response code.

              MOVE EIBRESP2   TO ABND-RESP2CODE


Assign APPLID to ABND-APPLID

The application ID is assigned to ABND-APPLID using the EXEC CICS ASSIGN command to capture the application identifier.

              EXEC CICS ASSIGN APPLID(ABND-APPLID)
END-EXEC


Move EIBTASKN to ABND-TASKNO-KEY

The task number is moved from EIBTASKN to ABND-TASKNO-KEY to store the current task number.

              MOVE EIBTASKN   TO ABND-TASKNO-KEY


Move EIBTRNID to ABND-TRANID

The transaction ID is moved from EIBTRNID to ABND-TRANID to store the current transaction identifier.

              MOVE EIBTRNID   TO ABND-TRANID


Perform POPULATE-TIME-DATE

The POPULATE-TIME-DATE paragraph is performed to gather the current date and time information.

              PERFORM POPULATE-TIME-DATE


Move WS-ORIG-DATE to ABND-DATE

The original date is moved from WS-ORIG-DATE to ABND-DATE to store the date of the event.

              MOVE WS-ORIG-DATE TO ABND-DATE


String WS-TIME-NOW-GRP-HH to ABND-TIME

The current time components are concatenated into a single string and moved to ABND-TIME to store the time of the event.

              STRING WS-TIME-NOW-GRP-HH DELIMITED BY SIZE,
':' DELIMITED BY SIZE,
WS-TIME-NOW-GRP-MM DELIMITED BY SIZE,
':' DELIMITED BY SIZE,
WS-TIME-NOW-GRP-MM DELIMITED BY SIZE
INTO ABND-TIME


Move WS-U-TIME to ABND-UTIME-KEY

The universal time is moved from WS-U-TIME to ABND-UTIME-KEY to store the universal time key.

              MOVE WS-U-TIME   TO ABND-UTIME-KEY


Move 'PLOP' to ABND-CODE

The code 'PLOP' is moved to ABND-CODE to set a specific code for the abend event.

              MOVE 'PLOP'      TO ABND-CODE


Assign PROGRAM to ABND-PROGRAM

The current program name is assigned to ABND-PROGRAM using the EXEC CICS ASSIGN command to capture the program identifier.

              EXEC CICS ASSIGN PROGRAM(ABND-PROGRAM)
END-EXEC


Move ZEROS to ABND-SQLCODE

Zeros are moved to ABND-SQLCODE to initialize the SQL code field.

              MOVE ZEROS      TO ABND-SQLCODE


String 'A010 - *** The delay messed up! ***' to ABND-FREEFORM

A freeform message is constructed and moved to ABND-FREEFORM to provide a detailed error message.

              STRING 'A010  - *** The delay messed up! ***'
DELIMITED BY SIZE,
' EIBRESP=' DELIMITED BY SIZE,
ABND-RESPCODE DELIMITED BY SIZE,
' RESP2=' DELIMITED BY SIZE,
ABND-RESP2CODE DELIMITED BY SIZE
INTO ABND-FREEFORM


The WS-ABEND-PGM program is linked with the ABNDINFO-REC communication area to handle the abend event.

              EXEC CICS LINK PROGRAM(WS-ABEND-PGM)
COMMAREA(ABNDINFO-REC)
END-EXEC


Display '*** The delay messed up ! ***'

A message is displayed to indicate that the delay has caused an issue.

              DISPLAY '*** The delay messed up ! ***'

Interim Summary

So far, we saw how the program handles the delay response and populates the time and date information for the abend record. Now, we will focus on the process of retrieving a container from a CICS channel and handling any errors that may occur during this retrieval.

Container retrieval


Retrieve Container

First, the code retrieves a container from a CICS channel using the EXEC CICS GET CONTAINER command. This command specifies the container name (WS-CONTAINER-NAME), the channel name (WS-CHANNEL-NAME), and the target variable (WS-CONT-IN). It also captures the length of the container (WS-CONTAINER-LEN) and the response codes (WS-CICS-RESP and WS-CICS-RESP2).

           EXEC CICS GET CONTAINER(WS-CONTAINER-NAME)
CHANNEL(WS-CHANNEL-NAME)
INTO(WS-CONT-IN)
FLENGTH(WS-CONTAINER-LEN)
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC.


Check Response

Next, the code checks if the response code (WS-CICS-RESP) is not equal to DFHRESP(NORMAL). If the response is not normal, it logs an error message displaying the response codes, container name, channel name, and container length. It then performs the GET-ME-OUT-OF-HERE section to handle the error.

           IF WS-CICS-RESP NOT = DFHRESP(NORMAL)
DISPLAY 'CRDTAGY3- UNABLE TO GET CONTAINER. RESP='
WS-CICS-RESP ', RESP2=' WS-CICS-RESP2
DISPLAY 'CONTAINER=' WS-CONTAINER-NAME ' CHANNEL='
WS-CHANNEL-NAME ' FLENGTH='
WS-CONTAINER-LEN
PERFORM GET-ME-OUT-OF-HERE
END-IF.


GET-ME-OUT-OF-HERE

The GET-ME-OUT-OF-HERE section is executed when there is an error in retrieving the container. This section issues a CICS RETURN command to terminate the transaction.

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

EXEC CICS RETURN
END-EXEC.

GMOFH999.
EXIT.

Credit score generation

This is the next section of the flow.


Generate Credit Score

First, we prepare to generate a new credit score for the customer. The credit score will be a random number between 1 and 999. Because a SEED was used on the first RANDOM function call earlier in the code, it is not necessary to use a SEED again for subsequent RANDOM function calls.

      *    Now generate a credit score between 1 and 999. Because we
* used a SEED on the first RANDOM (above) we don't need to
* use a SEED again when using RANDOM for a subsequent time


Compute Random Credit Score

Next, we compute the new credit score using the RANDOM function. The formula ((999- 1) *FUNCTION RANDOM) + 1 ensures that the generated credit score is within the range of 1 to 999.

           COMPUTE WS-NEW-CREDSCORE = ((999 - 1)
* FUNCTION RANDOM) + 1.


Assign Credit Score

Finally, we move the newly generated credit score (WS-NEW-CREDSCORE) to the variable WS-CONT-IN-CREDIT-SCORE, which is likely used elsewhere in the program to store the customer's credit score.

           MOVE WS-NEW-CREDSCORE TO WS-CONT-IN-CREDIT-SCORE.

Container storage and final error handling


Calculate Container Length

First, the length of the container data is calculated and stored in WS-CONTAINER-LEN (which holds the length of the container data). This is essential for specifying the length of the data to be stored in the container.

      *
COMPUTE WS-CONTAINER-LEN = LENGTH OF WS-CONT-IN.


Store Container Data

Next, the container data is stored using the EXEC CICS PUT CONTAINER command. This command takes the container name (WS-CONTAINER-NAME), the data to be stored (WS-CONT-IN), the length of the data (WS-CONTAINER-LEN), and the channel name (WS-CHANNEL-NAME). The response codes are stored in WS-CICS-RESP and WS-CICS-RESP2.

           EXEC CICS PUT CONTAINER(WS-CONTAINER-NAME)
FROM(WS-CONT-IN)
FLENGTH(WS-CONTAINER-LEN)
CHANNEL(WS-CHANNEL-NAME)
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC.


Check Response

Then, the response from the PUT CONTAINER command is checked. If the response code (WS-CICS-RESP) is not normal (DFHRESP(NORMAL)), an error message is displayed with the response codes, container name, channel name, and data length.

           IF WS-CICS-RESP NOT = DFHRESP(NORMAL)
DISPLAY 'CRDTAGY3- UNABLE TO PUT CONTAINER. RESP='
WS-CICS-RESP ', RESP2=' WS-CICS-RESP2
DISPLAY 'CONTAINER=' WS-CONTAINER-NAME
' CHANNEL=' WS-CHANNEL-NAME ' FLENGTH='
WS-CONTAINER-LEN


Handle Error

Finally, if an error occurred, the GET-ME-OUT-OF-HERE routine is performed to handle the error and exit the current process.

              PERFORM GET-ME-OUT-OF-HERE
END-IF.

End of function

This is the next section of the flow.


Start Finalization

The label A999 marks the beginning of the finalization section. This is where the transaction process is concluded, ensuring all necessary updates and logs are completed before ending the transaction.

       A999.
EXIT.

 

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