Skip to main content

Displaying Customer (BNK1DCS)

The BNK1DCS program is responsible for handling various key presses and performing corresponding actions such as restoring terminal definitions, processing maps, and sending termination messages. This ensures that the program responds appropriately to user inputs and maintains the terminal's state. The program also includes mechanisms for return and error handling to manage the program's response to errors and ensure a smooth return to the main menu or appropriate error handling routines.

The BNK1DCS program starts by setting up Abend handling to manage unexpected errors. It then evaluates user inputs, such as key presses, and performs actions like restoring terminal definitions, processing maps, and sending termination messages. If an error occurs, the program initializes error handling routines, gathers supplemental information, and performs cleanup tasks to ensure the terminal's state is maintained and the program can return to the main menu or handle the error appropriately.

Here is a high level diagram of the program:

Abend Handling Setup


Setting up Abend handling

First, the PREMIERE section sets up the Abend handling using the EXEC CICS HANDLE ABEND command. This ensures that if an abnormal termination (Abend) occurs, control is transferred to the ABEND-HANDLING label. This is crucial for maintaining the stability and reliability of the application by managing unexpected errors gracefully.

       PREMIERE SECTION.
A010.

*
* Set up the Abend handling
*
EXEC CICS HANDLE ABEND
LABEL(ABEND-HANDLING)
END-EXEC.


Input Evaluation and Operations


First Time Check

First, the program checks if it is the first time through by evaluating if EIBCALEN is zero. If true, it initializes the terminal with empty data fields, stores the terminal definition, and sends the map.

              WHEN EIBCALEN = ZERO
MOVE LOW-VALUE TO BNK1DCO
MOVE -1 TO CUSTNOL
SET SEND-ERASE TO TRUE
INITIALIZE WS-COMM-AREA

PERFORM STORE-TERM-DEF

MOVE STORED-UCTRANS TO WS-COMM-TERM

PERFORM SEND-MAP


PA Key Pressed

Next, the program checks if a PA key (DFHPA1, DFHPA2, or DFHPA3) is pressed. If true, it simply continues without any further action.

              WHEN EIBAID = DFHPA1 OR DFHPA2 OR DFHPA3
CONTINUE


PF3 Key Pressed

Then, the program checks if the PF3 key is pressed. If true, it restores the terminal definition and returns to the main menu.

              WHEN EIBAID = DFHPF3

*
* Set the terminal UCTRAN back to its starting position
*
PERFORM RESTORE-TERM-DEF

EXEC CICS RETURN
TRANSID('OMEN')
IMMEDIATE
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC


PF5 Key Pressed

If the PF5 key is pressed, the program processes the incoming data by performing the PROCESS-MAP operation.

              WHEN EIBAID = DFHPF5
PERFORM PROCESS-MAP


PF10 Key Pressed

Similarly, if the PF10 key is pressed, the program processes the incoming data by performing the PROCESS-MAP operation.

              WHEN EIBAID = DFHPF10
PERFORM PROCESS-MAP


AID or PF12 Key Pressed

If the AID or PF12 key is pressed, the program restores the terminal definition and sends a termination message.

              WHEN EIBAID = DFHAID OR DFHPF12
*
* Set the terminal UCTRAN back to its starting position
*
PERFORM RESTORE-TERM-DEF

PERFORM SEND-TERMINATION-MSG

EXEC CICS
RETURN
END-EXEC


CLEAR Key Pressed

When the CLEAR key is pressed, the program restores the terminal definition, erases the screen, and returns control to CICS.

              WHEN EIBAID = DFHCLEAR
*
* Set the terminal UCTRAN back to its starting position
*
PERFORM RESTORE-TERM-DEF

EXEC CICS SEND CONTROL
ERASE
FREEKB
END-EXEC

EXEC CICS RETURN
END-EXEC


ENTER Key Pressed

If the ENTER key is pressed, the program processes the content by performing the PROCESS-MAP operation.

              WHEN EIBAID = DFHENTER
PERFORM PROCESS-MAP


Other Key Pressed

For any other key pressed, the program sends an invalid key message to the user.

              WHEN OTHER
MOVE SPACES TO MESSAGEO
MOVE 'Invalid key pressed.' TO MESSAGEO
MOVE -1 TO CUSTNOL
SET SEND-DATAONLY-ALARM TO TRUE
PERFORM SEND-MAP


RESTORE-TERM-DEF

The RESTORE-TERM-DEF function restores the terminal's UCTRAN setting to its original state. This is crucial for maintaining the terminal's configuration consistency.

       RESTORE-TERM-DEF SECTION.
