Skip to main content

Transferring Funds (XFRFUN)

The XFRFUN program handles the transfer of funds within the banking application. It starts by setting up the environment, validating the transaction amount, updating the account in the DB2 database, and finally exiting the transaction. The program ensures that the transaction amount is valid before proceeding with the update and handles any potential errors or abends during the process.

The flow starts with setting up the environment for the transaction, then checks if the transaction amount is valid. If the amount is valid, it updates the account in the DB2 database. If the amount is not valid, it flags the transaction as a failure and exits. Finally, it exits the transaction after updating the account or flagging the failure.

Where is this program used?

This program is used once, in a flow starting from BNK1TFN as represented in the following diagram:

Lets' zoom into the flow:


Start Premiere Transaction

The PREMIERE section begins by setting up the environment for the transaction. It handles any potential abends and initializes key variables to default values.

       PREMIERE SECTION.
A010.

EXEC CICS HANDLE ABEND
LABEL(ABEND-HANDLING)
END-EXEC.

MOVE '0' TO HV-ACCOUNT-EYECATCHER.
MOVE '0' TO HV-ACCOUNT-SORTCODE.
MOVE '0' TO HV-ACCOUNT-ACC-NO.
MOVE 0 TO DB2-DEADLOCK-RETRY.


Validate Transaction Amount

The code checks if the transaction amount (COMM-AMT) is less than or equal to zero. If true, it flags the transaction as a failure and exits the transaction by performing GET-ME-OUT-OF-HERE.

      *    If the amount being transferred is negative, then
* flag this as a failure and finish.
*
IF COMM-AMT <= ZERO
MOVE 'N' TO COMM-SUCCESS
MOVE '4' TO COMM-FAIL-CODE
PERFORM GET-ME-OUT-OF-HERE
END-IF.


Update Account in DB2

If the transaction amount is valid, the code proceeds to update the account in the DB2 database by performing UPDATE-ACCOUNT-DB2.

           PERFORM UPDATE-ACCOUNT-DB2


Exit Transaction

Finally, the code exits the transaction by performing GET-ME-OUT-OF-HERE.

           PERFORM GET-ME-OUT-OF-HERE.


GET-ME-OUT-OF-HERE

The GET-ME-OUT-OF-HERE section handles the termination of the transaction by executing a CICS RETURN command and then performing a GOBACK.

       GET-ME-OUT-OF-HERE SECTION.
GMOOH010.
EXEC CICS RETURN
END-EXEC.

GOBACK.

GMOOH999.
EXIT.


UPDATE-ACCOUNT-DB2

The UPDATE-ACCOUNT-DB2 section handles the logic for updating the account in the DB2 database. It includes checks for transferring between the same account, updating the 'FROM' account, and updating the 'TO' account. It also handles rollback scenarios in case of failures.

       UPDATE-ACCOUNT-DB2 SECTION.
UAD010.

MOVE 'N' TO COMM-SUCCESS.
*
* Are we trying to transfer from and to the same account?
* We don't allow that.
*
IF COMM-FACCNO = COMM-TACCNO
AND COMM-FSCODE = COMM-TSCODE
*
* 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

 

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