Main Menu (BNKMENU)
The BNKMENU program is responsible for managing the main menu interactions in the CICS Bank Sample Application. It initializes the screen for first-time use, handles various key presses, processes valid input, and returns control to the main menu. The program ensures smooth navigation and error handling within the application.
The BNKMENU program starts by checking if it's the first time the screen is being used and initializes it with empty data if so. It then handles different key presses, such as PA keys, PF3, PF12, CLEAR, and ENTER, performing specific actions for each. If the ENTER key is pressed, it processes the menu map based on user input. Finally, it returns control to the main menu and handles any errors that occur during the process.
Here is a high level diagram of the program:
Initialization for first-time use
Check if first time through
First, the code checks if it is the first time through by evaluating if EIBCALEN
EVALUATE TRUE
*
* Is it the first time through? If so, send the map
* with erased (empty) data fields.
*
WHEN EIBCALEN = ZERO
Initialize screen with empty data
Next, the code initializes the screen with empty data by moving LOW-VALUE
BNK1MEO
ACTIONL
MOVE LOW-VALUE TO BNK1MEO
MOVE -1 TO ACTIONL
SET SEND-ERASE TO TRUE
Send map with erased data
Then, the code sets the SEND-ERASE
SEND-MAP
PERFORM SEND-MAP
Handle PA and special keys
Handling PA Key Presses
First, the code checks if a PA key (Program Attention key) is pressed. If any of the PA keys (DFHPA1
DFHPA2
DFHPA3
* If a PA key is pressed, just carry on
*
WHEN EIBAID = DFHPA1 OR DFHPA2 OR DFHPA3
CONTINUE
Handling PF3 or PF12 Key Presses
Next, the code checks if either PF3 or PF12 key is pressed. If either of these keys is pressed, the program performs the SEND-TERMINATION-MSG
* When Pf3 or Pf12 is pressed, terminate
*
WHEN EIBAID = DFHPF3 OR DFHPF12
PERFORM SEND-TERMINATION-MSG
EXEC CICS
RETURN
END-EXEC
Handling CLEAR Key Press
Then, the code checks if the CLEAR key is pressed. If the CLEAR key is pressed, the program sends a control command to erase the screen and free the keyboard, and then returns control to CICS.
* When CLEAR is pressed
*
WHEN EIBAID = DFHCLEAR
EXEC CICS SEND CONTROL
ERASE
FREEKB
END-EXEC
EXEC CICS RETURN
END-EXEC
Process valid input key (Enter)
User presses Enter
First, we check if the user has pressed the Enter key (EIBAID = DFHENTER
WHEN EIBAID = DFHENTER
Process Menu Map
Next, we perform the PROCESS-MENU-MAP
PERFORM PROCESS-MENU-MAP
Invalid Key Pressed
If any key other than Enter is pressed, we move to the WHEN OTHER
WHEN OTHER
Send Invalid Key Message
Then, we move low-values to BNK1MEO
SEND-DATAONLY-ALARM
SEND-MAP
MOVE LOW-VALUES TO BNK1MEO
MOVE 'Invalid key pressed.' TO MESSAGEO
MOVE -1 TO ACTIONL
SET SEND-DATAONLY-ALARM TO TRUE
PERFORM SEND-MAP
Return to CICS
This is the next section of the flow.
Returning Control to Main Menu
First, the EXEC CICS RETURN
EXEC CICS
RETURN TRANSID('OMEN')
COMMAREA(COMMUNICATION-AREA)
LENGTH(1)
RESP(WS-CICS-RESP)
Passing Communication Area
Next, the COMMAREA(COMMUNICATION-AREA)
COMMAREA(COMMUNICATION-AREA)
Setting Response Code
Finally, the RESP(WS-CICS-RESP)
RESP(WS-CICS-RESP)
Interim Summary
So far, we saw how the program handles the initialization for first-time use, processes various key presses, and returns control to the main menu. Now, we will focus on error handling, which includes checking the CICS response and managing abend situations.
Error Handling
Checking CICS Response
First, we check if WS-CICS-RESP
DFHRESP(NORMAL)
IF WS-CICS-RESP NOT = DFHRESP(NORMAL)
Initializing Abend Information
Next, we initialize the ABNDINFO-REC
EIBRESP
EIBRESP2
ABND-RESPCODE
ABND-RESP2CODE
INITIALIZE ABNDINFO-REC
MOVE EIBRESP TO ABND-RESPCODE
MOVE EIBRESP2 TO ABND-RESP2CODE
Assigning Application ID
Then, we execute the CICS ASSIGN command to get the application ID and store it in ABND-APPLID
EXEC CICS ASSIGN APPLID(ABND-APPLID)
END-EXEC
Moving Task and Transaction IDs
We move the task number EIBTASKN
ABND-TASKNO-KEY
EIBTRNID
ABND-TRANID
MOVE EIBTASKN TO ABND-TASKNO-KEY
MOVE EIBTRNID TO ABND-TRANID
Populating Time and Date
We perform the POPULATE-TIME-DATE
PERFORM POPULATE-TIME-DATE
Populating Time and Date Details
The POPULATE-TIME-DATE
ASKTIME
FORMATTIME
WS-ORIG-DATE
WS-TIME-NOW
POPULATE-TIME-DATE SECTION.
PTD010.
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.
Moving Date and Time
We move the original date WS-ORIG-DATE
ABND-DATE
WS-TIME-NOW-GRP-HH
WS-TIME-NOW-GRP-MM
WS-TIME-NOW-GRP-SS
ABND-TIME
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
Assigning Program Name
We execute another CICS ASSIGN command to get the program name and store it in ABND-PROGRAM
EXEC CICS ASSIGN PROGRAM(ABND-PROGRAM)
END-EXEC
Constructing Freeform Message
We construct a freeform message that includes the error details such as response codes. This message is stored in ABND-FREEFORM
STRING 'A010 - RETURN TRANSID(MENU) FAIL.'
DELIMITED BY SIZE,
' EIBRESP=' DELIMITED BY SIZE,
ABND-RESPCODE DELIMITED BY SIZE,
' RESP2=' DELIMITED BY SIZE,
ABND-RESP2CODE DELIMITED BY SIZE
INTO ABND-FREEFORM
Linking to Abend Handler
We execute the CICS LINK command to call the abend handler program WS-ABEND-PGM
ABNDINFO-REC
EXEC CICS LINK PROGRAM(WS-ABEND-PGM)
COMMAREA(ABNDINFO-REC)
END-EXEC
Finalizing Abend Information
Finally, we initialize the WS-FAIL-INFO
ABEND-THIS-TASK
INITIALIZE WS-FAIL-INFO
MOVE 'BNKMENU - A010 - RETURN TRANSID(MENU) FAIL' TO
WS-CICS-FAIL-MSG
MOVE WS-CICS-RESP TO WS-CICS-RESP-DISP
MOVE WS-CICS-RESP2 TO WS-CICS-RESP2-DISP
PERFORM ABEND-THIS-TASK
END-IF.
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human