CICS Tutorial
CICS Tutorial
BMS MACRO:
My role involved writing efficient code to ensure optimal performance and reliability, which is
crucial in a production environment.
BMS map is a program which is written in Assembly language to manage screens. The three macros
that are used to define the screen are DFHMSD, DFHMDI, and DFHMDF.
Columns Macros
1-8 Label
16-71 Operands
72 Continuation
DFHMSD is used to define a mapset with its characteristic and to end a mapset. So you will find
two DFHMSD in any BMS coding.
TYPE -It should be DSECT for Symbolic map generation, MAP for physical map generation and
FINAL to indicate the end of mapset. Alternatively symbolic parameter &SYSPARM can be coded in
the TYPE of defining DFHMSD and the value can be overridden in the PARM parameter of
assembly procedure. This avoids the change in the BMS coding.
MODE - IN for input maps like order entry screens and OUT for output maps like display screens
and INOUT for input-output maps like update screens.
LANG - It specifies the language in which the symbolic map is to be generated. It can be COBOL,
PLI, ASM or RPG.
STORAGE - AUTO is used to acquire separate symbolic map area for each mapset. BASE=MAP-
IOAREA allows multiple maps from more than one mapset to share same storage area. MAP-
IOAREA will be redefined multiple times to achieve it.
TIOAPFX - It should be ‘YES’ to reserve the prefix space of 12 bytes for BMS commands to access
TIOA properly. This is required for command level CICS.
CTRL -Device control requests are placed here. Multiple parameters are separated by comma.
FREEKB is used to unlock the keyboard. FRSET is used to reset the MDT of all the fields in all the
maps to zero. ALARM is used to set an alarm at screen display time. PRINT is used to send the
mapset to printer.
TERM -If anything other than 3270 terminal is used for display of screens, then it should be coded
here. This ensures device independence by means of providing the suffix. SUFFIX is used to specify
suffix for the terminal and it should correspond to TCT entry of the terminal.
DFHMDI is used to define a map with its characteristic in a mapset. There can be any number of
DFHMDI. Some of the important operands of DFHMDI are below:
SIZE
It has two arguments namely length and breadth and as a whole the size of the map is specified
here.
SIZE = (Line,Column)
LINE
The map starting line is mentioned here.
COLUMN
The map-starting column within the LINE is mentioned here.
CTRL -Device control requests are placed here. Multiple parameters are separated by comma.
FREEKB is
used to unlock the keyboard. FRSET is used to reset the MDT of all the fields in all the maps to
zero. ALARM is used to set an alarm at screen display time. PRINT is used to send the mapset to
printer.
TIOAPFX
It should be ‘YES’ to reserve the prefix space of 12 bytes for BMS commands to access TIOA
properly.
POS
It has two arguments that decided the position of the field. The two arguments are line and
column. It is the position where the attribute byte of the field starts.
So if you code POS = (1,1), the attribute byte for that field is on line 1 in column 1, and the actual
data starts in column 2.
LENGTH - The length of the field is coded here. It excludes the attribute character.
ATTRIB - All the input and output fields are prefixed by one byte attribute field that defin+es the
attributes of the field. Some of the attributes are:
1. ASKIP/PROT/UNPROT
Mutually exclusive parameters that define the type of the field.
UNPROT is coded for input and input-output fields.
PROT is coded for output and stopper fields.
ASKIP is coded for screen literals and skipper fields. The cursor automatically skipped to next field
and so you cannot enter data into skipper field.
2. NUM
0-9,Period and – are the only allowed characters.
3. BRT/NORM/DRK
Mutually exclusive parameters that define the intensity of the field.
4. IC
Insert Cursor. Cursor will be positioned on display of map. If IC is specified in more than one field
of a map, the cursor will be placed in the last field.
5. FSET
Independent of whether the field is modified or not, it will be passed to the program. MDT is set
for the field.
JUSTIFY
RIGHT is the default value. Code LEFT for numeric fields.
PICIN and PICOUT - It defines the Picture clause of the symbolic map in COBOL and useful for
numeric field editing.
INITIAL - The default value of the field is coded here. When the MAP is sent, this value will appear
in the field. The constant information like TITLE is coded using INITIAL keyword of field definition.
To avoid data traffic, these constant information fields should not be coded without LABEL
parameter. If there is no LABEL parameter, then symbolic map will not generated for those fields
as they are unnamed fields.
MAP('map-name')
MAPSET('mapset-name')
Specifies the name of the mapset to be used. It is needed unless mapset name is the same as the
map name.
FROM(data-area)
LENGTH(data-value)
Specifies the length of the data to be formatted as a halfword binary value. If the data area
sending the map is longer than the data to be mapped, LENGTH should be specified.
MAPONLY
DATAONLY
Specifies that only application program data is to be written(i.e. Only the data from- your program
is sent to the screen). Any default data or attributes from the map are ignored.
FREEKB
Keyboard should be unlocked after the data is written in screen. If FREEKB is not added, the
keyboard remains locked.
FRSET
Flag Reset turns off the modified data tag(MDT) in the attribute byte for all the fields on the screen
before what you are sending is placed there.
ERASE
This is used to clear the map on the screen when sending any map.
ERASEAUP
This is used to clear the previous value on the screen when sending thee data only.
CURSOR
This is used to position the cursor on the screen. Cursor is set by moving -1 to the L part of the
field and then sending the map.
OPTION 2
KCP
KCP is used to simultaneously control the execution of tasks and its related properties.
It handles all the issues related to multi-tasking.
PCP
It transfers the control between programs and in the end, it returns the control back to the
CICS.
FCP
FCP is used to provide application programs with services like read, insert, update or delete
records in a file.
It keeps exclusive control over the records in order to maintain data integrity during record
updates.
SCP
SCP is known as Storage Control Program. It is used to control allocation and deallocation of storage
within a CICS region.
Advertisement
Control Tables
CICS consists of IBM-supplied CICS control programs and tables. These tables need to be updated
accordingly with the application information for successful execution of CICS application programs.
Following are the important Control Tables −
TCT
TCT contains the terminal ID's that are connected to current CICS region.
Terminal Control Program along with terminal control table recognize the incoming data
from the terminal.
It contains the Transaction IDs (TRANSID) and the corresponding program names or program
IDs.
PPT
PPT is known as Processing Program Table. PPT contains Program name or Mapset name, Task Use
Counter; Language, Size, Main storage address, Load library address, etc.
FCT
All the files used in a CICS program must be declared in FCT and they are opened and closed
by CICS itself.
Transaction
When a transaction identifier TP02 is entered on the CICS terminal, first it checks if there is a
program associated with this Transaction identifier in the PCT table. If it finds one, then it checks in
the PPT table to find the location of the Program to execute it.
If the program is already available in the memory, it starts executing that particular program; if not, it
loads the program to the memory from the secondary storage and then starts executing it.
The terminal operator initiates the transaction by typing a 1 to 4 character transaction-id and
pressing the ENTER key.
Step 2
The TCP periodically checks all the terminals for input. When a message is received, it does the
following −
Step 3
The KCP takes control from the TCP and does the following −
Assigns priority to the task based on Terminal priority (Set in TCT), Operator priority (Set in
SNT), and Transaction priority (Set in PCT).
Adds the task to the queue of waiting programs.
Step 4
The PCP takes control from the KCP and does the following −
Step 5
The Application program takes control from the PCP and does the following −
Requests the TCP to place the message into the programs WORKING STORAGE area.
Step 6
The FCP takes control from the Application program and does the following −
Informs the KCP that this task can wait until the I/O is complete.
Step 7
Step 8
Step 9
Step 10
The PCP returns the control back to the KCP requesting it to end the task.
Step 11
The KCP instructs the SCP to free all the storage allocated to the task (except TIOA).
Step 12
The system sends a message to the screen and waits for the users response.
The time taken by user to respond is known as Think Time. This time is considerably high,
which is a major drawback of conversion programs.
The user provides the necessary input and presses an AID key.
The application processes the users input and sends the output.
The program is loaded into the main storage at the beginning and is retained till the
task .ends.
.Following are the two types of return statements which are used in
CICS −
Return-1
When the following unconditional return statement is issued, the
task and the transaction (program) is terminated.
EXEC CICS RETURN
END-EXEC.
Return-2
When the following conditional return, i.e., return with TRANSID
statement is issued, the control returns to the CICS with the next
transid to be executed. The next transaction starts when the user
presses an AID key.
EXEC CICS RETURN
TRANSID ('trans-id')
[COMMAREA(WS-COMMAREA)]
END-EXEC.
Advantages of Pseudo Conversion
The resources are best utilized. Resources are released as soon as the program is suspended
temporarily.
------------------------------------------------------------------------------------------------------------------------------
1
Analysis –
Write query
Here both the files have keys at 1-10. And only the matching records are written into output file.
REFORMAT fields tells the sort on what fields to be written into output file from the input files.
2. Both Files Matching Records + Non Matching from File1 (Left outer join)
//SYSIN DD *
SORT FIELDS=COPY
JOINKEYS FILES=F1,FIELDS=(1,10,A)
JOINKEYS FILES=F2,FIELDS=(1,10,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,71,F2:1,9)
/*
4. Both Files Matching Records + Non Matching from File2(Right outer join)
//SYSIN DD *
SORT FIELDS=COPY
JOINKEYS FILES=F1,FIELDS=(1,10,A)
JOINKEYS FILES=F2,FIELDS=(1,10,A)
JOIN UNPAIRED,F2
REFORMAT FIELDS=(F1:1,71,F2:1,9)
/*
//SYSIN DD *
SORT FIELDS=COPY
JOINKEYS FILES=F1,FIELDS=(1,10,A)
JOINKEYS FILES=F2,FIELDS=(1,10,A)
JOIN UNPAIRED,F2,ONLY
REFORMAT FIELDS=(F2:1,9)
/*
//SYSIN DD *
SORT FIELDS=COPY
JOINKEYS FILES=F1,FIELDS=(1,10,A)
JOINKEYS FILES=F2,FIELDS=(1,10,A)
JOIN UNPAIRED,F1,F2
REFORMAT FIELDS=(F1:1,71,F2:1,9)
/*
1. CEMT SET PROG(mapset-name) NEW –COMMAND TO ADD NEW COPY
Common Applications:
Load a new version of a COBOL program (Newcopy):
CEMT SET PROGRAM(PROGNAME) NEWCOPY
Used to debug application programs interactively. It intercepts execution before and after every EXEC
CICS command.
Common Applications:
Used to test individual CICS commands interactively without writing, compiling, or compiling a
COBOL program.
Common Applications:
4. CEBR
Used to inspect, modify, or delete the contents of Temporary Storage Queues (TSQs).
Common Applications:
Used to define, alter, and manage CICS system definitions (groups and lists).
Common Applications:
Dynamically install definitions so they are active immediately without a CICS reboot:
CEDA INSTALL GROUP(MYGRP)
Used to instantly look up the meaning of CICS error messages or abnormal termination (abend)
codes.
Common Applications:
Look up a transaction abend code (e.g., AEIL - occurs when a file is disabled):
CMAC AEIL
Sign-On Syntax: CESN (Pressing enter opens a secure menu to type User ID and Password).
Providing a step-by-step example of debugging a specific program error using CEDF or CECI.
Looking up the exact syntax options for a specific resource type within CEMT or CEDA.
DFHDCT TYPE=EXTRA, X
DESTID=Q2, X * Queue name
DSNAME=[Link], X * External dataset name
BLOCKSIZE=800, X * I/O block size
RECORDSIZE=80 X * Each record length
//SYSLIB DD DSN=[Link],DISP=SHR
//SYSIN DD DSN=[Link],DISP=SHR
//SYSLMOD DD DSN=[Link],DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSLMOD DD DSN=[Link],DISP=SHR
//SYSLIN DD DSN=[Link],DISP=SHR
Execution Stage
Programs can then use WRITEQ TD, READQ TD, etc., against the TDQs defined in DFHDCT.
TSQ :
FEATURE DESCRIPTION
IDENTIFICATION DIVISION.
PROGRAM-ID. DEMOPGM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-DATA.
05 WS-MSG PIC X(50).
LINKAGE SECTION.
01 DFHEIBLK.
COPY DFHEIBLK.
01 DFHCOMMAREA.