Processing Account Creation (CREACC)
The CREACC program is responsible for creating new bank accounts. It starts by setting up necessary fields, validating customer information, and then proceeds to count and validate customer accounts. The program ensures that only valid account types are processed and handles any errors that may occur during the process. Finally, it enqueues a named counter, finds the next available account number, and writes the new account details to the DB2
The flow starts with setting up fields and validating customer information. If the customer is valid, it counts and validates the customer's accounts. It then ensures the account type is valid, enqueues a named counter, finds the next available account number, and writes the new account details to the DB2
Where is this program used?
This program is used once, in a flow starting from BNK1CAC as represented in the following diagram:
Here is a high level diagram of the program:
Setups
Moving SORTCODE to REQUIRED-SORT-CODE
REQUIRED-SORT-CODEFirst, the SORTCODEREQUIRED-SORT-CODEREQUIRED-SORT-CODE2
MOVE SORTCODE TO
REQUIRED-SORT-CODE
REQUIRED-SORT-CODE2.
Moving ZERO to ACCOUNT-NUMBER
ACCOUNT-NUMBERNext, the ACCOUNT-NUMBER
MOVE ZERO TO ACCOUNT-NUMBER.
Initializing INQCUST-COMMAREA
INQCUST-COMMAREAThen, the INQCUST-COMMAREAINQCUST
INITIALIZE INQCUST-COMMAREA
Moving COMM-CUSTNO to INQCUST-CUSTNO
COMM-CUSTNOINQCUST-CUSTNOMoving to the next step, the COMM-CUSTNODFHCOMMAREAINQCUST-CUSTNO
MOVE COMM-CUSTNO IN DFHCOMMAREA TO INQCUST-CUSTNO.
Calling INQCUST Program
Finally, the INQCUSTEXEC CICS LINKINQCUST
More about INQCUST:
EXEC CICS LINK PROGRAM('INQCUST ')
COMMAREA(INQCUST-COMMAREA)
RESP(WS-CICS-RESP)
END-EXEC.
Customer validation
Call to INQCUST
First, the program makes a call to the INQCUSTEXEC CICS LINKINQCUSTINQCUST-COMMAREA
More about INQCUST:
EXEC CICS LINK PROGRAM('INQCUST ')
COMMAREA(INQCUST-COMMAREA)
RESP(WS-CICS-RESP)
END-EXEC.
Check Response
Next, the program checks the response from the INQCUSTEIBRESPINQCUST-INQ-SUCCESS
IF EIBRESP IS NOT EQUAL TO DFHRESP(NORMAL)
OR INQCUST-INQ-SUCCESS IS NOT EQUAL TO 'Y'
Handle Failure
If the response check fails, the program sets the COMM-SUCCESSCOMM-FAIL-CODEDFHCOMMAREAGET-ME-OUT-OF-HERE
MOVE 'N' TO COMM-SUCCESS IN DFHCOMMAREA
MOVE '1' TO COMM-FAIL-CODE IN DFHCOMMAREA
PERFORM GET-ME-OUT-OF-HERE
END-IF
Count Customer Accounts
If the response check is successful, the program proceeds to the CUSTOMER-ACCOUNT-COUNTDFHCOMMAREAINQACCCU-COMMAREAINQACCCU
CUSTOMER-ACCOUNT-COUNT SECTION.
CAC010.
MOVE 20 TO NUMBER-OF-ACCOUNTS IN INQACCCU-COMMAREA.
MOVE COMM-CUSTNO IN DFHCOMMAREA
TO CUSTOMER-NUMBER IN INQACCCU-COMMAREA.
SET COMM-PCB-POINTER TO NULL
EXEC CICS LINK PROGRAM('INQACCCU')
COMMAREA(INQACCCU-COMMAREA)
RESP(WS-CICS-RESP)
SYNCONRETURN
END-EXEC.
CAC999.
EXIT.
Interim Summary
So far, we saw how the program initializes various fields and makes a call to the INQCUSTINQACCCU
Account information fetching and validation
Retrieve Customer Account Information
First, the program performs the CUSTOMER-ACCOUNT-COUNT
PERFORM CUSTOMER-ACCOUNT-COUNT.
Check Response Status
Next, the program checks if the response status WS-CICS-RESPDFHRESP(NORMAL)GET-ME-OUT-OF-HERE
IF WS-CICS-RESP IS NOT EQUAL TO DFHRESP(NORMAL)
DISPLAY 'Error counting accounts'
MOVE 'N' to COMM-SUCCESS IN DFHCOMMAREA
MOVE 'N' to COMM-SUCCESS IN INQACCCU-COMMAREA
MOVE '9' TO COMM-FAIL-CODE IN DFHCOMMAREA
PERFORM GET-ME-OUT-OF-HERE
END-IF
Check Communication Success
Then, the program checks if the communication success flag COMM-SUCCESSINQACCCU-COMMAREAGET-ME-OUT-OF-HERE
IF COMM-SUCCESS IN INQACCCU-COMMAREA = 'N'
DISPLAY 'Error counting accounts'
MOVE 'N' to COMM-SUCCESS IN DFHCOMMAREA
MOVE '9' TO COMM-FAIL-CODE IN DFHCOMMAREA
PERFORM GET-ME-OUT-OF-HERE
END-IF
Account type validation
Checking Number of Accounts
First, the code checks if the number of accounts in INQACCCU-COMMAREACOMM-SUCCESSCOMM-FAIL-CODEGET-ME-OUT-OF-HERE
IF NUMBER-OF-ACCOUNTS IN INQACCCU-COMMAREA > 9
MOVE 'N' TO COMM-SUCCESS IN DFHCOMMAREA
MOVE '8' TO COMM-FAIL-CODE IN DFHCOMMAREA
PERFORM GET-ME-OUT-OF-HERE
END-IF
Validating Account Type
Next, the code performs ACCOUNT-TYPE-CHECK
* Validate the type of account e.g. MORTGAGE etc.
*
PERFORM ACCOUNT-TYPE-CHECK
ACCOUNT-TYPE-CHECK
ACCOUNT-TYPE-CHECKThe ACCOUNT-TYPE-CHECKDFHCOMMAREACOMM-SUCCESSCOMM-SUCCESSCOMM-FAIL-CODE
ACCOUNT-TYPE-CHECK SECTION.
ATC010.
*
* Validate that only ISA, MORTGAGE, SAVING, CURRENT and LOAN
* are the only account types available.
*
EVALUATE TRUE
WHEN COMM-ACC-TYPE IN DFHCOMMAREA(1:3) = 'ISA'
WHEN COMM-ACC-TYPE IN DFHCOMMAREA(1:8) = 'MORTGAGE'
WHEN COMM-ACC-TYPE IN DFHCOMMAREA(1:6) = 'SAVING'
WHEN COMM-ACC-TYPE IN DFHCOMMAREA(1:7) = 'CURRENT'
WHEN COMM-ACC-TYPE IN DFHCOMMAREA(1:4) = 'LOAN'
MOVE 'Y' TO COMM-SUCCESS OF DFHCOMMAREA
WHEN OTHER
MOVE 'N' TO COMM-SUCCESS OF DFHCOMMAREA
MOVE 'A' TO COMM-FAIL-CODE IN DFHCOMMAREA
END-EVALUATE.
ATC999.
EXIT.
Checking Validation Success
Then, the code checks if COMM-SUCCESSGET-ME-OUT-OF-HERE
IF COMM-SUCCESS OF DFHCOMMAREA = 'N'
PERFORM GET-ME-OUT-OF-HERE
END-IF
ENQ-NAMED-COUNTER
ENQ-NAMED-COUNTERThe ENQ-NAMED-COUNTERSORTCODECOMM-SUCCESSCOMM-FAIL-CODEGET-ME-OUT-OF-HERE
ENQ-NAMED-COUNTER SECTION.
ENC010.
MOVE SORTCODE TO NCS-ACC-NO-TEST-SORT.
EXEC CICS ENQ
RESOURCE(NCS-ACC-NO-NAME)
LENGTH(16)
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC.
IF WS-CICS-RESP NOT = DFHRESP(NORMAL)
MOVE 'N' TO COMM-SUCCESS IN DFHCOMMAREA
MOVE '3' TO COMM-FAIL-CODE IN DFHCOMMAREA
PERFORM GET-ME-OUT-OF-HERE
END-IF.
ENC999.
EXIT.
Account processing and outputs
Enqueue Named Counter
First, we enqueue the named counter for the account. This ensures that the account number generation is synchronized and unique.
PERFORM ENQ-NAMED-COUNTER.
Find Next Account
Next, we perform the FIND-NEXT-ACCOUNT
PERFORM FIND-NEXT-ACCOUNT.
FIND-NEXT-ACCOUNT
FIND-NEXT-ACCOUNTThe FIND-NEXT-ACCOUNT
FIND-NEXT-ACCOUNT SECTION.
FNA010.
MOVE 1 TO NCS-ACC-NO-INC.
INITIALIZE OUTPUT-DATA.
* <<sortcode>>-ACCOUNT-LAST
MOVE SPACES TO HV-CONTROL-NAME
MOVE ZERO TO HV-CONTROL-VALUE-NUM
MOVE SPACES TO HV-CONTROL-VALUE-STR
STRING REQUIRED-SORT-CODE DELIMITED BY SIZE
'-' DELIMITED BY SIZE
'ACCOUNT-LAST' DELIMITED BY SIZE
INTO HV-CONTROL-NAME
EXEC SQL
SELECT CONTROL_NAME,
CONTROL_VALUE_NUM,
CONTROL_VALUE_STR
INTO :HV-CONTROL-NAME,
:HV-CONTROL-VALUE-NUM,
Write Account to DB2
DB2Then, we perform the WRITE-ACCOUNT-DB2DB2
PERFORM WRITE-ACCOUNT-DB2
WRITE-ACCOUNT-DB2
WRITE-ACCOUNT-DB2The WRITE-ACCOUNT-DB2DB2
WRITE-ACCOUNT-DB2 SECTION.
WAD010.
INITIALIZE HOST-ACCOUNT-ROW.
MOVE 'ACCT' TO HV-ACCOUNT-EYECATCHER.
MOVE COMM-CUSTNO IN DFHCOMMAREA TO HV-ACCOUNT-CUST-NO.
MOVE SORTCODE TO HV-ACCOUNT-SORTCODE.
MOVE NCS-ACC-NO-VALUE TO NCS-ACC-NO-DISP.
MOVE NCS-ACC-NO-DISP(9:8) TO HV-ACCOUNT-ACC-NO.
MOVE COMM-ACC-TYPE IN DFHCOMMAREA TO HV-ACCOUNT-ACC-TYPE.
MOVE COMM-INT-RT TO HV-ACCOUNT-INT-RATE.
MOVE COMM-OVERDR-LIM TO HV-ACCOUNT-OVERDRAFT-LIM.
MOVE COMM-AVAIL-BAL IN DFHCOMMAREA TO HV-ACCOUNT-AVAIL-BAL.
MOVE COMM-ACT-BAL TO HV-ACCOUNT-ACTUAL-BAL.
PERFORM CALCULATE-DATES.
*
* Convert gregorian date (YYYYMMDD) to an integer
*
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human