cics-prg1 cobol considerations identification division. no differences environment division must be...

28
CICS-Prg 1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed! Data Division No FILE SECTION – (No SELECTS)

Upload: brianna-hunter

Post on 18-Dec-2015

229 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

CICS-Prg 1

COBOL Considerations

Identification Division. No differences

Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

Data Division No FILE SECTION – (No SELECTS)

Page 2: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

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

Page 3: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

CICS-Prg 3

COBOL Considerations (More)

Procedure Division Uses most COBOL statements Also uses CICS Commands like:

SEND MAPRECEIVE MAPREAD DATASETWRITE DATASETRETURNXCTL

Page 4: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

CICS-Prg 4

Where are WE?

Program must be able to determine!Always starts at beginning of ProgramStarts with initialized Working-StorageCan use several methods: EIBCALEN (First time program loaded) COMMAREA (Tran-ID, EIBAID) Hidden Data on Screen

Page 5: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

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

Page 6: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

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

Page 7: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

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 commarea0 (ZERO) means there is NO commarea

Page 8: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

CICS-Prg 8

Sample CICS COBOL Program

PROCEDURE DIVISION (Where are we?)IF first-time

SEND Initial-MapELSE

IF <ENTER>Process Screen

ELSEProcess Function-Key

END-IFEND-IFSEND MAP

Page 9: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

CICS-Prg 9

Sample CICS COBOL Program

PROCEDURE DIVISIONEVALUATE TRUE

WHEN EIBCALEN = 0Send Initial MAP

WHEN EIBAID = DFHENTERProcess Screen Data

WHEN EIBAID = DFHPF3 or DFHPF12Exit Program

WHEN OTHERInvalid key

END-EVALUATE

Page 10: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

CICS-Prg 10

Basic CICS Commands

General Structure:EXEC CICS

CICS COMMAND OPTION(value) …(Parameters as needed)

END-EXEC

Page 11: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

CICS-Prg 11

Basic CICS Commands

EXEC CICSSEND MAP(name)

[ MAPSET(name) ][ FROM(data-area) ][ MAPONLY | DATAONLY ][ ERASE | ERASEUP ][ CURSOR [ (value) ] ]

END-EXEC

Page 12: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

CICS-Prg 12

Basic CICS Commands

EXEC CICSRECEIVE MAP(map-

name)[ MAPSET(mapset-

name) ] INTO(data-area)

END-EXEC

Page 13: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

CICS-Prg 13

Basic CICS Commands

EXEC CICSRETURN [ TRANSID(name) ]

[ COMMAREA(data-area) ][ LENGTH(data-

value) ]END-EXEC Length – PIC S9(4) COMP or Literal

Page 14: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

CICS-Prg 14

Program Control Commands

EXEC CICSXCTL PROGRAM(name)

[ COMMAREA(data-area) ]

[ LENGTH(data-value) ]END-EXECNOTE: Program name must be in PPT.Works like COBOL ‘GO TO’ statement.

Page 15: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

CICS-Prg 15

Program Control Commands

EXEC CICSLINK PROGRAM(name)

[ COMMAREA(data-area) ][ LENGTH(data-value) ]

END-EXECNOTE: Program name must be in PPT.Works like COBOL ‘PERFORM’ statement.

Page 16: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

CICS-Prg 16

Basic CICS Commands

EXEC CICSREAD DATASET(filename)

INTO(data-area) RIDFLD(data-area)[ RRN | RBA ][ UPDATE ]

END-EXEC

Page 17: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

CICS-Prg 17

More CICS Commands

EXEC CICSWRITE DATASET(filename)

FROM(data-area) RIDFLD(data-area)[ RRN | RBA ]

END-EXEC

Page 18: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

CICS-Prg 18

More CICS Commands

EXEC CICSREWRITE

DATASET(filename) FROM(data-area)

END-EXECNOTES:

Record MUST be READ with UPDATE!data-area - NOT have to match Read

Page 19: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

CICS-Prg 19

More CICS Commands

EXEC CICSDELETE DATASET(filename)

[ RIDFLD(data-area) ][ RRN | RBA ]

END-EXECNOTE: If no RIDFLD last READ is

Deleted

Page 20: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

CICS-Prg 20

Basic CICS Commands

EXEC CICSABEND [ ABCODE(name) ]

END-EXEC

(ABCODE used to identify storage dump -

Usually omitted!)

Page 21: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

CICS-Prg 21

CICS Program Design

Event-driven designStructure Chart - Consider All FunctionsIdentify 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

Page 22: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

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)

Page 23: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

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)

Page 24: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

CICS-Prg 24

More CICS Commands

EXEC CICSUNLOCK DATASET(filename)

END-EXECNOTE: 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.

Page 25: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

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

Page 26: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

CICS-Prg 26

Checking for ExceptionsALL CICS Commands allow RESP Parm01 RESP-CODE PIC S9(8) COMP.

IF RESP-CODE = DFHRESP(NORMAL)MOVE ‘Y’ TO OK-COMMAND

ELSEIF RESP-CODE = DFHRESP(NOTFND)

MOVE ‘N’ TO REC-NOT-FOUNDELSE

PERFORM DISPLAY-MISC-ERROREND-IF

END-IF

Page 27: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

CICS-Prg 27

Preventing File Corruption

PREVENT 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

Page 28: CICS-Prg1 COBOL Considerations Identification Division. No differences Environment Division MUST be EMPTY in CICS Program! No SELECT statements allowed!

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)