Skip to main content

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 is zero. This indicates that the transaction is being executed for the first time.

           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 to BNK1MEO and setting ACTIONL to -1. This prepares the screen to be displayed with no pre-filled data.

                 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 flag to true, indicating that the map should be sent with erased (empty) data fields. It then performs the SEND-MAP operation to display the initialized screen to the user.

                 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, or DFHPA3) are pressed, the program continues without any specific action.

      *       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 function to send a termination message and then returns control to CICS.

      *       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). If the Enter key is pressed, we proceed to process the menu map.

              WHEN EIBAID = DFHENTER


Process Menu Map

Next, we perform the PROCESS-MENU-MAP operation, which handles the processing of the menu map based on the user's input.

                 PERFORM PROCESS-MENU-MAP


Invalid Key Pressed

If any key other than Enter is pressed, we move to the WHEN OTHER condition to handle invalid key presses.

              WHEN OTHER


Send Invalid Key Message

Then, we move low-values to BNK1MEO, set the message to 'Invalid key pressed.', set the action level to -1, and set the SEND-DATAONLY-ALARM to true. Finally, we perform the SEND-MAP operation to send the invalid key message to the user.

                 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 command is used to return control to the main menu transaction identified by 'OMEN'. This ensures that after completing a transaction, the user is redirected back to the main menu for further actions.

           EXEC CICS
RETURN TRANSID('OMEN')
COMMAREA(COMMUNICATION-AREA)
LENGTH(1)
RESP(WS-CICS-RESP)


Passing Communication Area

Next, the COMMAREA(COMMUNICATION-AREA) parameter is used to pass the communication area to the main menu transaction. This allows the main menu to have access to any relevant data from the completed transaction.

              COMMAREA(COMMUNICATION-AREA)


Setting Response Code

Finally, the RESP(WS-CICS-RESP) parameter is used to set the response code. This helps in determining the success or failure of the return operation and can be used for error handling or logging purposes.

              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 is not equal to DFHRESP(NORMAL). This condition determines if there was an abnormal response from the CICS transaction.

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


Initializing Abend Information

Next, we initialize the ABNDINFO-REC record and move the response codes EIBRESP and EIBRESP2 to ABND-RESPCODE and ABND-RESP2CODE respectively. This step preserves the response codes for further processing.

              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. This helps in identifying the application context during the abend.

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


Moving Task and Transaction IDs

We move the task number EIBTASKN to ABND-TASKNO-KEY and the transaction ID EIBTRNID to ABND-TRANID. These IDs are crucial for tracking the specific task and transaction that encountered the error.

              MOVE EIBTASKN   TO ABND-TASKNO-KEY
MOVE EIBTRNID TO ABND-TRANID



Populating Time and Date

We perform the POPULATE-TIME-DATE section to get the current date and time. This information is essential for logging the exact time of the error occurrence.

              PERFORM POPULATE-TIME-DATE


Populating Time and Date Details

The POPULATE-TIME-DATE section uses CICS commands to get the current time (ASKTIME) and format it (FORMATTIME). The formatted date and time are stored in WS-ORIG-DATE and WS-TIME-NOW respectively.

       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 to ABND-DATE and construct the time string from WS-TIME-NOW-GRP-HH, WS-TIME-NOW-GRP-MM, and WS-TIME-NOW-GRP-SS to store in ABND-TIME. This step ensures that the abend record has accurate date and time information.

              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. This helps in identifying the program where the error occurred.

              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 and is useful for debugging and logging purposes.

              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 with the communication area ABNDINFO-REC. This step triggers the abend handling process.

              EXEC CICS LINK PROGRAM(WS-ABEND-PGM)
COMMAREA(ABNDINFO-REC)
END-EXEC


Finalizing Abend Information

Finally, we initialize the WS-FAIL-INFO record and move the failure message and response codes to their respective fields. We then perform the ABEND-THIS-TASK section to complete the abend process.

              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