CICS Training Material
CICS Training Material
CICS Training Material
Table of Contents
Introduction to CICS Basic Mapping Support Program Control File Processing Error Handling Queues Interval and Task Control Recovery and Restart Program preparation CICS Supplied Transactions Case Study
2
Introduction to CICS
Customer Information Control System -CICS developed in late 1960s as a DB/DC control system CICS provides an interface between the Operating System and application programs Macro Level CICS - initial version Assembler macro to request CICS services Command Level CICS - high level lang.version - commands to request CICS services - Single command can replace series of macros
3. 4. 5. 6.
BATCH SYSTEM Input data is prepared and given in sequence (file) Processing sequence is predictable and hence restarting the process in case of failure is easy. Programs and files cant be shared Programs are scheduled through jobs O/P printed on paper or in sequential of VSAM or Indexed files Response time: Could be scheduled to be Hours or days
1. 2.
3. 4. 5. 6.
ONLINE SYSTEM Data is entered as needed not in sequence (terminal) Since processing sequence is unpredictable, special recovery/restart proc. is required in case of failure Programs and files can be shared Transaction can be run at any time O/p displayed on Terminal updated files Response Time: Could be in minutes or second. Usually in seconds
4
Users App.
DB/DC System
Terminals
Terminal Conversation
Conversational : A mode of dialogue between program and terminal based on a combination of sending message and receiving message within the same task Since human response is slower than the CPU speed, a significant amount of resource will be wasted just waiting
Pseudo-Conversational. A mode of dialogue between program and terminal which appears to the operator as a continuous conversation but which is actually carried by a series of tasks
10
11
Pseudo-Conversation Example
Transaction TSK1 Program PROG1
PROCEDURE DIVISION. : EXEC CICS RECEIVE END-EXEC. : EXEC CICS SEND END-EXEC. EXEC CICS RETURN TRANSID (TSK2) END-EXEC. Transaction TSK2 Program PROG2 PROCEDURE DIVISION. : EXEC CICS RECEIVE END-EXEC. : EXEC CICS SEND END-EXEC. EXEC CICS RETURN END-EXEC.
12
CICS Components
Control Programs (or Management Modules) Programs that interface between OS and app. pgm Handle the general functions that are crucial to operation of CICS Control Tables Define the CICS environment Functionally associated with the management module Control Blocks (or Areas) Contain system type information. Eg. Task Control Area contains information about the task
13
Tables
PCP FCP TCP KCP TSP TDP SCP ICP JCP Processing Program Table File Control Table Terminal Control Table Program Control Table Temp. Storage Table Destin. Control Table PPT FCT TCT PCT TST DCT
14
15
17
18
19
CICS Translator
The CICS translator converts CICS commands into the COBOL code so that it could be compiled by a Standard Cobol compiler
COBOL Statements
CICS Translator
20
Translator
When you compile a CICS/VS program the translator will automatically add many lines of code to your program, which can be seen in the compiled listing
21
Topics in BMS
Introduction to BMS Map and Mapset Physical and Symbolic Map Map Definition Macros Screen Manipulation/Handling Screen Design Considerations Interfacing with Terminal using a Map
23
Introduction to BMS
Introductory concepts
In online systems, formatted screens are used. In order to display formatted screen, a terminal (e.g. 3278) must receive a series of data stream called Native Mode Data Stream (NMDS) based on the hardware protocol; this NMDS is a mixture of Buffer Control Characters (BCCs) and text data. NMDS is designed for a particular terminal and is thus both device dependent and format dependent. So if NMDS is used, re-coding is required whenever there is change in the terminal device or screen format. To remove this device and format dependency from application program, CICS provides a facility called Basic Mapping Support (BMS).
24
Or
26
27
28
Types of MAPS
There are 2 types of MAPS Physical Map Physical Map is a map used by CICS (CSECT) Ensure device independence in the application program BMS macro coding ==> Assembly==> Link edit ==> Load module ==> LOADLIB ===> To be used by CICS Symbolic Map Ensure device and format independence in the application program Symbolic Map is a map used by Application Program (DSECT) BMS macro coding ==> Assembly ==> Symbolic map definition ==> COPYLIB ==> Copied (COPY) into CICS application program.
29
30
Symbolic MAP
Linkage editor
31
Physical Map
Physical Map. The BMS macros are assembled and link-edited into CICS load library to create the physical map. The mapset like any other CICS program is stored in CICS runtime library the PPT(Program Processing Table). At the program execution time the physical map is being used by CICS to load the screen image.
In case of input operations, the physical map defines the maximum length, the starting position for each field to be read and allows BMS to interpret an input NMDS. In case of output operations, the physical map defines the starting position, length, field characteristics and the default data for each field and allows BMS to construct an output NMDS.
32
Symbolic Map
The symbolic map is coded using the BMS macro, assembled separately and catalogued into a copy library. The symbolic map serves as a DSECT for referencing the Terminal Input/Output Area (TIOA). The program issues a COBOL COPY statement to include it in the program.
The symbolic maps represents the actual data structure of the fields defined in the physical map, and is used by the application program to send and receive information from the terminal, in the CICS SEND-MAP & RECEIVE MAP commands. The symbolic map can be used by the CICS application programs to dynamically to alter the field attributes, modify screen cursor position, and highlight , protect , unprotect specific fields on the 33 screen.
16 operands
72 contd.
X X X X
* * ANY COMMENTS
34
OPERATION OPERANDS
CONTD
: :
:
Comments
35
:
:
36
Order of Macros
DFHMSD TYPE=DSECT DFHMDI DFHMDF DFHMDF : DFHMDI DFHMDF DFHMDF : DFHMSD TYPE=FINAL END Mapset Map A field A field Map A field A field Mapset
37
DFHMSD Macro
The DFHMSD macro is used to define a mapset (TYPE=MAP) and its characteristics or to end a mapset definition (TYPE=FINAL). Only one mapset is allowed in one assembly run. All the maps in a map set get assembled together, and they're loaded together at execution time. Example: TSTMSET
X
DFHMSD
X X
STORAGE=AUTO, TIOAPFX=YES,
X
CNTL=(FREEKB,FRSET,PRINT)
38
To reserve the prefix space (12 bytes) for BMS commands to access TIOA properly. Required for the CICS command level.
40
To define the device control requests To unlock the keyboard To reset MDT to zero status To set an alarm at screen display time To indicate the mapset to be sent to the printer
This ensures device independence, required if other than 3270 terminal is being used To specify the user provided suffix number. This must correspond to the TCT parameter.
TERM=type
SUFFIX=nn
41
DFHMDI Macro
Defines a map and its characteristics Example EMPMAP DFHMDI SIZE=(ll,cc), X LINE=nn, X COLUMN=mm, X JUSTIFY=LEFT/RIGHT Options SIZE=(ll,cc) To define the size of the map by the line size (ll) and the column size (cc). Useful when the screen contains. LINE Indicates the starting line number of the map. COLUMN Indicates the starting column number of the map. JUSTIFY To specify the entire map (map fields) is to be left or right justified.
42
DFHMDF Macro
The DFHMDF macro is used to define a field in a map and its characteristics. This is the position on the screen where the field should appear. It's the position relative to the beginning of the map. Field starts with its attribute byte, so if POS=(1,1) is coded, then the attribute byte for that field is on line 1 in column 1, and the actual data starts in column 2. The length of the field (not counting the attribute byte) is specified. Literals can be specified within quotes; these character data is for an output field. It is used to define labels and titles for the screen and keep them independent of the program.
43
44
X X X X X X X X
45
Attribute character
Function: The attribute character is an invisible 1-byte character, which precedes a screen field and determines the characteristics of a field. ASKIP Autoskip. Data cannot be entered in this field. The cursor skips to the next field. PROT Protected field. Data cannot be entered into this field. If data is entered, it will cause the input-inhibit status. UNPROT Unprotected field. Data can be entered and this is used for all input fields. NUM Numeric field. Only numbers (0 to 9) and special characters (. and -) are allowed.
46
FSET Field set. MDT is set on so that the field data is to be sent from the terminal to the host computer regardless of whether the field is actually modified by the user.
47
48
3.
49
Skipper Technique
Unlabelled 1-byte field with the autoskip attribute DFHMDF POS(ll,cc),ATTRB=ASKIP,LENGTH=1 To skip the cursor to the next unprotected field after one unprotected field. Screen Layout : &xxxxx&$ &xx where $ Skipper field & Attribute byte X Unprotected field
50
Stopper Technique
Unlabelled 1-byte field with the protect attribute DFHMDF POS(ll,cc),ATTRB=PROT,LENGTH=1 To stop the cursor in order to prevent erroneous field overflow by terminal user. Screen Layout : &xxxxx&$#&$ where # Stopper field
51
53
Name + A: fields.
Name + I: The input data field. X00 will be placed if no data is entered. Note that space X40 is data. The application program should differentiate X00 from space (X40). Name + O: The output data field.
54
56
58
59
60
The cursor will be placed at FIELD1 field of the map MAP1 during execution.
61
1.
2.
3.
Symbolic Map
BMS
Output NDMS
Terminal
Physical Map
Data Entry
Symbolic Map
BMS
Input NDMS
Terminal
63
64
Field name + F
Field name + I
65
66
68
Conditions : INVREQ,LENGERR
70
71
72
AID KEYS
First time when a transaction is initiated the application program throws the screen image on the terminal thru SEND MAP command. Once the screen appears, the AID (Attention Identifier ) Keys are being used to send the information back from the terminal to CICS to application program. CICS application program needs to trap the attention identifier keys and process various functions related to the AID keys.
Salient Points PF keys, PA keys, ENTER & CLEAR key EIBAID in the CICS Executive Interface Block contains, recently used AID key.
73
74
75
76
77
78
79
Exercise - 1
80
82
Files do not need to exclusively defined in Application programs. The files do not need to opened and closed in a CICS application program , before being used in the program.
This list is called the FILE CONTROL TABLE (FCT) and is maintained by the systems programmers
When CICS/VS is started up. It goes through the FCT and makes all the files available. When CICS/VS is closed down it closes all the files.
Application programs do not need The FD Section, and the Input Output Section. Application program directly Refer to filenames in EXEC CICS Command.
83
Replaced by
Replaced by
EXEC CICS WRITE DATASET (File identifier) FROM (Record-Name) RID-FLD (Record- key) END-EXEC.
84
VSAM
Different types of VSAM Datasets used in CICS are : ESDS KSDS RRDS Entry Sequenced Dataset Key Sequenced Dataset Relative Record Dataset
85
86
88
89
90
Important Key-Words
Dataset/File :- Name in the FCT.
Into/From (WS-Rec) :- Working-Storage Area defined in the program where the CICS Puts/Gets the Data. RIDFLD :- Contains the Record Key.
RESP :- Contains the return code of the executed command. LENGTH :- Length of the Record to be Retrieved or Written.
91
Random READ
EXEC CICS READ File(filename) [SET() | Into()] RIdfld(Rec-Key)
END-EXEC.
92
93
Sequential Read
Sequential Read is done by Browse Oper. Establish the pointer to the First Record to be Read Using StartBr. Next and Previous Records can be Read as required Using ReadNext and ReadPrev. End the Browse Operation at last. Browse can be re-positioned. During Browse Operation, Records cannot be Updated.
94
95
96
Syntax of READNext/READPrev
EXEC CICS READNext | READPrev FILE(name) INTO(data-area)|SET(ptr-ref) RIDFLD(data-area) END-EXEC.
Condition : DUPKEY, ENDFILE, IOERR, LENGERR, NOTFND.
97
ENDBRowse
ENDBRowse terminates a Previously issued STARTBR.
SYNTAX : EXEC CICS ENDBR FILE(filename) END-EXEC. Condition: INVREQ
98
RESETBR
Its effect is the same as ENDBR and then giving another STARTBR.
Syntax : EXEC CICS RESETBR FILE(filename) RIDFLD(data-area) END-EXEC. Condition: IOERR, NOTFND.
99
WRITE Command
Adds a new record into the File. For ESDS, RIDFLD is not used but after write execution, RBA value is returned and Record will be written at the end of the File. For KSDS, RIDFLD should be the Record Key. The record will be written depending on the Key. MASSINSERTion must be done in ascending order of the Key.
100
101
REWRITE Command
Updates a Record which is Previously Read with UPDATE Option. REWRITE automatically UNLOCKs the Record after execution.
102
103
DELETE Command
Deletes a Record from a dataset. Record can be deleted in two ways, 1. RIDFLD with the full key in it 2. The record read with READ with UPDATE will be deleted. Multiple Records Delete is possible using Generic Option.
104
Syntax of DELETE
EXEC CICS DELETE FILE(filename) RIDFLD(data-area) END-EXEC.
Optional
105
UNLOCK
To Release the Record which has been locked by READ with UPDATE Command.
Syntax : EXEC CICS UNLOCK FILE(filename) : [other options] END-EXEC. Condition: DISABLED, IOERR, NOTOPEN.
106
General Exceptions
The following exceptions usually will occur for ALL CICS file handling commands.
FILENOTFOUND, NOTAUTH, SYSIDERR, INVREQ
107
110
111
HANDLE Condition
Example of Handle condition:
EXEC CICS HANDLE CONDITION NOTFND(RECORD-NOT-FOUND) END-EXEC
This condition catches the NOTFND condition and transfers control to the REC-NOT- FOUND paragraph in the program. The error handling logic can be coded in the REC-NOT-FND paragraph.
112
113
IGNORE Condition
IGNORE CONDITION condition ... condition specifies the name of the condition that is to be ignored( no action will be taken) Syntax : EXEC CICS IGNORE CONDITION ITEMERR LENGERR END-EXEC This command will not take any actions if the given two error occurs and will pass the control to the next instruction
114
Procedure Division.
EXEC CICS HANDLE CONDITION NOT-FND(REC-NOT-FOUND) END EXEC. : EXEC CICS READ DATASET(SAMPLE) RIDFLD(EMP-NO) INTO (EMP-REC) END-EXEC : GO TO LAST-PART
115
While returning the control, it can restore the Handle command using POP HANDLE.
117
120
PCT Entry
DFHPCT TYPE=ENTRY TRANSID= name PROGRAM=name TASKREQ=pf6 RESTART=yes/no ( TRANSEC = 1 to 64) RSLKEY= 1 to 24 resource level key SCTYKEY= 1 to 64 security key : : other options
121
PROGRAM CONTROL
122
123
LINK
Used to pass control from one application program to another The calling program expects control to be returned to it Data can be passed to the called program using COMMAREA If the called program is not already in main storage it is loaded
124
LINK Syntax
EXEC CICS LINK PROGRAM(name) [COMMAREA(data-area) [LENGTH(data-value)]] END-EXEC.
Conditions : PGMIDERR, NOTAUTH, LENGERR
125
XCTL
To transfer control from one application program to another in the same logical level
The program from which control is transferred is released Data can be passed to the called program using COMMAREA
126
XCTL Syntax
EXEC CICS XCTL PROGRAM(name) [COMMAREA(data-area) [LENGTH(data-value)]] END-EXEC.
Conditions : PGMIDERR, NOTAUTH, LENGERR
127
RETURN
To return control from one application program to another at a higher logical level or to CICS
Data can be passed using COMMAREA when returning to CICS to the next task
128
RETURN Syntax
EXEC CICS RETURN [TRANSID(name) [COMMAREA(data-area) [LENGTH(data-value)]]] END-EXEC.
Conditions : INVREQ, LENGERR
129
Level 0
Level 1
PROG B XCTL
Level 2
Level 3
Application Program Logic Levels
PROG D XCTL
PROG E RETURN
130
LOAD
To load program/table/map from the CICS DFHRPL concatenation library into the main storage Using load reduces system overhead Syntax : EXEC CICS Load Program(name) [SET (pointer-ref)] [LENGTH (data-area)] END-EXEC. Condition : NOTAUTH, PGMIDER
131
RELEASE
To RELEASE a loaded program/table/map Syntax :
EXEC CICS RELEASE PROGRAM(name) END-EXEC. Conditions : PGMIDERR, NOTAUTH, INVREQ
132
COMMAREA
Data passed to called program using COMMAREA in LINK and XCTL Calling program - Working Storage definition Called program - Linkage section definition under DFHCOMMAREA Called program can alter data and this will automatically available in calling program after the RETURN command ( need not use COMMAREA option in the return for this purpose ) EIBCALEN is set when COMMAREA is passed
133
CICS - DB2
CICS provides interface to DB2. DB2 requires CICS Attachment Facility to connect itself to CICS CICS programs can issue commands for SQL services in order to access the DB2 database.
EXEC SQL function [options] END-EXEC
135
Operating system
CICS REGION
DB2
REGION
DB2 Database
RCT Entry
The CICS-to-DB2 connection is defined by creating and assembling the resource control table (RCT) The information in RCT is used to control the interactions between CICS & DB2 resources DB2 attachment facility provides a macro (DSNCRCT) to generate the RCT. The RCT must be link-edited into a library that is accessible to MVS
137
DB2 - Precompiler
Source Program (EXEC SQL...
| EXEC CICS...) DB2 Precompiler | CICS command translator | Compile By COBOL | Linkedit by Linkage editor | Load Module
138
QUEUES
139
140
TDQs
Intra-partitioned - association within the same CICS subsystem Typical uses are - ATI (Automatic Task Initiation) associated with trigger level - Message switching - Broadcasting etc
Extra-partitioned - association external to the CICS subsystem, Can associate with any sequential device - Tape, DASD, Printer etc Typical uses are - Logging data, statistics, transaction error messages - Create files for subsequent processing by Non-CICS / Batch programs.
141
TDQs
Operations
Write data to a transient data queue (WRITEQ TD)
142
WRITEQ TD
Syntax : EXEC CICS WRITEQ TD QUEUE(name) FROM(data-area) [LENGTH(data-value)] [SYSID(systemname)] END-EXEC. Conditions: DISABLED, INVREQ, IOERR, ISCINVREQ, LENGERR, NOSPACE, NOTAUTH, NOTOPEN, QIDERR, SYSIDERR
143
READQ TD
Reads the queue destructively - Data record not available in the queue after the read. Syntax : EXEC CICS READQ TD QUEUE(name) {INTO(data-area) | SET(ptr-ref) } [LENGTH(data-value)] [NOSUSPEND] END-EXEC. Conditions : DISABLED, IOERR, INVREQ, ISCINVREQ, LENGERR, NOTAUTH, NOTOPEN, QBUSY, QIDERR, QZERO, SYSIDERR
144
DELETEQ TD
Deletes all entries in the queue Syntax : EXEC CICS DELETEQ TD QUEUE(name) END-EXEC.
Conditions: INVREQ, ISCINVREQ, NOTAUTH, QIDERR, SYSIDERR
145
146
147
148
TSQs
Operations Write and Update data Read data - Sequential and random Delete the queue Access Across transactions Across terminals Storage Main - Non-recoverable Auxiliary - Recoverable TST entry required, VSAM file DFHTEMP
149
150
WRITEQ TS
Syntax : EXEC CICS WRITEQ TS QUEUE(name) FROM(data-area) [LENGTH(data-value)] [NUMITEMS(data-area) | ITEM(data-area) [REWRITE] ] [MAIN|AUXILIARY] [NOSUSPEND] END-EXEC.
Conditions : ITEMERR, LENGERR, QIDERR, NOSPACE, NOTAUTH, SYSIDERR, IOERR, INVREQ, ISCINVREQ
151
READQ TS
Syntax : EXEC CICS READQ TS QUEUE(name) {INTO(data-area) | SET(ptr-ref) } LENGTH(data-value) [NUMITEMS(data-area)] [ITEM(data-area) | NEXT ] END-EXEC.
Conditions : ITEMERR, LENGERR, QIDERR, NOTAUTH, SYSIDERR, IOERR, INVREQ, ISCINVREQ
152
DELETEQ TS
Deletes all entries in the queue Syntax : EXEC CICS DELETEQ TS QUEUE(name) END-EXEC.
Conditions: INVREQ, ISCINVREQ, NOTAUTH, QIDERR, SYSIDERR
153
ASKTIME
Used to obtain current date and time Syntax : EXEC CICS ASKTIME[ABSTIME(data-area)] END-EXEC.
EIBDATE and EIBTIME updated with current date and time ABSTIME returns value of time in packed decimal format
155
FORMATTIME
Syntax : EXEC CICS FORMATTIME ABSTIME(data-ref) [YYDDD(data-area)] [YYMMDD(data-area)]... etc. [DATE(data-area) [DATEFORM[(data-area)]]] [DATESEP[(data-value)]] [DAYOFMONTH(data-area)] [MONTHOFYEAR(data-area)] [YEAR(data-area)]..... [TIME(data-area) [TIMESEP[(data-value)]]] END-EXEC. Condition: INVREQ
156
DELAY
Used to DELAY the processing of a task The issuing task is suspended for a specified interval or Until the specified time Syntax : EXEC CICS DELAY INTERVAL(hhmmss) | TIME(hhmmss) END-EXEC Conditions: EXPIRED, INVREQ
157
START
Used to start a transaction at the specified terminal and at the specified time or interval Data can be passed to the new transaction Syntax : EXEC CICS START TRANSID(transid) [TERMID(termid) TIME(hhmmss) | INTERVAL(hhmmss) ] END-EXEC Conditions : INVREQ, LENGERR,TERMIDERR, TRANSIDERR
158
159
161
RECOVERY
An attempt to come back to where the CICS system or the transaction was when the failure occurred
Recoverable Resources VSAM files Intrapartition TDQ TSQ in the auxiliary storage DATA tables Resource definitions & System definition files
162
RESTART
To resume the operation of the CICS system or the transaction when the recovery is completed
163
164
CICS automatically writes the before image information of the record into the dynamic log for the duration of one LUW ,the work between the two consecutive SYNC points When an ABEND occurs, CICS automatically recovers all recoverable resources using the info. in dynamic log (Set DTB=YES in PCT)
165
166
167
168
Program Preparation
169
Introduction
Preparing a Program to run in CICS Environment. Defining the Program in the CICS Region. Executing the Program.
170
Program preparation
IF DB2 : SOURCE
DB2 PRECOMPILER
CICS COMPILER
COBOL COMPILER
LOAD MODULE
LINK EDIT
171
Preparing a Program
CICS requires the following steps to prepare a program
Translating the Program. Assemble or Compile the Translator Output. & Link the Program.
172
Translation
Translates the EXEC CICS Statements into the Statements your Language (COBOL) Compiler can Understand. The Translator gives two outputs, a Program Listing as SYSPRINT and a Translated Source in SYSPUNCH. The SYSPUNCH is given as the input to the Program Compiler. If any Copy Books are used in the Program, there should not be any CICS Statements in the Copy Book.
173
Compiling or Linking
As the CICS Commands have been translated, the compilation of the CICS program is the same as language program. Hence, the compiler options can be specified as required.
174
175
176
CESN/CESF Transactions
To sign on to CICS system CESN [USERID=userid] [,PS=password] [,NEWPS=newpassword][,LANGUAGE=l] Userid & password values can be from 1-8 chars. In RACF, the Userid given in CESN is verified. NEWPS to change the password and LANGUAGE to choose national language Sign off by CESF which breaks the connection between the user and CICS If the Sign on is done twice for the same userid at the terminal, the previous operator will be signed off
177
178
179
180
CEDF (Contd..)
The points at which EDF interrupts execution of the program and sends a display to the terminal At transaction initialization, after EIB has been initialized and before the app. pgm given control Start of execution of each CICS command (auguement values can be changed at this point) End of execution of each CICS command and before the Handle condition mechanism is invoked (response code values can be changed) At program termination & at normal task termination When an ABEND occurs & at abnormal task termination. EIB values can be changed..& CEBR can be invoked
181
182
Exercise - 2
183
Thank You
184