Skip to main content

Transferring Funds (BNK1TFN)

The BNK1TFN program contains the functionality that allows the transfer of funds between accounts within the same bank. This process involves validating the input data, such as account numbers and transfer amounts, ensuring that the accounts are different and valid, and then performing the transfer operation. The program handles various user interactions, including sending maps, processing data, and handling errors or invalid inputs. It ensures that the transfer is executed correctly and updates the account balances accordingly.

The flow starts by evaluating the key pressed by the user. Depending on the key, it performs actions like sending maps with erased data fields, continuing without action, returning to the main menu, sending termination messages, erasing the screen, processing entered content, or notifying the user of an invalid key press. After handling the key press, the program returns control to the main transaction, ensuring the application flow continues smoothly. If an error occurs, it logs the error details and calls the abend handler for further processing.

Here is a high level diagram of the program:

Evaluate and Control Actions


Handling First Time Through

First, the code checks if it is the first time through by evaluating if EIBCALEN is zero. If it is, it moves low values to BNK1TFO, sets SEND-ERASE to true, and performs SEND-MAP to send the map with erased data fields.

           EVALUATE TRUE

*
* Is it the first time through? If so, send the map
* with erased (empty) data fields.
*
WHEN EIBCALEN = ZERO
MOVE LOW-VALUE TO BNK1TFO
SET SEND-ERASE TO TRUE
PERFORM SEND-MAP


Handling PA Key Presses

Moving to the next condition, if a PA key (DFHPA1, DFHPA2, or DFHPA3) is pressed, the program simply continues without any additional action.

      *       If a PA key is pressed, just carry on
*
WHEN EIBAID = DFHPA1 OR DFHPA2 OR DFHPA3
CONTINUE


Handling Pf3 Key Press

Next, if the Pf3 key (DFHPF3) is pressed, the program returns to the main menu by executing a CICS RETURN command with the transaction ID 'OMEN'.

      *       When Pf3 is pressed, return to the main menu
*
WHEN EIBAID = DFHPF3
EXEC CICS RETURN
TRANSID('OMEN')
IMMEDIATE
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC


Handling Aid or Pf12 Key Press

Then, if the aid key (DFHAID) or Pf12 key (DFHPF12) is pressed, the program performs SEND-TERMINATION-MSG and executes a CICS RETURN command to terminate the session.

      *       If the aid or Pf12 is pressed, then send a termination
* message.
*
WHEN EIBAID = DFHAID OR DFHPF12
PERFORM SEND-TERMINATION-MSG
EXEC CICS
RETURN
END-EXEC


Handling CLEAR Key Press

When the CLEAR key (DFHCLEAR) is pressed, the program sends a control command to erase the screen and free the keyboard, 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


Handling ENTER Key Press

When the ENTER key (DFHENTER) is pressed, the program performs PROCESS-MAP to process the content entered by the user.

      *       When enter is pressed then process the content
*
WHEN EIBAID = DFHENTER
PERFORM PROCESS-MAP



Handling Invalid Key Press

Finally, if any other key is pressed, the program moves low values to BNK1TFO, sets an invalid key message to MESSAGEO, sets SEND-DATAONLY-ALARM to true, and performs SEND-MAP to notify the user of the invalid key press.

      *
WHEN OTHER
MOVE LOW-VALUES TO BNK1TFO
MOVE 'Invalid key pressed.' TO MESSAGEO
* MOVE 10 TO CUSTNOL
SET SEND-DATAONLY-ALARM TO TRUE
PERFORM SEND-MAP


Return to CICS

This is the next section of the flow.


Return Control to Main Transaction

First, the RETURN command is used to pass control back to the main transaction. This is essential for ensuring that the application flow continues as expected after the current processing is complete.

      *
* Now RETURN
*
EXEC CICS
RETURN TRANSID('OTFN')
COMMAREA(WS-COMMAREA)
LENGTH(29)
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC.



Specify Transaction ID

Next, the TRANSID('OTFN') specifies the transaction ID to which control should be returned. This ensures that the correct transaction is resumed.

            EXEC CICS
RETURN TRANSID('OTFN')
COMMAREA(WS-COMMAREA)
LENGTH(29)
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC.



Pass Communication Area

Then, the COMMAREA(WS-COMMAREA) passes the communication area, which contains data that needs to be shared between transactions. This is crucial for maintaining the state and context of the application.

            EXEC CICS
RETURN TRANSID('OTFN')
COMMAREA(WS-COMMAREA)
LENGTH(29)
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC.



Set Length of Communication Area

The LENGTH(29) sets the length of the communication area to 29 bytes. This ensures that the correct amount of data is passed between transactions.

            EXEC CICS
RETURN TRANSID('OTFN')
COMMAREA(WS-COMMAREA)
LENGTH(29)
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC.



Handle Response Codes

Finally, the RESP(WS-CICS-RESP) and RESP2(WS-CICS-RESP2) handle the primary and secondary response codes from the CICS command. These response codes are used to determine if the command was successful or if any errors occurred.

            EXEC CICS
RETURN TRANSID('OTFN')
COMMAREA(WS-COMMAREA)
LENGTH(29)
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC.


Interim Summary

So far, we saw how the program handles different key presses such as PA keys, Pf3, aid or Pf12, CLEAR, ENTER, and other invalid keys, and how it returns control to the main transaction. Now, we will focus on error handling, where the program checks for abnormal CICS responses and processes them accordingly.

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)


Preserving Response Codes

Next, we preserve the response codes by moving EIBRESP to ABND-RESPCODE and EIBRESP2 to ABND-RESP2CODE. This ensures that we have the original response codes for logging and debugging.

              INITIALIZE ABNDINFO-REC
MOVE EIBRESP TO ABND-RESPCODE
MOVE EIBRESP2 TO ABND-RESP2CODE


Assigning Application ID

Then, we assign the application ID to ABND-APPLID using the EXEC CICS ASSIGN command. This helps in identifying which application encountered the error.

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


Moving Task and Transaction IDs

We move the task number and transaction ID to ABND-TASKNO-KEY and ABND-TRANID respectively. These values are crucial for tracking the specific task and transaction that failed.

              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 is important for logging the exact time of the error.

              PERFORM POPULATE-TIME-DATE


Populating Time and Date Details

The POPULATE-TIME-DATE section uses EXEC CICS ASKTIME to get the current time and EXEC CICS FORMATTIME to format it into a readable date and time. This formatted date and time are then used in the abend information.

       POPULATE-TIME-DATE SECTION.
PTD010.
*
* Fomate the date and time
*
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 to ABND-DATE and construct a time string from WS-TIME-NOW-GRP-HH, WS-TIME-NOW-GRP-MM, and WS-TIME-NOW-GRP-MM to ABND-TIME. This provides a complete timestamp for the error.

              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 assign the current program name to ABND-PROGRAM using EXEC CICS ASSIGN. This helps in identifying which program encountered the error.

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


Constructing Freeform Message

We construct a freeform message that includes the error codes and a descriptive message. This message is stored in ABND-FREEFORM and is useful for debugging and logging.

              STRING 'A010 - RETURN TRANSID(OCCS) 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

Finally, we link to the abend handler program using EXEC CICS LINK PROGRAM(WS-ABEND-PGM) COMMAREA(ABNDINFO-REC). This passes the abend information to the handler for further processing.

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

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