Generating and Storing Credit Scores (CRDTAGY1)
The CRDTAGY1
The CRDTAGY1
Here is a high level diagram of the program:
Setup and Delay
Generating Delay
First, the program sets up the container and channel names, and initializes the seed for the random number generator. It then computes a random delay amount between 1 and 3 seconds and executes a CICS DELAY command to introduce this delay.
PREMIERE SECTION.
A010.
*
* Generate a random number of seconds between 0 & 3.
* This is the delay amount in seconds.
*
MOVE 'CIPA ' 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.
Handling Delay Response
Next, the program checks if the delay response is not normal. If the response is not normal, it initializes the ABNDINFO-REC
POPULATE-TIME-DATE
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
POPULATE-TIME-DATE
POPULATE-TIME-DATE
The POPULATE-TIME-DATE
ABNDINFO-REC
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
Move Original Date to Abend Date
First, the original date is moved to the abend date field to record when the delay occurred.
MOVE WS-ORIG-DATE TO ABND-DATE
Format Current Time
Next, the current time is formatted into a string with hours, minutes, and seconds, and stored in the abend time field.
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 Current Time to Abend Time
Then, the formatted current time is moved into the abend time field.
INTO ABND-TIME
Move User Time to Abend UTime Key
Moving to the next step, the user time is moved to the abend UTime key field.
MOVE WS-U-TIME TO ABND-UTIME-KEY
Set Abend Code to PLOP
The abend code is set to 'PLOP' to indicate the type of error.
MOVE 'PLOP' TO ABND-CODE
Assign Program to Abend Program
The current program is assigned to the abend program field for tracking purposes.
EXEC CICS ASSIGN PROGRAM(ABND-PROGRAM)
END-EXEC
Move Zeros to Abend SQLCode
Zeros are moved to the abend SQL code field to reset any previous SQL error codes.
MOVE ZEROS TO ABND-SQLCODE
Format Freeform Abend Message
A freeform abend message is formatted with specific error details including response codes.
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 Abend Program with Abend Info
The abend program is linked with the abend information record to handle the error.
EXEC CICS LINK PROGRAM(WS-ABEND-PGM)
COMMAREA(ABNDINFO-REC)
END-EXEC
Display Delay Error Message
An error message is displayed to indicate that the delay caused an issue.
DISPLAY '*** The delay messed up ! ***'
Trigger Abend with Code PLOP
Finally, the abend is triggered with the code 'PLOP' to terminate the process due to the error.
EXEC CICS ABEND
ABCODE('PLOP')
END-EXEC
Interim Summary
So far, we saw how the program handles the delay response, including setting up the ABNDINFO-REC
Retrieve Container
Compute Container Length
First, the length of the container WS-CONT-IN
WS-CONTAINER-LEN
COMPUTE WS-CONTAINER-LEN = LENGTH OF WS-CONT-IN.
Get Container from CICS Channel
Next, the container is retrieved from the CICS channel using the EXEC CICS GET CONTAINER
WS-CONTAINER-NAME
WS-CHANNEL-NAME
WS-CONT-IN
WS-CONTAINER-LEN
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 Code
Then, the response code WS-CICS-RESP
DFHRESP(NORMAL)
IF WS-CICS-RESP NOT = DFHRESP(NORMAL)
DISPLAY 'CRDTAGY1 - 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
Handle Error
If an error occurs during the container retrieval, the GET-ME-OUT-OF-HERE
EXEC CICS RETURN
GET-ME-OUT-OF-HERE SECTION.
GMOFH010.
EXEC CICS RETURN
END-EXEC.
GMOFH999.
EXIT.
Generate and Store Credit Score
This is the next section of the flow.
Generate Credit Score
First, we generate a new credit score for the customer. The credit score is computed using the RANDOM
COMPUTE WS-NEW-CREDSCORE = ((999 - 1)
* FUNCTION RANDOM) + 1.
Move Credit Score to Container
Next, we move the newly generated credit score (WS-NEW-CREDSCORE
WS-CONT-IN-CREDIT-SCORE
MOVE WS-NEW-CREDSCORE TO WS-CONT-IN-CREDIT-SCORE.
Put Data Back into Container
Then, we compute the length of the container data (WS-CONTAINER-LEN
EXEC CICS PUT 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)
END-EXEC.
Final Error Handling and Exit
Check CICS Response
First, the code checks if the CICS response (WS-CICS-RESP
DFHRESP(NORMAL)
IF WS-CICS-RESP NOT = DFHRESP(NORMAL)
Display Error Message
If the CICS response is not normal, the code displays an error message. This message includes the response codes (WS-CICS-RESP
WS-CICS-RESP2
WS-CONTAINER-NAME
WS-CHANNEL-NAME
WS-CONTAINER-LEN
DISPLAY 'CRDTAGY1 - 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 Exit Routine on Error
Next, the code performs the GET-ME-OUT-OF-HERE
PERFORM GET-ME-OUT-OF-HERE
END-IF.
Perform Exit Routine
Finally, the code performs the GET-ME-OUT-OF-HERE
PERFORM GET-ME-OUT-OF-HERE.
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human