Generating and Storing Credit Scores (CRDTAGY2)
The CRDTAGY2
The flow starts with setting up a delay to simulate real-world processing time. If any errors occur during this delay, they are handled appropriately. Next, the program retrieves data from a CICS container, generates a random credit score, and stores this score back in the container. Finally, the program performs cleanup operations to ensure all resources are released and the process is safely terminated.
Here is a high level diagram of the program:
Setup Delay
Setting Container and Channel Names
First, the container name and channel name are set to 'CIPB' and 'CIPCREDCHANN' respectively. This is essential for identifying the data and communication channel used in subsequent operations.
MOVE 'CIPB ' TO WS-CONTAINER-NAME.
MOVE 'CIPCREDCHANN ' TO WS-CHANNEL-NAME.
Setting Seed Value
Next, the seed value for the random number generator is set using the task number (EIBTASKN
MOVE EIBTASKN TO WS-SEED.
Computing Delay Amount
Then, a random delay amount between 1 and 3 seconds is computed. This simulates a real-world delay in processing.
COMPUTE WS-DELAY-AMT = ((3 - 1)
* FUNCTION RANDOM(WS-SEED)) + 1.
Executing CICS Delay
The computed delay amount is then used to execute a CICS delay command. This introduces the actual delay in the program's execution.
EXEC CICS DELAY
FOR SECONDS(WS-DELAY-AMT)
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC.
Checking CICS Response
Finally, the response from the CICS delay command is checked. If the response is not normal, error handling procedures are initiated.
IF WS-CICS-RESP NOT = DFHRESP(NORMAL)
Handle Delay Errors
Checking CICS Response
First, the code checks if the CICS response code (WS-CICS-RESP
DFHRESP(NORMAL)
IF WS-CICS-RESP NOT = DFHRESP(NORMAL)
Initializing Error Information
Next, the code initializes the ABNDINFO-REC
EIBRESP
EIBRESP2
ABND-RESPCODE
ABND-RESP2CODE
INITIALIZE ABNDINFO-REC
MOVE EIBRESP TO ABND-RESPCODE
MOVE EIBRESP2 TO ABND-RESP2CODE
Collecting Supplemental Information
Then, the code collects additional information such as the application ID (APPLID
EIBTASKN
EIBTRNID
EXEC CICS ASSIGN APPLID(ABND-APPLID)
END-EXEC
MOVE EIBTASKN TO ABND-TASKNO-KEY
MOVE EIBTRNID TO ABND-TRANID
Populating Date and Time
Moving to the next step, the code performs the POPULATE-TIME-DATE
PERFORM POPULATE-TIME-DATE
Collecting Date and Time Information
The POPULATE-TIME-DATE
ASKTIME
FORMATTIME
WS-U-TIME
WS-ORIG-DATE
WS-TIME-NOW
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.
Formatting Date and Time
Next, the code moves the collected date and time into the ABND-DATE
ABND-TIME
MOVE WS-ORIG-DATE TO ABND-DATE
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
Assigning Program Information
Then, the code assigns the current program name to ABND-PROGRAM
EXEC CICS ASSIGN PROGRAM(ABND-PROGRAM)
END-EXEC
Creating Freeform Error Message
The code constructs a freeform error message that includes the response codes. This message is stored in ABND-FREEFORM
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
Linking to Abend Handler
Finally, the code links to the Abend Handler program (WS-ABEND-PGM
ABNDINFO-REC
EXEC CICS LINK PROGRAM(WS-ABEND-PGM)
COMMAREA(ABNDINFO-REC)
END-EXEC
Displaying Error Message and Abending
The code displays an error message and then abends the transaction with the code 'PLOP'. This ensures that the error is logged and the transaction is terminated gracefully.
DISPLAY '*** The delay messed up ! ***'
EXEC CICS ABEND
ABCODE('PLOP')
END-EXEC
Interim Summary
So far, we saw how the program handles setting up the delay, computing the delay amount, executing the CICS delay, and handling any errors that occur during this process. Now, we will focus on retrieving the container from the CICS channel and handling any errors that may arise during this operation.
Retrieve Container
Compute Container Length
First, the length of the container is computed and stored in WS-CONTAINER-LEN
COMPUTE WS-CONTAINER-LEN = LENGTH OF WS-CONT-IN.
Get Container from CICS Channel
Next, the code retrieves the container from the CICS channel using the EXEC CICS GET CONTAINER
WS-CONT-IN
WS-CICS-RESP
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 and Handle Errors
Then, the response code WS-CICS-RESP
DFHRESP(NORMAL)
GET-ME-OUT-OF-HERE
IF WS-CICS-RESP NOT = DFHRESP(NORMAL)
DISPLAY 'CRDTAGY2 - 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
GET-ME-OUT-OF-HERE
The GET-ME-OUT-OF-HERE
CICS RETURN
GET-ME-OUT-OF-HERE SECTION.
GMOFH010.
EXEC CICS RETURN
END-EXEC.
GMOFH999.
EXIT.
Generate Credit Score
This is the next section of the flow.
Generate Random Credit Score
First, we generate a random credit score between 1 and 999. The use of a SEED in the initial RANDOM function ensures that subsequent calls to RANDOM will produce a different value each time.
* 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 Credit Score
Next, we compute the new credit score using the formula ((
999
- 1) *
FUNCTION
RANDOM
) + 1
. This ensures the credit score falls within the desired range of 1 to 999.
COMPUTE WS-NEW-CREDSCORE = ((999 - 1)
* FUNCTION RANDOM) + 1.
Store Credit Score
Then, we store the newly computed credit score in WS-CONT-IN-CREDIT-SCORE
MOVE WS-NEW-CREDSCORE TO WS-CONT-IN-CREDIT-SCORE.
Store Credit Score and Handle Errors
Calculate Container Length
First, the length of the container data (WS-CONT-IN
WS-CONTAINER-LEN
COMPUTE WS-CONTAINER-LEN = LENGTH OF WS-CONT-IN.
Store Container in CICS Channel
Next, the container data (WS-CONT-IN
PUT CONTAINER
WS-CONTAINER-NAME
WS-CONTAINER-LEN
WS-CHANNEL-NAME
WS-CICS-RESP
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 code (WS-CICS-RESP
PUT CONTAINER
DFHRESP(NORMAL)
GET-ME-OUT-OF-HERE
IF WS-CICS-RESP NOT = DFHRESP(NORMAL)
DISPLAY 'CRDTAGY2 - 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
PERFORM GET-ME-OUT-OF-HERE
END-IF.
Final Cleanup
This is the next section of the flow.
Start Termination Process
First, the termination process is initiated by performing the GET-ME-OUT-OF-HERE
PERFORM GET-ME-OUT-OF-HERE.
A999.
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.
A999.
EXIT.
End Process
Finally, the process reaches the A999
A999.
EXIT.
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human