Download presentation
Published byBrianna Hunter Modified over 9 years ago
1
COBOL Considerations Identification Division. Environment Division
No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed! Data Division No FILE SECTION – (No SELECTS) CICS-Prg
2
COBOL Considerations (More)
Data Division WORKING-STORAGE SECTION. Switches, Flags, Variables, Records, etc. You get ‘fresh’ copy each time program loaded! LINKAGE SECTION (New Item!!) DFHCOMMAREA defined or CICS will! Used to receive data from CICS. CICS also inserts EIB Block definition CICS-Prg
3
COBOL Considerations (More)
Procedure Division Uses most COBOL statements Also uses CICS Commands like: SEND MAP RECEIVE MAP READ DATASET WRITE DATASET RETURN XCTL CICS-Prg
4
Where are WE? Program must be able to determine!
Always starts at beginning of Program Starts with initialized Working-Storage Can use several methods: EIBCALEN (First time program loaded) COMMAREA (Tran-ID, EIBAID) Hidden Data on Screen CICS-Prg
5
Where are We? (More) Beginning of Program must determine!
Can use series of ‘IF’ statements Can be nested (or not if careful!) Usually each path ends with RETURN Can use EVALUATE statement (Newer!) EVALUATE TRUE most common (New Dev) General WHEN OTHER for errors CICS-Prg
6
Sample CICS COBOL Program
WORKING-STORAGE SECTION. Switches, Flags, and Misc Variables COMMUNICATION-AREA (Your copy!) RESPONSE-CODE PIC S9(08) COMP. RECORD Descriptions COPY Library for MAP Other COPY Members as needed CICS-Prg
7
Sample CICS COBOL Program
LINKAGE SECTION. DFHCOMMAREA PIC X(nnn). If you don’t code it, CICS Will! The commarea (if any) placed here! EIBCALEN gives length of commarea 0 (ZERO) means there is NO commarea CICS-Prg
8
Sample CICS COBOL Program
PROCEDURE DIVISION (Where are we?) IF first-time SEND Initial-Map ELSE IF <ENTER> Process Screen Process Function-Key END-IF SEND MAP CICS-Prg
9
Sample CICS COBOL Program
PROCEDURE DIVISION EVALUATE TRUE WHEN EIBCALEN = 0 Send Initial MAP WHEN EIBAID = DFHENTER Process Screen Data WHEN EIBAID = DFHPF3 or DFHPF12 Exit Program WHEN OTHER Invalid key END-EVALUATE CICS-Prg
10
Basic CICS Commands General Structure: EXEC CICS CICS COMMAND
OPTION(value) … (Parameters as needed) END-EXEC CICS-Prg
11
Basic CICS Commands EXEC CICS SEND MAP(name) [ MAPSET(name) ]
[ FROM(data-area) ] [ MAPONLY | DATAONLY ] [ ERASE | ERASEUP ] [ CURSOR [ (value) ] ] END-EXEC CICS-Prg
12
Basic CICS Commands EXEC CICS RECEIVE MAP(map-name)
[ MAPSET(mapset-name) ] INTO(data-area) END-EXEC CICS-Prg
13
Basic CICS Commands EXEC CICS RETURN [ TRANSID(name) ]
[ COMMAREA(data-area) ] [ LENGTH(data-value) ] END-EXEC Length – PIC S9(4) COMP or Literal CICS-Prg
14
Program Control Commands
EXEC CICS XCTL PROGRAM(name) [ COMMAREA(data-area) ] [ LENGTH(data-value) ] END-EXEC NOTE: Program name must be in PPT. Works like COBOL ‘GO TO’ statement. CICS-Prg
15
Program Control Commands
EXEC CICS LINK PROGRAM(name) [ COMMAREA(data-area) ] [ LENGTH(data-value) ] END-EXEC NOTE: Program name must be in PPT. Works like COBOL ‘PERFORM’ statement. CICS-Prg
16
Basic CICS Commands EXEC CICS READ DATASET(filename) INTO(data-area)
RIDFLD(data-area) [ RRN | RBA ] [ UPDATE ] END-EXEC CICS-Prg
17
More CICS Commands EXEC CICS WRITE DATASET(filename) FROM(data-area)
RIDFLD(data-area) [ RRN | RBA ] END-EXEC CICS-Prg
18
More CICS Commands EXEC CICS REWRITE DATASET(filename) FROM(data-area)
END-EXEC NOTES: Record MUST be READ with UPDATE! data-area - NOT have to match Read CICS-Prg
19
More CICS Commands EXEC CICS DELETE DATASET(filename)
[ RIDFLD(data-area) ] [ RRN | RBA ] END-EXEC NOTE: If no RIDFLD last READ is Deleted CICS-Prg
20
Basic CICS Commands EXEC CICS ABEND [ ABCODE(name) ] END-EXEC
(ABCODE used to identify storage dump - Usually omitted!) CICS-Prg
21
CICS Program Design Event-driven design
Structure Chart - Consider All Functions Identify Events and Context Any action that starts program List All (Valid) Possible User Actions Design Appropriate Response Processing required for an event Managing user interaction CICS-Prg
22
CICS Program Design COMMAREA usually stores ‘context’
Get Key Add Customer Change Customer Delete Customer Response to same key can be different depending on ‘context’ (ENTER key) CICS-Prg
23
CICS Program Design Event/Response Chart
Helps with design or Program Serves as Documentation of Program Sometimes replaced with ‘Structure Chart’ Structure Chart ‘Evolves’ into Design Start with Major Functions Add Detail as Needed Assign Paragraph Numbering (If Used) CICS-Prg
24
More CICS Commands EXEC CICS UNLOCK DATASET(filename) END-EXEC
NOTE: If READ/UPDATE command is used and you determine that record does not need to be updated. Usually not needed as record is unlocked when the task is terminated. CICS-Prg
25
Exception Conditions Most Common Exceptions: DISABLED Dataset disabled
DUPREC Record already exists FILENOTFND Dataset not in FCT INVREQ Invalid request IOERR File I/O error NOTAUTH User not authorized NOTFND Record not in file CICS-Prg
26
Checking for Exceptions
ALL CICS Commands allow RESP Parm 01 RESP-CODE PIC S9(8) COMP. IF RESP-CODE = DFHRESP(NORMAL) MOVE ‘Y’ TO OK-COMMAND ELSE IF RESP-CODE = DFHRESP(NOTFND) MOVE ‘N’ TO REC-NOT-FOUND PERFORM DISPLAY-MISC-ERROR END-IF CICS-Prg
27
Preventing File Corruption
Add ‘busy’ flag in record (Special Maint) All programs MUST follow procedure Extra I/O required (to Set/Reset flag) DETECT Save copy and compare before updating OR – Add Maint-Timestamp and check it Notify User to get latest version of data CICS-Prg
28
Avoiding Deadlock Sometimes called ‘Deadly Embrace’
Happens when records from multiple files must be updated as a unit Withdraw from Savings – Deposit to Check Crash after withdraw? Where’s money? Must both be done or neither! (Atomic) CICS-Prg
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.