Anda di halaman 1dari 9

COBOL Considerations

Identification Division.


COBOL Considerations (More)


Data Division


No differences MUST be EMPTY in CICS Program! No SELECT statements allowed! No FILE SECTION (No SELECTS)
1

WORKING-STORAGE SECTION.
 Switches, Flags, Variables, Records, etc.  You get fresh copy each time program loaded!

Environment Division
  

LINKAGE SECTION (New Item!!)


 DFHCOMMAREA defined or CICS will!  Used to receive data from CICS.  CICS also inserts EIB Block definition

Data Division


CICS-Prg

CICS-Prg

COBOL Considerations (More)


Procedure Division
 

Where are WE?


ro ram must be able to determine! Always starts at be innin of ro ram Starts with initialized Workin -Stora e Can use several methods:

Uses most COBOL statements Also uses CICS Commands like:


 RETURN  XCTL  SEND MAP  RECEIVE MAP  READ DATASET

  

EIBCALEN (First time pro ram loaded) COMMAREA (Tran-ID, EIBAID) Hidden Data on Screen

CICS-Prg

CICS- r

Where are We? (More)


Be innin of ro ram must determine! Can use series of IF statements

Sample CICS COBOL ro ram


WORKING-STORAGE SECTION.
     

 

Can be nested (or not if careful!) Usually each path ends with RETURN EVALUATE TRUE most common (New Dev) General WHEN OTHER for errors
CICS- r

Can use EVALUATE statement


 

Switches, Fla s, 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- r

Sample CICS COBOL Program


LINKAGE SECTION.


Sample CICS COBOL Program


PROCEDURE DIVISION (Where are we?)
IF first-time SEND Initial-Map ELSE IF <ENTER> Process Screen ELSE Process Function-Key END-IF END-IF SEND MAP
CICS-Prg

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

Sample CICS COBOL Pro ram

Basic CICS Commands


General Structure:
EXEC CICS CICS COMMAND OPTION(value) (Parameters as needed) END-EXEC

PROCEDURE DIVISION
EVALUATE TRUE WHEN EIBCALEN = 0 First time in Program WHEN EIBAID = DFHENTER Process Screen WHEN EIBAID = DFHPF3 or DFHPF12 Exit Program WHEN OTHER Invalid key END-EVALUATE
CICS-Pr

CICS-Pr

10

Basic CICS Commands


EXEC CICS RETURN [ TRANSID(name) ] [ COMMAREA(data-area) ] [ LENGTH(data-value) ] END-EXEC Len th PIC S9(4) COMP or Literal


Basic CICS Commands


EXEC CICS XCTL PROGRAM(name) [ COMMAREA(data-area) ] [ LENGTH(data-value) ]

END-EXEC

CICS-Pr

11

CICS-Pr

12

Basic CICS Commands


EXEC CICS SEND MAP(name) [ MAPSET(name) ] [ FROM(data-area) ] [ MAPONLY | DATAONLY ] [ ERASE | ERASEUP ] [ CURSOR [ (value) ] ] END-EXEC
CICS-Pr


Basic CICS Commands


EXEC CICS RECEIVE MAP(map-name) [ MAPSET(mapset-name) ] INTO(data-area)

END-EXEC

13

CICS-Pr


14

Basic CICS Commands


EXEC CICS READ DATASET(filename) INTO(data-area) RIDFLD(data-area) [ RRN | RBA ] [ UPDATE ]

Basic CICS Commands


EXEC CICS ABEND [ ABCODE(name) ] END-EXEC (ABCODE used to identify stora e dump Usually omitted!)


END-EXEC
CICS-Pr


15

CICS-Pr


16

CICS Pro ram Desi n


Event-driven desi n Structure Chart - Consider All Functions Identify Events and Context
 
  

CICS Pro ram Desi n


COMMAREA usually stores context
   

Any action that starts pro ram List All (Valid) Possible User Actions


Get Key Add Customer Chan e Customer Delete Customer




Desi n Appropriate Response


 

Processin required for an event Mana in user interaction


  

Response to same key can be different dependin on context (ENTER key)




CICS-Pr


CICS-Pr
 

18

CICS Program Design


Event/Response Chart
  

More CICS Commands


EXEC CICS WRITE DATASET(filename) FROM(data-area) RIDFLD(data-area) [ RRN | RBA ]

Helps with design or Program Serves as Documentation of Program Sometimes replaced with Structure Chart Start with Major Functions Add Detail as Needed Assign Paragraph Numbering (If Used)
CICS-Prg 9

Structure Chart Evolves into Design


  

END-EXEC

CICS-Prg

20

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 21

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

22

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 23

Exception Conditions
Most Common Exceptions:
      

