Skip to main content

Creating Customer (BNK1CCS)

The BNK1CCS program is responsible for handling customer data screens in a banking application. It initializes customer data fields, handles various key presses, and manages return and error handling. The program achieves this by checking if it's the first time through, setting flags, performing terminal definitions, and sending maps. It also processes key presses like PA, PF3, PF12, CLEAR, and ENTER, and handles errors by linking to the Abend Handler program.

The BNK1CCS program starts by checking if it's the first time through and initializes customer data fields if needed. It sets flags and performs terminal definitions before sending the map to the terminal. The program then handles various key presses, such as PA, PF3, PF12, CLEAR, and ENTER, by performing specific actions for each key. Finally, it manages return and error handling by returning the CICS transaction and linking to the Abend Handler program if any errors occur.

Here is a high level diagram of the program:

Initialization and Setup


Check if first time through

First, the code checks if this is the first time through by evaluating if EIBCALEN is zero. If it is, it means the customer data screen needs to be initialized with empty fields.

           EVALUATE TRUE
*
* Is it the first time through? If so, send the map
* with erased (empty) data fields.
*
WHEN EIBCALEN = ZERO


Initialize customer data fields

Next, the code initializes various customer data fields to empty values. This includes setting BNK1CCO to LOW-VALUE and other fields like CUSTTITO, CHRISTNO, CUSTINSO, CUSTSNO, CUSTAD1O, CUSTAD2O, and CUSTAD3O to spaces.

                 MOVE LOW-VALUE TO BNK1CCO
MOVE SPACES TO CUSTTITO
MOVE SPACES TO CHRISTNO
MOVE SPACES TO CUSTINSO
MOVE SPACES TO CUSTSNO
MOVE SPACES TO CUSTAD1O
MOVE SPACES TO CUSTAD2O
MOVE SPACES TO CUSTAD3O



Set SEND-ERASE flag

Then, the code sets the SEND-ERASE flag to true by moving -1 to CUSTTITL and setting SEND-ERASE to true. This indicates that the map should be sent with erased (empty) data fields.

                 MOVE -1 TO CUSTTITL
SET SEND-ERASE TO TRUE
MOVE SPACES TO MESSAGEO


Perform STORE-TERM-DEF

Moving to the next step, the code performs the STORE-TERM-DEF section, which stores the terminal's uppercase translation settings.

                 PERFORM STORE-TERM-DEF


Perform SEND-MAP

Finally, the code performs the SEND-MAP section to send the initialized map to the terminal with the erased data fields.

                 PERFORM SEND-MAP

Key Handling


Handling PA Key Presses

First, the code checks if a PA key (DFHPA1, DFHPA2, or DFHPA3) is pressed. If so, it simply continues without any further action.

              WHEN EIBAID = DFHPA1 OR DFHPA2 OR DFHPA3
CONTINUE


Handling PF3 Key Press

Next, if the PF3 key is pressed, the terminal's UCTRAN setting is restored to its original state by calling RESTORE-TERM-DEF. Then, the program returns to the main menu by executing a CICS RETURN command with the transaction ID 'OMEN'.

              WHEN EIBAID = DFHPF3

*
* Set the terminal UCTRAN back to
* its starting position
*
PERFORM RESTORE-TERM-DEF

EXEC CICS RETURN
TRANSID('OMEN')
IMMEDIATE
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC


Handling PF12 Key Press

Then, if the PF12 key is pressed, a termination message is sent by calling SEND-TERMINATION-MSG. After that, the terminal's UCTRAN setting is restored to its original state by calling RESTORE-TERM-DEF, and the program returns control to CICS.

              WHEN EIBAID = DFHPF12
PERFORM SEND-TERMINATION-MSG

*
* Set the terminal UCTRAN back to
* its starting position
*
PERFORM RESTORE-TERM-DEF

EXEC CICS
RETURN
END-EXEC


Handling CLEAR Key Press

When the CLEAR key is pressed, the program sends a map (BNK1CCM) to the terminal, erasing the screen and freeing the keyboard. Then, the terminal's UCTRAN setting is restored to its original state by calling RESTORE-TERM-DEF, and the program returns control to CICS with the transaction ID 'OCCS'.

              WHEN EIBAID = DFHCLEAR
EXEC CICS SEND MAP('BNK1CCM')
MAPONLY
ERASE
FREEKB
END-EXEC

*
* Set the terminal UCTRAN back to
* its starting position
*
PERFORM RESTORE-TERM-DEF


EXEC CICS RETURN TRANSID('OCCS')
COMMAREA(WS-COMM-AREA)
END-EXEC


Handling ENTER Key Press

If the ENTER key is pressed, the program processes the content by calling PROCESS-MAP.

              WHEN EIBAID = DFHENTER
PERFORM PROCESS-MAP



Handling Other Key Presses

Finally, if any other key is pressed, the program moves the DFHCOMMAREA to WS-COMM-AREA, sets an invalid key pressed message, and sends the map with an alarm.

              WHEN OTHER
MOVE DFHCOMMAREA TO WS-COMM-AREA
MOVE LOW-VALUES TO BNK1CCO
MOVE SPACES TO MESSAGEO
MOVE 'Invalid key pressed.' TO MESSAGEO
SET SEND-DATAONLY-ALARM TO TRUE
PERFORM SEND-MAP


END-EVALUATE.


SEND-TERMINATION-MSG

The SEND-TERMINATION-MSG function sends a termination message to the terminal. If the response is not normal, it handles the error by preserving the response codes and linking to the Abend Handler program.

       SEND-TERMINATION-MSG SECTION.
STM010.
*
* Send the termination message
*
EXEC CICS SEND TEXT
FROM(END-OF-SESSION-MESSAGE)
ERASE
FREEKB
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC.

