CICS Infosys
CICS Infosys
Slides
CICS
Customer Information Control System
Slides
Objectives
Entry Criteria: Participants should have a through knowledge of RDBMS concepts like transactions, concurrency control, etc., & COBOL. Exit Criteria: Participants must know what is CICS, the need for CICS the screen layout, keys, etc. important CICS tables transactions and tasks starting and ending a transaction Conversational & Pseudoconversational Programming changing map attributes and positioning the cursor error handling in CICS programs complete BMS concepts methods of transferring control from one program to another methods of retaining data between two tasks and transferring data from one program to another File handling in CICS
2
Slides
References
CICS for microcomputers, Joseph J. Le Bert, McGraw-Hill Publishing Company CICS using COBOL, Andrew M. Suhy, Wadsworth Publishing Company IBM online manuals for CICS
Slides
Session Plan
------------------ session 1 --------------Introduction Special keys CICS Screen Starting a transaction Ending a CICS session Basic structure of a program COBOL commands not to be used CICS tables Conversational Programming Pseudo Conversational Programming Compiling a CICS program Running a CICS program Batch and Online programs Hello World program A conversational program A pseudo conversational program Application, Transaction, Program, Task ------------------ session 2 --------------Basic mapping support Physical map Symbolic map
4
Slides
Slides
CICS is an online transactionprocessor that supports development of on-line applications. CICS as an operating system
- DB/DC - Scheduling of tasks
CICS
prog1
prog2
Batch program 4
6
Slides
Slides
Why CICS ?
Why CICS
- To support applications needing up-to-the-minute data, you need to have online support) - Application development made easier as CICS handles the formatting and other components needed for online interface
Slides
Slides
AID keys
Enter Clear PF keys PA keys Other keys ALT, TAB, EOF (PF1 to PF24) (PA1 to PA3)
Screen format
1 2 3 ...
1 2 .. 24
...
80
10
Slides
CICS commands are embedded in a host language (in general, COBOL) A CICS program must contain
LINKAGE SECTION 01 DFHCOMMAREA and EXEC CICS RETURN END-EXEC. PIC X(n).
11
Slides
Slides
Conversational Programming
Once CICS starts execution of a program, it runs it till the completion of a program. (Wait periods -DC) All the normal programs other than in CICS environment we come across are conversational.
13
Slides
Slides
15
Slides
Slides
A Conversational program:
IDENTIFICATION DIVISION. PROGRAM-ID. CONV. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-PROMPT PIC X(07) VALUE NAME. 01 WS-INPUT PIC X(20). 01 WS-MESSAGE PIC X(10) VALUE HELLO MR.. 01 WS-LENGTH PIC S9(4) COMP VALUE +20. LINKAGE SECTION. 01 DFHCOMMAREA PIC X(01). PROCEDURE DIVISION. 000-MAIN. EXEC CICS SEND FROM (WS-PROMPT) LENGTH (7) ERASE END-EXEC.
17
Slides
EXEC CICS RECEIVE INTO (WS-INPUT) LENGTH (WS-LENGTH) END-EXEC. EXEC CICS SEND FROM (WS-MESSAGE) LENGTH (10) ERASE END-EXEC. EXEC CICS SEND FROM (WS-INPUT) LENGTH (20) END-EXEC. EXEC CICS RETURN END-EXEC. 099-MAIN-EXIT. EXIT.
18
Slides
19
Slides
PROCEDURE DIVISION. 000-MAIN. IF EIBCALEN = 0 PERFORM 100-INITIAL-ENTRY THRU 199-INITIAL-ENTRY-EXIT ELSE PERFORM 200-NEXT-ENTRY THRU 299-NEXT-ENTRY-EXIT END-IF. EXEC CICS RETURN TRANSID (EIBTRNID) COMMAREA (WS-COMMAREA) LENGTH (1) END-EXEC. 099-MAIN-EXIT. EXIT. *-------------------------------------------------100-INITIAL-ENTRY. EXEC CICS SEND FROM (WS-PROMPT) LENGTH (7) ERASE END-EXEC. 199-INITIAL-ENTRY-EXIT. EXIT.
20
Slides
200-NEXT-ENTRY. EXEC CICS RECEIVE INTO (WS-INPUT) LENGTH (WS-LENGTH) END-EXEC. EXEC CICS SEND FROM (WS-MESSAGE) LENGTH (10) ERASE END-EXEC. EXEC CICS SEND FROM (WS-INPUT) LENGTH (20) END-EXEC. EXEC CICS RETURN END-EXEC. 299-NEXT-ENTRY-EXIT. EXIT.
21
Slides
When CICS loads a program, it creates a task to run that program. For every task, CICS assigns values to EIB fields (which is put in the linkage section at pre compile).
01 DFHEIBLK. 02 EIBTIME 02 EIBDATE PIC S9(7) COMP-3. PIC S9(7) COMP-3.
02 EIBTRNID PIC X(4). 02 EIBTASKN PIC S9(7) COMP-3. 02 EIBTRMID PIC X(4). 02 EIBCPOSN PIC S9(4) COMP. 02 EIBCALEN PIC S9(4) COMP. 02 EIBAID etc.
22
PIC X.
Slides
Task:
a task is created for each executed transid. a task can consists of a single program or multiple programs. a task continues until a program returns control to CICS or until it issues a RETURN with a TRANSID in the pseudo conversational mode. CICS can handle several tasks at a time (multi tasking). several tasks can access the same code in main memory (multithreading) and hence CICS programs should be reentrant.
Though every task for the same program shares the object code, separate working storage, linkage section are created.
23
Slides
When a Transid is received by CICS, it checks if the associated program is already loaded. If so, it merely increases the usage counter by 1, else it loads the program into memory and make the counter 1. When a task gets completed, its counter is decremented by 1. When it becomes zero the program is unloaded (unless it is designated as main memory resident). One program can call other program. In conversational mode all these becomes a single task. In pseudo conversational mode each time the program is made active, a new task is created.
24
Slides
Both the COBOL program and the mapset program have to be compiled before using a map. The physical map describes details of all the fields. The symbolic map describes details of all the variable fields.
25
Slides
CICS allows to send either of the maps or both using the send map command. This facility reduces the network traffic between the computer and the terminal and increases the speed of transmission.
26
Slides
F3 - EXIT
F4 - NEXT EMP
F3 - EXIT
F4 - NEXT EMP
27
Slides
In the above map, all the fields in blue are constant fields, and all the fields in green are variable fields. Notice that when the user presses F4, the next employee details appear and at this time only the symbolic map need to be sent. In the above case the symbolic map will look like:
01 MY-FIRST-MAP. 05 FILLER 05 MP-NAME-L 05 MP-NAME-A 05 MP-NAME-D 05 MP-NO-L 05 MP-NO-A 05 MP-NO-D PIC X(12). PIC S9(4) COMP. PIC X. PIC X(4). PIC S9(4) COMP. PIC X. PIC X(4).
28
Slides
empdata DFHMSD TYPE=DSECT, CTRL=(FREEKB,FRSET), LANG=COBOL, MODE=INOUT, TERM=3270, TIOAPFX=YES empdata DFHMDI SIZE=(24,80), CTRL=(FREEKB) DFHMDF POS=(1,2), ATTRIB=(NORM,ASKIP), LENGTH=7, INITIAL=INFOSYS DFHMDF POS=(1,20), ATTRIB=(NORM,ASKIP), LENGTH=16, INITIAL=EMPL .... DFHMDF POS=(5,15), ATTRIB=(NORM,ASKIP), LENGTH=14, INITIAL=EMPL ....E: empname DFHMDF POS=(5,30), ATTRIB=(NORM,ASKIP), LENGTH=4 ..... ..... ..... ..... ..... ..... DFHMSD TYPE=FINAL END
x x x x x x x x x x x x x x x x x
29
Slides
SIZE = (lines,columns) LINE = line# COLUMN = column# POS = (line#,column#) / posn# LENGTH = number ATTRIB = (ASKIP/PROT/UNPROT, NUM, NORM/BRT/DRK, FSET, IC)
ASKIP - AutoSKIP, PROT - PROTected, UNPROT - UNPROTected. NORM - NORMal, BRT - BRighT, DRK - DaRK.
30
Slides
Sending a map:
EXEC CICS SEND MAP (mapname) MAPSET (mapsetname) FROM (symbolic mapname) [MAPONLY/DATAONLY] [ERASE/ERASEAUP] [CURSOR] END-EXEC.
31
Slides
Program
BMS
Terminal
Const 1 Const 2 Var A Var B Var A Var B Const 3 SEND MAP ... DATAONLY
32
Slides
Receiving a map:
EXEC CICS RECEIVE MAP (mapname) MAPSET (mapsetname) INTO (symbolic mapname) END-EXEC.
Slides
34
Slides
01 DFHAID. 02 DFHNULL PIC X VALUE IS ' '. 02 DFHENTER PIC X VALUE IS QUOTE. 02 DFHCLEAR PIC X VALUE IS '_'. 02 DFHPEN PIC X VALUE IS '='. 02 DFHOPID PIC X VALUE IS 'W'. 02 DFHMSRE PIC X VALUE IS 'X'. 02 DFHSTRF PIC X VALUE IS 'h'. 02 DFHTRIG PIC X VALUE IS '"'. 02 DFHPA1 PIC X VALUE IS '%'. 02 DFHPA2 PIC X VALUE IS '>'. 02 DFHPA3 PIC X VALUE IS ','. 02 DFHPF1 PIC X VALUE IS '1'. 02 DFHPF2 PIC X VALUE IS '2'. 02 DFHPF3 PIC X VALUE IS '3'. 02 DFHPF4 PIC X VALUE IS '4'. 02 DFHPF5 PIC X VALUE IS '5'. 02 DFHPF6 PIC X VALUE IS '6'. 02 DFHPF7 PIC X VALUE IS '7'. 02 DFHPF8 PIC X VALUE IS '8'. 02 DFHPF9 PIC X VALUE IS '9'. 02 DFHPF10 PIC X VALUE IS ':'. 02 DFHPF11 PIC X VALUE IS '#'. 02 DFHPF12 PIC X VALUE IS '@'. 02 DFHPF13 PIC X VALUE IS 'A'. 02 DFHPF14 PIC X VALUE IS 'B'. 02 DFHPF15 PIC X VALUE IS 'C'.
35
Slides
36
Slides
37
Slides
before sending the map. This is used mainly for the subsequent sending of maps in case of errors in any of the fields. Normally, the cursor is placed at the first field which has error.
38
Slides
Slides
40
Slides
ABEND - ABnormalEND This could happen when any error occurs which is not taken care in the program. We can check the ABEND code and give meaningful messages to the user. EXEC CICS HANDLE ABEND PROGRAM (abend-program) END-EXEC. OR EXEC CICS HANDLE ABEND LABEL (module-name) END-EXEC.
Forcing an ABEND:
EXEC CICS ABEND ABCODE (ws-abend-code) END-EXEC.
41
Slides
Slides
EXEC CICS XCTL PROGRAM (program-name) [COMMAREA (ws-commarea)] [LENGTH (ws-commarea-length)] END-EXEC. Control goes to the called program and does not return back. EXEC CICS START [TRANSID (transactionId)] [INTERVAL (hhmmss) | TIME (hhmmss)] [TERMID (terminal-name)] [FROM (ws-data-area)] [LENGTH (ws-data-area-length)] END-EXEC. This command can start a transaction on another terminal at specified time or after a specified interval and can pass data to the called program. If the terminal is not specified, when the calling program issues an unconditional RETURN, this new transaction starts.
43
Slides
CICS
Level 0
Level 1
Level 2
Level 3
44
Slides
Other differences:
When RETURN is used the EIBTRNID will have the value specified in TRANSID option. When LINK and XCTL is used the EIBTRNID retains the old value. When START is used the EIBTRNID gets the new value. In CICS a task ends when the RETURN command is executed. A logical unit of work in CICS is a task. We can not have the called program as a pseudo conversational program only in LINK since, the moment the RETURN command is executed in called program, the control comes back to the calling program. In all the commands except START the calling task gets terminated at the time the command is executed where as START needs an unconditional RETURN.
45
Slides
Slides
....... .......
....... .......
47
Slides
Return
DFHCA WS 1 Prog A
DFHCA WS 1 Prog A
XCTL, LINK
DFHCA WS 2 Prog B
Move
Slides
49
Slides
Writing a TSQ:
EXEC CICS WRITEQ TS QUEUE (queue-name) FROM (ws-data-area) LENGTH (ws-data-area-length) [ITEM (item-no)] [REWRITE] [MAIN / AUXILIARY] END-EXEC. Writing a queue which does not exist creates a queue. Queue name is normally prefixed with the 4 char terminalid (EIBTRMID) for uniqueness. Item specifies which record being written. Leaving this out writes at the end. Rewrite is used for updating a pre read item. TSQs are by default on secondary storage to save memory.
50
Slides
Reading a TSQ:
EXEC CICS READQ TS QUEUE (queue-name) INTO (ws-data-area) LENGTH (ws-data-area-length) [ITEM (item-no)] [NEXT] END-EXEC. If both ITEM and NEXT are not specified, by default it is taken as next.
Deleting a TSQ:
EXEC CICS DELETEQ TS QUEUE (queue-name) END-EXEC. Notice that deletion of one particular record is not possible from a TSQ. Also, queue created by one task can be deleted by other if it knows the name of the queue.
51
Slides
Slides
Slides
Slides
TDQ commands:
EXEC CICS WRITEQ TD QUEUE (queue-name) FROM (ws-data) LENGTH (ws-data-length) END-EXEC. EXEC CICS READQ TD QUEUE (queue-name) INTO (ws-data) LENGTH (ws-data-length) END-EXEC. EXEC CICS DELETEQ TD QUEUE (queue-name) END-EXEC. Giving TD is a must, TS is default if not given.
55
Slides
Two kinds of TDQs: Intra partition and extra partition. Intra Partition data queues share data for tasks within a CICS partition. Extra Partition data queues share data outside a CICS partition. Both types use identical commands. TDQs are normally not used. For list processing, we always use TSQs. DFHCOMMAREA is generally used for retaining data in pseudo conversational mode.
56
Slides
Writing a dataset.
EXEC CICS WRITE DATASET (filename) FROM (ws-data-area) RIDFLD (keyfield-name) END-EXEC.
Updating a dataset.
EXEC CICS REWRITE DATASET (filename) FROM (ws-data-area) END-EXEC.
Writing a dataset.
EXEC CICS DELETE DATASET (filename) [RIDFLD (keyfield-name)] END-EXEC. 57
Slides
Slides
Slides
Summary
In this course we have seen
what is CICS, the need for CICS the screen layout, keys, etc. batch and online programs important CICS tables transactions and tasks starting and ending a transaction Conversational & Pseudoconversational Programming changing map attributes and positioning the cursor error handling in CICS programs CICS commands complete BMS concepts methods of transferring control from one program to another methods of retaining data between two tasks and transferring data from one program to another File handling in CICS
60