DISABLED DUPREC FILENOTFND INVREQ IOERR NOTAUTH NOTFND

Dataset disabled Record already exists Dataset not in FCT Invalid request File I/O error User not authorized Record not in file
CICS-Prg 24

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 ELSE PERFORM DISPLAY-MISC-ERROR END-IF END-IF
CICS-Prg 25

Preventing File Corruption


PREVENT
  

Add busy fla in record (Special Maint) All pro rams MUST follow procedure Extra I/O required (to Set/Reset fla )


DETECT
  

Save copy and compare before updatin OR Add Maint-Timestamp and check it Notify User to et latest version of data
 

Avoidin Deadlock
Sometimes called Deadly Embrace Happens when records from multiple files must be updated as a unit
 

Pro ram Control Commands


EXEC CICS RETURN [ TRANSID(name) ] [ COMMAREA(data-area) ] [ LENGTH(data-value) ] END-EXEC

CICS-Prg

Withdraw from Savin s Deposit to Check Crash after withdraw? Where s money?


Must both be done or neither! (Atomic)

CICS-Pr


27

CICS-Pr


28

Pro ram Control Commands


EXEC CICS LINK PROGRAM(name) [ COMMAREA(data-area) ] [ LENGTH(data-value) ]

Pro ram Control Commands


EXEC CICS XCTL PROGRAM(name) [ COMMAREA(data-area) ] [ LENGTH(data-value) ]

END-EXEC NOTE: Pro ram name must be in PPT. Works like COBOL PERFORM statement.
!

END-EXEC NOTE: Pro ram name must be in PPT.


!

CICS-Pr


29

CICS-Pr


30

Terminal Handling
CURSOR Positioning (in SEND MAP)


Terminal Handling (More)


CURSOR Positioning (in SEND MAP)


IC option in DFHMDF Macro (ATTRB Parm)


 If more than one

Symbolic Cursor Positioning (Preferred!)


 CURSOR

LAST position is used.

DIRECT Cursor Positioning


     

with no position parameter!

CURSOR(nnn) where nnn is position on screen Displacement from start of the screen ( Row 1 ) * 80 + ( Column 1 ) 0 is Row 1, Column 1 1919 is Row 24, Column 80 (24 by 80 Screen) Changes in screen require changes to program

 Specify the FIELD where the CURSOR goes  Place 1 in the LENGTH Attribute of the field

where the cursor is to be placed


 FIELD NAME with L appended is LENGTH  If more than one FIRST position is used.  BINARY HALFWORD - PIC S9(04) COMP.

(Not used much - too complex!)


CICS-Prg 1 CICS-Prg 2

"

Terminal Handlin (More yet)


Determinin the position of CURSOR when the user types an AID key.
  
% &

Attribute Modification
Symbolic Map includes Attribute byte Field Name with A appended Cryptic bit codes and names used Copy library supplied by IBM (Horrible) Most shops have their own copy book We don t have extended attributes !

EIBCPOSN in EIB Block (binary halfword) READ only-Available before RECEIVE MAP Can be used to determine user selection instead of requirin user to enter character
'

CICS-Pr
$

33

CICS-Pr
$

34

Editin Input Data


All data entered should be validated Required data must be present Numeric data needs to be normalized Alpha data should not be spaces Meanin ful error messa es displayed Very tedious codin required! Do checkin from bottom to top !
& & & & %

Misc CICS Commands


EXEC CICS SEND TEXT FROM(data-area) [ LENGTH(data-value) ] [ ERASE ] [ FREEKB]

END-EXEC NOTE: No FREEKB user must hit RESET!


35 CICS-Pr
$

CICS-Pr
$

36

Misc CICS Commands


EXEC CICS HANDLE AID option(procedure name) END-EXEC

Misc CICS Commands


HANDLE AID Options:
    

PA1-PA3 PF1-PF24 ENTER CLEAR ANYKEY

Pro ram Attention Keys Pro ram Function Keys The ENTER Key The CLEAR Key Any key not Specified (Except the ENTER key)
0 0