RTD010.
*
* We must now restore the UCTRAN setting back to what it
* was at the start
*

MOVE DFHCOMMAREA TO WS-COMM-AREA.

MOVE WS-COMM-TERM TO WS-UCTRANS.

EXEC CICS SET TERMINAL(EIBTRMID)
UCTRANST(WS-UCTRANS)
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC.

IF WS-CICS-RESP NOT = DFHRESP(NORMAL)
*
* Preserve the RESP and RESP2, then set up the
* standard ABEND info before getting the applid,


STORE-TERM-DEF

The STORE-TERM-DEF function stores the current UCTRAN setting of the terminal. This is important for ensuring that the terminal's state can be restored later.

       STORE-TERM-DEF SECTION.
STD010.

*
* Inquire on the terminal and store the UCTRANS settings
*
EXEC CICS INQUIRE
TERMINAL(EIBTRMID)
UCTRANST(WS-UCTRANS)
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC.

*
* Store the original UCTRAN value
*
MOVE WS-UCTRANS TO STORED-UCTRANS.

*
* If Uppercase translation is switched on,
* then set it to NOUCTRAN(451).

Interim Summary

So far, we saw how the program handles various key presses and performs corresponding actions such as restoring terminal definitions, processing maps, and sending termination messages. These steps ensure that the program responds appropriately to user inputs and maintains the terminal's state. Now, we will focus on the return and error handling mechanisms, which manage the program's response to errors and ensure a smooth return to the main menu or appropriate error handling routines.

Return and Error Handling


Checking EIBCALEN

First, we check if EIBCALEN is not zero, indicating that this is not the first time through. If true, we move various fields from DFHCOMMAREA to WS-COMM-AREA to preserve the state.

           IF EIBCALEN NOT = ZERO
MOVE COMM-TERM OF DFHCOMMAREA TO WS-COMM-TERM
MOVE COMM-EYE OF DFHCOMMAREA TO WS-COMM-EYE
MOVE COMM-SCODE OF DFHCOMMAREA TO WS-COMM-SCODE
MOVE COMM-CUSTNO OF DFHCOMMAREA TO WS-COMM-CUSTNO
MOVE COMM-NAME OF DFHCOMMAREA TO WS-COMM-NAME
MOVE COMM-ADDR OF DFHCOMMAREA TO WS-COMM-ADDR
MOVE COMM-DOB OF DFHCOMMAREA TO WS-COMM-DOB
MOVE COMM-CREDIT-SCORE OF DFHCOMMAREA
TO WS-COMM-CREDIT-SCORE
MOVE COMM-CS-REVIEW-DATE OF DFHCOMMAREA
TO WS-COMM-CS-REVIEW-DATE
MOVE COMM-UPD OF DFHCOMMAREA TO WS-COMM-UPDATE
END-IF.


Returning TRANSID

Next, we execute a CICS RETURN command with TRANSID('ODCS'), passing the WS-COMM-AREA and setting response codes in WS-CICS-RESP and WS-CICS-RESP2.

           EXEC CICS
RETURN TRANSID('ODCS')
COMMAREA(WS-COMM-AREA)
LENGTH(266)
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC.


Handling Error Response

Then, we check if WS-CICS-RESP is not equal to DFHRESP(NORMAL). If true, we initialize ABNDINFO-REC, move response codes to ABND-RESPCODE and ABND-RESP2CODE, and gather supplemental information like APPLID, TASKNO, and TRANID. We then perform POPULATE-TIME-DATE to get the current date and time, and format it into ABND-DATE and ABND-TIME.

           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

The POPULATE-TIME-DATE section uses CICS commands to get the current time and format it into a human-readable date and time, storing these in WS-ORIG-DATE and WS-TIME-NOW.

       POPULATE-TIME-DATE SECTION.
PTD10.
D DISPLAY 'POPULATE-TIME-DATE SECTION'.

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.


Finalizing Error Handling

Moving to the final steps, we set additional fields in ABNDINFO-REC, create a freeform error message, and link to the WS-ABEND-PGM program. We then initialize WS-FAIL-INFO, move error messages to display fields, and perform cleanup tasks like RESTORE-TERM-DEF and ABEND-THIS-TASK.

              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
END-STRING

MOVE WS-U-TIME TO ABND-UTIME-KEY
MOVE 'HBNK' TO ABND-CODE

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

MOVE ZEROS TO ABND-SQLCODE

STRING 'A010 - RETURN TRANSID(ODCS) FAIL'
DELIMITED BY SIZE,
'EIBRESP=' DELIMITED BY SIZE,
ABND-RESPCODE DELIMITED BY SIZE,

 

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