Skip to main content

Handling Delay and Error Management (CRDTAGY5)

The CRDTAGY5 program is responsible for generating a random delay, handling errors, retrieving and updating containers, and generating credit scores. This is achieved through a series of steps 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.

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 PREMIERE section starts by setting up the container and channel names, and initializing the seed for the random number generator. This is used to compute a random delay amount between 1 and 3 seconds. The delay is then executed using the EXEC CICS DELAY command. If the response is not normal, it proceeds to handle the error by calling the POPULATE-TIME-DATE paragraph.

       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-NAME is set to 'CIPE ' and WS-CHANNEL-NAME is set to 'CIPCREDCHANN '. These names are used later to interact with the CICS containers.

           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 EIBTASKN to WS-SEED. This seed ensures that the random number generation is based on the current task number.

           MOVE EIBTASKN           TO WS-SEED.


Computing the Delay Amount

Then, the delay amount is computed using the FUNCTION RANDOM with the seed. The result is a random number between 1 and 3 seconds, which is stored in WS-DELAY-AMT.

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


Executing the Delay

The delay is executed using the EXEC CICS DELAY command for the computed number of seconds. 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 Errors

If the response code WS-CICS-RESP is not normal, the program proceeds to handle the error. It initializes the ABNDINFO-REC and moves the response codes to ABND-RESPCODE and ABND-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-DATE paragraph is performed to get the current date and time. This information is then moved to the ABND-DATE and ABND-TIME fields for error logging.

              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

First, the ABNDINFO-REC structure is initialized to ensure it starts with a clean state for collecting abend information.

              INITIALIZE ABNDINFO-REC


Move EIBRESP to ABND-RESPCODE

Next, the response code from the EXEC Interface Block (EIB) is moved to ABND-RESPCODE to capture the primary response code.

              MOVE EIBRESP    TO ABND-RESPCODE


Move EIBRESP2 to ABND-RESP2CODE

Then, the secondary response code from the EIB is moved to ABND-RESP2CODE to capture additional response information.

              MOVE EIBRESP2   TO ABND-RESP2CODE


Assign APPLID to ABND-APPLID

The application ID is assigned to ABND-APPLID to identify the application where the abend occurred.

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


Move EIBTASKN to ABND-TASKNO-KEY

The task number is moved to ABND-TASKNO-KEY to record the specific task that encountered the abend.

              MOVE EIBTASKN   TO ABND-TASKNO-KEY


Move EIBTRNID to ABND-TRANID

The transaction ID is moved to ABND-TRANID to capture the transaction that was running when the abend occurred.

              MOVE EIBTRNID   TO ABND-TRANID


Perform POPULATE-TIME-DATE

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

              PERFORM POPULATE-TIME-DATE


Move WS-ORIG-DATE to ABND-DATE

The original date is moved to ABND-DATE to record when the abend occurred.

              MOVE WS-ORIG-DATE TO ABND-DATE


Format and move time to ABND-TIME

The current time is formatted and moved to ABND-TIME to capture the exact time of the abend.

              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 to ABND-UTIME-KEY for additional time tracking.

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


Move 'PLOP' to ABND-CODE

The abend code 'PLOP' is moved to ABND-CODE to specify the type of abend.

              MOVE 'PLOP'      TO ABND-CODE


Assign PROGRAM to ABND-PROGRAM

The current program name is assigned to ABND-PROGRAM to identify which program encountered the abend.

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


Move ZEROS to ABND-SQLCODE

Zeros are moved to ABND-SQLCODE to reset any previous SQL error codes.

              MOVE ZEROS      TO ABND-SQLCODE


Format and move freeform message to ABND-FREEFORM

A freeform error message is formatted and moved to ABND-FREEFORM to provide additional context about the abend.

              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 is linked with ABNDINFO-REC to handle the abend using the collected information.

              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 CONTAINER command. This command specifies the container name, channel name, and the variables to store the container's content and length. The response codes are stored in 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.


Checking Response Status

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 '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

The GET-ME-OUT-OF-HERE section is executed when there is an error in retrieving the container. This section contains a EXEC CICS RETURN command, which returns control to CICS, effectively terminating the current 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 generate a new credit score for the customer. This score is a random number between 1 and 999. The COMPUTE statement calculates this score using the RANDOM function, which generates a random number. The formula ensures that the score falls within the desired range.

      *    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 COMPUTE statement calculates the new credit score. The RANDOM function generates a random number, which is then scaled to fit within the range of 1 to 999. This ensures that the credit score is a realistic value for the customer.

           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 CONTAINER command. This command updates the container with the data from WS-CONT-IN and specifies the container name, channel name, and response variables.

           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 is not normal, it indicates an error.

           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 routine is then performed to handle the error.

              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. which indicates the beginning of the finalization process. This step is crucial as it marks the point where the transaction processing is being concluded.


A999.
EXIT.

 

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