CICS-Pr
(

37

CICS-Pr
(

Handle AID Example (Old)


EXEC CICS HANDLE AID PF3(900-MENU) CLEAR( 50-CLEAR) ENTER(700-ENTER) ANYKEY(750-ERROR)
1

Error Processin
There are over 70 CICS error Conditions Mercifully only a few are handled TWO Methods of handlin exceptions:

2

HANDLE CONDITION (Old Method)


 Similar in function to HANDLE AID

END-EXEC NOTE: HANDLE AID sets up RECEIVE MAP! Not executed when encountered! In OLD Pro s.
0

RESPONSE Code checkin


 Allows cleaner pro ram structure
4 0

CICS-Pr
(

39

CICS-Pr
(

40

Stran e Exception - MAPFAIL


MAPFAIL Condition


HANDLE CONDITION (Old!)


EXEC CICS HANDLE CONDITION condition(procedure-name) condition(procedure-name) up to 16 per statement END-EXEC

Raised by RECEIVE MAP with no data


 User entered no data but pressed AID key  User pressed CLEAR key or PA key

Simplest to PREVENT it from occurrin


 Check EIBAID to see what key was pressed  Don t issue RECEIVE MAP if PA or CLEAR hit  Include DUMMY field with MDT set ON
0

CICS-Pr
(

41

CICS-Pr
(

42

HANDLE CONDITION
Common CONDITIONS
      

HANDLE CONDITION Example


EXEC CICS HANDLE CONDITION MAPFAIL(500-NO-DATA) DUPREC(600-DUPLICATE) NOTOPEN END-EXEC NOTE: Condition by itself will nullify it!
CICS-Prg
5 6 5 5

DUPREC MAPFAIL NOSPACE NOTOPEN NOTFND PGMIDERR ERROR

Record already exists No data sent by user No space left in file Data set not OPEN Record not in file Program not in PPT ALL conditions not coded
CICS-Prg

HANDLE CONDITION (Notes)


Not an executable command Establishes paragraph to correct error Can issue multiple times Last one executed is in effect Causes GO TO to paragraph named Done BEFORE CICS Command executed OLD method of codin AVOID!
7

RESPONSE CHECKING (NEW!)


ADD RESP option to CICS Command Define binary fullword PIC S9(8) COMP Name that field in each RESP option COPY of EIBRESP from EIB EIBRESP2 (RESP2) also available
 

Not many CICS Commands use it Seldom needed as RESP is usually enou h
9

CICS-Prg

CICS-Pr
8

46

USE General ERROR Handlin


Most shops have a standard error handlin method If not, use sample linka e on Pa e 255 Sample pro ram is on Pa e 257 Called whenever a condition is not handled in the pro ram Displays error to user and terminates
B B B B B A

LINKAGE SECTION
Used to access data left by previous execution of a pro ram Data should be moved to your W/S! Each execution starts with initial W/S Define COMMAREA in Workin -Stora e DEFINE DFHCOMMAREA in Linka e RETURN references Workin -Stora e
B B B B B B

CICS-Pr
@

47

CICS-Pr
@

48

Executive Interface Block


EIB efinition a e CICS Co In inkage Section after C Contains several useful fiel s
D D D D E F I P Q R T S W

EIB Useful iel s


y

iler E
V

EIBC E , EIB I , EIBCP S , EIB E, EIB I E, EIB I , EIB I , EIB S CE


X Y ` X a b ` a X c c d c e ` a c e d a e e

ost ke t current CICS (Page 2 ou can u ate a fe of t e -EIB


g f h W r s t u f

) I
V v P

EIBC EIB I EIBCP EIB EIB I EIB EIB EIB S EIB S


X X a b a X c d c e c e e a

S E E I I CE
` a a

engt of C E Current I Ke resse Position of CU S ask E( ) ask i e ( SS) ransaction of ask er inal I of ask ecentl use esource a e ecentl accesse ata Set
Y b d d X e X X a e b e a X c a a a c d d c a c e e ` e a

G H T

c ` d

c c c c

i p

CICS-Prg

9
C

CICS-Prg

EBUGGI G EIB IE
y

S
t W

ccess to eav Stuff


Infrequentl

EIB EIB EIB EIB EIB


  
d e

ESP ESP2 C E S CE
P S V X c Y

ast CICS Co an Co letion Status ore Co letion Status es onse Co e ( ) ecent esource a e
I t t f T t f V W I P S f V V v t

CW

U

Co

on Work rea
U

P P GC I EC
Y

EXEC CICS ESS CW ( ointer) [ CS ( ointer) ] [ W ( ointer) ] [ C U ( ointer) ]


U f U f u U f u u U f U P P V

-EXEC

Q V V V V c Y

Installation efine (So eti es an


t t t U h

a a e Progra a e ata Set a e


d ` ` a `

CS W C U
U u T

Co on S ste rea ransaction Work rea er inal Control a le User rea ust esta lis ressa ilit if nee e
u U U u t u g U s U W W W g g h

u u

CICS-Prg

CICS-Prg

ee e Stuff

Infrequentl

ee e Stuff

EXEC CICS ESS CW (


U

ESS

CW )
U

-EXEC - evel CICS


I

E: ol overs fro C ore! Sel o nee e an


v u R W t T U S W t W W t h

V S

CICS-Prg

CICS-Prg

Anda mungkin juga menyukai