Handling Delay and Error Management (CRDTAGY5)
The CRDTAGY5
The flow starts with setting up the container and channel names, followed by initializing the seed for the random number generator. A random delay amount is then computed and executed. If an error occurs, it is handled appropriately. The program then retrieves a container from the CICS channel, generates a credit score, updates the container, and handles any errors that may occur during these processes.
Here is a high level diagram of the program:
Setup and random delay generation
Handling Delay and Error Management
First, the PREMIEREEXEC CICS DELAYPOPULATE-TIME-DATE
PREMIERE SECTION.
A010.
*
* Generate a random number of seconds between 0 & 3.
* This is the delay amount in seconds.
*
MOVE 'CIPE ' 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.
EXEC CICS DELAY
FOR SECONDS(WS-DELAY-AMT)
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC.
Setting Up Container and Channel Names
Moving to setting up the container and channel names, WS-CONTAINER-NAMEWS-CHANNEL-NAME
MOVE 'CIPE ' TO WS-CONTAINER-NAME.
MOVE 'CIPCREDCHANN ' TO WS-CHANNEL-NAME.
Initializing the Seed
Next, the seed for the random number generator is initialized by moving EIBTASKNWS-SEED
MOVE EIBTASKN TO WS-SEED.
Computing the Delay Amount
Then, the delay amount is computed using the FUNCTION RANDOMWS-DELAY-AMT
COMPUTE WS-DELAY-AMT = ((3 - 1)
* FUNCTION RANDOM(WS-SEED)) + 1.
Executing the Delay
The delay is executed using the EXEC CICS DELAYWS-CICS-RESPWS-CICS-RESP2
EXEC CICS DELAY
FOR SECONDS(WS-DELAY-AMT)
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC.
Handling Errors
If the response code WS-CICS-RESPABNDINFO-RECABND-RESPCODEABND-RESP2CODE
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.
*
Populating Time and Date
The POPULATE-TIME-DATEABND-DATEABND-TIME
PERFORM POPULATE-TIME-DATE
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
Error handling for delay
Initialize ABNDINFO-REC
ABNDINFO-RECFirst, the ABNDINFO-REC
INITIALIZE ABNDINFO-REC
Move EIBRESP to ABND-RESPCODE
ABND-RESPCODENext, the response code from the EXEC Interface Block (EIB) is moved to ABND-RESPCODE
MOVE EIBRESP TO ABND-RESPCODE
Move EIBRESP2 to ABND-RESP2CODE
EIBRESP2ABND-RESP2CODEThen, the secondary response code from the EIB is moved to ABND-RESP2CODE
MOVE EIBRESP2 TO ABND-RESP2CODE
Assign APPLID to ABND-APPLID
ABND-APPLIDThe application ID is assigned to ABND-APPLID
EXEC CICS ASSIGN APPLID(ABND-APPLID)
END-EXEC
Move EIBTASKN to ABND-TASKNO-KEY
ABND-TASKNO-KEYThe task number is moved to ABND-TASKNO-KEY
MOVE EIBTASKN TO ABND-TASKNO-KEY
Move EIBTRNID to ABND-TRANID
ABND-TRANIDThe transaction ID is moved to ABND-TRANID
MOVE EIBTRNID TO ABND-TRANID
Perform POPULATE-TIME-DATE
POPULATE-TIME-DATEThe POPULATE-TIME-DATE
PERFORM POPULATE-TIME-DATE
Move WS-ORIG-DATE to ABND-DATE
WS-ORIG-DATEABND-DATEThe original date is moved to ABND-DATE
MOVE WS-ORIG-DATE TO ABND-DATE
Format and move time to ABND-TIME
ABND-TIMEThe current time is formatted and moved to ABND-TIME
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
WS-U-TIMEABND-UTIME-KEYThe universal time is moved to ABND-UTIME-KEY
MOVE WS-U-TIME TO ABND-UTIME-KEY
Move 'PLOP' to ABND-CODE
ABND-CODEThe abend code 'PLOP' is moved to ABND-CODE
MOVE 'PLOP' TO ABND-CODE
Assign PROGRAM to ABND-PROGRAM
ABND-PROGRAMThe current program name is assigned to ABND-PROGRAM
EXEC CICS ASSIGN PROGRAM(ABND-PROGRAM)
END-EXEC
Move ZEROS to ABND-SQLCODE
ABND-SQLCODEZeros are moved to ABND-SQLCODE
MOVE ZEROS TO ABND-SQLCODE
Format and move freeform message to ABND-FREEFORM
ABND-FREEFORMA freeform error message is formatted and moved to 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
Link to WS-ABEND-PGM with ABNDINFO-REC
WS-ABEND-PGMABNDINFO-RECThe WS-ABEND-PGMABNDINFO-REC
EXEC CICS LINK PROGRAM(WS-ABEND-PGM)
COMMAREA(ABNDINFO-REC)
END-EXEC
Display error message
An error message is displayed to notify the user about the abend.
DISPLAY '*** The delay messed up ! ***'
Execute CICS ABEND with code 'PLOP'
Finally, the CICS ABEND command is executed with the code 'PLOP' to terminate the task abnormally.
EXEC CICS ABEND
ABCODE('PLOP')
END-EXEC
Interim Summary
So far, we saw how the program handles delay and error management, including setting up container and channel names, initializing the seed for the random number generator, computing the delay amount, executing the delay, and handling errors if the response is not normal. Now, we will focus on retrieving the container from the CICS channel and handling any errors that may occur during this process.
Container retrieval and error handling
Retrieving Container from CICS Channel
First, the code attempts to retrieve a container from a CICS channel using the EXEC CICS GET CONTAINERWS-CICS-RESPWS-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.
Checking Response Status
Next, the code checks if the response code WS-CICS-RESPDFHRESP(NORMAL)GET-ME-OUT-OF-HERE
IF WS-CICS-RESP NOT = DFHRESP(NORMAL)
DISPLAY 'CRDTAGY5 - 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.
Handling Error with GET-ME-OUT-OF-HERE
GET-ME-OUT-OF-HEREThe GET-ME-OUT-OF-HEREEXEC CICS RETURN
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 generate a new credit score for the customer. This score is a random number between 1 and 999. The COMPUTERANDOM
* 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 WS-NEW-CREDSCORE = ((999 - 1)
* FUNCTION RANDOM) + 1.
MOVE WS-NEW-CREDSCORE TO WS-CONT-IN-CREDIT-SCORE.
Compute Random Score
Next, the COMPUTERANDOM
COMPUTE WS-NEW-CREDSCORE = ((999 - 1)
* FUNCTION RANDOM) + 1.
Assign Score to Customer
Finally, the newly computed credit score is moved to the customer's credit score field. This step updates the customer's record with the new score, which can then be used for further processing or decision-making.
MOVE WS-NEW-CREDSCORE TO WS-CONT-IN-CREDIT-SCORE.
Container update and error handling
Calculate Container Length
First, the length of the container data is calculated and stored in WS-CONTAINER-LEN
COMPUTE WS-CONTAINER-LEN = LENGTH OF WS-CONT-IN.
Put Data in Container
Next, the data is put into the container using the EXEC CICS PUT CONTAINERWS-CONT-IN
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
IF WS-CICS-RESP NOT = DFHRESP(NORMAL)
Handle Error
If an error occurs, an error message is displayed with the response codes and container details. The GET-ME-OUT-OF-HERE
DISPLAY 'CRDTAGY5- 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.
Section end
This is the next section of the flow.
Start Finalization
The section starts with the label A999.
A999.
EXIT.
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human