Cics
Cics
CICS is a DB/DC system which is used in online applications. CICS was developed because batch operating
system can execute only batch programs. CICS programs can be written in COBOL, C, C++, Java, etc.
These days, users want information within seconds and in real time. To provide such quick service, we need
a system which can process information online. CICS allows users to communicate with the back-end
system to get the desired information. Examples of online programs include online banking system, flight
reservation, etc. Following image shows the components of CICS and how they are inter-related −
Functions of CICS
The main functions performed by CICS in an application are as follows −
Features of CICS
The features of CICS are as follows −
CICS is an operating system in itself, as it manages its own processor storage, has its own task
manager which handles execution of multiple programs, and provides its own file management
functions.
CICS provides online environment in batch operating system. Jobs submitted are executed
immediately.
CICS is a generalized transaction processing interface.
It is possible to have two or more CICS regions at the same time, as CICS runs as a batch job in the
operating system at the back-end.
CICS – Environment
CICS itself acts as an operating system. Its job is to provide an environment for online execution of
application programs. CICS runs in one region or partition or address space. CICS handles scheduling for
programs running under it. CICS runs as a batch job and we can view it in the spool by issuing the command
PREFIX CICS*. There are five major services which are provided by CICS. All these services together
perform a task.
CICS Environment
Following are the services which we will be discussing in detail step by step −
System Services
Data Communication Services
Data Handling Services
Application Programming Services
Monitoring Services
System Services
CICS maintains control functions to manage the allocation or de-allocation of resources within the system
which are as follows −
Task Control − Task control provides task scheduling and multitasking features. It takes care of the
status of all CICS tasks. Task Control allocates the processor time among concurrent CICS tasks.
This is called multitasking. CICS tries to prioritize the response time to the most important task.
Program Control − Program Control manages loading and releasing of application programs. As
soon as a task begins, it becomes necessary to associate the task with the appropriate application
program. Although many tasks may need to use the same application program, CICS loads only one
copy of the code into memory. Each task threads its way through this code independently, so many
users can all be running transactions that are concurrently using the same physical copy of an
application program.
Storage Control − Storage Control manages acquiring and releasing of main storage. Storage
control acquires, controls, and frees dynamic storage. Dynamic storage is used for input/output areas,
programs, etc.
Interval Control − Interval Control offers timer services.
CICS releases application programs from the burden of dealing with terminal hardware issues
through the use of Basic Mapping Support (BMS).
CICS provides Multi Region Operation (MRO) through which more than one CICS region in the
same system can communicate.
CICS provides Inter System Communication (ISC) through which a CICS region in a system can
communicate with the CICS region on another system.
Monitoring Services
Monitoring Services monitor various events within CICS address space. It provides series of statistical
information that can be used for system tuning.
CICS – Basic Terms
We must have knowledge of the basic terms used in CICS to get a better understanding of how it works.
Application programs use CICS for communication with remote and local terminals and subsystems.
CRT Monitor
The CRT monitor displays the output or the input fields of the application program. A screenshot of a 3278
Model of CRT monitor is shown below. It has the following characteristics −
Keyboard
Non-AID Keys − All other keys for alphabets, numeric, punctuation etc. are Non-Aid keys. When
the user types text or numbers using non-aid keys, CICS will not even know if the user is typing
anything or not.
AID Keys − AID keys are known as Attention Identifier Keys. CICS can detect only AID keys.
After typing all the input, only when the user presses one of the AID keys, CICS takes control. AID
Keys : ENTER, PF1 to PF24, PA1 to PA3, CLEAR. AID keys are further divided into two categories
−
o PF Keys − PF keys are known as function keys. PF keys allow transfer of data from terminal
to CICS. PF Keys are ENTER and PF1 to PF24.
o PA Keys − PA keys are known as Program Access keys. PA keys do not allow transfer of
data between terminal and CICS. PA Keys are PA1 to PA3 and CLEAR.
Transaction
A CICS program is invoked through a transaction. A CICS transaction is a collection of logically related
programs in an application. The whole application could be logically divided into several transactions.
Transaction identifiers which are 1 to 4 characters long are used to identify the transactions which
the users want to do.
A programmer links one program to the transaction identifier which is used to invoke all the
application programs for that particular transaction.
Task
A Task is a unit of work which is specific to a user.
Users invoke an application by using one of the transaction identifiers. CICS looks up for the
transaction identifier to find out which program to invoke first to do the work requested. It creates a
task to do the work, and transfers control to the mentioned program.
A transaction can be completed through several tasks.
A task can receive data from and send data to the terminal that started it. It can read and write files
and can start other tasks also.
The difference between a transaction and a task is that several users can invoke a transaction but each user
initiates his own task.
LUW
LUW stands for Logical Unit of Work. LUW states that a piece of work should be done completely or not
done at all. A task can contain several Logical Unit of Works in CICS. We will discuss more about it in
upcoming modules.
Application
An application is a series of logically grouped programs to form several transactions which is used to
complete a specific task for the end-user.
CICS – Nucleus
The five CICS system components described earlier are a convenient grouping of CICS system programs,
each of which performs its own specialized functions. The core of CICS known as the CICS Nucleus which
consists of IBM-supplied CICS Control Programs and Control Tables.
Control Programs
CICS nucleus is constructed by the control programs and corresponding control tables. It provides unique
advantages. It makes the CICS system highly flexible and thus easy to maintain. Following are the important
control programs of CICS −
TCP
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
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.
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
PCT
It contains the Transaction IDs (TRANSID) and the corresponding program names or program IDs.
TRANSID is unique in PCT table.
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
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.
Transaction Life Cycle
The transaction life cycle has the following steps −
Step 1
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 −
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 program’s WORKING STORAGE area.
Requests the FCP to retrieve records from the files.
Step 6
The FCP takes control from the Application program and does the following −
Step 7
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
CESN
CESN is known as CICS Execute Sign On.
CEDA
CEDA is known as CICS Execute Definition and Administration. It is used by CICS System Administrators
to define CICS table entries and other administration activities.
CEMT
CEMT is known as CICS Execute Master Terminal. It is used to inquire and update the status of CICS
environments and also for other system operations.
Using CEMT command, we can manage transactions, tasks, files, programs, etc.
To get all the possible options, type CEMT and press ENTER. It will display all the options.
CEMT is basically used for loading a new program into the CICS or for loading a new copy of the
program into the CICS after the program or mapset is changed.
Example
One can overwrite the status of the file displayed to change it. Following example shows how to close a file
−
CEMT
** Press ENTER & Following Screen is displayed **
CECI
CECI is known as CICS Execute Command Interpreter. Many CICS commands can be executed using
CECI.
CECI is used to check the syntax of the command. It executes the command, only if the syntax is
correct.
Type the CECI option on the empty CICS screen after having logged in. It gives you the list of
options available.
Example
Following example shows how to send mapped output data to terminal. We will be discussing about MAPS
in the upcoming modules.
CEDF
CEDF is known as CICS Execute Debug Facility. It is used for debugging the program step by step, which
helps in finding the errors.
Type CEDF and press enter in the CICS region. The terminal is in EDF mode message will be displayed.
Now type the transaction id and press the enter key. After initiation, with each enter key, a line is executed.
Before executing any CICS command, it shows the screen in which we can modify the values before
proceeding further.
CMAC
CMAC is known as CICS Messages for Abend Codes. It is used to find the explanation and reasons for
CICS Abend Codes.
Example
CMAC abend-code
CESF
CESF is known as CICS Execute Sign Off. It is used to Sign Off from the CICS region.
Example
Following example shows how to log off from the CICS region −
CESF LOGOFF
CEBR
CEBR is known as CICS Execute Temporary storage Browse. It is used to display contents of a temporary
storage queue or TSQ.
CEBR is used while debugging to check if the items of the queue are being written and retrieved properly.
We will discuss more about TSQ in the upcoming modules.
Example
CEBR queue-id
CICS Concepts
Each command could be achieved by executing a series of CICS macros. We will discuss some basic
features which will help us understand the concepts better −
Multitasking
This feature of operating system allows more than one task to be executed concurrently. The task may be
sharing the same program or using different programs. The CICS schedules the task in its own region.
Multi-threading
This feature of the operating system allows more than one task to be executed concurrently sharing the same
program. For multi-threading to be possible, an application program should be a re-entrant program under
the operating system or a quasi-reentrant under the CICS.
Re-entrancy
A re-entrant program is one which does not modify itself and can re-enter in itself and continue processing
after an interruption by the operating system.
Quasi-reentrancy
A quasi-reentrant program is a re-entrant program under CICS environment. CICS ensures re-entrancy by
acquiring a unique storage area for each task. Between CICS commands, the CICS has the exclusive right to
use the CPU resources and it can execute other CICS commands of other tasks.
There are times when many users are concurrently using the same program; this is what we call multi-
threading. For example, let’s suppose 50 users are using a program A. Here the CICS will provide 50
working storage for that program but one Procedure Division. And this technique is known as quasi-
reentrancy.
CICS – COBOL Basics
CICS programs are written in COBOL language in Mainframes. We will be discussing about writing a
simple COBOL-CICS program, compiling it, and then executing it.
CICS Program
We will be writing a simple COBOL-CICS program which displays some message on the CICS output
screen. This program is to demonstrate the steps involved in executing a COBOL-CICS program. Following
are the steps to code a simple program −
Step 1
Step 2
Step 3
Create a new member inside the PDS and code the following program −
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
01 WS-MESSAGE PIC X(40).
01 WS-LENGTH PIC S9(4) COMP.
PROCEDURE DIVISION.
A000-MAIN-PARA.
MOVE 'Hello World' TO WS-MESSAGE
MOVE '+12' TO WS-LENGTH
EXEC CICS SEND TEXT
FROM (WS-MESSAGE)
LENGHT(WS-LENGTH)
END-EXEC
EXEC CICS RETURN
END-EXEC.
Step 4
After coding the program, we need to compile it. We can compile the program using the following JCL −
Step 5
Open a CICS session.
Step 6
Step 7
Execute the program using the associated transaction-id. Transaction-id is provided by the Administrator. It
will show the following output −
Program Compilation
The following flowchart shows the steps used in compiling a COBOL-CICS program −
Translator
The function of a translator is to check for syntax errors in CICS commands. It translates them into
equivalent COBOL statements.
Compiler
The function of a compiler is to expand the COBOL copy books. It compiles the code after checking the
source code for syntax errors.
Linkage Editor
The function of a Linkage Editor is to link different object modules to create a single load module.
CICS – BMS
BMS is known as Basic Mapping Support. An application consists of formatted screens which act as a
bridge between the terminal and the CICS programs. For communication to occur between the terminal and
the CICS programs, we use CICS terminal input/output services. We use BMS to create screen designs with
proper positions and attributes. Following are the functions of BMS −
BMS acts as an interface between the terminal and the CICS programs.
The design and format of the screen is separate from the logic of application.
BMS makes the application hardware independent.
Formatted Screen
The screen shown below is a Menu Screen and can be designed using BMS. Its key points are as follows −
The screen could have a Title, date, and any other information that is to be displayed.
The Option 1, 2, and 3 are the Unnamed fields which are the titles of the screen.
In the Selection field, we need to provide the input. This input is then sent to the CICS program for
further processing.
At the bottom of the screen, Action keys are displayed.
All the fields and the screen itself is defined with BMS macros. When the whole map is defined, we
can use JCL to assemble it.
Map
Map is a single screen format which can be designed using BMS macros. It can have names containing 1 to
7 chars.
Mapset
Mapset is a collection of maps which are linked together to form a load module. It should have a PPT entry.
It can have names from 1 to 7 chars.
BMS Macros
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.
DFHMSD
DFHMSD macro generates Mapset definition. It is macro identifier which shows that we are starting a
mapset. The mapset name is the load module name and an entry in PPT table must be present. The following
table shows the list of parameters which can be used in DFHMSD −
4 If STORAGE =
AUTO – To acquire a separate symbolic map area for each mapset
BASE – To have the same storage base for the symbolic maps of from more than one mapset
CTRL
7 TIOAPFX = YES/NO
YES – To reserve the prefix space (12 bytes) for BMS commands to access TIOA properly. Required
for the CICS command level.
Example
The following example shows how to code a mapset definition −
DFHMDI
DFHMDI macro generates map definitions. It shows that we are starting a new map. Mapname is followed
by the DFHMDI macro. Mapname is used to send or receive maps. The following table shows the
parameters which we use inside a DFHMDI macro −
1 SIZE = (Line,Column)
This parameter gives the size of the map. BMS allows us to build a screen using several maps, and
this parameter becomes important when we are using more than one maps in a single mapset.
LINE
2
It indicates the starting line number of the map.
COLUMN
3
It indicates the starting column number of the map.
JUSTIFY
4
It is used to specify the entire map or the map fields to be left or right justified.
CTRL
TIOAPFX = YES/NO
6
YES – To reserve the prefix space (12 bytes) for BMS commands to access TIOA properly. Required
for the CICS command level.
Example
DFHMDF macro is used to define field names. The field name is mentioned against which DFHMDF macro
is coded. This field name is used inside the program. We do not write field name against constant field
which we do not want to use inside the program. The following table shows the list of parameters which can
be used inside a DFHMDF macro −
1 This is the position on the screen where the field should appear. A field starts with its attribute byte, 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
2
This is the length of the field, not counting the attribute byte.
INITIAL
3 This is the character data for an output field. We use this to specify labels and titles for the screen and
keep them independent of the program. For the first field in the menu screen, for example, we will
code: INITIAL = ‘MENU’.
JUSTIFY
4
It is used to specify the entire map or the map fields to be left or right justified.
ATTRB
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.
5 NUM – Numeric field. Only numbers (0 to 9) and special characters(‘.’ and ‘-‘) are allowed.
IC – Insert cursor. The cursor will be positioned in this field. In case, IC is specified more than once,
the cursor is placed in the last field.
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.
PICIN
6
PICIN applies to the data field which is used as input like PICIN = 9(8).
7 PICOUT
PICIN applies to the data field which is used as output like PICOUT = Z(8).
Example
Physical Map
Physical Map is a load module in the load library which contains information about how the map should be
displayed.
It contains the details about the attributes of all the fields in the map and their positions.
It contains the display format of the map for a given terminal.
It is coded using BMS macros. It is assembled separately and link edited into the CICS library.
Symbolic Map
A Symbolic Map is a Copy book in the library. The Copy book is used by the CICS application program to
send and receive data from the terminal.
It contains all the variable data which is copied into program’s WORKINGSTORAGE section.
It has all the named fields. The application programmer uses these fields to read and write data into
the map.
Skipper Field
If we place a skipper field after the named unprotected field, then while entering the value, once the
specified length is reached, the cursor will automatically position to the next unprotected field. The
following example shows how to add a skipper field −
Stopper Field
If we place a stopper field after the named unprotected field, then while entering the value, once the
specified length is reached, the cursor will stop its positioning. The following example shows how to add a
stopper field −
Attribute Byte
The attribute byte of any field stores information about the physical properties of the field. The following
diagram and the table explain the significance of each bit.
Bit Position Description Bit Settings
0&1 Determined by contents of bit 2 to 7
00 – Unprotected Alphanumeric
01 – Unprotected Numeric
2&3 Protection & Shift
10 – Protected Stop
11 – Protected Skip
00 – Normal
01 – Normal
4&5 Intensity
10 – Bright
11 – No-display ( Dark )
6 Must be Zero Always
0 – Field has not been modified
7 Modified Data Tag
1 – Field has been modified
MDT is a flag which holds a single bit. It specifies whether the value is to be transferred to the
system or not.
Its default value is 1, when the field value is changed.
If MDT is 0, then data cannot be transferred; and if MDT is 1, then data can be transferred.
Send Map
The send map command writes formatted output to the terminal. It is used to send the map to the terminal
from the application program. The following code segment shows how to send a map to the terminal −
The following table lists the parameters used in a send map command along with their significance.
5 It is the logical opposite of MAPONLY. We use it to modify the variable data in a display that has
already been created. Only the data from your program is sent to the screen. The constants in the map
are not sent.
ERASE
6
It causes the entire screen to be erased before what we are sending is shown.
ERASEUP
7
It causes only unprotected fields to be erased.
FRSET
8
Flag Reset turns off the modified data tag in the attribute byte for all the fields on the screen before
what you are sending is placed there.
CURSOR
9
It can be used to position the cursor on the terminal screen. Cursor can be set by moving -1 to the L
part of the field and then sending the map.
ALARM
10
It causes the audible alarm to be sounded.
FREEKB.
11
The keyboard is unlocked if we specify FREEKB in either the map or the SEND command.
PRINT
12
It allows the output of a SEND command to be printed on a printer.
FORMFEED
13
It causes the printer to restore the paper to the top of the next page before the output is printed.
Receive Map
When we want to receive input from a terminal, we use the RECEIVE MAP command. The MAP and
MAPSET parameters have exactly the same meaning as for the SEND MAP command. The following code
segment shows how to receive a map −
Mapset Execution
The following steps are necessary to develop and execute a mapset −
File I/O statements like Open, Read, Write, Rewrite, Close, Delete, and Start. All file I/O in CICS is
handled by the file control module and they have their own set of statements like READ, WRITE,
REWRITE, and DELETE which we will be discussing in the upcoming modules.
File Section and Environment Division is not required.
COBOL statements that invoke operating system functions like Accept, Date/Time cannot be used.
Do not use DISPLAY, MERGE, STOP RUN, and GO BACK.
The EIB is unique to a task and it exists for the duration of the task. It contains a set of system
related information corresponding to the task.
It contains information about transaction identifier, time, date, etc., which is used by the CICS during
the execution of an application program.
Every program that executes as a part of the task has access to the same EIB.
The data in EIB at runtime can be viewed by executing the program in CEDF mode.
EIB Fields
The following table provides a list of fields which are present in EIB −
Non-Conversational Programs
Conversational Programs
Pseudo-Conversational Programs – We will discuss in the next module
They are similar to batch programs that run in the batch mode. So in CICS, they are rarely
developed.
We can say they are used just for displaying a sequence of screens at regular intervals of time.
Example
The following example shows a non-conversational program which will simply display “HELLO WORLD”
on the CICS terminal as output −
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-MESSAGE PIC X(30).
PROCEDURE DIVISION.
********************************************************
* SENDING DATA TO SCREEN *
********************************************************
MOVE 'HELLO WORLD' TO WS-MESSAGE
EXEC CICS SEND TEXT
FROM (WS-MESSAGE)
END-EXEC
********************************************************
* TASK TERMINATES WITHOUT ANY INTERACTION FROM THE USER*
********************************************************
EXEC CICS RETURN
END-EXEC.
Conversational Program
Sending a message to the terminal and receiving a response from the user is called a Conversational. An
online application achieves a conversation between the user and the application program by a pair of SEND
and RECEIVE command. The key points of a Conversational program are as follows −
The system sends a message to the screen and waits for the user’s 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 user’s input and sends the output.
The program is loaded into the main storage at the beginning and is retained till the task ends.
Example
The following example shows a conversion program which takes input from the user and then simply
displays the same input on the CICS terminal as output −
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-MESSAGE PIC X(30) VALUE SPACES.
PROCEDURE DIVISION.
MOVE 'ENTER MESSAGE' TO WS-MESSAGE
********************************************************
* SENDING DATA FROM PROGRAM TO SCREEN *
********************************************************
EXEC CICS SEND TEXT
FROM (WS-MESSAGE)
END-EXEC
********************************************************
* GETTING INPUT FROM USER *
********************************************************
EXEC CICS RECEIVE
INTO(WS-MESSAGE)
END-EXEC
EXEC CICS SEND TEXT
FROM (WS-MESSAGE)
END-EXEC
********************************************************
* COMMAND TO TERMINATE THE TRANSACTION *
********************************************************
EXEC CICS RETURN
END-EXEC.
CICS – Pseudo Programming
As of now, we have covered non-conversion and conversion programs. Conversion programs have a major
drawback as their think time is considerably high. To overcome this problem, pseudo-conversion
programming came into the picture. We will now discuss more about pseudo-conversion programs.
Pseudo-Conversion Program
Following is the sequence of events which take place in a pseudo-conversion program −
Step 1 − The system sends a message to the screen and terminates the transaction, specifying the
transaction to be started when the user input is received.
Step 2 − The system allocates the resources used by this transaction to other transactions running in
the system. So we can utilize the resources in a pseudo-conversion program till the user gives the
input.
Step 3 − The system polls the terminal input at regular intervals of time. When the input is received,
it is processed and the output is displayed.
Step 4 − The application program is loaded into the main storage when needed and released when
not in use.
COMMAREA
COMMAREA is known as communication area. COMMAREA is used to pass data between tasks. The
following example shows how to pass COMMAREA where WSCOMMAREA and WS-COMMAREA-
LENGTH are declared in Working Storage Section −
DFHCOMMAREA
It is used to pass data from one program to another program. The programs can exist in the same
transaction or in different transaction also.
It is declared in the Linkage Section of the program at 01 level.
It should have the same picture clause as WS-COMMAREA.
Data can be moved back from DFHCOMMAREA to WS-COMMAREA using a MOVE statement.
Example
After sending the map, the task ends and waits for the user response. At this stage, the data needs to be
saved, because though the task has ended, the transaction has not. When this transaction is to be resumed, it
would require the prior status of the task. User enters the input. This now has to be received by the
RECEIVE MAP command and then validated. The following example shows how to declare COMMAREA
and DFHCOMMAREA −
WORKING-STORAGE SECTION.
01 WS-COMMAREA.
05 WS-DATA PIC X(10).
LINKAGE SECTION.
01 DFHCOMMAREA.
05 LK-DATA PIC X(10).
Pseudo Code
Given below is the logic of pseudo code which we use in pseudo programming −
Example
The following example shows a pseudo-conversion program −
******************************************************************
* PROGRAM TO DEMONSTRATE PSEUDO-CONVERSATION *
******************************************************************
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-MESSAGE PIC X(30).
01 WS-COMMAREA PIC X(10) VALUE SPACES.
LINKAGE SECTION.
01 DFHCOMMAREA PIC X(10).
PROCEDURE DIVISION.
MOVE DFHCOMMAREA TO WS-COMMAREA
IF WS-COMMAREA = SPACES
******************************************************************
* TRANSACTION GETTING EXECUTED FOR THE FIRST TIME *
******************************************************************
MOVE 'HELLO' TO WS-MESSAGE
EXEC CICS SEND TEXT
FROM (WS-MESSAGE)
END-EXEC
MOVE 'FIRST' TO WS-COMMAREA
******************************************************************
* TASK ENDS AS A RESULT OF RETURN. IF AID KEY PRESSED, NEXT *
* TRANSACTION SHOULD BE TP002. DATA PASSED FROM WS-COMMAREA TO *
* DFHCOMMAREA *
******************************************************************
EXEC CICS RETURN
TRANSID('TP002')
COMMAREA(WS-COMMAREA)
END-EXEC
******************************************************************
* IF COMMAREA IS NOT EMPTY , THEN TP002 HAS BEEN EXECUTED ONCE *
* ALREADY, USER INTERACTION IS FACILITATED BY RECEIVE *
******************************************************************
ELSE
EXEC CICS RECEIVE
INTO(WS-MESSAGE)
END-EXEC
EXEC CICS SEND TEXT
FROM (WS-MESSAGE)
END-EXEC
******************************************************************
* TASK ENDS AS A RESULT OF RETURN, NO NEXT TRANSACTION SPECIFIED *
* TO BE EXECUTED *
******************************************************************
EXEC CICS RETURN
END-EXEC
END-IF.
The resources are best utilized. Resources are released as soon as the program is suspended
temporarily.
It looks as if it is in conversational mode.
It has better response time.
Return Statements
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.
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.
EIBAID is one byte long and holds the actual attention identifier value used in the 3270 input stream.
CICS provides us with a pre-coded set of variables which can be used in the application program by
writing the following statement −COPY DFHAID
DFHAID
DFHAID is a copybook which is used in application programs to include CICS pre-coded set of variables.
The following content is present in the DFHAID copybook −
01 DFHAID.
02 DFHNULL PIC X VALUE IS ' '.
02 DFHENTER PIC X VALUE IS ''''.
02 DFHCLEAR PIC X VALUE IS '_'.
02 DFHCLRP 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'.
02 DFHPF16 PIC X VALUE IS 'D'.
02 DFHPF17 PIC X VALUE IS 'E'.
02 DFHPF18 PIC X VALUE IS 'F'.
02 DFHPF19 PIC X VALUE IS 'G'.
02 DFHPF20 PIC X VALUE IS 'H'.
02 DFHPF21 PIC X VALUE IS 'I'.
02 DFHPF22 PIC X VALUE IS '¢'.
02 DFHPF23 PIC X VALUE IS '.'.
02 DFHPF24 PIC X VALUE IS '<'.
Example
The following example shows how to use DFHAID copybook in an application program −
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
DATA DIVISION.
WORKING-STORAGE SECTION.
COPY DFHAID.
PROCEDURE DIVISION.
A000-AIDKEY-PARA.
EVALUATE EIBAID
WHEN DFHAID
PERFORM A000-PROCES-PARA
WHEN DFHPF1
PERFORM A001-HELP-PARA
WHEN DFHPF3
PERFORM A001-EXIT-PARA
END-EVALUATE.
Cursor Positioning
There are two ways to override the position specified in the map definition.
One way is to specify the screen position relative to line and column number in the CURSOR option
on the send map command.
Other way is to move -1 to the symbolic map variable suffixed with L. Then, send the map with a
CURSOR option in the SEND MAP.
Example
The following example shows how to override the cursor position for the NAME field −
MOVE -1 TO NAMEL
EXEC CICS SEND
MAP ('map-name')
MAPSET ('name-field')
ERASE
FREEKB
CURSOR
END-EXEC.
To override the attributes of a field, we must include DFHATTR in the application program. It is
provided by CICS.
The attribute required can be chosen from the list and moved to the symbolic field variable suffixed
with ‘A’.
01 CICS-ATTRIBUTES.
05 ATTR-UXN PIC X(01) VALUE SPACE.
05 ATTR-UXMN PIC X(01) VALUE 'A'.
05 ATTR-UXNL PIC X(01) VALUE 'D'.
05 ATTR-UXMNL PIC X(01) VALUE 'E'.
05 ATTR-UXBL PIC X(01) VALUE 'H'.
05 ATTR-UXMBL PIC X(01) VALUE 'I'.
05 ATTR-UXD PIC X(01) VALUE '<'.
05 ATTR-UXMD PIC X(01) VALUE '('.
05 ATTR-U9N PIC X(01) VALUE '&'.
05 ATTR-U9MN PIC X(01) VALUE 'J'.
05 ATTR-U9NL PIC X(01) VALUE 'M'.
05 ATTR-U9MNL PIC X(01) VALUE 'N'.
05 ATTR-U9BL PIC X(01) VALUE 'Q'.
05 ATTR-U9MBL PIC X(01) VALUE 'R'.
05 ATTR-U9D PIC X(01) VALUE '*'.
05 ATTR-U9MD PIC X(01) VALUE ')'.
05 ATTR-PXN PIC X(01) VALUE '-'.
05 ATTR-PXMN PIC X(01) VALUE '/'.
05 ATTR-PXNL PIC X(01) VALUE 'U'.
05 ATTR-PXMNL PIC X(01) VALUE 'V'.
05 ATTR-PXBL PIC X(01) VALUE 'Y'.
05 ATTR-PXMBL PIC X(01) VALUE 'Z'.
05 ATTR-PXD PIC X(01) VALUE '%'.
05 ATTR-PSN PIC X(01) VALUE '0'.
05 ATTR-PSMN PIC X(01) VALUE '1'.
05 ATTR-PSNL PIC X(01) VALUE '4'.
05 ATTR-PSMNL PIC X(01) VALUE '5'.
05 ATTR-PSBL PIC X(01) VALUE '8'.
05 ATTR-PSMBL PIC X(01) VALUE '9'.
05 ATTR-PSD PIC X(01) VALUE '@'.
05 ATTR-PSMD PIC X(01) VALUE "'".
CICS – File Handling
CICS allows us to access file data in many ways. Most file accesses are random in online system as the
transactions to be processed are not batched and sorted into any kind of order. Therefore CICS supports the
usual direct access methods − VSAM and DAM (Direct Access Method). It also allows us to access data
using database managers.
CICS – Error Handling
There are many types of abends and errors which one can face while using a CICS application. Errors can
arise due to both hardware of software issues. We will be discussing about errors and error handling in this
module.
CICS Errors
Following are the CICS errors which can arise during the execution of CICS applications −
Some expected CICS errors arise when the conditions are not normal in the CICS system. For
example, if we are reading a particular record and the record is not found, then we get the “Not
Found” error. Mapfail is a similar error. Errors in this category are handled by explicit logic in the
program.
Logical errors arise due to some reasons like division by zero, illegal character in numeric field, or
transaction id error.
Errors that are related to hardware or other system conditions are beyond the control of an
application program. For example, getting input/output error while accessing a file.
CICS – Control Operations
CICS Program Control Program (PCP) manages the flow of application programs. All the application
programs must have an entry in the Processing Program Table. Following are the commands which are used
for program control services −
XCTL
Link
Load
Release
Return
XCTL
The fundamental explanation of XCTL is as follows −
XCTL command is used to pass the control from one program to another at the same level.
It does not expect the control back.
It is similar to GO TO statement.
An XCTL program can be a pseudo-conversational.
Example
The following example shows how to use XCTL command to pass the control to another program −
IDENTIFICATION DIVISION.
PROGRAM-ID. PROG1.
WORKING-STORAGE SECTION.
01 WS-COMMAREA PIC X(100).
PROCEDURE DIVISION.
This command transfers the control to be passed to program ‘PROG2’ with 100 bytes of data.
COMMAREA is an optional parameter and is the name of the area containing the data to be passed or the
area to which results are to be returned.
Link
Link command is used to transfer the control to another program at lower level. It expects the control back.
A Linked program cannot be pseudo-conversational.
Example
The following example shows how to use Link command to pass the control to another program −
IDENTIFICATION DIVISION.
PROGRAM-ID. PROG1.
WORKING-STORAGE SECTION.
01 WS-COMMAREA PIC X(100).
PROCEDURE DIVISION.
Load
Load command is used to load a program or a table. Following is the syntax of Load command −
Release
Release command is used to release a program or a table. Following is the syntax of Release command −
Return
Return command is used to return the control to the next higher logical level. Following is the syntax of
Return command −
ASKTIME
ASKTIME is used to request for current time and date or timestamp. We then move this value to the
working storage variable inside the program. Following is the syntax of ASKTIME command −
FORMATTIME
FORMATTIME formats the timestamp into the required format based on the options, which can be
YYDDD, YYMMDD, or YYDDMM for date. DATESEP indicates the separator for the DATE as does the
TIMESEP variable for TIME. Following is the syntax of FORMATTIME command −
COMMAREA
The COMMAREA behaves like a scratch pad that can be used to pass data from one program to another
program, either within the same transaction or from different transactions. It should be defined in the
LINKAGE SECTION using DFHCOMMAREA name.
A TSQ is a queue of records that can be created, read and deleted by different tasks or programs in
the same CICS region.
A queue identifier is used to identify TSQ.
A record within a TSQ is identified by the relative position known as the item number.
The records in TSQ, remains accessible until the entire TSQ is explicitly deleted.
The records in TSQ can be read sequentially or directly.
TSQs may be written in the main storage or the auxiliary storage in the DASD.
WRITEQ TS
This command is used to add items to an existing TSQ. Also, we can create a new TSQ using this command.
Following is the syntax of WRITEQ TS command −
Syntax
EXEC CICS WRITEQ TS
QUEUE ('queue-name')
FROM (queue-record)
[LENGTH (queue-record-length)]
[ITEM (item-number)]
[REWRITE]
[MAIN /AUXILIARY]
END-EXEC.
Following are the details of parameters used in the WRITEQ TS command −
READQ TS
This command is used read the Temporary Storage Queue. Following is the syntax of READQ TS −
Syntax
EXEC CICS READQ TS
QUEUE ('queue-name')
INTO (queue-record)
[LENGTH (queue-record-length)]
[ITEM (item-number)]
[NEXT]
END-EXEC.
DELETEQ TS
This command is used delete the Temporary Storage Queue. Following is the syntax of DELETEQ TS −
Syntax
EXEC CICS DELETEQ TS
QUEUE ('queue-name')
END-EXEC.
The contents of the queue can be read only once as it gets destroyed once a read is performed and
hence the name Transient.
It cannot be updated.
It requires an entry in DCT.
WRITEQ TD
This command is used to write Transient data queues and they are always written to a file. Following is the
syntax of WRITEQ TD command −
Syntax
EXEC CICS WRITEQ TD
QUEUE ('queue-name')
FROM (queue-record)
[LENGTH (queue-record-length)]
END-EXEC.
READQ TD
This command is used read the Transient data queue. Following is the syntax of READQ TD −
Syntax
EXEC CICS READQ TD
QUEUE ('queue-name')
INTO (queue-record)
[LENGTH (queue-record-length)]
END-EXEC.
DELETEQ TD
This command is used delete the Transient data queue. Following is the syntax of DELETEQ TD −
Syntax
EXEC CICS DELETEQ TD
QUEUE ('queue-name')
END-EXEC.
CICS – Intercommunication
The mutual communication that takes place between two or more systems is known
as intercommunication.
Benefits of Intercommunication
The important benefits of intercommunication are as follows −
Basic Terminologies
One must have a knowledge of basic terminologies used in the CICS system. Following are the basic terms
−
Local System
Local Resource
Remote System
Remote Resource
MVS Sysplex
MVS Sysplex is a configuration of multiple MVS operating systems. They work as a single system by
sharing functions and programs.
CICSPlex
CICSPlex is commonly described as a set of interconnected CICS regions that process customer workload.
A CICSPlex is a set of interconnected CICS regions that own Terminals, Applications, Resources, etc.
Intercommunication Methods
There are two ways in which CICS can communicate with other systems −
MRO − Multi Region Operation is used when two CICS regions within the same MVSPLEX needs
to communicate with each other.
ISC − Inter System Communication is used when a CICS region in a LOCAL server has to
communicate with a CICS region in the REMOTE server.
CICS – Status Codes
While working with CICS, you may encounter abends. Following are the common abend codes with their
description which will help you to resolve the issues −
ASRA
1
Program Check Exception
AEI0
2
Program ID Error
AEI9
3
Map Fail condition
AEIO
4
Duplicate Key
AEIN
5
Duplicate Record
AEID
6
End of file reached
AEIS
7
File is not open
AEIP
8
Invalid request condition
AEY7
9
Not authorized to use the resource
APCT
10
Program not found
AFCA
11
Dataset not found
AKCT
12
Time out error
ABM0
13
Specified map not found
AICA
14
Program in infinite loop
15 AAOW
Internal logic error
CICS – Interview Questions
These CICS Interview Questions have been designed especially to get you acquainted with the nature of
questions you may encounter during your interview for the subject of CICS. As per our experience, good
interviewers hardly plan to ask any particular question during an interview – normally questions start with
some basic concept of the subject and later, they continue based on further discussion and how you answer −
What’s the CICS command used to access the current date and time?
For Skipper field, use ASKIP and for stopper field use PROT.
How do you set the MDT option to ‘ON’ status, even if data is not entered?
Mention FSET option in DFHMDF or set it dynamically in the program using FIELD+A attribute field.
Which CICS service transaction is used to gain accessibility to CICS control tables?
What is a mapset?
Mapset is a collection of maps which are linked edited together to form a load module. It should have a PPT
entry. It can have names from 1 to 7 chars.
The CICS translator converts the EXEC CICS commands into call statements for a specific programming
language.
What are the differences between an EXEC CICS XCTL and an EXEC CICS LINK command?
The XCTL command transfers the control to an application program at the same logical level and it does not
expect the control back, while the LINK command passes the control to an application program at the next
logical level and expects the control back.
The EIBRCODE tells the application program if the last CICS command was executed successfully or not.
What is the effect of including the TRANSID in the EXEC CICS RETURN command?
The next time the end-user presses an attention key, CICS will start the transaction specified in the
TRANSID option.
To specify the paragraph or program label to which the control is to be passed if the “handle condition”
occurs.
What is the difference between the INTO and the SET option in the EXEC CICS RECEIVE MAP command?
The INTO option moves the information in the TIOA into the reserved specified area, while the SET option
simply returns the address of the TIOA to the specified BLL cell or “address-of” a linkage section.
What is the difference between getting the system time with EIBTIME and ASKTIME command?
The ASKTIME command is used to request the current date and time. Whereas, the EIBTIME field ha the
value at the task initiation time.
The TCT defines the characteristics of each terminal with which CICS can communicate.
What is a deadlock?
A deadlock occurs when a task is waiting for a resource held by another task which, in turn, is waiting for a
resources held by the first task.
MRO is the mechanism by which different CICS address spaces with in the same CPU can communicate
and share resources.
A program is considered reentrant if more than one task can execute the code without interfering with the
other tasks execution.
The common work area is a storage area that can be accessed by any task in a CICS system.
What is the meaning and use of the EIBAID field?
EIBAID is a key field in the execute interface block; it indicates which attention key the user pressed to
initiate the task.
What is BMS?
BMS stands for Basic Map Support. It allows you to code assembler level programs to define screens.
What is Next?
Further, you can go through the examples which you have practiced with the subject and make sure you are
able to speak confidently on them. If you are a fresher, then the interviewer does not expect you to answer
very complex questions. Hence you should have a strong hold over the fundamental concepts of the subject.