Skip to main content

Credit Score Generation and Update (CRDTAGY4)

The CRDTAGY4 program is responsible for generating and updating credit scores. It achieves this by setting up container and channel names, generating a random delay, handling errors, retrieving containers, and updating them with new credit scores. The program ensures accurate logging and graceful error handling.

The flow starts with setting up container and channel names, followed by generating a random delay. If any errors occur, they are logged with accurate timestamps. The program then retrieves the container, generates a new credit score, updates the container with this score, and checks the response status. If any errors are detected, they are handled gracefully.

Here is a high level diagram of the program:

Setup and 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 generating a random delay amount. This delay is then applied using the EXEC CICS DELAY command. If the response from this command is not normal, it proceeds to handle the error by preserving the response codes and gathering additional information such as application ID, task number, and transaction ID. It then performs the POPULATE-TIME-DATE paragraph to get the current date and time, and formats this information for error logging.

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

MOVE 'CIPD ' 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.

IF WS-CICS-RESP NOT = DFHRESP(NORMAL)


POPULATE-TIME-DATE

The POPULATE-TIME-DATE section is responsible for obtaining the current time and date. It uses the EXEC CICS ASKTIME command to get the current time in an absolute format and then formats this time into a more readable date and time format using the EXEC CICS FORMATTIME command. This information is then used in the error handling process to provide accurate timestamps for logging purposes.

       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.

Container retrieval and error handling


Handling Error Conditions

First, the code checks if the response from the GET CONTAINER command is not normal. If the response is not normal, it logs the error details and performs the GET-ME-OUT-OF-HERE routine to handle the error gracefully.

           IF WS-CICS-RESP NOT = DFHRESP(NORMAL)
DISPLAY 'CRDTAGY4 - 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 responsible for returning control to CICS in case of an error. This ensures that the program exits gracefully without causing further issues.

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

EXEC CICS RETURN
END-EXEC.

GMOFH999.
EXIT.

Interim Summary

So far, we saw how the program handles delay and error management, including setting up container and channel names, generating a random delay, and logging errors with accurate timestamps. We also covered the retrieval of containers and the graceful handling of errors using the GET-ME-OUT-OF-HERE routine. Now, we will focus on generating a new credit score and updating the container with this new score.

Credit score generation and container update


Generate Credit Score

First, we generate a new credit score between 1 and 999 using the RANDOM function. This score is stored in WS-NEW-CREDSCORE.

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


Update Container with Credit Score

Next, we move the new credit score to WS-CONT-IN-CREDIT-SCORE and then update the container with this new score using the PUT CONTAINER command. The container's length is calculated and the data is put back into the container.

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

*
* Now PUT the data back into a container
*
COMPUTE WS-CONTAINER-LEN = LENGTH OF WS-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)


Check Response Status

Then, we check the response status using WS-CICS-RESP. If the response is not normal, an error message is displayed, and the GET-ME-OUT-OF-HERE routine is performed.

           IF WS-CICS-RESP NOT = DFHRESP(NORMAL)
DISPLAY 'CRDTAGY4- 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.


Handle Error if Any

Finally, the GET-ME-OUT-OF-HERE routine is performed to handle any cleanup or exit procedures.

           PERFORM GET-ME-OUT-OF-HERE.

 

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