COUSR03C
Source: cbl/COUSR03C.cbl
Type: CICS transaction program
COUSR03C — Delete User (CardDemo)
Purpose
This CICS program provides the "Delete User" function in the CardDemo administrative subsystem. It lets an administrator look up a user by User ID from the USRSEC file, review that user's details (first name, last name, user type) on screen, and confirm deletion of the user record. It is a screen-driven (BMS map COUSR3A/COUSR03) transaction identified by transaction ID CU03.
How it works
- MAIN-PARA is the entry point and controls all flow based on whether the program is being entered fresh or re-entered (via
EIBCALENandCDEMO-PGM-REENTER): - On first entry with no commarea (
EIBCALEN = 0), it routes back to the sign-on programCOSGN00CviaRETURN-TO-PREV-SCREEN. - On first entry with a commarea, it initializes the screen (map fields set to
LOW-VALUES), and if a user ID was already selected (CDEMO-CU03-USR-SELECTED), it pre-loads that user's data by callingPROCESS-ENTER-KEY, then sends the screen viaSEND-USRDEL-SCREEN. - On subsequent entries (re-enter), it receives screen input (
RECEIVE-USRDEL-SCREEN) and dispatches based on the key pressed (EIBAID):- Enter →
PROCESS-ENTER-KEY(look up the user) - PF3 →
RETURN-TO-PREV-SCREEN(back to calling program, orCOADM01Cif none recorded) - PF4 →
CLEAR-CURRENT-SCREEN(reset the screen) - PF5 →
DELETE-USER-INFO(perform the actual delete) - PF12 →
RETURN-TO-PREV-SCREENtoCOADM01C - Any other key → error message "invalid key" and the screen is re-sent
- Enter →
- PROCESS-ENTER-KEY validates that a User ID was entered, then calls READ-USER-SEC-FILE to fetch the record and populates the name/type fields for display.
- DELETE-USER-INFO validates the User ID, re-reads the record (READ-USER-SEC-FILE), and then calls DELETE-USER-SEC-FILE to remove it.
- READ-USER-SEC-FILE issues a CICS
READ ... UPDATEagainst theUSRSECfile and branches on the response code (NORMAL,NOTFND,OTHER), each path setting a message and re-sending the screen. - DELETE-USER-SEC-FILE issues the CICS
DELETEagainst the same dataset (relying on the priorREAD ... UPDATEto hold the record for delete), then handlesNORMAL(success message + clears fields),NOTFND, andOTHERresponses. - SEND-USRDEL-SCREEN always calls POPULATE-HEADER-INFO (titles, date/time, transaction/program name) before sending the BMS map.
- CLEAR-CURRENT-SCREEN and INITIALIZE-ALL-FIELDS reset the input fields and message.
- RETURN-TO-PREV-SCREEN performs a CICS
XCTLto the target program (defaulting toCOSGN00Cif none is set), passing along the commarea and recording this program/transaction as the "from" context.
Inputs & outputs
| Resource | Type | Usage |
|---|---|---|
USRSEC (via WS-USRSEC-FILE) |
CICS file/dataset | Read (with UPDATE option) and deleted in READ-USER-SEC-FILE / DELETE-USER-SEC-FILE. Keyed by SEC-USR-ID. No SQL tables are used — this is a CICS file, not DB2 (confirmed by empty sql_tables in parsed facts). |
COUSR3A map / COUSR03 mapset |
BMS screen | Sent (SEND-USRDEL-SCREEN) and received (RECEIVE-USRDEL-SCREEN) for all user interaction — displays User ID, first/last name, user type, and error messages. |
DFHCOMMAREA (LINKAGE SECTION) |
CICS commarea | Carries CARDDEMO-COMMAREA context between programs (from/to program, transaction ID, reenter flag, selected user ID) across XCTL and RETURN. |
Copybooks: COCOM01Y, CSUSR01Y, CSDAT01Y, CSMSG01Y, COTTL01Y, COUSR03, DFHAID, DFHBMSCA |
Data structures | Provide commarea layout, security/user record layout (SEC-USER-DATA/SEC-USR-ID), date/time formatting fields, standard messages/titles, the map's I/O layout, and CICS AID/attribute constants. No calls to other programs are shown in the parsed facts other than implicit XCTL targets (COSGN00C, COADM01C), which are dynamic (moved into CDEMO-TO-PROGRAM), so they are not captured as static calls. |
Things to know
- No SQL involved — despite being part of a "CardDemo" system, this program interacts with a CICS VSAM-style file (
USRSEC) viaEXEC CICS READ/DELETE, not DB2 SQL. The parser's emptysql_tableslist confirms this. - Hard-coded values: transaction ID
CU03, program nameCOUSR03C, file nameUSRSEC, and fallback target programsCOSGN00C/COADM01Care all hard-coded literals in working storage or inline MOVE statements. - Read-before-delete pattern:
DELETE-USER-SEC-FILEdoes not specify aRIDFLD/key on theEXEC CICS DELETE— it relies on the precedingREAD ... UPDATEinREAD-USER-SEC-FILEto have positioned/locked the record. If the delete path is ever reached without a preceding successfulUPDATE-mode read, the delete would likely fail; the two calls are tightly coupled and this coupling is not enforced structurally, only by the calling sequence (DELETE-USER-INFOperformsREAD-USER-SEC-FILEimmediately beforeDELETE-USER-SEC-FILE). - Error handling is done via response code (
RESP/RESP2) checks after each CICS call, with three-way branching (NORMAL/NOTFND/OTHER) that setsWS-ERR-FLG, builds a message intoWS-MESSAGE, and re-sends the screen. Non-NORMAL/NOTFNDcases (OTHER) are logged viaDISPLAY(likely to a CICS log/JES output) with resp/reason codes but otherwise handled the same generic way ("Unable to lookup/Update User...") — the actual underlying cause is not surfaced to the end user. - No confirmation step visible for the delete itself beyond the initial lookup message "Press PF5 key to delete this user..." — pressing PF5 directly triggers deletion (via
DELETE-USER-INFO) without an additional explicit "are you sure" prompt; the PF5 keypress itself doubles as the confirmation gesture, driven purely by the on-screen instructional message. - Field-length quirk: on some error paths cursor positioning is set via
-1onUSRIDINL(User ID field length) even in cases unrelated to the User ID itself (e.g.,READ-USER-SEC-FILE'sOTHERbranch sets-1onFNAMEL, First Name field, rather thanUSRIDINL) — worth verifying this is intentional cursor placement rather than a copy/paste inconsistency. - Commarea reentry logic depends on
CDEMO-PGM-REENTERflag andEIBCALEN; if a caller doesn't set up the commarea correctly (e.g.,CDEMO-CU03-USR-SELECTEDnot properly cleared between invocations), stale user selection could cause an unexpected auto-lookup on entry — this is inferred from the code but not independently verified against all calling programs.
CICS commands
RETURN, SEND, RECEIVE, READ, DELETE
Copybooks
COCOM01Y, COTTL01Y, COUSR03, CSDAT01Y, CSMSG01Y, CSUSR01Y, DFHAID, DFHBMSCA
Paragraph flow
flowchart TD
MAIN_PARA["MAIN-PARA"]
PROCESS_ENTER_KEY["PROCESS-ENTER-KEY"]
DELETE_USER_INFO["DELETE-USER-INFO"]
RETURN_TO_PREV_SCREEN["RETURN-TO-PREV-SCREEN"]
SEND_USRDEL_SCREEN["SEND-USRDEL-SCREEN"]
RECEIVE_USRDEL_SCREEN["RECEIVE-USRDEL-SCREEN"]
POPULATE_HEADER_INFO["POPULATE-HEADER-INFO"]
READ_USER_SEC_FILE["READ-USER-SEC-FILE"]
DELETE_USER_SEC_FILE["DELETE-USER-SEC-FILE"]
CLEAR_CURRENT_SCREEN["CLEAR-CURRENT-SCREEN"]
INITIALIZE_ALL_FIELDS["INITIALIZE-ALL-FIELDS"]
CLEAR_CURRENT_SCREEN --> INITIALIZE_ALL_FIELDS
CLEAR_CURRENT_SCREEN --> SEND_USRDEL_SCREEN
DELETE_USER_INFO --> DELETE_USER_SEC_FILE
DELETE_USER_INFO --> READ_USER_SEC_FILE
DELETE_USER_INFO --> SEND_USRDEL_SCREEN
DELETE_USER_SEC_FILE --> INITIALIZE_ALL_FIELDS
DELETE_USER_SEC_FILE --> SEND_USRDEL_SCREEN
MAIN_PARA --> CLEAR_CURRENT_SCREEN
MAIN_PARA --> DELETE_USER_INFO
MAIN_PARA --> PROCESS_ENTER_KEY
MAIN_PARA --> RECEIVE_USRDEL_SCREEN
MAIN_PARA --> RETURN_TO_PREV_SCREEN
MAIN_PARA --> SEND_USRDEL_SCREEN
PROCESS_ENTER_KEY --> READ_USER_SEC_FILE
PROCESS_ENTER_KEY --> SEND_USRDEL_SCREEN
READ_USER_SEC_FILE --> SEND_USRDEL_SCREEN
SEND_USRDEL_SCREEN --> POPULATE_HEADER_INFO
Paragraphs
| Paragraph | Line | Performs |
|---|---|---|
| MAIN-PARA | 82 | RETURN-TO-PREV-SCREEN, PROCESS-ENTER-KEY, SEND-USRDEL-SCREEN, RECEIVE-USRDEL-SCREEN, PROCESS-ENTER-KEY, RETURN-TO-PREV-SCREEN |
| PROCESS-ENTER-KEY | 142 | SEND-USRDEL-SCREEN, READ-USER-SEC-FILE, SEND-USRDEL-SCREEN |
| DELETE-USER-INFO | 174 | SEND-USRDEL-SCREEN, READ-USER-SEC-FILE, DELETE-USER-SEC-FILE |
| RETURN-TO-PREV-SCREEN | 197 | |
| SEND-USRDEL-SCREEN | 213 | POPULATE-HEADER-INFO |
| RECEIVE-USRDEL-SCREEN | 230 | |
| POPULATE-HEADER-INFO | 243 | |
| READ-USER-SEC-FILE | 267 | SEND-USRDEL-SCREEN, SEND-USRDEL-SCREEN, SEND-USRDEL-SCREEN |
| DELETE-USER-SEC-FILE | 305 | INITIALIZE-ALL-FIELDS, SEND-USRDEL-SCREEN, SEND-USRDEL-SCREEN, SEND-USRDEL-SCREEN |
| CLEAR-CURRENT-SCREEN | 341 | INITIALIZE-ALL-FIELDS, SEND-USRDEL-SCREEN |
| INITIALIZE-ALL-FIELDS | 349 |