Skip to main content

Deleting Customer (DELCUS)

The DELCUS program is responsible for deleting a customer record from the system. This process involves initializing the deletion, verifying the customer's existence, retrieving and deleting associated accounts, and finally removing the customer record from the VSAM file. The program ensures that all related data is properly handled before completing the deletion process.

The flow starts by setting up the necessary information to identify the customer. It then verifies if the customer exists, retrieves any associated accounts, deletes those accounts, and finally removes the customer record from the system. Each step ensures that the data is correctly processed and the deletion is successful.

Where is this program used?

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

Lets' zoom into the flow:


Initializing Customer Deletion

First, the PREMIERE section initializes the customer deletion process by setting up the required sort code and customer number. This is essential for identifying the customer record to be deleted.

       PREMIERE SECTION.
A010.

MOVE SORTCODE TO REQUIRED-SORT-CODE
REQUIRED-SORT-CODE OF CUSTOMER-KY
DESIRED-KEY-SORTCODE.

MOVE COMM-CUSTNO OF DFHCOMMAREA
TO DESIRED-KEY-CUSTOMER.



Calling INQCUST Program

Next, the program calls INQCUST to verify the existence of the customer. This step ensures that the customer record is valid and can be processed for deletion.

           INITIALIZE INQCUST-COMMAREA.
MOVE COMM-CUSTNO OF DFHCOMMAREA TO
INQCUST-CUSTNO.

EXEC CICS LINK PROGRAM(INQCUST-PROGRAM)
COMMAREA(INQCUST-COMMAREA)
END-EXEC.


Handling INQCUST Response

Then, the program checks the response from INQCUST. If the inquiry is unsuccessful, it sets the deletion success flag to 'N' and returns, terminating the process.

More about INQCUST: Get Customer Record (INQCUST)


IF INQCUST-INQ-SUCCESS = 'N'
MOVE 'N' TO COMM-DEL-SUCCESS
MOVE INQCUST-INQ-FAIL-CD TO COMM-DEL-FAIL-CD
EXEC CICS RETURN
END-EXEC
END-IF.


Retrieving Customer Accounts

Moving to the next step, the program performs GET-ACCOUNTS to retrieve any accounts associated with the customer. If accounts are found, it proceeds to delete them.

           PERFORM GET-ACCOUNTS
*
* If there are related accounts found then delete
* them.
*
IF NUMBER-OF-ACCOUNTS > 0
PERFORM DELETE-ACCOUNTS
END-IF


The GET-ACCOUNTS section calls the INQACCCUprogram to get all the accounts of the given customer.

More about INQACCCU: Retrieving Customer Accounts (INQACCCU)

       GET-ACCOUNTS SECTION.
GAC010.
*
* Link to INQACCCU to get all of the accounts for a
* given customer number.
*
MOVE COMM-CUSTNO OF DFHCOMMAREA
TO CUSTOMER-NUMBER OF INQACCCU-COMMAREA.
MOVE 20 TO NUMBER-OF-ACCOUNTS IN INQACCCU-COMMAREA.
SET COMM-PCB-POINTER OF INQACCCU-COMMAREA
TO DELACC-COMM-PCB1

EXEC CICS LINK PROGRAM('INQACCCU')
COMMAREA(INQACCCU-COMMAREA)
SYNCONRETURN
END-EXEC.


The DELETE-ACCOUNTS section calls the DELACCprogram to delete account.

More about DELACC: Deleting Account (DELACC)

       DELETE-ACCOUNTS SECTION.
DA010.

*
* Go through the entries (accounts) in the array,
* and for each one link to DELACC to delete that
* account.
*
PERFORM VARYING WS-INDEX FROM 1 BY 1
UNTIL WS-INDEX > NUMBER-OF-ACCOUNTS
INITIALIZE DELACC-COMMAREA
MOVE WS-APPLID TO DELACC-COMM-APPLID
MOVE COMM-ACCNO(WS-INDEX) TO DELACC-COMM-ACCNO

EXEC CICS LINK PROGRAM('DELACC ')
COMMAREA(DELACC-COMMAREA)
END-EXEC

END-PERFORM.


Deleting Customer Record

After deleting the accounts, the program performs DEL-CUST-VSAM to delete the customer record from the VSAM file. This step ensures that the customer data is completely removed from the system.

      *
* Having deleted the accounts and written the
* details to the PROCTRAN datastore, if we haven't abended
* then we must go on to delete the CUSTOMER record
*

PERFORM DEL-CUST-VSAM



Finalizing Deletion Process

Finally, the program sets the deletion success flag to 'Y' and clears any failure codes. It then performs GET-ME-OUT-OF-HERE to end the process and return control.

           MOVE 'Y' TO COMM-DEL-SUCCESS.
MOVE ' ' TO COMM-DEL-FAIL-CD.

PERFORM GET-ME-OUT-OF-HERE.

A999.
EXIT.

 

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