CICS So Far
CICS So Far
• CICS is and OLTP system designed to control information in an online environment by providing database and
data communication functions.
• CICS provides an interface between application programs and operating system services, such as data access
and communication access.
• On a mainframe, CICS runs under an operating system like MVS or OS/390 or z/OS. Although CICS runs as a
batch job, it can handle hundreds of interactive users that are using a variety of applications.
CICS Interface
CICS Services
• Telecommunication
• Multitasking
• Multithreading
• Inter-system Communication
Non-Conversational Transaction
• In a non-conversational transaction the requirement is immediate and only infrequently requires further
follow-up
• A conversational transaction is an online transaction that sits idle while it waits for the user input
• In a conversational program, the initial map is sent to the terminal first and it waits for the user input. It
retrieves the input data from the terminal, processes the data and sends its output to the terminal and waits
again.
• While the conversational program waits for the user’s input, the task associated with that program remains in
storage. Because of that, conversational programs are inefficient in terms of virtual storage usage.
• Not ideal in a computing world where it makes unusual demands on the resources
Conversational Transaction - Illustration
Conversational Transaction - Processing
Pseudo-Conversational Transaction
• Achieved by relinquishing the control of computer resources till the terminal user responds back
• In pseudo-conversational programming, a program ends after it sends data to the terminal. This releases some
of the resources that are used by the program. Then, CICS restarts the program when the user completes an
entry and presses one of the terminal’s attention identifier (AID) keys.
• For 3270 terminal usage, CICS provides both presentation logic and business logic
• CICS can also be used with other types of user interfaces where in the front-end program provides the
presentation logic and CICS provides the business logic
Application, Transaction and Task
• Application – An application is a collection of programs which accomplishes some specific user work
• A Logical Unit of Work (LUW) is a piece of work like file update, database update which when done, is fully
done or not done at all
• It starts when the first CICS command is executed in the present task and ends when a SNYCPOINT (with or
without rollback) is executed
• If a SYNCPOINT is not issued in the program, then at the end of the task, CICS issues an auto SYNCPOINT on
successful completion and a ROLLBACK on an abend
Transaction internals in CICS
Task Control Used to control the execution of a task. Provides for temporarily suspending a task that is monopolizing CICS
resources or gaining exclusive control of a CICS resource.
Dump Control Provides a transaction dump when a fatal error is encountered during the execution of an application program. The
dump can then be used to help debug the program.
Trace Control Maintains a trace table that indicates the sequence of CICS operations performed. This table can be used to help
debug a program.
Journal Control Creates a record or journal that can be used to restore files in the event of a task or system failure.
Transient Data Control Provides a convenient way to use sequential files called destinations to store data. Records written to a destination
are added to the end of the destination. Records are read sequentially from a destination and then deleted.
Multitasking in CICS
• Multitasking means that CICS allows more than one task to be executed at the same time
• Although all of the operating systems that support CICS are capable of multitasking on their own, CICS
provides multitasking within the single address space provided by the operating system.
Multithreading in CICS
• Basic Mapping Support (BMS) provides an interface between terminals and application programs
• BMS provides for device independence. It inquires the target device and converts the data stream appropriately
• An attribute byte is an extra 1 byte for each field that stores information about the physical properties of the field
Protected
Unprotected
Dark
Bright
Numeric
Askip
Modified Data Tag
Basic Mapping Support (BMS) – Attribute Bytes
Basic Mapping Support (BMS) – Attribute Bytes
Example – 1
Example – 2
Basic Mapping Support (BMS) – Attribute Bytes
• In addition to the field attributes some 3270 terminals have extended attributes as well like extended colors (blue,
pink, etc.) , extended highlighting (flashing, underscoring, etc.) and so on.
Basic Mapping Support (BMS) – Macros
Format – 1
Format – 2
Basic Mapping Support (BMS) – DFHMSD keywords
Keyword Description
TYPE=&SYSPARM|DSECT|MAP|FINAL MAP generates only a physical map
DESCT generates only a symbolic map
&SYSPARM generates both physical and symbolic maps
FINAL ends a mapset
LANG=COBOL|ASM|PLI|C Specifies in what language the symbolic map to be generated
MODE=INOUT|IN|OUT IN – map is used only for input
OUT – map is used only for output
INOUT – map is used for both input and output
TERM=termtype Termtype specifies the terminal type
TIOAPFX=YES|NO YES – filler is included in the symbolic map
NO – filler is not included in the symbolic map
STORAGE=AUTO|BASE=dataname AUTO – separate memory is acquired for each symbolic map in the mapset
BASE – same memory area is used for each symbolic map
Basic Mapping Support (BMS) – DFHMSD keywords
Keyword Description
CTRL=([FREEKB][ALARM][FRSET][PRINT][,length] FREEKB – unlock a keyboard after a SEND command
ALARM – terminal alarm is to sound when a map is sent
FRSET – prior to SEND MAP instruction, the MDT attribute
flags at the terminal are to be reset
PRINT – mapset to be sent to the printer
Length – line length on the printer
Basic Mapping Support (BMS) – DFHMDI
Keyword Description
SIZE=(line,column) Specifies how much screen is to be covered – the number of rows and columns
LINE=number Line number where the map starts
COLUMN=number Column number where the map starts
Basic Mapping Support (BMS) – DFHMDF
If we place a skipper field after the named If we place a stopper field after the named
unprotected field, then while entering the value, unprotected field, then while entering the value,
once the specified length is reached, the cursor once the specified length is reached, the cursor
will automatically position to the next unprotected will stop its positioning
field
NUM DFHMDF POS=(10,10), X
NUM DFHMDF POS=(10,10), X LENGTH=5, X
LENGTH=5, X ATTRB=(UNRPOT)
ATTRB=(UNRPOT) DFHMDF POS=(10,17), X
DFHMDF POS=(10,17), X LENGTH=1, X
LENGTH=1, X ATTRB=(PROT)
ATTRB=(AKSIP)
DFHBMSCA
• CICS provides the standard attribute character list in the form of a copy library member named DFHBMSCA
• The list covers the most required attribute characters for an application program
• The list can be used by copying DFHBMSCA into the WORKING-STORAGE SECTION of the application program through
the COPY statement.
WORKING-STORAGE SECTION.
...
COPY DFHBMSCA.
DFHBMSCA – Example
• If the selection field name is SELECTM, then executing the below statement before sending the map to the
terminal, would make the field unprotected bright and also sets the MDT tag off.
MOVE DFHBMBRY TO SELECTMA
The SEND MAP command
• The SEND MAP command sends a map to the terminal
• It sends mapped data to the terminal through application program
The SEND MAP command
Keyword Description
MAP(mapname) Specifies the name of the map to be sent to the terminal. This can be either a literal or a
dataname containing the literal.
MAPSET(mapsetname) Specifies the name of the mapset. It can be a literal or a dataname containing the literal.
FROM(dataname) Specifies the 01-level dataname from the symbolic map. Not to be used if MAPONLY is
specified.
LENGTH(value) Specifies the length of the data area that is to be formatted. It should not exceed the
length of the FROM data area.
DATAONLY Specifies only application program data to be written
MAPONLY Specifies only default map data to be written to the screen. It does not add any data from
the application program to the screen if MAPONLY is specified.
CURSOR(value) Specifies the cursor position in the map when SEND MAP is executed. If no value is
specified, then the cursor will be positioned at the first unprotected field of the map.
FREEKB Specifies that the keyboard is to be unlocked when the map is sent to the terminal
The SEND MAP command
Keyword Description
ALARM Specifies the alarm on the terminal to be activated when sending the map
FRSET Specifies to reset all the Modified Data Tags (MDT) of all current map fields in the terminal
buffer
ERASE Specifies to erase the screen buffer and print buffer before sending the map to the screen
ERASEAUP Erases all the unprotected fields on the screen before sending the map to the screen
HANDLE This is default. CICS will apply it if this is not specified.
NOHANDLE NOHANDLE indicates to CICS that all condition codes are to be ignored by CICS letting the
application handle them. NOHANDLE on a CICS command should include the additional
keyword RESP(dataname).
RESP(dataname) RESP indicates that CICS should place the condition code (the response code) in a COBOL data
area. These two keywords can be used with any CICS command. RESP must point to a full-
word data item PIC S9(8) COMP.
SEND MAP – Logical Steps
1. CICS constructs the data stream using MAP. Data fields containing LOW-VALUES are not included
2. Attribute bytes from the symbolic map replace those in the map if the attribute byte fields in symbolic map
are not LOW-VALUES
3. The first length field in the symbolic map that has -1 as its value becomes the cursor position, overriding any
specified in the MAP.
4. Using options in the SEND MAP command, the data stream is sent to the terminal
SEND MAP – Examples
EXEC CICS SEND MAP(‘ERC1502’)
MAPSET(‘ERC1500’) • Sends both physical and symbolic map
FROM(ERC1502I) • Erases the screen before before displaying map on the
ERASE screen
CURSOR • Places the cursor on the first field whose length field is -1
END-EXEC
Keyword Description
MAP(mapname) Specifies the map name that is used to identify the map
MAPSET(mapsetname) Specifies the mapset name
INTO(dataname) Specifies the data area where the data received from the screen needs to be written
SET(ptr-ref) Specifies the pointer reference to the map data stored in the memory location
ASIS Specifies lowercase data in the input is not converted to uppercase
RECEIVE MAP – Logical Steps
1. CICS receives the terminal input when the user presses an AID key.
2. CICS updates the EIB (Executive Information Block) and then initiates the transaction identified for this
terminal from the previous RETURN TRANSID command
3. When the application issues a RECEIVE MAP command, CICS formats the data into the symbolic map
identified in the RECEIVE command
RECEIVE MAP – Examples
• Execute Interface Block (EIB) is a CICS area that contains information related to the current task
• There is one EIB for each task and it exists for the duration of that task
• Every program that executes as part of the task has access to the same EIB
• The fields of EIB can be addressed directly in a COBOL program
• The fields in EIB should only be read and not try to modify them
Execute Interface Block (EIB) - DFHEIBLK
Keyword Description
EIBAID Attention identifier that tells which keyboard key was used to transmit the last input
EIBCALEN Length of the communication area (COMMAREA)
EIBCPOSN Position of the cursor at the time of the last input command. Expressed as single number
relative to the position 0 on the screen.
EIBDATE The date on which the current task started
EIBTIME The time at which the current task started
EIBTASKN The task number that is a 7-digit packed decimal number. CICS assigns a sequential
number to each task it executes.
EIBTRMID The name of the terminal associated with the task. This name is 4 characters long.
EIBTRNID The transaction identifier of the current task. This is 4 characters long.
Execute Interface Block (EIB) – EIBAID and DFHAID
• EIBAID is one byte long and holds the actual identifier value used in the 3270 input stream.
• DFHAID is a copybook that is used in the application programs to include CICS pre-coded set of variables
SEND CONTROL
• CICS SEND CONTROL is a terminal output command
• It sends control information to the terminal without sending any data
Positioning the cursor
• Static Cursor Positioning
ITEMNO DFHMDF POS=(6,15)
Achieved by setting the attribute option IC in LENGTH=8
the DFHMDF macro definition for that field ATTRB=(UNPROT,FSET,IC)
….
MOVE -1 TO EMPNOL.
• Dynamic/Symbolic Cursor Positioning EXEC CICS SEND MAP(‘EMPMAP1’)
MAPSET(‘EMPSET1’)
Move -1 to the corresponding length field in
FROM(EMPMAP1I)
the symbolic map to inform CICS to position CURSOR
the cursor at that field END-EXEC.
Map related errors
Error Description
MAPFAIL MAPFAIL occurs if the data mapped is of length zero. On a RECEIVE MAP command when there is no data
to be transferred to your program from the screen, this error occurs.
INVMPSZ Stands for Invalid Map Size. The error occurs in the below two scenarios:
MAP is too wide for the terminal
MAP is too long for the terminal
INVREQ This error occurs in below scenarios depending on the RECEIVE MAP conditions
1. RECEIVE MAP command issued in task which is not related to the terminal
2. Remotely linked program tries to execute RECEIVE MAP command
LENGERR This error occurs when the LENGTH option is zero or negative in a SEND MAP
CICS Application Programming
• Reentrant Program
A program is said to be reentrant if it does not modify itself and can reenter in itself and resume
processing after an interruption
• Quasi-Reentrant Program
A quasi-reentrant program is a reentrant program under CICS environment. CICS ensures reentrancy 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.
CICS Application Programming
Passing data between transactions
Keyword Description
TRANSID The next transaction id to be executed at the terminal
COMMAREA The communication area which is to be made available to the invoking program. In the invoking
program the data area is in DFHCOMMAREA of the LINKAGE SECTION.
LENGTH The length of the COMMAREA in bytes
CICS RETURN
Source Program
Translated
Source Program
PRECOMPILE Listing
Load Module