IF WS-CICS-RESP NOT = DFHRESP(NORMAL)
*
* 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


RESTORE-TERM-DEF

The RESTORE-TERM-DEF function restores the terminal's UCTRAN setting to its original state. If the response is not normal, it handles the error by preserving the response codes and linking to the Abend Handler program.

       RESTORE-TERM-DEF SECTION.
RTD010.
*
* We must now restore the UCTRAN setting back to what it
* was at the start
*
MOVE DFHCOMMAREA TO WS-COMM-AREA.

MOVE WS-COMM-TERM TO WS-UCTRANS.

EXEC CICS SET TERMINAL(EIBTRMID)
UCTRANST(WS-UCTRANS)
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC.

IF WS-CICS-RESP NOT = DFHRESP(NORMAL)
*
* 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

Interim Summary

So far, we saw how the initialization and setup process works, including checking if it's the first time through, initializing customer data fields, setting the SEND-ERASE flag, performing STORE-TERM-DEF, and sending the map. We also covered key handling, detailing how the program responds to various key presses such as PA, PF3, PF12, CLEAR, ENTER, and other keys. Now, we will focus on return and error handling, where the program returns the CICS transaction and handles any errors that may occur.

Return and Error Handling


Return CICS Transaction

First, the code returns the CICS transaction with the transaction ID 'OCCS' and the communication area WS-COMM-AREA. It also sets the response codes WS-CICS-RESP and WS-CICS-RESP2.

           EXEC CICS
RETURN TRANSID('OCCS')
COMMAREA(WS-COMM-AREA)
LENGTH(248)
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC.


Check Response

Next, the code checks if the response WS-CICS-RESP is not equal to DFHRESP(NORMAL). If the response is not normal, it proceeds to handle the error.

           IF WS-CICS-RESP NOT = DFHRESP(NORMAL)


Initialize Abend Info

Then, the code initializes the ABNDINFO-REC record and moves the response codes EIBRESP and EIBRESP2 to ABND-RESPCODE and ABND-RESP2CODE respectively.

              INITIALIZE ABNDINFO-REC
MOVE EIBRESP TO ABND-RESPCODE
MOVE EIBRESP2 TO ABND-RESP2CODE


Get Supplemental Info

Moving to the next step, the code gets supplemental information by assigning the application ID to ABND-APPLID.

              EXEC CICS ASSIGN APPLID(ABND-APPLID)
END-EXEC


Populate Time and Date

Next, the code performs the POPULATE-TIME-DATE section to get the current date and time.

              PERFORM POPULATE-TIME-DATE


POPULATE-TIME-DATE

The POPULATE-TIME-DATE section uses CICS commands to get the current time and format it into WS-ORIG-DATE and WS-TIME-NOW.

       POPULATE-TIME-DATE SECTION.
PTD10.

EXEC CICS ASKTIME
ABSTIME(WS-U-TIME)
END-EXEC.

EXEC CICS FORMATTIME
ABSTIME(WS-U-TIME)
DDMMYYYY(WS-ORIG-DATE)
TIME(WS-TIME-NOW)
DATESEP
END-EXEC.

PTD999.
EXIT.


Move Date and Time

Then, the code moves the original date WS-ORIG-DATE to ABND-DATE and constructs the time string ABND-TIME using WS-TIME-NOW-GRP-HH, WS-TIME-NOW-GRP-MM, and WS-TIME-NOW-GRP-MM.

              MOVE WS-ORIG-DATE TO ABND-DATE
STRING WS-TIME-NOW-GRP-HH DELIMITED BY SIZE,
':' DELIMITED BY SIZE,
WS-TIME-NOW-GRP-MM DELIMITED BY SIZE,
':' DELIMITED BY SIZE,
WS-TIME-NOW-GRP-MM DELIMITED BY SIZE
INTO ABND-TIME


Assign Program

Next, the code assigns the current program name to ABND-PROGRAM.

              EXEC CICS ASSIGN PROGRAM(ABND-PROGRAM)
END-EXEC


Move SQL Code

Then, the code moves zeros to ABND-SQLCODE to initialize it.

              MOVE ZEROS      TO ABND-SQLCODE


Create Freeform String

Moving forward, the code creates a freeform string ABND-FREEFORM that contains the error message and response codes.

              STRING 'A010 -RETURN TRANSID(OCCS) FAIL'
DELIMITED BY SIZE,
'EIBRESP=' DELIMITED BY SIZE,
ABND-RESPCODE DELIMITED BY SIZE,
' RESP2=' DELIMITED BY SIZE,
ABND-RESP2CODE DELIMITED BY SIZE
INTO ABND-FREEFORM


Next, the code links to the Abend Handler program WS-ABEND-PGM with the communication area ABNDINFO-REC.

              EXEC CICS LINK PROGRAM(WS-ABEND-PGM)
COMMAREA(ABNDINFO-REC)
END-EXEC


Initialize Fail Info

Then, the code initializes the fail information WS-FAIL-INFO and moves the fail message to WS-CICS-FAIL-MSG along with the response codes to WS-CICS-RESP-DISP and WS-CICS-RESP2-DISP.

              INITIALIZE WS-FAIL-INFO
MOVE 'BNK1CCS - A010 - RETURN TRANSID(OCCS) FAIL' TO
WS-CICS-FAIL-MSG
MOVE WS-CICS-RESP TO WS-CICS-RESP-DISP
MOVE WS-CICS-RESP2 TO WS-CICS-RESP2-DISP


Perform Restore Term Def

Next, the code performs the RESTORE-TERM-DEF section to restore terminal definitions.

              PERFORM RESTORE-TERM-DEF


Perform Abend Task

Finally, the code performs the ABEND-THIS-TASK section to abend the task.

              PERFORM ABEND-THIS-TASK

 

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