Skip to main content

Deleting Account (DELACC)

The DELACC program is responsible for deleting an account from the database. It achieves this by first retrieving the account record using the account number and sort code, and then deleting the account if it exists. The program also logs the transaction if the deletion is successful.

The flow starts with the PREMIERE section, which initiates the account deletion process by moving the sort code to the required sort code of the account key. It then retrieves the account record from the database in the READ-ACCOUNT-DB2 section. If the account is found, the DEL-ACCOUNT-DB2 section deletes the account record. Finally, the GET-ME-OUT-OF-HERE section ends the process by returning control to the calling program.

Where is this program used?

This program is used multiple times in the codebase as represented in the following diagram:

Lets' zoom into the flow:


PREMIERE Section

The PREMIERE section initiates the account deletion process. It starts by moving the SORTCODE to REQUIRED-SORT-CODE of ACCOUNT-KEY-RID, which is necessary for identifying the account to be deleted. Then, it performs the READ-ACCOUNT-DB2 paragraph to retrieve the account record from the database.

       PREMIERE SECTION.
A010.

MOVE SORTCODE TO REQUIRED-SORT-CODE OF ACCOUNT-KEY-RID.

*
* Get the account record
*
PERFORM READ-ACCOUNT-DB2.

*
* If a matching account record was successfully
* retrieved then delete it
*
IF DELACC-DEL-SUCCESS = 'Y'

PERFORM DEL-ACCOUNT-DB2
IF DELACC-DEL-SUCCESS = 'Y'
PERFORM WRITE-PROCTRAN
END-IF
END-IF


READ-ACCOUNT-DB2 Section

The READ-ACCOUNT-DB2 section retrieves the account record from the database using the account number and sort code. If the account is found, it sets the DELACC-DEL-SUCCESS flag to 'Y'. If the account is not found, it sets the DELACC-DEL-SUCCESS flag to 'N' and returns an error code.

       READ-ACCOUNT-DB2 SECTION.
RAD010.

*
* Take the Account number from the comm area and retrieve
* the account record from the datastore.
*
MOVE DELACC-ACCNO
TO HV-ACCOUNT-ACC-NO.

MOVE SORTCODE TO HV-ACCOUNT-SORTCODE.

EXEC SQL
SELECT ACCOUNT_EYECATCHER,
ACCOUNT_CUSTOMER_NUMBER,
ACCOUNT_SORTCODE,
ACCOUNT_NUMBER,
ACCOUNT_TYPE,
ACCOUNT_INTEREST_RATE,
ACCOUNT_OPENED,
ACCOUNT_OVERDRAFT_LIMIT,


DEL-ACCOUNT-DB2 Section

The DEL-ACCOUNT-DB2 section deletes the account record from the database if the DELACC-DEL-SUCCESS flag is 'Y'. If the deletion is successful, it performs the WRITE-PROCTRAN paragraph to log the transaction.

       DEL-ACCOUNT-DB2 SECTION.
DADB010.

*
* Delete the ACCOUNT row where the SORTCODE and ACCOUNT
* NUMBER match.
*
EXEC SQL
DELETE FROM ACCOUNT
WHERE ACCOUNT_SORTCODE = :HV-ACCOUNT-SORTCODE AND
ACCOUNT_NUMBER = :HV-ACCOUNT-ACC-NO
END-EXEC.

IF SQLCODE NOT = 0
MOVE ' ' TO DELACC-SUCCESS
MOVE 'N' TO DELACC-DEL-SUCCESS
MOVE '3' TO DELACC-DEL-FAIL-CD
END-IF.

DADB999.
EXIT.


GET-ME-OUT-OF-HERE Section

The GET-ME-OUT-OF-HERE section ends the process by executing the GOBACK statement, which returns control to the calling program.

       GET-ME-OUT-OF-HERE SECTION.
GMOFH010.

GOBACK.

GMOFH999.
EXIT.

 

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