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-DB2DEL-ACCOUNT-DB2GET-ME-OUT-OF-HERE
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 PREMIERESORTCODEREQUIRED-SORT-CODEACCOUNT-KEY-RIDREAD-ACCOUNT-DB2
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
READ-ACCOUNT-DB2The READ-ACCOUNT-DB2DELACC-DEL-SUCCESSDELACC-DEL-SUCCESS
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
DEL-ACCOUNT-DB2The DEL-ACCOUNT-DB2DELACC-DEL-SUCCESSWRITE-PROCTRAN
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
GET-ME-OUT-OF-HEREThe GET-ME-OUT-OF-HEREGOBACK
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