Sei sulla pagina 1di 102

CICS Training Material

_______________________________________________________________________________

Table of Contents

1. INTRODUCTION TO CICS..........................................................................3
1.1. Objectives..........................................................................................................3
1.2. Application Systems ..........................................................................................3
1.3. Comparison of BATCH & ONLINE Systems..........................................................4
1.4. CICS Introduction................................................................................................4
4
1.5. CICS Terminolgy ................................................................................................4
1.6. Features of CICS................................................................................................6
1.7. CICS System Components..................................................................................8
1.8. CICS Control Programs And Tables ....................................................................8
1.9. Sign ON And Sign OFF......................................................................................11
2. CICS APPLICATION PROGRAMMING.......................................................12
2.1. Objectives........................................................................................................12
2.2. Structure Of a CICS Application Program.........................................................12
2.3. Termination Statements...................................................................................13
Commands for a Small Program..............................................................................13
2.5. Execption Conditions.......................................................................................17
..............................................................................................................19
2.6. Sample Program(s)..........................................................................................19
2.7. Program Preparation........................................................................................22
2.8. DB2 Precompiler...............................................................................................23
2.9. Translator.........................................................................................................23
2.10. CICS Transactions ..........................................................................................23
2.11. Exercise..........................................................................................................26
26
3. MAPS AND DISPLAYS.............................................................................27
3.1. Objectives........................................................................................................27
3.2. Introduction to BMS..........................................................................................27
3.3. Screen Layout Documentation.........................................................................28
3.4. Physical MAP ..................................................................................................28
3.5. Symbolic Map ..................................................................................................33
3.6. Sending a Map to the Screen..........................................................................36
3.7. Extended Attributes.........................................................................................37
3.8. Cursor Positioning ............................................................................................37
3.9. SEND CONTROL command ...............................................................................38
3.10. Common CICS Program Declarations.............................................................38
3.11. Receiving a Map from the Screen..................................................................39
3.12. Ending a CICS Transaction (RETURN Command)............................................42
3.13. Multipage message with Single Panel............................................................42
3.14. Pseudo Conversational Applications..............................................................45
3.15. Structure of a sample Application Program....................................................47
3.16. Exercise..........................................................................................................49
3.17. Passing control to other programs.................................................................50
4. FILE HANDLING ...................................................................................53
4.1. Introduction......................................................................................................53
53
4.2. VSAM Datasets.................................................................................................54
4.3. Exercise...........................................................................................................69
4.4. DB2 Database.................................................................................................71
4.5 PRECOMPILATION..............................................................................................81

_______________________________________________________________________________
CICS Training Material Revision 2.0
1
CICS Training Material
_______________________________________________________________________________
5. CICS QUEUEING FACILITIES...................................................................85
5.1. Objectives........................................................................................................85
5.2. CICS Queueing Facilities...................................................................................85
5.3. Transient DATA QUEUE (TDQ)..........................................................................85
5.4. Temporaty Storage Queue(TSQ)......................................................................89
APPENDIX..................................................................................................93
A. COMMON ABEND CODES.....................................................................................93
B. JCL ......................................................................................................................95

_______________________________________________________________________________
CICS Training Material Revision 2.0
2
CICS Training Material
_______________________________________________________________________________

1. INTRODUCTION TO CICS

1.1. Objectives
• Application Systems
• Batch & Online
• CICS Introduction
• CICS System Terminology and Concept
• CICS Control Programs & Tables
• CICS Sign on and Sign off process

1.2. Application Systems


There are two types of computer application systems. They are Batch application system
and Online application system. BATCH processing allows a user to submit the job to run in
the background, without the job waiting for any interaction with the user whereas ONLINE
processing allows a user to interact with a computer and access its resources via a
terminal. The batch application system has system environment where jobs will run one by
one in conventional way, whereas the Online system has a system environmnent where
many transactions run concurrently.

Examples for Online Systems are: Railway Reservation System, Hotel Room Booking etc.
Examples for Batch Systems are: Monthly Reports like Payslips and other Statements.

_______________________________________________________________________________
CICS Training Material Revision 2.0
3
CICS Training Material
_______________________________________________________________________________

1.3. Comparison of BATCH & ONLINE Systems

Batch System Online System

Input Data from card, tape, disk Data from terminal


Batch, sequential, scheduled Random, concurrent
Start of job Operator (or operating system) Once CICS is initialised, entering the
initiates the job. Other jobs in the transaction id triggers the transaction
same region must wait to start.
Processing Single task singlethread Multitask multithread.
Priority in job scheduling Priority processing
End of job Each Job Each transaction. Once CICS is terminated,
no transactions can be entered.
Output Printed reports, output files. User Messages to terminals, User updated files,
system must wait for batch jobs to log. Reports printed in printers.
produce Instant feedback reports
(daily, weekly, monthly)
Turnaround Usually much longer Usually almost instantly
Resource Less More
Example Monthly Sales Report Airline Reservation System

1.4. CICS Introduction

Customer Information Control System (CICS) was developed in 1960 by IBM. It is an


Online Control System, and a General Purpose Data Communication System.
This runs as a subsystem on IBM mainframes.
It provides an environment to handle all the special requirements of online processing.
CICS acts as an interface between the operating system and the database products

1.5. CICS Terminolgy


1.5.1. Task

A basic unit of work, which is scheduled by Operating system is called Task. CICS
as a whole is one of many tasks under OS (Other tasks: TSO, Batch jobs etc.)
Similar to OS, CICS schedules a unit of work within CICS region. This is called a
CICS task which is a unit of work scheduled by CICS. Multiple terminals may invoke
the same task.

_______________________________________________________________________________
CICS Training Material Revision 2.0
4
CICS Training Material
_______________________________________________________________________________

1.5.2. Transaction

Transaction is an entity, which initiates execution of a task. Under CICS, a CICS


transaction is a CICS task which is initiated thru a transaction identifier(1 to 4
characters) .This transaction identifier must be registered in the Program control
Table (PCT).

A CICS transaction can create more than one task concurrently if the same
transaction is initiated more than once .We can also say a transaction is an
exchange between a terminal and a database representing an application process.
For example, an enquiry, or a deposit and balance update. Using transaction
identifier, we can execute a task under CICS region.

1.5.3. Program

These are prepared set of statements compiled or assembled into an executable


module of machine instructions. Under OS, CICS is a set of programs, which
achieve some units of work. Under CICS, an application program is a set of
instructions to perform some units of work. Many programs may be called from a
single transaction, and many transactions may be associated with the same
program.

1.5.4. Terminal Oriented Task

A task invoked by a terminal. The terminal, which invokes a task remains associated
with that task so that when the program sends data, it will go to the invoking
terminal, is called divert terminal.

1.5.5. EXEC IINTERFACE BLOCK (EIB)

CICS automatically provides some system related information to each task in the form of
EIB, which is unique to CICS command level.

CICS automatically updates certain fields of this block when a task is initiated and after
each command is executed. The application program can access these fields when
required.

1.5.6. Conversational transaction

♦ Program uses a pair of SEND (for sending messages to the terminal) and
RECEIVE (for receiving input from termincal) commands.

♦ Task waits until the user responds.


♦ Resources are held until the user responds. Since human response is slower
than the CPU speed, a significant amount of resources will be wasted hence a
very inefficient way of conversing with the user.

_______________________________________________________________________________
CICS Training Material Revision 2.0
5
CICS Training Material
_______________________________________________________________________________

1.5.7. Non Conversational transaction

• The non-conversation mode does not involve any conversation with the
terminal user. Usually the transaction in this mode is a one-way
transaction for output only.
• Mainly used for report printing or message switching.

1.5.8. Pseudo conversational transaction

• The task is terminated after a message is sent, with a linkage to the next task.
All resources associated with the task, including the storage, are released.
• When the user completes his/her response (by pressing ENTER or PF key),
the next task is automatically initiated by CICS.
• The task receives data from the terminal and processes it.
• This is a multitask operation from the system’s point of view. As the resources
are freed while waiting for user’s response, this is more efficient.
• Although the task ended the transaction is not complete. Before the first end it
must save necessary information for the second task. A task normally ends
when the first program issues the return command.

1.5.9. CICS REGION

JCL is not required to run a CICS application program. . CICS itself is a job
executed through JCL like other batch jobs. Once the CICS job starts, this job is
considered as one CICS region, under which more than one application
transaction (or programs) can be executed concurrently.

1.5.10. MRO

Multi Region Operation is communication between a CICS system and other CICS
system in the same processor.

1.6. Features of CICS


• MULTI TASKING -More than one task can be executed concurrently
regardless of whether the task uses the same program or different. CICS
provides multitasking environment where more than one CICS task can be run
concurrently using task switching mechanism.
In this a task is suspended, on a command that causes a wait, and the next
highest priority task that is wating takes control.

CICS provides services to the suspended task depending upon the command, and
it is then placed in the queue of waiting task according to its priority number.

• MULTI THREADING – Multithreading is the system environment where the


tasks are sharing the same program under multitasking environment.

_______________________________________________________________________________
CICS Training Material Revision 2.0
6
CICS Training Material
_______________________________________________________________________________
We can say Multithreading is a subset of multitasking since it concerns tasks,
which use the same program.

Several terminals requiring the same program will use only one copy of the
program thus saving main storage.

This feature is possible because multitasking allows each task requiring the same
program to use part of the same copy of the program when that task is active.

• NON-REENTRANT - A non-reentrant program is a program, which modifies


itself during execution so that it cannot reenter to itself. Therefore it cannot be
used in the multithreading environment. Eg. Batch Programs.

• REENTRANT - Program that does not modify itself in any way during
execution, so that it can continue processing after an interruption by the
Operating System (OS). The interruption is done by OS Supervisory calls
(SVC) in reentrancy program. It is called reenterable program or serially
reusable program. On-line program is an example for Reentrant program.

The reentrant program works can be described in the following.

For example let us take three OS Tasks A, B & C. An OS task (A) which uses a
program has exclusive use of the CPU resource. At an interruption time (i.e., SVC)
in the program,the OS task (A) is suspended. OS saves the status of the OS task
(A) and executes other tasks B , C.When other OS taks reach a SVC while the
task A’s wait status becomes complete , OS restores the status of the task (A)
(i.e. ‘reenter’ to the program) and continues to execute until the next SVC.

This process makes it possible for tasks A B & C to run concurrently. If tasks A B
and C , data areas of the program will be destroyed unless the data area is to be
kept unique to each task.

• QUASI REENTRANT - A quasi-reenterant program is a reentrant program


which does not modify itself and continue processing after an interruption by
CICS ,which during interruption executes other CICS tasks including CICS
taks of the same program.So we call Quasi-reneterancy is a reentrant program
under CICS environment.

Under CICS, a program interruption is done not at the Supervisory call (SVC) time
but at the time of CICS command. The CICS command is RETURN with
Transaction identifier (TRANSID). Reentrancy under the CICS environment called
‘quasi’ inorder to distinguigh this from the reentrant program, which is the term
under OS/multithreading environment. Pseudoconversation programs are an
example for quasi-reentrancy.

The sample CICS command is as follows:

EXEC CICS RETURN


TRANSID(‘GCXX’)
_______________________________________________________________________________
CICS Training Material Revision 2.0
7
CICS Training Material
_______________________________________________________________________________
COMMAREA(W-COMMAREA)
LENGTH(LENGTH OF W-COMMAREA)
END-EXEC.

Note: A program can be specified as reentrant by coding the RENT option during
compilation

1.7. CICS System Components

The essential role of CICS is to act as an interface between application programs and the
operating system as the DB/DC control system. CICS consists of five major system
components:

• Data Communication functions – Provides an Interface between CICS and the


terminals, and also with other systems. To free application programs from
terminal hardware through Basic Mapping Support (BMS). To provide multi
region operation (MRO) through which more than one CICS region in a
system can communicate. It can also provide Inter System Communication.

• Data Handling Functions – Provides an Interface between CICS and user data.
It can interface with data access methods such as VSAM and database access
methds such as DB2. It can maintain data integrity by control of simultaneous
record updates and also protection of data at abnormal termination of a task or
at system failures (OS or CICS)

• Application Program Services – Interface between CICS and user application


programs.
It can interface with COBOL, PL/I or Assembler programs. Command level
translator and Execution diagnostic facility (EDF) are some of the services offered.

• System Services – Interface between CICS and Operating System like


program control such as load and release of application programs, aquiring
and freeing of storage, task scheduling based on the task priority.

• Monitoring Functions – Monitoring events within CICS and providing statistics.

1.8. CICS Control Programs And Tables

CICS has a set of IBM-supplied Control Programs and corresponding CICS user-specified
control Tables, which form its core portion called the CICS nucleus. All user CICS
resources have to be defined in these tables. They are

CICS Control Programs CICS Control Tables


(IBM-Suppied) (User-Specified)
_______________________________________________________________________________
CICS Training Material Revision 2.0
8
CICS Training Material
_______________________________________________________________________________
FCP (File Control Program) FCT (File Control Table)
KCP (Task Control Program) PCT (Program Control Table)
PCP (Program Control Program) PPT (Processing Program Table)
JCP (Journal Control Program) JCT (Journal Control Table)
TCP (Terminal Control Program) TCT (Terminal Control Table)
TDP (Transient Storage Program) TST (Temporary Storage Table)

Note: For executing a program in CICS the following are required.


i) Register an entry in PCT for Transaction
ii) Register an entry in PPT for Program
iii) Register an entry in FCT for file used in the program defined in PCT and PPT.

1.8.1 CICS Management Services.

CICS environment services consists of five management modules.

a. Terminal Management:
• Comprises of TCP - Polls Terminals, Handles different communication protocols,
Logs data communication errors.
• Terminal Control Table (TCT) – Describes each terminal in the network by type,
priority and address.
• Terminal I/O Area (TIOA) - The initial 12 bytes filler in the symbolic map.
1. Holds messages from the terminal until working-storage for the application
program is defined.
2. Holds messages being sent to a terminal until the line is free for
transmission.

b. Program Management:

Program management comprises of the following:

• Program Control Program (PCP) – Keeps track of which programs are in storage
and where they are located.

• Processing Program Table (PPT) – Defines system elements such as program


name, program language, primary storage address and disk address.

c. Storage Management:

• Storage management has only a storage control program (SCP) which aquires and
releases storage as necessary.

d. File Management:

_______________________________________________________________________________
CICS Training Material Revision 2.0
9
CICS Training Material
_______________________________________________________________________________
• File Control Program (FCP) interacts with system access methods to perform file I/O
requests.

• File Control Table (FCT) contrains information on files related to the following.

1. File name, Buffer requirements, allowable services such as read/write or


read only.
2. File characteristics.
• File I/O Area (FIOA) holds the control interval that contains the requested logical
record.

e. Task Management:

Task management comprises the following:

• Task Control Program (KCP)


1. Tracks which terminal is using which program.
2. Controls task priority.

• Program Control Table (PCT) contains information about programs, related to the
following:
1. The transaction ID and its associated program.
2. Task priority and security.

• Task Control Area (TCA) contains pointers to storage areas and control areas for
programs and terminals.

1.8.2 INITIATION OF CICS TRANSACTION

a. Terminal Control.

A transaction identifier (GC99) is entered in a terminal.

TCP with TCT recognizes incoming data from the terminal.

SCP acquires the storage for the terminal I/O area(TIOA) .

TCP places the data from the terminal into TIOA and sets the pointer into the TCT
entry of the terminal. If there is no task associated with this terminal TCP passes
control to KCP which realizes the transaction identifier in TIOA.

b. Task control.

KCP creates a task for the transaction then checks whether the transaction identifier
is a valid entry in the Program Control Table (PCT)

If the trans-id is invalid an error message is sent to the terminal and the task is
terminated. Otherwise it requests the SCP to acquire storage for the Task Control
Area (TCA) in which KCP prepares control data for the task.

KCP assigns a priority to the task , then places it in the queue of waiting tasks.

_______________________________________________________________________________
CICS Training Material Revision 2.0
10
CICS Training Material
_______________________________________________________________________________
KCP through PCT tries to find the application program associated with the
transaction.

c. Program control

If PPT entry of the application program does not show the resident address of the
program, KCP passes control to PCP, which fetches the application program from
the load library and places it into the main storage. KCP passes control to the
application program. The application program starts its processing. This is how the
transaction is initiated.

The following are different ways of initiating CICS transaction.

1. By a transaction identifier entered in a terminal.


2. By a transaction identifier associated with the terminal for psedo-
conversation.
3. By a START Command which initiates transaction specified in the
parameter.
4. By automatic task initiation (ATI) in Transient Destination Queue (TDQ).
5. By a terminal 3270 attention identifier any of the PF Keys, PA Keys could be
defined in PCT to Initiate CICS transaction.
.

1.9. Sign ON And Sign OFF


• A user has to sign on to CICS by issuing the CESN transaction before
executing any transaction
• All transactions should be executed on a CLEAR screen.
• A user can sign off from CICS by issuing CESF LOGOFF in the CICS region.

Example:

1. Logon to CICS region and clear the Screen.


2. Type CESN and Press ENTER

The following screen will appear:

Type your userid and password, then press ENTER:

Userid . . . . Groupid . . .
Password . . .
Language . . .
New Password . . .

Type Userid and Password & start using CICS.


3. For logoff type CESF LOGOFF and press ENTER.

_______________________________________________________________________________
CICS Training Material Revision 2.0
11
CICS Training Material
_______________________________________________________________________________

2. CICS APPLICATION PROGRAMMING

2.1. Objectives

• Structure of a CICS Application Program


• CICS Management Functions
• CICS Program Preparation
• Conversational & Pseudoconversational transactions
• Simple CICS Commands
• Passing Data across tasks

2.2. Structure Of a CICS Application Program


You write a CICS program in much the same way as you write any other program. You can
use COBOL, OO COBOL, C, C++, PL/I, or assembler language to write CICS application
programs. Most of the processing logic is expressed in standard language statements, but
you use CICS commands for some functions. The Structure of CICS application program is
explained below.

IDENTIFICATION DIVISION
PROGRAM - ID. (required)
AUTHOR. }

DATE-WRITTEN. } (Optional but recommended)


DATE-COMPILED. }
REMARKS. }

ENVIRONMENT DIVISION. (Only header is required)


DATA DIVISION.
FILE SECTION. (is not required)
WORKING-STORAGE SECTION. (required)
LINKAGE SECTION. (optional)
PROCEDURE DIVISION.
COBOL statements and CICS commands

The following COBOL statements are prohibited.


• ACCEPT, CURRENT-DATE, DATE, DAY, DISPLAY, EXHIBIT, STOP RUN,
TRACE
• Any I/O statements (OPEN, CLOSE, READ, WRITE, REWRITE, DELETE,
START)
• REPORT WRITER and SORT features
• CALL statement is allowed if the called program does not issue any CICS
command or COBOL statements mentioned above.
_______________________________________________________________________________
CICS Training Material Revision 2.0
12
CICS Training Material
_______________________________________________________________________________
Some of the restrictions mentioned above have been removed under VS COBOL II.
Improvements by VS COBOL II
VS COBOL II Provides a much better interface to CICS than VS COBOL . In results some
of the restrictions mentioned above have been removed in VS COBOL II. They are:

GOBACK Control will be returned to another VS COBOL II or CICS.


STOP RUN: Control will be returned to CICS.
EXIT PROGRAM : Control will be returned from a VS COBOL II subprogram to a
VS COBOL II main program.
CALL: A CICS application program written in VS COBOL II can call a
subprogram written in VS COBOL II(reentrany by
definition),regardless of whether the subprogram issues CICS
command or not.

2.3. Termination Statements


• CICS has its own command for terminating a program. Nevertheless, COBOL
and VS COBOL II have three statements to conclude programs. Control must
not be allowed to pass beyond the last statement of a CICS Program.
• STOP RUN in COBOL uses operating system facilities, and therefore, is
discouraged.
• EXIT PROGRAM is ignored if the program has not been called.
• CICS RETURN COMMAND and/or GOBACK statement is recommended.

Commands for a Small Program


2.4.1 CICS Command Format

A CICS command consists of a keyword phrase, the function, its options and the
arguments for options and a delimiter.

Example.

EXEC CICS SEND FROM (FLDA) LENGTH (5) END-EXEC

Keyword Function Option Argument Option Argument Delimiter

Be careful about periods. Avoid them after END-EXEC where you don’t really want them.
For eg, within an IF . . . THEN . . . ELSE statement, the translator places a period into the
generated code if a period follows END-EXEC. The period following END-EXEC terminates
the IF statement also.

_______________________________________________________________________________
CICS Training Material Revision 2.0
13
CICS Training Material
_______________________________________________________________________________
Eg. IF A = B
EXEC CICS
...........
END-EXEC
ELSE
MOVE ‘NO’ TO ANSWER
END-IF.
The above example, as given, will not give any error. However, if a period follows the END-
EXEC, the period terminates the IF statement also, and the program doesn’t recognize the
ELSE portion, generating a compilation error

2.4.2. RECEIVE Command

EXEC CICS
RECEIVE INTO (DATA-AREA) LENGTH (DATA-AREA)
END-EXEC.

• RECEIVE command is used to receive into memory, data from the terminal to
which this CICS transaction is associated.
• A receiving area must be defined in working-storage section and has to be
specified in the INTO parameter.
• Length field must be defined in working-storage section as S9(4) COMP field. It
has to be specified in LENGTH option.

Eg. EXEC CICS RECEIVE INTO (VAR1) LENGTH (10) END-EXEC.

2.4.3. SEND Command

EXEC CICS
SEND FROM (data-area) LENGTH (data-area)
END - EXEC

• The data to be sent must be stored in working-storage section, and this field
name has to be specified in the FROM parameter.
• LENGTH is optional
Eg.
MOVE "HELLO" TO VAR!
EXEC CICS SEND FROM (VAR1) END-EXEC.

2.4.3.1 SEND TEXT COMMAND

_______________________________________________________________________________
CICS Training Material Revision 2.0
14
CICS Training Material
_______________________________________________________________________________
The SEND TEXT Command is used to send a single-stream text to a terminal. BMS
Maps are not required for SEND TEXT Command

Format

EXEC CICS SEND TEXT


FROM(data-value)
LENGTH(data-value)
[HEADER(data-value)]
[TRAILER(data-value)]
[ERASE]
END-EXEC.

EX: EXEC CICS SEND TEXT(REC1) END-EXEC.

MULTITEXT OPERATION

The Multitext Operation is used to send the multitext message to the


terminal as one logical text.

For the mutitext operations,it is required to use two commands as follows:

• Use the SEND TEXT Command with the ACCUM Option for accumulating the
text block.
• Then Issue the SEND PAGE command to send the entire text

2.4.4. Formatting TIME and DATE

There are two fields in the EIB called EIBDATE and EIBTIME, which contain the
date and time values at task initiation time. There are different commands to
process this date and time.

2.4.5. ASKTIME Command


• Used to request the current date and time. The date and time together are
obtained in a variable whose picture clause should be S9(15) COMP-3.

EXEC CICS
ASKTIME ABSTIME (data-area)
END-EXEC.

Eg. EXEC CICS ASKTIME ABSTIME (WS-TIME) END-EXEC.

2.4.6. Format TIME Command

• Used to format the date and time information in various formats, using the
ABSTIME value obtained with the ASKTIME command.
EXEC CICS FORMATTIME

_______________________________________________________________________________
CICS Training Material Revision 2.0
15
CICS Training Material
_______________________________________________________________________________
ABSTIME(data-area) (required)
[YYDDD(data-area)]
[YYMMDD(data-area)]
[YYDDMM(data-area]
[MMDDYY(data-area]
[DDMMYY(data-area]
[DATESEP(data-value)] (default is “/”)
[DAYOFWEEK(data-area)]
[DAYOFMONTH(data-area)
[MONTHOFYEAR(data-area]
[YEAR(data-area]
[TIME(data-area]
[TIMESEP(data-value)] (default is “:”)
END-EXEC.

Eg. EXEC CICS FORMAT TIME ABSTIME(WS-TIME) YEAR(WS-YEAR) END-EXEC.

2.4.7. DELAY Command

• Used to delay the processing of a task for the specified time interval or until the
specified time.

EXEC CICS DELAY [INTERVAL(hhmmss) | TIME(hhmmss)]


END-EXEC
If hhmms = ‘001500’, task will be suspended for 15 minutes if INTERVAL is specified or
until 00:15:00 if TIME is specified.

2.4.8. ASSIGN Command

• Used to Access the length of CICS storage areas.

_______________________________________________________________________________
CICS Training Material Revision 2.0
16
CICS Training Material
_______________________________________________________________________________
EXEC CICS
ASSIGN [CWALENG(data-area)]
[TCTUALENG(data-area)]
[TWALENG(data-area)]
[USERID(data-area)]
[ABCODE(data-area)]
END-EXEC
CWALENG : To access the length of Common Work Area(CWA)
TCTUALENG : To access the length of Terminal Control Table User Area(TCTUA)
TWALENG : To access the length of Transaction work area(TWA)
USERID : To access the User id
ABCODE : To access the abend code

2.5. Execption Conditions

Exception conditions are those that could occur during execution of a command. There are
different ways of handling these exception conditions.

2.5.1. RESP option

• Define a fullword binary field S9(8) comp in working storage as the response
field.
• Code RESP option with the response field in any CICS command.
• After command execution, check the response code in the response field with
DFHRESP (xxxxxxx) where xxxxxxx is NORMAL for normal completion or
Any exceptional condition (depending upon the command)
Eg.
WORKING-STORAGE SECTION.
01 ws-resp PIC S9(8) COMP.
01 ws-send-unsuccessful PIC X(1).
PROCEDURE DIVISION.
EXEC CICS
SEND FROM(data) RESP(ws-resp)
END-CICS.
IF ws-resp = DFHRESP(INVREQ)
MOVE ‘N’ to ws-send-unsuccessful.

_______________________________________________________________________________
CICS Training Material Revision 2.0
17
CICS Training Material
_______________________________________________________________________________
2.5.2. HANDLE CONDITION

• The HANDLE CONDITION command is used to transfer control to the


procedure label specified, when the exceptional condition specified occurs.
• It remains active until the end of the program or if another HANDLE
CONDITION request overrides it.
• This command cannot detect ordinary program ABENDs, such as data
exception errors (0C4, 0C7), unrelated to CICS commands.
Eg.

EXEC CICS
HANDLE CONDITION
LENGERR (lengerr-para)
ERROR (other-errors-para)
END-EXEC.
Control is transferred to lengerr-para if LENGERR condition occurs for any command. For
any other error, control is transferred to other-errors-para.

2.5.3. IGNORE CONDITION

• The IGNORE CONDITION command causes no action to be taken if the


exception condition specified occurs in the program.
• Control transfers to the next statement in the program.
• Requests by the IGNORE CONDITION command are valid until the
subsequent HANDLE CONDITION command for the same condition.
Eg.
EXEC CICS
IGNORE CONDITION LENGERR
END-CICS.
EXEC CICS
RECEIVE INTO(data) LENGTH(value)
END-EXEC.
If LENGERR occurs during the RECEIVE command, it is ignored, and control is transferred
to the statement after the RECEIVE statement.

NOHANDLE Option

• If the NOHANDLE option is specified in any CICS command, no action will be


taken for any exceptional condition occurring during execution of this
command.
Eg.

_______________________________________________________________________________
CICS Training Material Revision 2.0
18
CICS Training Material
_______________________________________________________________________________
EXEC CICS
SEND FROM(data)
LENGTH (value)
NOHANDLE
END-EXEC.
Even if an exception condition occurs during the SEND command, it is ignored and control
is transferred to the statement after the SEND statement.

2.5.5 HANDLE ABEND Command

• The HANDLE ABEND Command is used to intercept an abnormal termination


(ABEND) within a program and to activate, cancel,or reactivate an exit for ABEND
processing.
The HANDLE CONDITION command, which intercepts only the abnormal
conditions of the CICS command execution.

Format is

EXEC CICS handle abend program (name) label (label) cancel reset
END-EXEC.

PROGRAM or LABEL is used to activate an exit (I.e.,to pass control) to a program


or a paragraph,respectively,for the ABEND processing . CANCEL is used to
cancel the previously established HANDLE ABEND request. RESET is to
reactivate the previously cancelled HANDLE ABEND request.
2.5.6 HANDLE AID Command

The Handle Aid command is used to specify the label (paragraph) to which control is to be
passed when a specified aid is received in the program. After the completion of a terminal
input command such as RECEIVE control will be passed to the specified paragraph in the
program.

EXEC CICS HANDLE AID (label)


PF1 (label)
PF2 (label)
ENTER (label)
ANYKEY (label)
END-EXEC.

• The key ranges are PA1 to PA3, PF1 to PF24, ENTER , CLEAR.
• The above keys are called Attention Identifier (AID) Keys.
• ANYKEY means any of the above except ENTER key.
• A specific key option will override an ANYKEY option.
• An option without a label deactivates a previous label set for that option.

2.6. Sample Program(s)


Sample program 1
_______________________________________________________________________________
CICS Training Material Revision 2.0
19
CICS Training Material
_______________________________________________________________________________

440000 IDENTIFICATION DIVISION.


460000 PROGRAM-ID. TRGxxxP1.
460010 *THIS SAMPLE PROGRAM
460100 *RECEIVE DATA FROM (UNFORMATTED) SCREEN AND SEND IT TO
460200 *THE SCREEN BACK WITH ADDITIONAL INFORMATIONS
480000 ENVIRONMENT DIVISION.
540000 DATA DIVISION.
540100 WORKING-STORAGE SECTION.
540200 01 VAR1.
540210 02 FILLER PIC X(18) VALUE "MY USER ID IS : ".
540220 02 USERID PIC X(10) VALUE SPACES.
540230 01 VARX.
540240 02 FILLER PIC X(5).
540250 02 USERID1 PIC X(10) VALUE SPACES.
540300 01 W-LEN PIC S9(4) COMP.
540500 01 W-TEXT PIC X(25) VALUE SPACES.
600000 PROCEDURE DIVISION.
660100 MAIN-PROC.
660110 MOVE 15 TO W-LEN.
660200 EXEC CICS
660300 RECEIVE INTO(VARX) LENGTH(W-LEN)
660400 END-EXEC.
660900 MOVE USERID1 TO USERID.
790113 EXEC CICS
790114 SEND TEXT FROM(VAR1) ERASE
790200 END-EXEC.
790600 END-PARA.
930560 EXEC CICS RETURN END-EXEC.
930570 GOBACK.
****** **************************** Bottom of Data ****************************

Sample program 2

100001 IDENTIFICATION DIVISION.


100002 PROGRAM-ID. TRGXXXP1.
100003 *This program gets system date & time displays on the screen
100004 ENVIRONMENT DIVISION.
100005 DATA DIVISION.
100006 WORKING-STORAGE SECTION.
100007 01 WS-TIME PIC S9(15) COMP-3.
100008 01 WS-GRP.
100009 02 FILLER PIC X(18) VALUE ' SYSTEM DATE IS : '.
100010 02 W-DATE PIC X(8).
100011 02 FILLER PIC X(18) VALUE ' SYSTEM TIME IS : '.
100012 02 W-TIME PIC X(8).
100013 01 W-RESP PIC S9(8) COMP.
100014 01 W-TEXT PIC X(32) VALUE SPACES.
100015 PROCEDURE DIVISION.
100016 MAIN-PROC.
100017 EXEC CICS
100018 ASKTIME ABSTIME(WS-TIME)

_______________________________________________________________________________
CICS Training Material Revision 2.0
20
CICS Training Material
_______________________________________________________________________________
100019 END-EXEC.
100020 EXEC CICS
100021 FORMATTIME
100022 ABSTIME(WS-TIME)
100023 DDMMYY(W-DATE)
100024 DATESEP('/')
100025 TIME(W-TIME)
100026 TIMESEP(':')
100028 RESP(W-RESP)
100029 END-EXEC.
100030 IF W-RESP = DFHRESP(NORMAL)
100031 CONTINUE
100032 ELSE
100033 MOVE 'FORMATTIME ERROR! JOB CANCELED!! ‘ TO W-TEXT
100035 EXEC CICS SEND FROM(W-TEXT) END-EXEC
100035 PERFORM END-PARA
100046 END-EXEC.
100048 EXEC CICS
100049 SEND FROM(WS-GRP) ERASE
100055 END-EXEC.
100057 END-PARA.
100058 EXEC CICS RETURN END-EXEC.
100065 GOBACK.

*************************** Bottom of Data ****************************

Sample Program 3

440000 IDENTIFICATION DIVISION.


460000 PROGRAM-ID. TRGXXXP1.
460010 *THIS PROGRAM DISPLAYS USER ID USING THE ASSIGN COMMAND
460020 *(WITHOUT ACCEPTING INPUT FROM SCREEN)
480000 ENVIRONMENT DIVISION.
540000 DATA DIVISION.
540100 WORKING-STORAGE SECTION.
540200 01 VAR1.
540210 02 FILLER PIC X(18) VALUE "MY USER ID IS : ".
540220 02 USERID PIC X(10) VALUE SPACES.
540300 01 W-LEN PIC S9(4) COMP.
540400 01 W-RESP PIC S9(8) COMP.
540500 01 W-TEXT PIC X(25) VALUE SPACES.
600000 PROCEDURE DIVISION.
660100 MAIN-PROC.
660120 EXEC CICS ASSIGN USERID(USERID) END-EXEC.
790113 EXEC CICS
790114 SEND TEXT FROM(VAR1) ERASE
790200 END-EXEC.
930560 EXEC CICS RETURN END-EXEC.
930570 GOBACK.
****** **************************** Bottom of Data ****************************

Sample Program 4

_______________________________________________________________________________
CICS Training Material Revision 2.0
21
CICS Training Material
_______________________________________________________________________________
000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. TRG072P1.
000210 *SAMPLE Program for SEND TEXT WITH ACCUM
000300 ENVIRONMENT DIVISION.
000400 DATA DIVISION.
000500 WORKING-STORAGE SECTION.
003600 01 TEXT-HEADER.
003700 10 FILLER PIC S9(4) COMP VALUE 29.
003800 10 FILLER PIC X VALUE '&'.
003900 10 FILLER PIC X.
004000 10 FILLER PIC X.
004100 10 FILLER PIC X(29) VALUE
004200 'COMPANY PROFILE - PAGE && '.
004203 01 TEXT-LENGTH PIC S9(4) COMP.
004210 01 TEXT-BODY1 PIC X(10) VALUE 'TEST1'.
004220 01 TEXT-BODY2 PIC X(10) VALUE 'TEST2'.
004230 01 W-USERID PIC X(8).
004300 PROCEDURE DIVISION.
004400 MAIN-PROC.
004401 EXEC CICS ASSIGN USERID(W-USERID) END-EXEC.
004402 MOVE 10 TO TEXT-LENGTH
004410 EXEC CICS SEND TEXT
004420 FROM(TEXT-BODY1)
004421 LENGTH(TEXT-LENGTH)
004430 HEADER(TEXT-HEADER)
004440 ACCUM
004450 ERASE
004460 END-EXEC.
004461 MOVE 10 TO TEXT-LENGTH
004470 EXEC CICS SEND TEXT
004480 FROM(TEXT-BODY2)
004481 LENGTH(TEXT-LENGTH)
004490 ACCUM
004491 ERASE
004492 END-EXEC.
004493 EXEC CICS SEND PAGE
004494 END-EXEC.
004700 EXEC CICS
004800 RETURN
004900 END-EXEC.
005000 GOBACK.
****** **************************** Bottom of Data ****************************

2.7. Program Preparation

Steps for preparing a CICS program


• DB2 Precompilation (if any DB2 statements present)
• CICS Translation (converts CICS command level code into COBOL code)
• Program Compilation
• Link-Editing

_______________________________________________________________________________
CICS Training Material Revision 2.0
22
CICS Training Material
_______________________________________________________________________________
• Running the DB2 precompiler first is the preferred method. DB2 precompiler
precedes another process, binding, not mentioned here.
• Messages or warnings are provided on all the listings.
• The transaction identifiers, associated programs and files need to be defined to
CICS. This is usually done by the Systems Programmers.

2.8. DB2 Precompiler

The DB2 precompiler recognizes EXEC SQL statements, which it will comment out and
replace with, in our case, COBOL PERFORM and CALL statements.

2.9. Translator

The Translator recognizes the EXEC CICS statements. They are commented out and
replaced with statements in the appropriate language. In a COBOL-CICS program, MOVE
instructions and CALL Statemenets are inserted and passed on to the COBOL compiler.
The following is an example of how a CICS command is converted into corresponding
COBOL code.
Example

*****EXEC CICS RETURN END-EXEC


Move ‘ 00160 ‘ TO DFHEIVO
Call ’DFHEI1’ Using DFHEIVO.
*****EXEC SQL SELECT * into
*****:DCLEMP from CICSDB.EMP
*****Where empno = : Reckey END EXEC
Perform SQL initial until SQL-Int-Done
Call ‘ DSNHLI’ using SQL - PLIST2

Note: Refer APPENDIX for Corresponding JCL

2.10. CICS Transactions


2.10.1 CEMT (CICS Supplied Extended Master Terminal Transaction):

It is CICS supplied transaction, which manipulates the CICS environment such as


transaction, programs, files, TSQs and tasks. It is menu -driven and easy-to-use
transaction, but due to its nature of manipulation the application progrmammer or
end-users can’t use freely. But it helps programmers for program testing, monitoring
and touble shooting. The three functions of CEMT are

INQUIRE: To inquire about the status of CICS environements


SET: To update the status of CICS environement
PERFORM: For further systems operation

Eg:
_______________________________________________________________________________
CICS Training Material Revision 2.0
23
CICS Training Material
_______________________________________________________________________________

CEMT SET PROG (TRGXXXP1) NE

This will take the newly compiled version of program TRGXXXP1 for updation. But
cannot be performed if the program is in use. If ‘NE’ is not given the CEMT
command will display the status of the program TRGXXXP1 which was compiled
before updation..

CEMT SET PROG (MAPXXX) NE

This transaction will take the new copy or latest compiled version of the map
MAPXXX.

To Update File Status used in the program TRGXXXP1&Type the following


command & press enter.

CEMT S FILE (TRGXXXF1)

The status of the file TRGXXXF1 will be displayed as below.

STATUS: RESULTS - OVERTYPE TO MODIFY

File (TRGXXXF1) Vsa Ope Ena Rea Upd Add Bro Del Sha
Dsn( TRGXXX.VSAM.ESDS)

RESPONSE: NORMAL

If you change the ‘Ope’ to ‘Clo” and press enter, then the file which is opened will be
closed.

Note: you should always check RESPONSE for NORMAL, Otherwise it will show
error message.

2.10.2 EDF (Execution Diagnostic Facility)

CEDF is a CICS supplied transaction, which monitors the execution of an application


program as an interactive debugging aid.

The terminal that you are using for the EDF interaction must be in transceive (ATI/TTI)
status and be able to send and receive data. This is the most common status for
display terminals, but you can find out by asking your system programmer to check its
status.

For a transaction initiated at a terminal, you can use EDF on the same terminal as the
transaction you are testing, or on a different one. On the same terminal, you must
start by clearing the screen and entering the transaction code CEDF, otherwise you
may get unpredictable results. The message THIS TERMINAL: EDF MODE ON is
displayed at the top of an empty screen. You clear the screen again and run your
transaction in the normal way.

If you are using two terminals, you enter CEDF tttt at one, naming the second in tttt.
Then you run your transaction on the second terminal.

_______________________________________________________________________________
CICS Training Material Revision 2.0
24
CICS Training Material
_______________________________________________________________________________
Example:
(i) Let us say your transaction identifier is GC01
(ii) If you want to execute the program in interactive debugging mode. Enter
CEDF and then transaction identifier as follows:

CEDF and press ENTER


GC01 and press ENTER

It will wait for your response before executing each CICS command

2.10.3 CECI – For testing CICS Commands Under CICS Environment

CECI (Command Level Interpreter) is a CICS supplied transaction, which performs


syntax checking of a CICS command.

Command-level interpreter (CECI)

You can use the command-level interpreter (CECI) transaction to check the syntax
of CICS
Commands and process these commands interactively on a 3270 screen. CECI
allows you to follow through most of the commands to execution and display the
results. It also provides you with a reference to the syntax of the whole of the CICS
command-level application programming and system programming interface.

CECI interacts with your test system to allow you to create or delete test data,
temporary storage queues, or to deliberately introduce wrong data to test out error
logic. You can also use CECI to repair corrupted database records on your
production system.

Example: To check the delay command.(Delay interval is one minute.),the following


command will do syntax checking and also execution.

CECI Delay interval (000100)

Question mark (?) before the CECI command requests a syntax check only. No
execution.
CECI ? delay inerval(000100)

Steps for executing application program in CICS:


1 Translate,compile,linkedit a CICS application program (command
level) into the CICS application library(LOADLIB)
2 Define the transatiion identifier (1 to 4 charactes length) into PCT,one
of the CICS tables, which is associated with program .
3 Define the program into PPT. If you are using File(s) in your program
Define entrie(s) in File control Table (FCT).
4 Sign onto CICS
5 Check the status of the program under CICS environement using
CEMT transaction (Ex: CEMT SET PROGRAM(TRGxxxP1) NEWCOPY)

_______________________________________________________________________________
CICS Training Material Revision 2.0
25
CICS Training Material
_______________________________________________________________________________
6 If You want to use Diagnostic Facility use CEDF (Ex: Type CEDF &
enter)
7 Enter the transaction identifier

2.11. Exercise
1. Write a simple CICS program to receive the current transaction ID from the
screen and send a message to the screen as ‘My Transaction ID is XXXX’,
where XXXX is the transaction ID.
2. Write a CICS program to send the current system date on to the screen in the
format ‘20-10-01’ and the current time in the format ‘12:12:12’.
3. Write a CICS program to send the message ‘Current date is ‘, followed by a
delay of 10 seconds, followed by the display of the actual date.

_______________________________________________________________________________
CICS Training Material Revision 2.0
26
CICS Training Material
_______________________________________________________________________________

3. MAPS AND DISPLAYS


3.1. Objectives
• Introduction to BMS
• Physical Maps and Symbolic maps
• Screen layout documentation
• Symbolic Map in application program
• Output Mapping
• Common Declarations

3.2. Introduction to BMS


To make the application program device independent and format independent, CICS
provides Basic Mapping Support (BMS) to deal with the formatted screen operations.
Screens defined through BMS are called “MAPs”.

BMS is a part of Terminal Management service module of CICS . BMS is a facility that
moves data streams to and from the terminal.

Primary functions of BMS.


• It allows the programmer to define operands in the map program using assembly
macros, without having to know the physical characteristics of the actual terminals
used
• It removes device dependent codes from an application program by placing them in
maps
• It removes constant information from an application program by placing the default
constants (eg .titles, field labels) in maps
• It uses program control services to load the appropriate physical map into main
storage when required
• It uses terminal control services to transmit data from or to a terminal
• The maps are assembled off-line and generated before the application programs
can actually use it .If a screen layout has to be only changed subsequently the
application program need not be recompiled.

_______________________________________________________________________________
CICS Training Material Revision 2.0
27
CICS Training Material
_______________________________________________________________________________
3.3. Screen Layout Documentation

Protected Field (Constant Data) Cursor Field


Stopper Field

NAME : C__________

SEX : _ Unprotected
Fields
AGE : __

Numeric Field
• Constants describe the meaning of the field.
• Protected fields cannot be changed.
• Unprotected fields can be changed.
• The cursor can be interpreted as an invitation to “Start Entering Here”.
• A stopper field after NAME can cause the cursor to skip to the next
unprotected field (SEX).
• A stopper field after AGE should lock the keyboard indicating field overrun.

3.4. Physical MAP


3.4.1 Physical Map Features.

♦ Coded using BMS macros assembled and linkedited into CICS Load Library.
♦ It is a program in the form of load module stored in one of the runtime libraries
and CICS loads it when executing a program using this map.
♦ For input operations, it defines the maximal data length and starting position of
each field to be read, and allows BMS to interpret an input data stream
♦ For output operations, it defines the starting position, length, field
characteristics (Attribute Bytes) and default data for each field, and allows BMS
to construct an output data stream.

Physical Map Generation

• The Physical Map is actually a program (defined to PPT) in the form of a Load
Module.
• The Physical Map is coded using BMS macros.
• The BMS macros are then assembled separately and link edited into the CICS
load library

_______________________________________________________________________________
CICS Training Material Revision 2.0
28
CICS Training Material
_______________________________________________________________________________
3.4.2. Physical Map Contents

DFHMSD Mapset Name : Mapset Specification


DFHMDI Map Name : Map Specification
DFHMDF Field Name : Field Specification
DFHMDF Field Name : Field Specification
DFHMDI Map Name : Map Specification (Map 2)
DFHMDF Field Name : Field Specification
DFHMSD Type=Final

• Mapset is the actual resource defined to CICS as a PPT entry.


• Mapset is a collection of maps (screens).
• There can be any no. of maps defined per mapset.
• System programmer defines the mapset in PPT (Processing Programming
Table).

DFHMDF, DFHMSD, DFHMDI are all CICS BMS macros. Formats of BMS Macros are
described below. Users by default won’t code their own macros. They define the
screens using some facility like SDF (Screen Definition Facility) provided by IBM, and
generate the macros and the symbolic maps through SDF itself. The macros are then
assembled to get the Physical Map, and optionally the Symbolic Map also.

BMS MACROS AND FORMAT

The BMS map definition macros are purely assembler macros. Macro is an instruction
similar to assembler macro, which is a group of assembler instructions for a specific
function. The following coding convention to be maintained.

Col. Col Col


1 16 72

Symbol Operation Operand(parameters separted by commas) Continuation Character

Symbol: Mapset /Map/Mapfield names can be defined.

Operation:In operation, the following Macros can be defined:


DFHMSD, DFHMDI, DFHMDF

Operands:Operands are explained below .

Ex:

SAMPLE DFHMSD TYPE=MAP,MODE=INOUT,LANG=COBOL

Where TYPE, MODE, LANG are the operands for the mapset SAMPLE.

_______________________________________________________________________________
CICS Training Material Revision 2.0
29
CICS Training Material
_______________________________________________________________________________
Column 72 is for Continuation character. If we define a mapfield and if it continues to
second line then we have to specify ‘X’ at column 72 for continuation otherwise it can be
blank.

3.4.2.1. DFHMSD macro

• Used to define a mapset and its characteristics or to end a mapset definition.


• For one assembly run, only one mapset is allowed.

FORMAT
mapset DFHMSD TYPE=&SYSPARM, X
[MODE=INOUT,] X
[LANG=COBOL,] X
[STORAGE=AUTO,] X
[TIOAPFX=YES,] X
[CTRL=(FREEKB, FRSET,PRINT)]

Mapset can be only 1 to 7 characters.

3.4.2.2. OPTIONS

TYPE : Type of Map


DSECT : generates symbolic map.
MAP : generates physical map
FINAL To indicate the end of mapset coding.
& SYSPARM : Is used to control the type of map through JCL

MODE : Specifies whether mapset is used for input/output or both.


IN Mapname field name is suffixed with “I” length field is suffixed
with “L”
OUT Mapname fieldname suffixed with “O”. Attribute byte is
suffixed with “A”.
INOUT : Generates both input and output symbolic map areas.

LANG : To define the language of application program.


Eg. COBOL,ASM,PL1,RPG
STORAGE
AUTO : To acquire separate symbolic map area for each mapset.
BASE : Same storage base is used for the symbolic maps for more
than one mapset.

_______________________________________________________________________________
CICS Training Material Revision 2.0
30
CICS Training Material
_______________________________________________________________________________
TIOAPFX = YES To reserve the prefix space (12 bytes) for BMS command to
access TIOA.
CTRL
FREEKB To unlock keyboard after each output operation. Otherwise
the user must press the RESET key each time.
FRSET Specifies that all Modified Data Tags be turned off when the
map is sent to the terminal. Use this option if you want the
terminal only to transmit data that the operator modifies.
ALARM : To send an alarm at screen display time.
PRINT : To indicate the mapset to be sent to the printer.

TERM=type : Required if other than 3270 terminal is used.

SUFFIX = nn : To specify the user provided suffix number.for mapset

3.4.2.3. DFHMDI MACRO

• Used to define a map and its characteristics in a mapset.


• One DFHMSD macro can have any number of DFHMDI macros.

FORMAT

Mapname DFHMDI SIZE = (24,80), X


LINE=1, X
COLUMN=1, X
JUSTIFY = LEFT

Mapname can be 1 to 7 characters ghin length.


3.4.2.4. Options

SIZE(l,c) : Defines the size of map by no. of lines(l), no. of columns(c)


LINE Starting Position of map in line numbers.
i.e., Starting line number of a map.
COLUMN : Starting position of map in column numbers.
i.e Staring column number of a map.
JUSTIFY : Specificies the map to be LEFT justified or RIGHT justified.
DFHMDI macro has other options similar to the DFHMSD macro as CTRL,
TIOAPFX. If these are specified in DFHMDI, DFHMDI macro overrides the ones
specified in DFHMSD macro.

_______________________________________________________________________________
CICS Training Material Revision 2.0
31
CICS Training Material
_______________________________________________________________________________
3.4.2.5. DFHMDF macro

• Used to define a field in a map and its characteristics.


• Any number of DFHMDFs can be issued in a DFHMDI macro.

FORMAT

DFHMDF POS=(1,8), X
LENGTH=20, X
ATTRB=(ASKIP,BRT), X
INITIAL=‘EMPLOYEE NAME’
empn DFHMDF POS (1,30), X
LENGTH=20, X
ATTRIB=(UNPROT,NORM)

3.4.2.6. Options
INITIAL : Defines initial value of the field
ATTRIB : Defines attribute character of the field.
LENGTH : Length of field
JUSTIFY : Justify the field to RIGHT or LEFT. LEFT is default.
PICIN :} PICTURE clause of field.
PICOUT :}

3.4.2.7. PICIN/PICOUT
When data is sent out via the ‘O’ suffix fields or received into the ‘I’ suffix fields, you
may want a definition other than PIC X. PICIN AND PICOUT allows the user to use
other COBOL PICs such as $ , Z etc. PICIN tells BMS how to move data into the ‘I’
suffix field. PICOUT tells COBOL how to display the data. This option is allowed
only for COBOL applications and not in any other languages.
Eg. : F1 DFHMDF POS=40,LENGTH=10,PICOUT=’$$$,$$0.00’
F2 DFHMDF
POS=60,LENGTH=6,PICIN=’9999V99’,PICOUT=’ZZ9.99’

3.4.2.8. ATTRIBUTE CHARACTER


• Invisible 1 byte character, which precedes the screen field and determines
the characteristics of the field.

3.4.2.9. ATTRIBUTE OPTIONS


ASKIP: Auto skip. Cursor skips to the next field. Data cannot be entered into
this field.
PROT : Protected field. Data cannot be entered into this field.

_______________________________________________________________________________
CICS Training Material Revision 2.0
32
CICS Training Material
_______________________________________________________________________________
UNPROT: Unprotected field. Data can be entered. Should be specified for all
input fields.
NUM : Numeric field, only (0 to 9) and (“.” & “_”) are allowed.
BRT : To Highlight the field
NORM : Normal display
DRK : Dark display (invisible).
IC : Insert Cursor. Cursor is positioned in this field.
If IC is specified on more than one field of a map, cursor will be
placed in the last field.
FSET : Field set (MDT on). Regardless of field being modified or not, MDT
will be set.

MDT (Modified Data Tag)

• One bit attribute character.


• If OFF (0), it indicates that the field has not been modified by the terminal
operator, or the field need not be received from the terminal.
• If ON (1), it indicates that the field has been modified by the terminal operator.
• Effective use of MDT reduces the amount of data traffic on communication line.

3.4.3.1 HOW TO SET/RESET MDT?

♦ If the field on the screen is modified by the terminal user, MDT is automatically
SET to “1” (ON).
♦ IF CTRL=FRSET is specified in the DFHMSD or DFHMDI macro, MDT will be
reset to “0” (OFF) when the map is sent to the terminal.
♦ IF FSET is specified in the ATTRB parameter of DFHMDF macro, MDT will be
set to “1” (ON) regardless of whether the terminal user modifies or not.
♦ MDT is set ON/OFF depending upon the amount of information needed to be
transmitted to and from the terminal. Protected fields will have MDT OFF.
Unprotected fields will have their MDT set automatically when any change is
made.

3.5. Symbolic Map


♦ The Symbolic Map is the actual data structure of the fields defined in the
physical screen.
♦ It ensures the device and format independence in the application programs.
♦ A layout change in the formatted screen can be done independent of the
application program coding as long as field name and length remain the same.
♦ Serves as a DSECT (COBOL data structure) for referencing the TIOA. This
structure defines all the variable fields which one might read or write in a
program.
♦ Symbolic map is included in the program by issuing a COBOL COPY
statement in the working-storage section.

_______________________________________________________________________________
CICS Training Material Revision 2.0
33
CICS Training Material
_______________________________________________________________________________

Symbolic Map Generation

• The Symbolic Map is a copy library member.


• It is generated during the assembly of the BMS macros (as mentioned in
Physical Map Generation).
• This map is included in the application program for accessing the screen fields.

3.5.1. Using Symbolic Map in the Application Program


Symbolic Map is included in the program in the Working-Storage Section as COPY
map setname.

3.5.2. Format of Symbolic Map

(Assuming there are 2 fields called FLD1 and FLD2 in the map MAPNAM1)

01 MAPNAM1I.
02 FILLER PIC X(12).
02 FLD1L COMP PIC S9(4). ----------> The length of the field (L)
02 FLD1F PIC X. ----------> Field attribute (F/A)
02 FILLER REDEFINES FLD1F.
03 FLD1A PIC X.
02 FLD1I PIC 9(5). ----------> Field data (I)
02 FLD2L COMP PIC S9(4).
02 FLD2F PIC X.
02 FILLER REDEFINES FLD2F.
03 FLD2A PIC X.
02 FLD2I PIC X(6).
01 MAPNAM1O redefines MAPNAM1I.
02 FILLER PIC X(12).
02 FILLER PIC X(3).
02 FLD1O PIC 9(5). -----------> Field data (O)
02 FILLER PIC X(3).
02 FLD20 PIC X(6).
MAPNAM1I is used while receiving maps, while MAPNAM1O is used while sending maps.

3.5.3. Symbolic Map Suffixes

3.5.3.1 INPUT

_______________________________________________________________________________
CICS Training Material Revision 2.0
34
CICS Training Material
_______________________________________________________________________________
“L” Halfword binary - Contains the length of data entered by the terminal
operator
“F” One byte flag field - If EOF (erase to end of field) key is pressed, it will
contain x‘80’, and “l” field will contain zeros.
“I” Contains the data received from the screen.
3.5.3.2 OUTPUT

“A” one byte field that describes the Attributes of the field. Sets the following
attributes :
PROTECTED/UNPROTECTED
ASKIP
NUM
MDT
Non-Display (DARK) / Display(NORMAL/BRIGHT)

“O” contains the data to be sent to the terminal.

SAMPLE MAP

001000 MAP072 DFHMSD TYPE=MAP,MODE=INOUT,LANG=COBOL, X


010000 STORAGE=AUTO,TIOAPFX=YES
020000 HEADER DFHMDI SIZE=(24,80),CTRL=(PRINT,FREEKB)
020010 DFHMDF POS=(04,15),ATTRB=(ASKIP,NORM),LENGTH=15, X
020020 INITIAL='EMPLOYEE MASTER'
020100 DFHMDF POS=(08,10),ATTRB=(ASKIP,NORM),LENGTH=8, X
020200 INITIAL='CODE:'
020300 CODEDFHMDF POS=(08,20),ATTRB=(UNPROT,FSET,IC),LENGTH=4, X
020400 INITIAL='___'
020500 DFHMDF POS=(08,25),ATTRB=(PROT,NORM),LENGTH=1,
020600 INITIAL=' '
025000 DFHMDF POS=(10,10),ATTRB=(ASKIP,NORM),LENGTH=8, X
030000 INITIAL='NAME:'
030010 NAME DFHMDF POS=(10,20),ATTRB=(UNPROT,FSET),LENGTH=20, X
030020 INITIAL='__________________'
030030 DFHMDF POS=(10,41),ATTRB=(PROT,NORM),LENGTH=1, X
030040 INITIAL=' '
030100 DFHMDF POS=(12,10),ATTRB=(ASKIP,NORM),LENGTH=8, X
030200 INITIAL='ADDRESS:'
030210 ADDR DFHMDF POS=(12,19),ATTRB=(UNPROT,FSET),LENGTH=20, X
030220 INITIAL='____________________'
030221 DFHMDF POS=(12,40),ATTRB=(PROT,NORM),LENGTH=1, X
030222 INITIAL=' '
030223 DFHMDF POS=(14,10),ATTRB=(ASKIP,NORM),LENGTH=8, X
030224 INITIAL='PHONE:'
030225 PH DFHMDF POS=(14,19),ATTRB=(UNPROT,FSET),LENGTH=10, X
030226 INITIAL='____________________'
030227 DFHMDF POS=(14,30),ATTRB=(PROT,NORM),LENGTH=1, X
030228 INITIAL=' '
_______________________________________________________________________________
CICS Training Material Revision 2.0
35
CICS Training Material
_______________________________________________________________________________
030229 DFHMDF POS=(16,10),ATTRB=(ASKIP,NORM),LENGTH=20, X
030230 INITIAL='DATE OF BIRTH'
030231 DOB DFHMDF POS=(16,31),ATTRB=(UNPROT,FSET),LENGTH=10, X
030232 INITIAL='____________________'
030233 DFHMDF POS=(16,42),ATTRB=(PROT,NORM),LENGTH=1, X
030234 INITIAL=' '
030240 MSG DFHMDF POS=(21,03),ATTRB=(PROT),LENGTH=40
030300 FHMDF POS=(24,10),ATTRB=(ASKIP,BRT),LENGTH=20, X
030400 INITIAL='PF1 HELP PF3 EXIT'
035100 DFHMSD TYPE=FINAL
997000 END

3.6. Sending a Map to the Screen


3.6.1.SEND MAP Command

EXEC CICS
SEND MAP(Mapname)
[MAPSET(Mapsetname)]
[MAPONLY|DATAONLY]
[FROM(data-area)]
[LENGTH(data-value)]
[ERASE | ERASEUP]
[FREEKB]
[FRSET]
END-EXEC
Exception Conditions : INVMPSZ - Specified map is too wide for the terminal.
INVREQ - Not a valid request (Check for errors)

Mapname and Mapsetname are self-explanatory.


DATAONLY Sends only application data to the screen (without the other items on
the screen)
MAPONLY Sends only the map to the screen with the default map data (without
any application program data). If this option is specified, FROM
option cannot be specified.
FROM Specifies the data area containing the data to be processed. If not
specified, the name defaults to the name of the mapset suffixed with
“O”. (MAPNAM1O)
LENGTH Specifies the length of the data area to be formatted (should be
specified if the data area is longer than the length of the field)
ERASE Specifies that the screen is to be cleared and cursor positioned in the
upperleft corner of the screen.

_______________________________________________________________________________
CICS Training Material Revision 2.0
36
CICS Training Material
_______________________________________________________________________________
ERASEUP Erase only the unprotected fields.
FREEKB Specifies that the 3270 keyboard should be unlocked after the map is
sent. If not specified, the keyboard remains locked.
FRSET Set MDT flags of all the fields to ‘0’.

3.6.2. SEND MAP coding alternatives

• Using constants in the name field for MAP and MAPSET (FROM is not
required)

Eg.
SEND MAP(‘MAP1’) MAPSET(‘SET1’)
Using variables in the name field for MAP and MAPSET (This makes FROM(data-
area) a required parameter)

Eg. MOVE ‘MAP1’ TO MAPVAR.


MOVE ‘SET1’ TO SETVAR.
SEND MAP(MAPVAR) MAPSET(SETVAR) FROM(MAP1O)

1. Using only the MAP parameter.


In this case the name in the MAP option must be the MAPSET name. i.e both MAP
& MAPSET names are same.

Eg. SEND MAP (‘SETA’)

3.7. Extended Attributes

If the color or highlighting of a field has to be changed, additional symbolic fields are
needed which are called the EXTENDED ATTRIBUTES
Coding DSATTS (for symbolic map) and MAPATTS (for physical map) parameters in
the BMS macro definitions allows the use of extended attribute characteristics.
MAPATTS parameter allows you to set up the physical map with any of the
characteristic(s) coded.
DSATTS parameter creates appropriate suffixed labels for the attribute
characteristic(s) coded.

3.8. Cursor Positioning


3.8.1. Static Positioning.

IC is Insert cursor. If IC option is specified in the ATTRB field of DFHMDF


macro, the cursor will be placed at this field. If IC is specified in more than one
field of a map, then the cursor will be placed in the last field.

_______________________________________________________________________________
CICS Training Material Revision 2.0
37
CICS Training Material
_______________________________________________________________________________

3.8.2. Dynamic/Symbolic Positioning

Place -1 into the field-length field (“L” suffix) of the required field before the
SEND MAP command. Cursor will be placed at this field when the map is sent.
Example:
Move –1 to AddressL
Perform send-map
The above example will place the cursor at address field. The addressL will be
defined in the symbolic map.

3.8.3. Dynamic/Relative Positioning

CURSOR (data-value) option is used.


Data-value will have the value at which the cursor has to be positioned.
Eg. EXEC CICS SEND
MAP (.........)
MAPSET (....)
CURSOR (100)
ERASE
END-EXEC.

3.9. SEND CONTROL command

This is used to send device controls to a terminal without any map or data. Commonly,
this is used to clear a screen at the end of a transaction, or before sending a map.

EXEC CICS
SEND CONTROL [ERASE]
[FREEKB]
END-EXEC

3.10. Common CICS Program Declarations


WORKING-STORAGE SECTION.
COPY DFHAID.
COPY DFHBMSCA.
COPY MAPSET1.

COPY DFHAID Declares Attention Identifier (AID) constant. Attention identifier (AID)
indifcates which method the terminal operator has used to initiate the transer of information
from the terminal devices to CICS. Used to trap PF,ENTER, CLEAR Keys etc. The
DFHAID member contains the following AID codes :
DFHENTER, DFHCLEAR, DFHPA1 to DFHPA3, DFHPF1 to DFHPF12.
_______________________________________________________________________________
CICS Training Material Revision 2.0
38
CICS Training Material
_______________________________________________________________________________
The EIBAID field can be tested after each terminal control (or BMS) input operation.
Eg:Exec CICS Receive Map(…) Mapset(…) ..End-exec.
If EIBAID = DFHPF1 perform Update-routine.
Execution results: If PF1 function key is pressed, then upate-routine paragraph will be
performed

COPY DFHBMSCA Declare field attribute bytes. Used to dynamically set field attributes
on Screen. See Appendix at the end of the material for more details.

COPY MAPSET1 Copy Symbolic Map into the CICS Application program.

3.11. Receiving a Map from the Screen


3.11.1. RECEIVE MAP Command

EXEC CICS
RECEIVE MAP(mapname)
[MAPSET(mapsetname)]
[INTO(data-area)]
[LENGTH(data-value)]
END-EXEC
Exception Conditions: MAPFAIL - Data received has a length of ‘0’. (when nothing is entered on the
screen)

Mapname and Mapsetname are self-explanatory.


INTO Specifies the data area into which the field values are to be written.
LENGTH Specifies the length of the data area to be formatted
Note: Make it a point to move LOW-VALUES to the INTO data-area before issuing the
RECEIVE command. This will prevent junk data from being received into the data-area.

3.11.2. RECEIVE MAP coding alternatives

• Using constants in the name field for map and mapset (INTO is not required).
This is commonly used.
Eg. RECEIVE MAP(‘MAP1’) MAPSET(‘SET1’)

• Using variables in the name field for MAP and MAPSET. This makes INTO a
required parameter.
Eg. MOVE ‘MAP1’ TO MAPVAR
MOVE ‘SET1’ TO SETVAR

_______________________________________________________________________________
CICS Training Material Revision 2.0
39
CICS Training Material
_______________________________________________________________________________
RECEIVE MAP(MAPVAR) MAPSET(SETVAR) INTO(MAP1I)

• Using only the MAP parameter. In this case the name in the MAP option must
be the MAPSET name.

Eg. RECEIVE MAP (‘SET1’)

AID/CURSOR

On a RECEIVE MAP, CICS updates the EIB with the following information:
• The screen cursor position relative to zero is placed in EIBCPOSN.
• The name of the input key the terminal operator pressed is placed in the field
EIBAID.

3.11.4. AID/CURSOR sample coding

WORKING-STORAGE SECTION.
COPY DFHAID.
.......
PROCEDURE DIVISION.
IF EIBAID=DFHPF12 THEN
........
IF EIBAID=DFHENTER THEN
.......
IF EIBCPOSN LESS THAN 80 THEN
........

When a program is invoked through a transaction, the EIBAID and EIBCPOSN fields of
the EIB can be checked prior to issuing a RECEIVE MAP command. This enables the
program to take action depending upon the key pressed or depending upon the cursor
position.
If the operator uses any PA key or presses the CLEAR key, no data is transmitted.
EIBAID is useful when function keys are defined for the user. For eg.
PF12 may be the exit function
PF3 may be an update function etc.
EIBCPOSN can be used to determine where the cursor was positioned on the screen.

3.11.5. CURSLOC

_______________________________________________________________________________
CICS Training Material Revision 2.0
40
CICS Training Material
_______________________________________________________________________________
MAPSETA DFHMSD TYPE=&SYSPARM, MODE=INOUT,TERM=ALL,
LANG=COBOL, TIOAPFX=YES, STORAGE=AUTO
MAP1 DFHMDI SIZE=(24,80),LINE=1,COLUMN=1,CURSLOC=YES
DFHMDF POS(2,1),LENGTH=4,INITIAL=‘NAME’, ATTRIB=ASKIP
NAME DFHMDF POS(2,6),LENGTH=20, ATTRB=(UNPROT, IC)
DFHMDF POS(2,27),LENGTH=1,ATTRB=PROT

CURSLOC=YES allows you to determine after a RECEIVE MAP command, which map field
had the cursor in it. CURSLOC=NO is the default
CURSLOC=(NO/YES) may be coded on the DFHMSD or the DFHMDI macro. If coded on
the DFHMSD macro, it will provide a default for all the maps in that mapset.
If CURSLOC=YES is specified, BMS will set the ‘F’ suffix field to X’02’ indicating that field
contained the cursor. If the cursor is in a field for which there is no symbolic label (i.e. a
DFHMDF with no label), the program will not be notified.
Note: The ‘F’ suffix field continues to be used to indicate the operator key pressed. The
Erase-to-End-of-Fixed (EOF) key can be identified by the field being set to X’80’.
Therefore, with CURSLOC=YES, it is possible to have both these conditions occur for the
same field, in which case the ‘F’ suffix field will contain a X’82’.

_______________________________________________________________________________
CICS Training Material Revision 2.0
41
CICS Training Material
_______________________________________________________________________________
3.12. Ending a CICS Transaction (RETURN Command)
EXEC CICS
RETURN [TRANSID(name)]
[COMMAREA(data-area)]
[LENGTH(data-area)]
END-EXEC
Exception Conditions : INVREQ - Transaction name not found.
LENGERR - Length specified is greater than the length of the COMMAREA
data-area.

EXAMPLE:
Define COMMAREA in working-stroage section as
01 COMMAREA.
02 VARS PIC X(4).

In Procredure division code


EXEC CICS
RETURN TRANSID(‘GC72’)
COMMAREA(COMMAREA)
LENGTH(LENGTH OF COMMAREAR)
END-EXEC

TRANSID: Specifies the next transaction to be invoked from here. If not specified, the
current transaction ends, and control is transferred back to CICS. Transaction name should
be a 4 letter word (Eg. “GC01”).
COMMAREA: Specifies a communication area to be made available for the next program, if
needed. This is the area used for passing data from one program to another. In the
receiving program, variable DFHCOMMAREA must be specified in the Linkage Section,
which now contains the data in the communication area. Data-area refers to an area
defined in the Working-Storage section of the calling program.
LENGTH: The length of the COMMAREA.

3.13. Multipage message with Single Panel


The Multipage message with single map panel is used to send a logical message
consisting of a series of single map panels (called pages).
For the Operations of multipage message with single map panel, the application program
must follow the following:

Issue the SEND MAP command with ACCUM and PAGING Options, which accumulates
the map as a multipage message.
Repeat step 1 until all maps are accumulated
Issue the SEND PAGE Command, which sends the entire maps as one logical message.

_______________________________________________________________________________
CICS Training Material Revision 2.0
42
CICS Training Material
_______________________________________________________________________________

Example

ACCUM-PARA.
EXEC CICS SEND MAP (‘HEADER’)
MAPSET (‘map072’)
ERASE
ACCUM
PAGING
END-EXEC.

PAGE-RTN.

EXEC CICS SEND PAGE END-EXEC.

The above Send command will do page accumulation but will not send the actual screen.
At the completion of SEND PAGE Command a series of maps/screens are actually sent to
the terminal as one logical message.

Sample Program for Sending and Receiving MAP


Sample program 1

_______________________________________________________________________________
CICS Training Material Revision 2.0
43
CICS Training Material
_______________________________________________________________________________
IDENTIFICATION DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
COPY DFHAID.
COPY DFHBMSCA.
COPY MAPSET1. (structure of MAPSET1 will be similar to the one described earlier.
PROCEDURE DIVISION.
EXEC CICS
SEND MAP(MAPNAM1)
MAPSET(MAPSET1)
FREEKB
ERASE
FROM(MAPNAM1O)
END-EXEC.
MOVE LOW-VALUES TO MAPNAM1I.
EXEC CICS
RECEIVE MAP(MAPNAM1)
MAPSET(MAPSET1)
INTO(MAPNAM1I)
END-EXEC.
EXEC CICS
RETURN
END-EXEC.

This program will send the map MAPNAM1 to the screen, wait for the user to enter data,
and when the user presses the ENTER key, receives the map, and ends the transaction,
returning the control to CICS.
RECEIVE MAP is executed only when the user presses any of the function keys or the
ENTER key. Till then, the program waits endlessly.

Sample program 2

440000 IDENTIFICATION DIVISION.


460000 PROGRAM-ID. TRGXXXP1.
480000 ENVIRONMENT DIVISION.
540000 DATA DIVISION.
540100 WORKING-STORAGE SECTION.
540200 COPY MAP1.

_______________________________________________________________________________
CICS Training Material Revision 2.0
44
CICS Training Material
_______________________________________________________________________________
600000 PROCEDURE DIVISION.
660100 MAIN-PROC.
790102 PERFORM SEND-MAP
790105 PERFORM RECEIVE-MAP
790106 EXEC CICS RETURN END-EXEC.
790108 GOBACK.
790111 SEND-MAP.
790112 MOVE LOW-VALUES TO HEADERO.
790113 EXEC CICS
790114 SEND MAPSET('MAPXXX') MAP('HEADER') FROM(HEADERO)
790120 ERASE
790200 END-EXEC.
930100 RECEIVE-MAP.
930200 EXEC CICS
930300 RECEIVE MAPSET('MAPXXX') MAP('HEADER') INTO(HEADERO)
930400 END-EXEC.
*********************************** Bottom of Data ****************************

3.14. Pseudo Conversational Applications


Three techniques are available in order to develop the pseudo-conversational
transaction. They are

• Multiple transaction identifiers and multiple programs. Multiple PCT (for


transaction identifiers) and Multiple PPT (for programs) entries to be registered
in CICS tables to execute the job. A conversational program is divided into
separate programs after sending a message and before receiving the
message. For each separate program, a unique CICS transaction identifier is
assigned. Before terminating the program, each program issues the RETURN
command with the next transaction identifier which is associated with the next
program, unless it is a last return to CICS itself. In this, a series of terminal
conversations can be carried out continuously. The disadvantage is more
number of PPT and PCT entries are used.

• Multiple transaction identifiers and one program:.This is same as


Technique 1 but instead of dividing into separate programs ,these separate
programs are combined into one physical program,which has two functional
routines to achieve the same functions as the physically separte programs in
technique 1. Other areas are same as technique 1.Here Multiple PCT (for
transaction identifiers) and One PPT(for a program) entries to be registered in
CICS tables to execute the job. Here also disadvantage is resources used by
entering more PCT and a PPT in CICS Table(s).

_______________________________________________________________________________
CICS Training Material Revision 2.0
45
CICS Training Material
_______________________________________________________________________________
• One Transaction identifier and one program: This technique is the best out
of all the three because the entries in CICS Tables are one PPT and one PCT
like our normal conversation but not wasting the time by waiting for user
response. Here we use same program & transaction identifier in TRANSID of
RETURN command with Communication area (COMMAREA) to pass
information.

Example: If your program TRGXXXP1 is Associated with transaction identifier


GCXX

EXEC CICS RETURN TRANSID (‘GCXX’)


COMMAREA (COMMAREA)
END-EXEC.
Pseudo-conversation is the most commonly implemented method of applications. Assume
2 transactions:

TRN1 - Program1 TRN2 - Program2


Send Receive
Return TRANSID (TRN2) Send
Return

Return Transid will terminate the transaction and specify TRN2 as the next transaction.
When operator enters data and presses the ENTER key, the transaction TRN2 will
automatically start (a new task is initiated), and program2 will be invoked.

3.14.1. Passing Data to the next task

COMMAREA
• COMMAREA is a very important concept while developing CICS applications.
It is used for passing data from one pseudo-conversational task to another or
while linking one program to another.
• A COMMAREA is a CICS maintained unit of storage for passing and receiving
data between CICS programs
• The first time a COMMAREA is passed, it must be defined as an area of
storage in the working storage section of the program passing the
COMMAREA.
• The RETURN command has a parameter for passing a COMMAREA to the
program associated with the subsequent transaction.
• The subsequent program (the receiver of the COMMAREA) must define a
variable called DFHCOMMAREA in its LINKAGE SECTION. Once this is done,
it will automatically access the COMMAREA fields.

3.14.2. Returning to the same program

♦ In the previous example, by coding RETURN TRANSID (TRN1) instead of


RETURN TRANSID(TRN2), Program1 can hand over control to itself once the
operator presses the ENTER key.

_______________________________________________________________________________
CICS Training Material Revision 2.0
46
CICS Training Material
_______________________________________________________________________________
♦ In this case, Program1, as both the sender and the receiver of the
COMMAREA, needs the Working-Storage Section definition to SEND and the
Linkage Section definition of DFHCOMMAREA to RECEIVE.
♦ Also, Program1 must be able to distinguish between the FIRST TIME entry into
the program when there is no COMMAREA, and subsequent times when
COMMAREA data exists in the Linkage Section. This is done using the
EIBCALEN field of the EIB.

3.14.3. EIBCALEN

• Is a part of Execute interface block (EIB) .The EIBCALEN field is included in


DFHEIBLK copy library, which is automatically copied into CICS application
program by CICS translator and compiler.
• Contains the length of the COMMAREA field.
• The first time it exists in a program, COMMAREA does not exist; therefore
EIBCALEN =0
• While returning the control to CICS, the working storage data is sent via the
COMMAREA parameter in the RETURN TRANSID.
• On subsequent entry into the program, COMMAREA exists, and is
automatically made accessible to CICS through the Linkage Section. The
EIBCALEN field contains the length of the DFHCOMMAREA.
• Thus, if EIBCALEN = 0, it is a first time entry, and if > 0, it is not the first time.

3.15. Structure of a sample Application Program


Sample pseudoconversational program:
Sample Program 1:

_______________________________________________________________________________
CICS Training Material Revision 2.0
47
CICS Training Material
_______________________________________________________________________________
IDENTIFICATION DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
COPY DFHAID.
COPY DFHBMSCA.
COPY MAPSET1. (structure of MAPSET1 will be similar to the one described earlier.
01 WS-COMMAREA PIC X(1) VALUE ‘A’.
LINKAGE SECTION.
01 DFHCOMMAREA PIC X(1).
PROCEDURE DIVISION.
IF EIBCALEN = 0
EXEC CICS
SEND MAP(MAPNAM1)
MAPSET(MAPSET1)
FREEKB
ERASE
FROM(MAPNAM1O)
END-EXEC
EXEC CICS
RETURN TRANSID(‘E01A’)
COMMAREA(WS-COMMAREA)
END-EXEC
ELSE
MOVE LOW-VALUES TO MAPNAM1I
EXEC CICS
RECEIVE MAP(MAPNAM1)
MAPSET(MAPSET1)
INTO(MAPNAM1I)
END-EXEC
EXEC CICS
RETURN
END-EXEC
END-IF.

Sample Program 2:

_______________________________________________________________________________
CICS Training Material Revision 2.0
48
CICS Training Material
_______________________________________________________________________________
440000 IDENTIFICATION DIVISION.
460000 PROGRAM-ID. TRGXXXP1.
460100 *THIS SAMPLE CONVERSATION PROGRAM SEND SCREEN AND
460200 *RECEIVE DATA FROM SCREEN USING PSEUDO CONVERSATION
480000 ENVIRONMENT DIVISION.
540000 DATA DIVISION.
540100 WORKING-STORAGE SECTION.
540110 COPY MAP1.
540200 01 COMMAREA.
540210 02 VARS PIC X(4).
540255 LINKAGE SECTION.
540256 01 DFHCOMMAREA.
540257 02 VARS PIC X(4).
600000 PROCEDURE DIVISION.
660100 MAIN-PROC.
660200 IF EIBCALEN = 0
790102 PERFORM SEND-MAP
790103 PERFORM RETURN-TRANS
790104 ELSE
790105 PERFORM RECEIVE-MAP.
790106 PERFORM TRANS-END.
790111 SEND-MAP.
790112 MOVE LOW-VALUES TO HEADERO.
790113 EXEC CICS
790114 SEND MAPSET('MAPXXX') MAP('HEADER') FROM(HEADERO)
790120 ERASE
790200 END-EXEC.
930100 RECEIVE-MAP.
930200 EXEC CICS
930300 RECEIVE MAPSET('MAPXXX') MAP('HEADER') INTO(HEADERO)
930400 END-EXEC.
930500 RETURN-TRANS.
930600 EXEC CICS RETURN
930700 TRANSID('GCXX')
930800 COMMAREA(COMMAREA)
930900 LENGTH(LENGTH OF COMMAREA)
931000 END-EXEC.
931100 TRANS-END.
931200 EXEC CICS RETURN END-EXEC.
931300 GOBACK.
*********************************** Bottom of Data ****************************

3.16. Exercise

_______________________________________________________________________________
CICS Training Material Revision 2.0
49
CICS Training Material
_______________________________________________________________________________
1 Design a screen for accepting two numbers from the user and displaying t he
sum on the screen. Write a program to send this screen, receive input, and
send the output. Write the program in both conversational and pseudo
conversational methods.

1. Design a mapset with 3 maps – a header map, a body map, and a message
map. The header should display the current date and time on the right top
corner, and the user-id on the left. The body map should contain a screen for
receiving two nos. and displaying the sum. The message map should appear
in the bottom and display messages if any. Write a CICS program to send the
header, the body, and the message maps. If user presses the ENTER key
without any data, the time should be updated automatically. If the user enters
any wrong data, message should be displayed.

3.17. Passing control to other programs


3.17.1 Application program logical levels

CICS Programs run under various levels.


• The first program runs at the highest level.
• Other programs can be invoked using either the LINK or the XCTL command.
A LINKed program runs at the next lower logical level, while a XCTLed
program runs at the same level.
• RETURN command passes control back to the program at one logical level
higher.

Thus a LINKed program returns to the original program, at the instruction following the
LINK command, while an XCTLed program doesn’t return to the calling program.

Logical levels
CICS
0

Prog A Prog B
XCTL B LINK C 1
RETURN RETURN

Prog C Prog D
XCTL D LINK xx
2
RETURN RETURN

The Program A (Prog A) is at the logical level 1,so that the RETURN command in Prog A
will cause control to be returned to CICS itself at the level 0. Since Program A issues the
XCTL command for program B will be at the level 1.Therefore the RETURN command in
_______________________________________________________________________________
CICS Training Material Revision 2.0
50
CICS Training Material
_______________________________________________________________________________
prog B will also control to be returned to CICS itself as level 0, not prog A at level 1.Since
prog B issues the LINK command for PROG C, program C will be the level 2. Therefore the
return command in prog C will be cause control to be returned to Prog B at the level 1.
Since prog C issues XCTL command for prog D, prog D will be at level 2.Therefore, the
RETURN command in prog D will cause control to be returned to prog B at the level 1,not
at level 2.

Data may be passed between the two programs through the COMMAREA option of the
LINK or XCTL command
• Program1 issues LINK to Program2.
• The LINKed program Program2 runs at a new logical level and returns back to
the LINKing program.
• Program2 obtains the Commarea data through a variable DFHCOMMAREA
coded in its Linkage Section.
• When Program2 issues RETURN, control passes back to Program1.

3.17.2. LINK command

The LINK Command is used to pass control from Main application program at one logical
level to another subprogram at the next logical level. The Main program expects control to
be returned back from subprogram. This is achieved by RETURN Command given in
subprogram. After executing the LINK command in Main program ,the program will execute
the next statement .The COMMAREA is to communicate data from main program to
subprogram and the LENGTH is length of the COMMAREA.

EXEC CICS
LINK PROGRAM (pgmname)
[COMMAREA (ws-commarea)]
[LENGTH (ws-length)]
END-EXEC
Exception Conditions - NOTAUTH -- Security check
PGMIDERR – Program specified is not found in PPT
Eg. EXEC CICS LINK PROGRAM (PROG1) COMMAREA (WS-COMMAREA)
END-EXEC

3.17.3. XCTL Command

The XCTL Command is used to pass control from Main application program at one logical
level to another program at the same level. Main program doesn’t expect control to be
returned back from subprogram. The COMMAREA is to communicate data from main
program to next program and the LENGTH is length of the COMMAREA. After the
execution of XCTL Command, Control willl not return back to main program. This command
has less overheads so that performance is better when compared to LINK Command.

_______________________________________________________________________________
CICS Training Material Revision 2.0
51
CICS Training Material
_______________________________________________________________________________
EXEC CICS
XCTL PROGRAM (pgmname)
[COMMAREA (ws-commarea)]
[LENGTH (ws-length)]
END-EXEC
Exception Conditions - NOTAUTH - Security check
PGMIDERR - Program specified is not found in PPT
LENGERR - Occurs when length specified is greater than the
Length of data area specified in commarea.

Example

EXEC CICS LINK PROGRAM('TRGXXXP1') COMMAREA(W-AREA) END-EXEC.


EXEC CICS XCTL PROGRAM('TRGYYYP1') COMMAREA(W-AREA) END-EXEC.

Where W-AREA is defined in Working storage.

_______________________________________________________________________________
CICS Training Material Revision 2.0
52
CICS Training Material
_______________________________________________________________________________

4. FILE HANDLING

4.1. Introduction
CICS allows a program to access data files in a variety of ways. In an online system most
file accesses are random because the transactions to be processed are generally not
grouped together. The CICS file Control Program provides application programs with
services to Read, Write, Rewrite and Delete records in a file.
In addition, it makes application programs independent of the database structure, manages
exclusive control over the record in order to maintain data integrity during record updates.

4.1.1. Special Services of file control

Data independence is a concept of program being independent of the database structure


or the data access methods. CICS achieves this by eliminating from the application
programs the following COBOL statements and JCL parameters such as:

Input-Output Section

SELECT statement

FD Statement

Open/Close Statement

JCL Parameters

The system programmer defines the File Control Table (FCT) to specify the characteristics
of files to be used under CICS while the application programmer simply codes the relative
file control commands in the program. The access method being used is transparent to the
application programmer.

4.1.2. Exclusive control during updates

If a task is updating a record the other tasks must be restrained from accessing that record
till the task is completed. This control is called exclusive control over the resources during
updates. In CICS environment many tasks might be concurrently accessing the same file or
record.

CICS will secure exclusive control of the Control Interval where the record to be updated
resides in the VSAM file so that nobody else can access the same record or control interval
until the record is rewritten,deleted or the program issues an UNLOCK commandor the task
terminates.

4.1.3. File Open / Close

_______________________________________________________________________________
CICS Training Material Revision 2.0
53
CICS Training Material
_______________________________________________________________________________
When an application program accesses a file, the file must be open under CICS . For this
FCT defines a file open / close status.

Files are not opened and closed by the application program, instead they are opened and
closed in the following manner:

a. Files that are used by all applications may be opened when CICS
is initialised at the beginning of the day and closed when CICS is
terminated.
b. The users may actually open and close files many times during
the day using the Master Terminal Transaction (CEMT)

4.2. VSAM Datasets


CICS refers to the VSAM dataset by means of a logical filename. Entry for the VSAM file
has to be defined in the FCT (File Control Table). Each entry contains all descriptive
information for the file it represents, including the actual dataset it refers to. The
programmer needs to know only the name of the logical file and the physical dataset.name.
He then defines the dataset as per his requirements.
The FILE parameter coded in the program must refer to the file name defined in the FCT.
CICS uses the following VSAM structures.

• Key Sequenced Data Set (KSDS)


• Entry Sequenced Data Set (ESDS)
• Relative Record Data Set (RRDS)

Files are opened by CICS :

• Immediately after system initialization if specified in the FCT.


• In response to a file access request from an application if the file is closed.
• In response to a master terminal CEMT request from an operator.
• Application program is not responsible for open / close of files operation.

4.2.1. Program Organization

Working-Storage Section.
File record description, including the record key. (no FD entries)
Procedure Division.
Move value of the record key to be read to the record key field.
EXEC CICS READ FILE(filename)

4.2.2. Recrod Identification (RIDFLD) for VSAM dataset


Key of the record to be read is specified in the RIDFLD.
It can specify ,
• RECORD KEY
• RELATIVE BYTE ADDR.
• RELATIVE RECORD NUM.

_______________________________________________________________________________
CICS Training Material Revision 2.0
54
CICS Training Material
_______________________________________________________________________________
• PARTIAL KEY
For KSDS Key specified can be a full key or partial key.
If partial key, keylength has to be provided.
RBA (Relative Byte Address) can also be used instead
of actual key value.
For ESDS RIDFLD contains a 4 byte RBA.
For RRDS RIDFLD contains 4 Byte binary Relative Record
Number. (RRN)
Example

WORKING-STORAGE SECTION.
05 RECKEY PIC X(6).
PROCEDURE DIVISION.
MOVE value TO RECKEY.
RIDFLD must be set to the value of the key of the record to be retrieved.
RIDFLD must be large enough to hold a full record key even when a partial key is
used.

4.2.3. Common exception conditions for File Handling Commands

DISABLED File is disabled. Enable it using SET FILE command.


DUPKEY More than one record with the same key is present in the file
while reading.
FILENOTFOUND File specified is not found in FCT
NOTAUTH Security check failed for the file.
NOTOPEN File is not open. Set the file open using SET FILE command.

4.2.4. READ Command

With INTO option (Full Key)


EXEC CICS
READ FILE(filename)
[UPDATE]
INTO(data-area)
[LENGTH(data-area)]
RIDFLD(data-area)
END-EXEC

INTO Names the field in the working storage section where the data has to be
placed.
RIDFLD The Record Identification field Can be a KEY (KSDS), RBA (ESDS), RRN
(RRDS)

_______________________________________________________________________________
CICS Training Material Revision 2.0
55
CICS Training Material
_______________________________________________________________________________
LENGTH Half-word binary. It indicates maximum length of the record to be read. It is
optional. Compulsory for Variable length records.
UPDATE File is to be read for Update or Delete operation.

4.2.4.1. With GTEQ option


Used to read a non-specific record whose key is equal to or greater than the full key data specified.
EXEC CICS
READ FILE(filename)
INTO(data-area)
RIDFLD(REC-KEY)
LENGTH(WS-LEN)
GTEQ
END-EXEC
4.2.4.2. With GENERIC option

_______________________________________________________________________________
CICS Training Material Revision 2.0
56
CICS Training Material
_______________________________________________________________________________
Used to read a nonspecific record based on the generic key (i.e, a higher part of key) specified,
instead of full key.This can be used when you don’t know the complete information of the key.

EXEC CICS
READ FILE(filename)
INTO (data-area)
RIDFLD(REC-KEY)
KEYLENGTH(3) -------> specifies length of Generic key. It must be specified.
GENERIC
LENGTH(WS-LEN)
END-EXEC

EXAMPLE:

MOVE 80 TO WK-LEN
MOVE ‘BAG’ TO REC-KEY
EXEC CICS
READ FILE(‘TRGXXXF1’)
INTO (REC1)
RIDFLD(REC-KEY)
KEYLENGTH(3)
GENERIC
LENGTH(WS-LEN)
END-EXEC

Execution results: Suppose the file TRGXXXF1 has the following records in order

ARG112
ARG111
BAG110 - This record, the first record of the generic key ‘BAG’ ,will be read
first
BAG112

4.2.4.3. Exception conditions for READ command

INVREQ -READ or READ with UPDATE not allowed according to FCT


-READ UPDATE issued without releasing the lock held.
-The keylength and generic options are specified but the length specified is
greater than or equal to length of full key.
LENGERR The length of record read exceeds the length specified
_______________________________________________________________________________
CICS Training Material Revision 2.0
57
CICS Training Material
_______________________________________________________________________________
NOTFND Record not found

Example
MOVE 50 to WS - LEN.
MOVE ‘BAG’ TO REC-KEY.
EXEC CICS READ
FILE(‘FILEAAA’)
INTO(data-area)
RIDFLD(REC-KEY)
KEYLENGTH(3)
GENERIC
LENGTH (WS-LEN)
END-EXEC.
DATA IN FILE: BAG 112
BAG 111
BAG 110
This record will be read BAG 112 as this is the first record with generic key ‘BAG’.

WRITE command

_______________________________________________________________________________
CICS Training Material Revision 2.0
58
CICS Training Material
_______________________________________________________________________________
EXEC CICS
WRITE FILE(filename)
FROM(data-area)
LENGTH(data-value)
RIDFLD(data-area)
[KEYLENGTH (data-value)
[MASSINSERT]
END-EXEC
Exceptional Conditions : INVREQ WRITE not allowed
WRITE issued for a file opened with READ/UPDATE
DISABLED,DUPREC,FILENOTFOUND,NOSPACE,NOTAUTH,NOTOPEN

The MASSINSERT option is used when adding multiple records in ascending key
sequence. This option is coded for every write command in a series of writes. Mass insert
operation must be terminated by issuing the UNLOCK command.

4.2.5.1. UNLOCK Command

To release exclusive control of the record established by the previous READ command with
UPDATE option

EXEC CICS
UNLOCK FILE(filename)
END-EXEC
Exception Conditions : DISABLED, FILENOTFOUND, NOTAUTH, NOTOPEN

4.2.6. REWRITE Command

The primary key cannot be modified. This command must be preceded by a READ
UPDATE command

_______________________________________________________________________________
CICS Training Material Revision 2.0
59
CICS Training Material
_______________________________________________________________________________
EXEC CICS REWRITE FILE(filename)
FROM(data-area)
LENGTH(data-value)
END-EXEC
Exceptional Conditions :DUPREC Attempt to rewrite a record with duplicate key
INVREQ REWRITE tried without previous READ UPDATE
command
NOSPACE No space available for updating the record
FILENOTFOUND, NOTOPEN, NOTAUTH can also occur.
Data-value in LENGTH option is the length of the new record

DELETE

Group Delete Approach


In this case DELETE is issued with a GENERIC option

EXEC CICS
DELETE FILE(filename)
RIDFLD(data-area)
KEYLENGTH(data-value)
GENERIC
NUMREC(data-area)
END-EXEC
Exception Conditions : INVREQ DELETE not allowed
DELETE without RIDFLD and without prior READ/UPDATE
DELETE issued for an ESDS
DELETE with RIDFLD for file opened with READ/UPDATE
DISABLED, DUPKEY, FILENOTFOUND, NOTAUTH, NOTOPEN can also
occur.
NUMREC data-area contains the number of records deleted on a GENERIC DELETE. A
half-word binary field S9(4) COMP should be provided to NUMERIC.

KEYLENGTH indicates the length of the generic key. Higher part of the key information
must be supplied in the RIDFLD.
Records cannot be deleted from an ESDS.

4.2.7.2. Delete after Read/Update approach


This command follows READ with UPDATE option. This deletes the record just read

_______________________________________________________________________________
CICS Training Material Revision 2.0
60
CICS Training Material
_______________________________________________________________________________
EXEC CICS
READ FILE(filename)
UPDATE
INTO(data-area)
LENGTH(data-area)
RIDFLD(data-area)
END-EXEC
EXEC CICS
DELETE FILE(Filename)
END-EXEC
Direct Delete

Here the RIDFLD is provided and the corresponding record is deleted. Cannot be used if a
READ UPDATE command is pending on the file.

EXEC CICS
DELETE FILE(filename)
END-EXEC
EXEC CICS
DELETE FILE (name)
RIDFLD(data-area)
END-EXEC
Exceptional Conditions
INVREQ Delete operation is not allowed on the file.

Read with update operation is pending on the file.


NOTFND Record not found.

Example:

MOVE ‘BAG001’ TO REC-ID


EXEC CICS
DELETE FILE(‘TRGXXXF1’)
RIDFLD(REC-ID)
END-EXEC

4.2.8.Deadly Embrace
One transaction needs exclusive use of some resource held by a second transaction and
the second transaction cannot release the resource because it is waiting for some resource
held by the first.
Only way of breaking the deadlock is to cancel one or both the transactions.
_______________________________________________________________________________
CICS Training Material Revision 2.0
61
CICS Training Material
_______________________________________________________________________________

4.2.9.Consideration for avoiding Deadlocks

• Online mass updates/deletes should be avoided. Batch jobs should be used.


READ UPDATE command should be paired with REWRITE, DELETE or UNLOCK
commands

4.2.10.Browse VSAM Datasets

Establish
Position

Retrieve Next
Record
Yes
Yes
No
Process Record
Process
No
No
Change End of Browse
Position
Yes

Terminate Browse

♦ Establish position
♦ Retrieve and process records
♦ Terminate browse.
♦ Record retrieved as a part of browse cannot be updated during browse.

4.2.10.1. Browse Commands

STARTBR The STARTBR command is used to Establish a browse starting position for
a file.This command is for establishing the position only. The actual record will be read by
the READNEXT or READPREV commands.

_______________________________________________________________________________
CICS Training Material Revision 2.0
62
CICS Training Material
_______________________________________________________________________________

READPREV The READPREV command is used to read a record from a file


backward.The STARTBR command should have been issued before this command and
should successful.If you specify the command in a perform loop it will read previous records
till end of file condition or till the condition specified in perform statement is reached.

READNEXT The READNEXT command is used to read a record from a file sequentially
forward.The STARTBR command should have been issued before starting the command
and should be successful. If you specify the command in a perform loop it will read records
forward till end of file condition or till the condition specified in perform statement is
reached.

RESETBR The RESETBR command is used to reestablish another starting point within
the same browse operation against the same file.Otherwise the RESETBR performs
exactly same as the STARTBR command.

ENDBR This command is to terminate the browse operations.At the end of the
STARTBR or RESETBR command operations this command has to be issued to end the
browse operations.

4.2.10.2. STARTBR Command

EXEC CICS
STARTBR FILE(filename)
RIDFLD(data-area)
[GTEQ | EQUAL]
[KEYLENGTH(data-value) [GENERIC]]
END-EXEC
Exception Conditions : INVREQ Browse operations not allowed
KEYLENGTH value is less than 0 or greater than file length
DISABLED, DUPKEY, NOTOPEN, NOTAUTH, NOTFND,FILENOTFOUND
can also occur.

GTEQ If no record is found for exact key, CICS places position on the next
available record. Default for a KSDS or RRDS.
EQUAL If no record is found for the exact key, exceptional conditionoccurs.
NOTFND Default for an ESDS.
GENERIC Places the position at the first record satisfying the partial key.

4.2.10.3.READNEXT command

To read a record of a file sequentially forward. STARTBR must have been successfully
completed before READNEXT command.
_______________________________________________________________________________
CICS Training Material Revision 2.0
63
CICS Training Material
_______________________________________________________________________________

EXEC CICS
READNEXT FILE(filename)
INTO(data-area)
LENGTH(data-value)
RIDFLD(data-area)
END-EXEC
Exception Conditions : INVREQ READNEXT issued without a previous successful STARTBR
KEYLENGTH value is less than 0 or greater than file length
ENDFILE End of file reached during BROWSE
DUPKEY, NOTAUTH, NOTFND, FILENOTFOUND can also occur.

4.2.10.4. READPREV Command


To read records of a file sequentially backward. STARTBR must have been successfully
completed before READPREV command.
Options, parameters and exception conditions are same as for READNEXT command.

4.2.10.5. RESETBR Command


To re-establish another starting point within the same browse operation against the same
file.
Performs same function as STARTBR without the need to issue ENDBR.

EXEC CICS
RESETBR FILE(filename)
RIDFLD(data-area)
[KEYLENGTH(data-value) [GENERIC]]
[GTEQ|EQUAL]
END-EXEC
Exception Conditions : INVREQ RESETBR issued without previous STARTBR
FILENOTFOUND, NOTAUTH, NOTFND

Explanations for these options, and the exception conditions possible are same for
STARTBR.
EXAMPLE
startbr command
readnext command
MOVE ‘TRG’ to REC-KEY
EXEC CICS RESETBR FILE(‘FILEAAA’)
RIDFLD(REC-KEY)
GTEQ
_______________________________________________________________________________
CICS Training Material Revision 2.0
64
CICS Training Material
_______________________________________________________________________________
END-EXEC.
Browse operation is reset to TRG111. (for the same sample data given for the READ FILE
command)

4.2.10.6. ENDBR Command


To terminate the browse operation initiated by a prior STARTBR command.

EXEC CICS
ENDBR FILE(name)
END-EXEC
Exception Conditions : INVREQ ENDBR issued without previous STARTBR
NOTAUTH, FILENOTFOUND

4.2.10.7. Multiple Browse Operations

• Several concurrent browse operations can be performed against the same file.
Each browse operation is to be identified by the REQID parameter in the
browse commands.
• Other parameters and options remain the same as for the single browse
operation.
Example
Operation (1)
MOVE ‘ARG’ to REC-KEY-1.
EXEC CICS STARTBR
FILE (‘FILEAAA’)
REQID(1)
RIDFLD(REC-KEY-1)
GTEQ
END-EXEC.
Operation (2)
MOVE ‘BAG’ TO REC-KEY-2.
EXEC CICS STARTBR
FILE (‘FILEAAA’)
REQID(2)
RIDFLD(REC-KEY -2)
GTEQ
END-EXEC.

_______________________________________________________________________________
CICS Training Material Revision 2.0
65
CICS Training Material
_______________________________________________________________________________
Operation (1)
EXEC CICS READNEXT
FILE (‘FILEAAA’)
REQID(1)
INTO(FILE-AREA)
RIDFLD(REC-KEY-1)
END-EXEC.

Operation (2)
EXEC CICS READNEXT
FILE (‘FILEAAA’)
REQID (2)
INTO (FILE-AREA)
RIDFLD(REC-KEY-2)
END-EXEC.

Sample program

Create a VSAM-KSDS data set,record size 80, then use the below metioned CICS program
for writing data on KSDS data set.

440000 IDENTIFICATION DIVISION.


460000 PROGRAM-ID. TRGXXXP1.
480000 ENVIRONMENT DIVISION.
540000 DATA DIVISION.
540100 WORKING-STORAGE SECTION.
540210 01 COMMAREA.
540211 05 VARS PIC X(4).
540212 COPY MAP1.
540264 01 REC1.
540265 10 KEYR PIC X(4).
540266 10 NAMER PIC X(20).
540267 10 ADDRESSR PIC X(20).
540268 10 PHNOR PIC X(10).
540269 10 DOBR PIC X(10).
540270 10 FILLER1 PIC X(15).
540271 77 REC-KEY PIC 9(4).
540272 77 WS-RESP PIC S9(8) COMP.
540273 77 WS-ERR-MSG PIC X(20) VALUE "ERROR OCCURED".
540274 LINKAGE SECTION.
540275 01 DFHCOMMAREA.
540280 05 VARS PIC X(4).
600000 PROCEDURE DIVISION.
660100 MAIN-PROC.
660200 MOVE DFHCOMMAREA TO COMMAREA.
_______________________________________________________________________________
CICS Training Material Revision 2.0
66
CICS Training Material
_______________________________________________________________________________
790100 IF EIBCALEN = 0 THEN
790101 MOVE LOW-VALUES TO HEADERO
790102 PERFORM SEND-MAP
790103 PERFORM RETURN-TRANS
790104 ELSE
790105 PERFORM RECEIVE-MAP
790106 PERFORM RETURN-PARA
790107 END-IF.
790109 GOBACK.
790111 SEND-MAP.
790114 EXEC CICS
790115 SEND MAPSET('MAPXXX') MAP('HEADER') FROM(HEADERI)
790200 END-EXEC.
930100 RECEIVE-MAP.
930200 EXEC CICS
930300 RECEIVE MAPSET('MAPXXX') MAP('HEADER') INTO(HEADERO)
930400 END-EXEC.
930500 MOVE SPACES TO FILLER1.
930502 MOVE NAMEI TO NAMER.
930503 MOVE ADDRI TO ADDRESSR.
930504 MOVE PHI TO PHNOR.
930505 MOVE DOBI TO DOBR.
930506 MOVE CODEI TO REC-KEY KEYR.
930507 EXEC CICS SEND TEXT FROM(REC1) END-EXEC.
930508 EXEC CICS WRITE
930509 FILE ('TRGXXXF1')
930510 FROM (REC1)
930511 RIDFLD(REC-KEY)
930512 LENGTH(LENGTH OF REC1)
930513 RESP(WS-RESP)
930514 END-EXEC.
930515 IF WS-RESP = DFHRESP(NORMAL)
930516 CONTINUE
930517 ELSE
930518 EXEC CICS
930519 SEND TEXT FROM(WS-ERR-MSG)
930520 LENGTH(LENGTH OF WS-ERR-MSG)
930522 END-EXEC.
930523 PERFORM RETURN-PARA.
930524 RETURN-TRANS.
930525 MOVE 'TEST' TO VARS OF COMMAREA.
930526 EXEC CICS
930530 RETURN TRANSID('GCXX')
930531 COMMAREA(COMMAREA)
930532 LENGTH(LENGTH OF COMMAREA)
930540 END-EXEC.
930555 RETURN-PARA.
930560 EXEC CICS RETURN END-EXEC.
930570 GOBACK.
****** **************************** Bottom of Data ****************************

SAMPLE PROGRAM For BROWSE OPERATION

_______________________________________________________________________________
CICS Training Material Revision 2.0
67
CICS Training Material
_______________________________________________________________________________

000100 IDENTIFICATION DIVISION.


000200 PROGRAM-ID. TRGXXXP1.
000210 *THIS SAMPLE PROGRAM IS FOR LEARNING BROWSE COMMANDS
000220 *USE ESDF (DIAGNOSTIC FACILITY) TO RUN THE PROGRAM
000300 ENVIRONMENT DIVISION.
000400 DATA DIVISION.
000500 WORKING-STORAGE SECTION.
000520 COPY MAP1.
003600 01 REC1.
003700 10 KEYR PIC X(4).
003800 10 NAMER PIC X(20).
003900 10 ADDRESSR PIC X(20).
004000 10 PHNOR PIC X(10).
004100 10 DOBR PIC X(10).
004200 10 FILLER PIC X(16).
004210 77 WS-RESP PIC S9(8) COMP.
004220 77 ERRMSG PIC X(22) VALUE 'ERROR IN HANDLING FILE'.
004300 PROCEDURE DIVISION.
004400 MAIN-PROC.
004500 MOVE 'A004' TO KEYR.
004510 EXEC CICS
004520 STARTBR FILE('TRGXXXF1')
004530 RIDFLD(KEYR)
004550 END-EXEC.
004560 PERFORM READPREV-PARA
004680 IF WS-RESP = DFHRESP(NORMAL)
004682 MOVE 'A002' TO KEYR
004683 EXEC CICS
004684 RESETBR
004685 FILE ('TRGXXXF1')
004686 RIDFLD(KEYR)
004687 END-EXEC
004689 PERFORM READNEXT-PARA
004693 CONTINUE
004694 ELSE
004695 EXEC CICS
004696 SEND FROM(ERRMSG)
004697 END-EXEC.
004700 EXEC CICS
004800 RETURN
004900 END-EXEC.
005000 GOBACK.
005010 READNEXT-PARA.
005100 EXEC CICS
005200 READNEXT
005300 FILE ('TRGXXXF1')
005400 INTO (REC1)
005500 RIDFLD(KEYR)
005600 RESP(WS-RESP)
005700 END-EXEC.
005701 MOVE LOW-VALUES TO HEADERO.
005710 MOVE KEYR TO CODEO

_______________________________________________________________________________
CICS Training Material Revision 2.0
68
CICS Training Material
_______________________________________________________________________________
005720 MOVE NAMER TO NAMEO
005730 MOVE ADDRESSR TO ADDRO
005740 MOVE PHNOR TO PHO
005750 MOVE DOBR TO DOBO
005751 MOVE 'DISPLAYED ' TO MSGO.
005752 EXEC CICS SEND MAPSET('MAPXXX') MAP('HEADER')
005753 FROM (HEADERO)
005754 END-EXEC.
005760 EXEC CICS RECEIVE MAPSET('MAPXXX') MAP('HEADER')
005761 INTO (HEADERI)
005770 END-EXEC.
005800 READPREV-PARA.
005900 EXEC CICS
006000 READPREV
006100 FILE ('TRGXXXF1')
006200 INTO (REC1)
006300 RIDFLD(KEYR)
006400 RESP(WS-RESP)
006500 END-EXEC.
006501 MOVE LOW-VALUES TO HEADERO.
006510 MOVE KEYR TO CODEO
006520 MOVE NAMER TO NAMEO
006530 MOVE ADDRESSR TO ADDRO
006540 MOVE PHNOR TO PHO
006550 MOVE DOBR TO DOBO
006560 MOVE 'DISPLAYED ' TO MSGO.
006561 EXEC CICS SEND MAPSET('MAPXXX') MAP('HEADER')
006562 FROM(HEADERO)
006563 END-EXEC.
006570 EXEC CICS RECEIVE MAPSET('MAPXXX') MAP('HEADER')
006571 INTO (HEADERI)
006580 END-EXEC.
****** **************************** Bottom of Data ****************************

4.3. Exercise
1. (i) Develop the Department Master Maintenance (DMM) transaction,based on the
following specification. File name can be given as Userid.TRG.KSDS(Userid is
Your logon id)

Create a VSAM /KSDS Dataset

Field Name Pic Contents

_______________________________________________________________________________
CICS Training Material Revision 2.0
69
CICS Training Material
_______________________________________________________________________________
DEPTNO X(4) Department Number
DESCRPTN X(20) Description

(ii)Transaction id is GC01 with program id TRG001P1


Send instruction message and receive messages as . follows

-ENTER FUNCTION , KEY AND DESCRIPTION (IF REQD) IN FORM


FFF KKKK

Where FFF : ADD-Add a new Department code


DEL:Delete an existing Department Code
UPD:Update an existing record
EXT:Exit program

(iii) Upon receiving control again,read the input message and validate the data.If
thefunction(FFF) is invalid or Key (KKKK) not specified ,send error
message and repeat (ii) .
(iv) If the function is ADD,write a dummy record with new department code for
later use ,send a message for add and terminate the task.If error, send error
message & repeat step(ii)
(v) If the function is DEL,deletete the department code entered ,send a
delete message and terminate the task.If error send error message &
repeat step (ii)
(vi) If the function is UPD,read the record for the key and move description field
from input to description field defined in the following screen(if record not
found repeat step (ii) by sending error message )and then send and
receive Description data from the screen as follows

DESCRIPTION DDDDDDDDDDDDDDDDDDDD
.
WHERE DDDDDDDDDDDD: Description data

After receiving the data ,update the record and terminate the task.
(vii) If function is EXT,terminate the task.

2. (i) Develop the Department Master Maintenance (DMM) transaction,based on the


following specification.File name can be given as Userid.TRG.KSDS(Userid is Your
logon id)

Create a VSAM /KSDS Dataset

Field Name Pic Contents

DEPTNO X(4) Department Number


DESCRPTN X(20) Description

And create some data thru cobol program

(ii) Transaction id is GC01 with program id TRG001P1

_______________________________________________________________________________
CICS Training Material Revision 2.0
70
CICS Training Material
_______________________________________________________________________________
Send instruction message and receive messages as follows

-ENTER FUNCTION AND KEY IN FORM OF FFF KKKK


DDDDDDDDDDDDDDDDDDDD

Where FFF : DIS-Display an existing Department code


EXT:Exit from program
BRW: Browse/for first record enter key
NXT:Reading next record
KKKK : KEY
Description field(DDDDDDDDDDDD) is protected field
(iii) Upon receiving control again,read the input message and validate the
data.If thefunction(FFF) is invalid or Key (KKKK) not specified ,send error
message and repeat (ii) .
(iv) If the function is DIS,read the record & display department discription on
the screen ,send a message for display and terminate the task..(Use
(v) READ command for getting a record)
(vi) If the function EXT ,Terminate the task.
(vii) If the function is BRW,read the record & display department description on
the screen ,clear screen repeatstep (ii). For getting next record funtion key
NXT to be used.
(viii) If the function is NXT ,read next record and display on the screen,repeat
step (ii)

4.4. DB2 Database

SQL statements can be embedded in the CICS application program to communicate data
requests to the DB2 database. SQLCODEs can be used to determine the result of the
execution of SQL commands. Plan name needs to be predefined in the RCT (Resource
Control Table). This is usually done by system programmers.
We can access DB2 data from CICS programs. When DB2 data is accessed from
CICS, multiple threads can be active simultaneously, enabling concurrent access to
a DB2 subsystem by multiple users of a CICS region. A mechanism called CICS
Attachment Facility connects CICS with DB2. Using this facility, each CICS region
can be connected to only one DB2 subsystem at a time. Each subsystem can,
however, to be connected to more than one CICS region at a time.

_______________________________________________________________________________
CICS Training Material Revision 2.0
71
CICS Training Material
_______________________________________________________________________________
CICS provides an interface to DB2, but DB2 requires its own region independent of
the CICS region. Both CICS and DB2 require its own unique regions under the OS.
CICS application programs can be issue a set of commands for SQL services in
order to access the DB2 database.

Sample CICS/DB2 Program

Program 1:

000110 ******************************************************************

000111 * THIS PROGRAM IS FOR DISPLAYING ALL THE RECORDS OF A TABLE *

000112 * INTO CICS SCREEN. *

000113 ******************************************************************

000120 IDENTIFICATION DIVISION.

000200 PROGRAM-ID. TRGXXXP1.

000300 ENVIRONMENT DIVISION.

000400 DATA DIVISION.

000500 WORKING-STORAGE SECTION.

000510 ******************************************************************

000520 * DCLGEN TABLE(EMP) *

000530 * LIBRARY(TRGXXX.DB2.INPUT(THIRD)) *

000540 * ACTION(REPLACE) *

000550 * LANGUAGE(COBOL) *

000560 * QUOTE *

000570 * ... IS THE DCLGEN COMMAND THAT MADE THE FOLLOWING STATEMENTS *

000580 ******************************************************************

000590 EXEC SQL DECLARE EMP TABLE

000591 ( EMPNO DECIMAL(4, 0) NOT NULL,

000592 ENAME VARCHAR(20),

000593 SAL DECIMAL(7, 2),

000594 DEPTNO DECIMAL(2, 0)

000595 ) END-EXEC.

_______________________________________________________________________________
CICS Training Material Revision 2.0
72
CICS Training Material
_______________________________________________________________________________
000596 ******************************************************************

000597 * COBOL DECLARATION FOR TABLE EMP *

000598 ******************************************************************

000599 01 DCLEMP.

000600 10 EMPNO PIC S9(4)V USAGE COMP-3.

000601 10 ENAME.

000602 49 ENAME-LEN PIC S9(4) USAGE COMP.

000603 49 ENAME-TEXT PIC X(20).

000604 10 SAL PIC S9(5)V9(2) USAGE COMP-3.

000605 10 DEPTNO PIC S9(2)V USAGE COMP-3.

000606 ******************************************************************

000607 * THE NUMBER OF COLUMNS DESCRIBED BY THIS DECLARATION IS 4 *

000608 ******************************************************************

000610 01 HEADERI.

000710 10 FILLER PIC X(12).

000720 10 CODEL COMP PIC S9(4).

000730 10 CODEF PIC X.

000740 10 FILLER REDEFINES CODEF.

000750 15 CODEA PIC X.

000760 10 CODEI PIC X(4).

000770 10 NAMEL COMP PIC S9(4).

000780 10 NAMEF PIC X.

000790 10 FILLER REDEFINES NAMEF.

000791 15 NAMEA PIC X.

000792 10 NAMEI PIC X(20).

000793 10 SALARYL COMP PIC S9(4).

000794 10 SALARYF PIC X.

000795 10 FILLER REDEFINES SALARYF.

000796 15 SALARYA PIC X.

000797 10 SALARYI PIC 9(5).9(2).

_______________________________________________________________________________
CICS Training Material Revision 2.0
73
CICS Training Material
_______________________________________________________________________________
000798 10 DEPTNOL COMP PIC S9(4).

000799 10 DEPTNOF PIC X.

000800 10 FILLER REDEFINES DEPTNOF.

000801 15 DEPTNOA PIC X.

000802 10 DEPTNOI PIC 9(2).

002000 01 HEADERO REDEFINES HEADERI.

002100 10 FILLER PIC X(12).

002200 10 FILLER PIC X(3).

002300 10 CODEO PIC X(4).

002400 10 FILLER PIC X(3).

002500 10 NAMEO PIC X(20).

002600 10 FILLER PIC X(3).

002700 10 SALARYO PIC 9(5).9(2).

002800 10 FILLER PIC X(3).

002900 10 DEPTNOO PIC X(2).

003600 01 REC1.

003700 10 KEYR PIC X(4).

003800 10 NAMER PIC X(20).

003900 10 SALARYR PIC X(20).

004000 10 DEPTNOR PIC X(10).

004200 10 FILLER PIC X(25).

004400 EXEC SQL INCLUDE SQLCA END-EXEC.

004500 EXEC SQL DECLARE C1 CURSOR FOR

004510 SELECT *

004520 FROM EMP

004530 END-EXEC.

004540 77 EOT PIC S9(9) COMP VALUE +100.

004600 PROCEDURE DIVISION.

004700 PARA0.

008000 EXEC SQL WHENEVER SQLERROR GOTO DBERROR END-EXEC.

_______________________________________________________________________________
CICS Training Material Revision 2.0
74
CICS Training Material
_______________________________________________________________________________
008100 EXEC SQL WHENEVER SQLWARNING GOTO DBERROR END-EXEC.

008200 EXEC SQL WHENEVER NOT FOUND CONTINUE END-EXEC.

008300 PARA1.

008310 EXEC SQL OPEN C1 END-EXEC.

008320 EXEC SQL FETCH C1 INTO :DCLEMP END-EXEC.

008330 IF SQLCODE NOT = EOT

008340 PERFORM SEND-MAP UNTIL SQLCODE IS NOT EQUAL TO ZERO.

008350 EXEC SQL CLOSE C1 END-EXEC.

008360 STOP RUN.

009600 EXEC CICS RETURN END-EXEC.

009700 GOBACK.

009800 SEND-MAP.

009801 MOVE LOW-VALUES TO HEADERI.

009802 MOVE SPACES TO NAMEI.

009810 MOVE ENAME-TEXT TO NAMEI.

009820 MOVE SAL TO SALARYI.

009830 MOVE DEPTNO TO DEPTNOI.

009840 MOVE EMPNO TO CODEI.

009900 EXEC CICS

010000 SEND MAP('HEADER') MAPSET('MAP081')

010100 ERASE

010200 END-EXEC.

010210 EXEC SQL FETCH C1 INTO :DCLEMP END-EXEC.

010220 * EXEC CICS

010230 * DELAY INTERVAL(000005)

010240 * END-EXEC.

010300 DBERROR.

010400 DISPLAY " SQL ERROR ".

010500 STOP RUN.

Program 2:

_______________________________________________________________________________
CICS Training Material Revision 2.0
75
CICS Training Material
_______________________________________________________________________________
000110 *********************************************************************************************

000111 * THIS PROGRAM IS FOR INSERTING OR DELETING THE RECORDS FROM *

000112 * A TABLE AND THEN DISPLAYING ALL THE RECORDS THROUGH CICS. *

000113 **********************************************************************************************

000120 IDENTIFICATION DIVISION

000200 PROGRAM-ID. TRGXXXP1

000300 ENVIRONMENT DIVISION

000400 DATA DIVISION

000500 WORKING-STORAGE SECTION

000510 ****************************************************************************************

000520 * DCLGEN TABLE (EMP) *

000530 * LIBRARY (TRGXXX.DB2.INPUT (THIRD)) *

000540 * ACTION (REPLACE) *

000550 * LANGUAGE (COBOL) *

000560 * QUOTE *

000570 * ... IS THE DCLGEN COMMAND THAT MADE FOLLOWING STATEMENTS *

000580 *****************************************************************************************

000590 EXEC SQL DECLARE EMP TABLE

000591 (EMPNO DECIMAL (4, 0) NOT NULL,

000592 ENAME VARCHAR (20),

000593 SAL DECIMAL (7, 2),

000594 DEPTNO DECIMAL (2, 0)

000595 ) END-EXEC

000596 *********************************************************************************************

000597 * COBOL DECLARATION FOR TABLE EMP *

000598 ******************************************************************

000599 01 DCLEMP.

000600 10 EMPNO PIC S9(4)V USAGE COMP-3.

000601 10 ENAME.

000602 49 ENAME-LEN PIC S9(4) USAGE COMP.

_______________________________________________________________________________
CICS Training Material Revision 2.0
76
CICS Training Material
_______________________________________________________________________________
000603 49 ENAME-TEXT PIC X(20).

000604 10 SAL PIC S9(5)V9(2) USAGE COMP-3.

000605 10 DEPTNO PIC S9(2)V USAGE COMP-3.

000606 ******************************************************************

000607 * THE NUMBER OF COLUMNS DESCRIBED BY THIS DECLARATION IS 4 *

000608 ******************************************************************

000610 01 HEADERI.

000710 10 FILLER PIC X(12).

000720 10 CODEL COMP PIC S9(4).

000730 10 CODEF PIC X.

000740 10 FILLER REDEFINES CODEF.

000750 15 CODEA PIC X.

000760 10 CODEI PIC S9(4)V.

000770 10 NAMEL COMP PIC S9(4).

000780 10 NAMEF PIC X.

000790 10 FILLER REDEFINES NAMEF.

000791 15 NAMEA PIC X.

000792 10 NAMEI PIC X(20).

000793 10 SALARYL COMP PIC S9(4).

000794 10 SALARYF PIC X.

000795 10 FILLER REDEFINES SALARYF.

000796 15 SALARYA PIC X.

000797 10 SALARYI PIC 9(5)V9(2).

000798 10 DEPTNOL COMP PIC S9(4).

000799 10 DEPTNOF PIC X.

000800 10 FILLER REDEFINES DEPTNOF.

000801 15 DEPTNOA PIC X.

000802 10 DEPTNOI PIC S9(2)V.

002000 01 HEADERO REDEFINES HEADERI.

002100 10 FILLER PIC X(12).

_______________________________________________________________________________
CICS Training Material Revision 2.0
77
CICS Training Material
_______________________________________________________________________________
002200 10 FILLER PIC X(3).

002300 10 CODEO PIC S9(4)V.

002400 10 FILLER PIC X(3).

002500 10 NAMEO PIC X(20).

002600 10 FILLER PIC X(3).

002700 10 SALARYO PIC 9(5)V9(2).

002800 10 FILLER PIC X(3).

002900 10 DEPTNOO PIC S9(2)V.

003000 01 REC.

003010 10 FILLER PIC X(15).

003100 10 EMPNOR PIC S9(4)V USAGE COMP-3.

003200 10 ENAMER.

003300 49 ENAMER-LEN PIC S9(4) USAGE COMP.

003400 49 ENAMER-TEXT PIC X(20).

003410 10 FILLER PIC X(3).

003500 10 SALR PIC S9(5)V9(2) USAGE COMP-3.

003501 10 FILLER PIC X(3).

003510 10 DEPTNOR PIC S9(2)V USAGE COMP-3.

004400 EXEC SQL INCLUDE SQLCA END-EXEC.

004500 EXEC SQL DECLARE C1 CURSOR FOR

004510 SELECT *

004520 FROM EMP

004530 END-EXEC.

004540 77 EOT PIC S9(9) COMP VALUE +100.

004600 PROCEDURE DIVISION.

004700 PARA0.

008000 EXEC SQL WHENEVER SQLERROR GOTO DBERROR END-EXEC.

008100 EXEC SQL WHENEVER SQLWARNING GOTO DBERROR END-EXEC.

008200 EXEC SQL WHENEVER NOT FOUND CONTINUE END-EXEC.

_______________________________________________________________________________
CICS Training Material Revision 2.0
78
CICS Training Material
_______________________________________________________________________________
008210 PERFORM PARA2.

008300 PARA1.

008310 EXEC SQL OPEN C1 END-EXEC.

008320 EXEC SQL FETCH C1 INTO :DCLEMP END-EXEC.

008330 IF SQLCODE NOT = EOT

008340 PERFORM SEND-MAP UNTIL SQLCODE IS NOT EQUAL TO ZERO.

008350 EXEC SQL CLOSE C1 END-EXEC.

008360 STOP RUN.

009600 EXEC CICS RETURN END-EXEC.

009700 GOBACK.

009800 SEND-MAP.

009801 MOVE LOW-VALUES TO HEADERI.

009802 MOVE SPACES TO NAMEI.

009810 MOVE ENAME-TEXT TO NAMEI.

009820 MOVE SAL TO SALARYI.

009830 MOVE DEPTNO TO DEPTNOI.

009840 MOVE EMPNO TO CODEI.

009900 EXEC CICS

010000 SEND MAP('HEADER') MAPSET('MAP081')

010100 ERASE

010200 END-EXEC.

010210 EXEC SQL FETCH C1 INTO :DCLEMP END-EXEC.

010220 * EXEC CICS

010230 * DELAY INTERVAL(000005)

010240 * END-EXEC.

010300 DBERROR.

010400 DISPLAY " SQL ERROR ".

010500 STOP RUN.

010600 PARA2.

010700 EXEC SQL OPEN C1 END-EXEC.

_______________________________________________________________________________
CICS Training Material Revision 2.0
79
CICS Training Material
_______________________________________________________________________________
010710 MOVE LOW-VALUES TO HEADERI.

010800 EXEC CICS SEND MAP('HEADER') MAPSET('MAP081')

010900 ERASE

011000 END-EXEC.

011100 EXEC CICS RECEIVE MAP('HEADER') MAPSET('MAP081')

011200 END-EXEC.

011210 MOVE +10 TO ENAMER-LEN.

011300 MOVE CODEI TO EMPNOR.

011400 MOVE NAMEI TO ENAMER-TEXT.

011500 MOVE SALARYI TO SALR.

011600 MOVE DEPTNOI TO DEPTNOR.

011700 EXEC SQL

011800 INSERT INTO EMP VALUES(:EMPNOR, :ENAMER, :SALR, :DEPTNOR)

011810 * DELETE FROM EMP WHERE ENAME = :ENAMER

011900 END-EXEC.

012000 EXEC SQL CLOSE C1 END-EXEC.

Sample CICS/DB2 JCL

000100 //TRGXXXJ JOB ,,NOTIFY=&SYSUID


000200 // JCLLIB ORDER=(TRG000.COB.PROCLIB)
000300 //STEP01 EXEC DFHDSN,MEM=TRGXXXC1,WSPC=500
000400 //TRN.SYSIN DD DISP=SHR,DSN=TRGXXX.CICS3.SRCLIB3(&MEM)
000401 //PC.DBRMLIB DD DISP=SHR,DSN=TRGXXX.DBRMLIB.DATA(&MEM)
000410 //LKED.SYSLMOD DD DISP=SHR,DSN=CICSTS13.TRG.PROGLOAD(&MEM)
000411 //LKED.SYSIN DD *
000412 INCLUDE SYSLIB(DSNCLI)
000413 NAME TRGXXXP1(R)
000420 /*
000421 //*
000430 //BIND EXEC PGM=IKJEFT01,DYNAMNBR=20,COND=(4,LT)
000440 //STEPLIB DD DISP=SHR,DSN=DSN610.SDSNLOAD
000450 //SYSTSPRT DD SYSOUT=(*)
000460 //SYSTSIN DD *
000470 DSN

_______________________________________________________________________________
CICS Training Material Revision 2.0
80
CICS Training Material
_______________________________________________________________________________
000480 BIND PLAN(TRGXXXP1) -
000490 MEMBER(TRGXXXC1) -
000500 VALIDATE(BIND) -
000510 ISOLATION(CS) -
000520 RELEASE(C) -
000530 EXPLAIN(NO)-
000540 OWNER(TRGXXX)-
000550 LIB('TRGXXX.DBRMLIB.DATA')
000580 /*

000590 //o

4.5 PRECOMPILATION

Pre-compiler Functions:

Program used: DSNHPC

INPUT  EMBEDDED SQL PROGRAM

OUTPUT

 Modified source

 DBRMLIB – Database Request Module

Other Sources needed:

 DCLGEN

This produces modules that can be included in a program. It builds a COBOL


copybook.

 Expands the DB2 related INCLUDE statements.


 Checks the SQL syntax.
 Separates SQL from NON-SQL statements and places SQL statements in
Database Request Module (DBRM)
 In the Modified source program, all SQL statements will be commented and
corresponding CALLs to DB2 Runtime Interface Module is placed.
 Places TIMESTAMP in the Modified source in the DBRM member and load
module.
COMPILE

_______________________________________________________________________________
CICS Training Material Revision 2.0
81
CICS Training Material
_______________________________________________________________________________

Program Used: IGYCRCTL

INPUT  Modified Source Program

OUTPUT  OBJ Module

Other Sources needed:

 COPYLIBS

Process:

 The COPYLIB members will be expanded.


 The COBOL syntax will be checked.
 Places the time stamp written in the precompiler step in the OBJ module.
LINK EDIT

Program Used: IEWL

INPUT  OBJ Module

OUTPUT  Load Module

Process:

 The executable load module is produced


 The subprograms if exists will be merged along with the system libraries.
 Places the timestamp written from the precompiler step in the load module.
BIND

Program Used: IKJEFT01

INPUT  DBRM LIB produced in precompiler step

OUTPUT  PLAN

Function:

Reads the SQL statements from DBRMs and produces a mechanism to access data
from tables.

Parameters given while binding:

1. Owner, Qualifier
2. Action (REPLACE/ADD)
3. Isolation (CS/RR)
_______________________________________________________________________________
CICS Training Material Revision 2.0
82
CICS Training Material
_______________________________________________________________________________
4. Acquire (USE/DEALLOCATE)
5. Release (COMMIT/DEALLOCATE)
6. Validate (BIND/RN)
7. Explain
8. Flag.

Owner:

Name of the owner who created the PLAN

Qualifier:

Name where the table reside

Action:

Add or Replace the existing plan (BINDADD & BINDREPLACE)

Isolation:

This determines the mode of page locking implemented by the programs as it runs.
CS – Cursor Stability:
Releases the page locks as soon as another page is accessed or an COMMIT is
issued. Improves concurrency.
RR – Repeatable Read (DEFAULT):
Releases the page locks until a COMMIT is issued.

Acquire:

This determines the mode of table space locking implemented by the program as it
runs.

Use:

Table space locks are acquired when the table space is accessed.

Allocate:

Table space locks are acquired when the plan is allocated.

Release:

Commit:
Table space locks are released at COMMIT or ROLLBACK time.
Deallocate:

_______________________________________________________________________________
CICS Training Material Revision 2.0
83
CICS Training Material
_______________________________________________________________________________
Table space locks are released only when the plan finishes and is deallocated.

Validate:

Method of checking for the existence and validity for DB2 access tables and
authorization
Bind – Validates at Bind time itself
Run – Validates at run time.

Flag:

Returns the informational, warning, error and completion messages.

_______________________________________________________________________________
CICS Training Material Revision 2.0
84
CICS Training Material
_______________________________________________________________________________

5. CICS QUEUEING FACILITIES


5.1. Objectives

To know about
• CICS Queues

5.2. CICS Queueing Facilities

CICS offers two facilities to store data that are temporary in nature. The data can be
collected by 1 or more online transactions, to be used later by the same transaction or by a
different transaction or even passed to a batch program. These queues are Transient Data
Queues(TDQ) and Temporary Storage Queues( TSQ).

5.3. Transient DATA QUEUE (TDQ)


Transient Data Queue (TDQ) is a queue used to store data records by a CICS
application program. The Transient Data Control Program (TCP) provides the capability to
store and retrieve data in TDQ.

♦ A temporary sequential file on an auxiliary storage.


♦ Identified by a 4-character ID called Destination ID.
♦ Destination ID and other characteristics of a TDQ are defined in the
Destination Control Table (DCT) by the system programmer.
♦ New records are added to the end of the queue.
♦ TDQ’s must be read sequentially. Once a record is read, it cannot be read
again by any other task.
♦ Cannot update a record in a TDQ.
♦ 2 types of TDQs - Intra Partition TDQ & Extra Partition TDQ.

5.3.1. Intra Partition TDQ

♦ Group of sequential records processed by the same CICS region.


♦ All Intra-partition TDQs are stored in only 1 physical file (VSAM).
♦ Records from the queue can be retrieved/written sequentially.
♦ Destructive Read - Once a record is read, it is deleted. It cannot be read again.
♦ Several tasks can write to the same TDQ but only 1 task can read from TDQ.
♦ Intra Partition TDQ is used in applications such as

_______________________________________________________________________________
CICS Training Material Revision 2.0
85
CICS Training Material
_______________________________________________________________________________

Interface among CICS transactions.


Appl. Pgm 1 -----> TDQ ------> Appl. Pgm 2 ------> Reports

5.3.2. Extra Partition TDQ

• Group of sequential records processed between transactions of the CICS


region and systems outside the CICS region.
• Each queue is a separate physical file & may be on disk or, tape
• Files have to be open within the CICS region when they are used by the CICS
transaction.
• TDQ can be defined as an Input or Output but not both.
• Queue records are fixed, variable, blocked or unblocked.
• Extrapartition TDQ is used in applications such as

Interface to batch (or TSO or PC)


CICS Pgm 1 -----> TDQ ------> Batch Pgm 2
Interface from batch
Batch Pgm 1 -----> TDQ ------> CICS Pgm 2

5.3.3. Automatic Task Initiation (ATI)


ATI is a facility through which a CICS transaction can be initiated automatically.
The number of records in an intra-partition TDQ triggers the transaction initiation.
The transaction identifier must be specified in the DCT entryof the intra-partition
TDQ with a non-zero trigger level. If the number of records in aTDQ reaches the
trigger level, the trans-id specified will be initiated automatically by CICS. The
practical applications are:
Message Routing
Message Broadcast.
Report Printing

5.3.4. Transient Data Output

Used to write a record in a TDQ (destination) The General format is:

_______________________________________________________________________________
CICS Training Material Revision 2.0
86
CICS Training Material
_______________________________________________________________________________
EXEC CICS
WRITEQ TD QUEUE(name)
FROM(data-area)
[LENGTH(data-value)]
END-EXEC
QUEUE: The name is upto four characters, and defined in the DCT

FROM : Specifies the data area to be written

LENGTH: Specifies length of record to be written. Required for variable length records.

_______________________________________________________________________________
CICS Training Material Revision 2.0
87
CICS Training Material
_______________________________________________________________________________
5.3.5. Transient Data Input

Used to read a record of a TDQ (destination)


The general command format is

EXEC CICS
READQ TD QUEUE(name)
INTO(data-value)
[LENGTH(data-value)]
END-EXEC

5.3.6. Transient Data Queue Delete (only for intrapartition queue)

Used to delete an intra-partition TDQ entirely.


The general command format is

EXEC CICS
DELETEQ TD QUEUE(name)
END-EXEC

Common Exception Conditions

LENGERR Length specified in output is greater than the maximum record size
allowed in the DCT.
Length option is not coded for variable length record
Record length longer than length specified for input area.
QZERO The queue is empty, meaning end of file on a READQ.
INVREQ READQ attempts to read a queue opened for output. (cannot occur for
extrapartition queue)
WRITEQ attempts to write to queue opened for input. (cannot occur for intrapartition
queue)
DELETEQ attempts to delete an Extrapartition queue.
NOSPACE No space in the Intrapartition TDQ for a WRITEQ command.
NOTOPEN Destination is closed. (only for extrapartition queue)
QBUSY READQ attempts to access a record in an Intrapartition TDQ that is being
written to or deleted by another task. The task waits until the queue is no
longer being used for output.
IOERR Input/Output error on the queue.
QIDERR The Dest-Id specified cannot be found in DCT.

_______________________________________________________________________________
CICS Training Material Revision 2.0
88
CICS Training Material
_______________________________________________________________________________
5.4. Temporaty Storage Queue(TSQ)
Temporary Storage Queue (TSQ) is a queue used to store data records by a CICS
application program. The temporary Storage Program (TSP) provides the capability to store
and retrieve data in TSQ.

• TSQ is a queue of stored variable length records, and typically used as a


scratch pad.
• Created & deleted dynamically by an application program.
• Queue ID is of length 1-8 bytes and a record within a TSQ is identified by the
relative position number called item number.
• Records can be stored in main or auxiliary storage.
• The records once written remain accessible until the entire TSQ is deleted.
• Records can be read sequentially or directly, and can be updated

5.4.1. Naming Convention

In order to avoid confusion and to maintain data security, a naming convention will be
required.
E.g DTTTTANN
where D Division (‘A’ for accounts, ‘B’ for budget’, etc)
TTTT Terminal id(EIBTRMID)
A Application code ( A, B, C ...)
NN Queue no. ( 1, 2, 3 ...)

5.4.2. WRITEQ TS

EXEC CICS
WRITEQ TS QUEUE(name)
FROM(data-area)
[LENGTH(data-value)]
[ITEM(data-area)]
[REWRITE ]
[MAIN / AUXILLARY]
END-EXEC

QUEUE Specifies a 1-8 character name of the TSQ in which an item is to be


written. If no queue exists with the name CICS will create one before
writing the item in the queue.
FROM specifies the data area that contains the record to be written.
LENGTH specifies the length of an item to be (re) written defined as PIC S9(4)
comp.
ITEM Contains the item number assigned to the record just written.

_______________________________________________________________________________
CICS Training Material Revision 2.0
89
CICS Training Material
_______________________________________________________________________________
REWRITE Used to rewrite the record identified by ITEM.
MAIN / AUXILIARY To specify the storage medium. Main storage or VSAM dataset .

5.4.3. READQ TS

EXEC CICS
READQ TS QUEUE(name)
INTO(data-area)
[LENGTH(data-value)]
[ITEM(data-value) / NEXT]
[NUMITEMS(data-area)]
END-EXEC

ITEM For direct reading of the item no. specified.


NEXT . To retrieve the next logical record in the TSQ. Mutually exclusive to
NUMITEMS A S9(4) comp data area to store the no. of items in the TSQ.

5.4.4. DELETEQ TSQ

EXEC CICS
DELETEQ TS QUEUE(name)
END-EXEC

All records in TSQ are deleted. All associated storage is released.

5.4.5. Common Execption Conditions

ITEMERR Item number specified is invalid, or attempt made to read beyond the
end of the queue by the NEXT option.
LENGERR Length specified is greater than the maximum record length.
NOSPACE Sufficient space not available in temporary storage.
IOERR Irrecoverable I/O error
QIDERR Specified queue id is not present.

5.4.6 Some CICS Transactions for QUEUE

CEBR (Temporary Storage Browse) is a CICS - supplied transaction which browses


Temporary Storage Queue (TSQ).To view the file use the following command.

Example : CEBR Filename

_______________________________________________________________________________
CICS Training Material Revision 2.0
90
CICS Training Material
_______________________________________________________________________________
BROWSING CICS QUEUE

• CEBR can be invoked while you are already in the CEDF mode.
• Press the PF5 key to display the working storage section.
• Then, press PF12 key to invoke CEBR.
• CEBR allows to browse information in Temporary Storage (TS) queues.
• Help (PF1) give you a list of CEBR commands on the screen.
• TS queues are retained until purged.

SAMPLE PROGRAM (TSQ)

000100 IDENTIFICATION DIVISION.


000200 PROGRAM-ID. TRGXXXP1.
000300 ENVIRONMENT DIVISION.
000400 DATA DIVISION.
000500 WORKING-STORAGE SECTION.
000510 COPY MAP1.
000600 01 COMMAREA.
000700 05 VARS PIC X(4).
003800 01 REC1.
003900 10 KEYR PIC X(4).
004000 10 NAMER PIC X(20).
004100 10 ADDRESSR PIC X(20).
004200 10 PHNOR PIC X(10).
004300 10 DOBR PIC X(10).
004400 10 FILLER1 PIC X(15).
004500 77 REC-KEY PIC 9(4).
004600 77 WS-RESP PIC S9(8) COMP.
004700 77 WS-ERR-MSG PIC X(20) VALUE "ERROR OCCURED".
004800 LINKAGE SECTION.
004900 01 DFHCOMMAREA.
005000 05 VARS PIC X(4).
005100 PROCEDURE DIVISION.
005200 MAIN-PROC.
005300 MOVE DFHCOMMAREA TO COMMAREA.
005400 IF EIBCALEN = 0 THEN
005500 MOVE LOW-VALUES TO HEADERO
005600 PERFORM SEND-MAP
005700 PERFORM RETURN-TRANS
005800 ELSE
005900 PERFORM RECEIVE-MAP
006000 PERFORM RETURN-PARA
006100 END-IF.
006200 GOBACK.
006300 SEND-MAP.
006400 EXEC CICS
006500 SEND MAPSET('MAPXXX') MAP('HEADER') FROM (HEADERO)
006600 ERASE
006700 END-EXEC.
006800 RECEIVE-MAP.
006900 EXEC CICS
007000 RECEIVE MAPSET('MAPXXX') MAP('HEADER') INTO (HEADERI)
007100 END-EXEC.

_______________________________________________________________________________
CICS Training Material Revision 2.0
91
CICS Training Material
_______________________________________________________________________________
007200 MOVE SPACES TO FILLER1.
007300 MOVE NAMEI TO NAMER.
007400 MOVE ADDRI TO ADDRESSR.
007500 MOVE PHI TO PHNOR.
007600 MOVE DOBI TO DOBR.
007700 MOVE CODEI TO REC-KEY KEYR.
007800 EXEC CICS WRITEQ TS
007900 QUEUE('TRGXXXF')
008000 FROM (REC1)
008100 RESP(WS-RESP)
008200 MAIN
008300 END-EXEC.
008400 IF WS-RESP = DFHRESP(NORMAL)
008500 CONTINUE
008600 ELSE
008700 EXEC CICS
008800 SEND TEXT FROM(WS-ERR-MSG)
008900 LENGTH(LENGTH OF WS-ERR-MSG)
009000 END-EXEC.
009100 RETURN-TRANS.
009200 EXEC CICS
009300 RETURN TRANSID('GCXX')
009400 COMMAREA(COMMAREA)
009500 LENGTH(LENGTH OF COMMAREA)
009600 END-EXEC.
009700 RETURN-PARA.
009800 EXEC CICS RETURN END-EXEC.
009900 GOBACK.
****** **************************** Bottom of Data ****************************

EXERCISE

(i) Create a ESDS DATASET & Using TSQ Commands provide for
addition,deletion,updation as per the example given at the end of chapter 4.

_______________________________________________________________________________
CICS Training Material Revision 2.0
92
CICS Training Material
_______________________________________________________________________________

APPENDIX
A. COMMON ABEND CODES
Abend codes are generated by the occurrence of some Exception Conditions on
excecuting CICS commands. The most common way of overcoming these abends is to
code HANDLE CONDITIONS for these conditions in the program, and also check the
program carefully for any other possible errors. Most of these errors occur during file
handling or due to data exception error.
ABM0 Mapname could not be found
User Action : Correct the program so that it supplies a valid mapname to BMS, and check
that the map actually exists.
AEIA ERROR condition was raised by one of the CICS commands
AEID EOF condition was raised
AEIL DSIDERR error condition was raised
AEIM NOTFND error condition was raised
AEIQ IOERR error condition was raised
AEIR NOSPACE error condition was raised
AEIO DUPKEY error condition was raised
AEIP INVREQ error condition was raised
AEIS NOTOPEN error condition was raised
AEIT ENDFILE error condition was raised
AEIV LENGERR error condition was raised
AEIZ ITEMERR error condition was raised
AEI0 PGMIDERR error condition was raised
AEI2 ENDDATA error condition was raised
AEIW QZERO error condition was raised
AEI1 TRANSIDERR error condition was raised
AEI8 MAPFAIL error condition was raised
AEI9 MAPFAIL error condition was raised
AEXL DISABLED error condition was raised
AEYH QIDERR error condition was raised
AEY7 NOTAUTH error condition was raised

AFCA Program has tried to do I/O on a disabled file, or an application request


resulted in an implicit OPEN which failed, causing the file to be disabled.
User Action: Determine why the file has been disabled. Retry the transaction
when the file has been enabled again.

APCT An application program could not be found in the PPT when it was needed.
Another possible cause is that the entry is in the PPT but is disabled, or the
program itself has a zero length.
User Action: Check if the name of the program is correct. If the program is
available, try issuing NEWCOPY command again for it.
ASRA This abend is issued by CICS when it traps a program check suffered by an
application program. Examples of program checks that can cause an ASRA
abend are 0C4's and 0C7's.
User Action: Check if any invalid move or other invalid statements have been
coded in the program. Correct the program and try again. Most of the time, it
is a program error.

_______________________________________________________________________________
CICS Training Material Revision 2.0
93
CICS Training Material
_______________________________________________________________________________

ASRB This abend is issued by CICS when it traps an MVS abend that occurred
during the life of an application task. Examples of abends that can cause an
ASRB abend are S213's, S013, etc.

_______________________________________________________________________________
CICS Training Material Revision 2.0
94
CICS Training Material
_______________________________________________________________________________

B. JCL
JCL for translate, compile & linkedit - CICS COBOL program

000100 //TRGXXXJC JOB ,,NOTIFY=&SYSUID


000200 // JCLLIB ORDER=(TRG000.COB.PROCLIB)
000300 //STEP01 EXEC PROC=DFHEITVL,MEM=PSDO
000400 //TRN.SYSIN DD DISP=SHR,DSN=TRGXXX.CICS.SRCLIB(&MEM)
000900 //LKED.SYSLMOD DD DISP=SHR,DSN=CICSTS13.TRG.PROGLOAD(&MEM)
000910 //LKED.SYSIN DD *
001000 NAME TRGXXXP1(R)
001100 /*

Procedure DFHEITVL used In the compilation JCL

000100 //DFHEITVL PROC SUFFIX=1$, Suffix for translator module


000200 //*
000300 //* This procedure has been changed since CICS/ESA Version 3
000400 //*
000500 //* Parameter INDEX2 has been removed
000600 //*
000700 // INDEX='CICSTS13.CICS', Qualifier(s) for CICS libraries
000900 // DSCTLIB='CICSTS13.CICS.SDFHCOB', Private macro/dsect@BA25137C
001000 // COMPHLQ='IGY.V2R1M0', Qualifier(s) for COBOL compiler
001100 // OUTC=A, Class for print output
001200 // REG=2M, Region size for all steps
001300 // LNKPARM='LIST,XREF', Link edit parameters
001400 // STUB='DFHEILIC', Link edit INCLUDE for DFHECI
001500 // LIB='SDFHCOB', Library
001600 // WORK=SYSDA Unit for work datasets
001700 //* This procedure contains 4 steps
001800 //* 1. Exec the COBOL translator
001900 //* (using the supplied suffix 1$)
002000 //* 2. Exec the VS COBOL II compiler
002100 //* 3. Reblock &LIB(&STUB) for use by the linkedit step
002200 //* 4. Linkedit the output into dataset &PROGLIB
002300 //*
002400 //* The following JCL should be used
002500 //* to execute this procedure
002600 //*
002700 //* //APPLPROG EXEC DFHEITVL
002800 //* //TRN.SYSIN DD *
002900 //* .
003000 //* . Application program
003100 //* .
003200 //* /*
003300 //* //LKED.SYSIN DD *
003400 //* NAME anyname(R)
003500 //* /*
003600 //*
003700 //* Where anyname is the name of your application program.
003800 //* (Refer to the system definition guide for full details,

_______________________________________________________________________________
CICS Training Material Revision 2.0
95
CICS Training Material
_______________________________________________________________________________
003900 //* including what to do if your program contains calls to
004000 //* the common programming interface.)
004100 //*
004200 //TRN EXEC PGM=DFHECP&SUFFIX,
004300 // PARM='COBOL2',
004400 // REGION=&REG
004500 //STEPLIB DD DSN=&INDEX..SDFHLOAD,DISP=SHR
004600 //SYSPRINT DD SYSOUT=&OUTC
004700 //SYSPUNCH DD DSN=&&SYSCIN,
004800 // DISP=(,PASS),UNIT=&WORK,
004900 // DCB=BLKSIZE=400,
005000 // SPACE=(400,(400,100))
005100 //*
005200 //COB EXEC PGM=IGYCRCTL,REGION=&REG,
005300 // PARM='NODYNAM,LIB,OBJECT,RENT,RES,APOST,MAP,XREF'
005400 //*STEPLIB DD DSN=&COMPHLQ..COB2COMP,DISP=SHR
005500 //STEPLIB DD DSN=&COMPHLQ..SIGYCOMP,DISP=SHR
005600 //SYSLIB DD DSN=&DSCTLIB,DISP=SHR
005700 // DD DSN=&INDEX..SDFHCOB,DISP=SHR
005800 // DD DSN=&INDEX..SDFHMAC,DISP=SHR
005900 // DD DSN=&INDEX..SDFHSAMP,DISP=SHR
006000 //SYSPRINT DD SYSOUT=&OUTC
006100 //SYSIN DD DSN=&&SYSCIN,DISP=(OLD,DELETE)
006200 //SYSLIN DD DSN=&&LOADSET,DISP=(MOD,PASS),
006300 // UNIT=&WORK,SPACE=(80,(250,100))
006400 //SYSUT1 DD UNIT=&WORK,SPACE=(460,(350,100))
006500 //SYSUT2 DD UNIT=&WORK,SPACE=(460,(350,100))
006600 //SYSUT3 DD UNIT=&WORK,SPACE=(460,(350,100))
006700 //SYSUT4 DD UNIT=&WORK,SPACE=(460,(350,100))
006800 //SYSUT5 DD UNIT=&WORK,SPACE=(460,(350,100))
006900 //SYSUT6 DD UNIT=&WORK,SPACE=(460,(350,100))
007000 //SYSUT7 DD UNIT=&WORK,SPACE=(460,(350,100))
007100 //*
007200 //COPYLINK EXEC PGM=IEBGENER,COND=(7,LT,COB)
007300 //SYSUT1 DD DSN=&INDEX..&LIB(&STUB),DISP=SHR
007400 //SYSUT2 DD DSN=&&COPYLINK,DISP=(NEW,PASS),
007500 // DCB=(LRECL=80,BLKSIZE=400,RECFM=FB),
007600 // UNIT=&WORK,SPACE=(400,(20,20))
007700 //SYSPRINT DD SYSOUT=&OUTC
007800 //SYSIN DD DUMMY
007900 //*
008000 //LKED EXEC PGM=IEWL,REGION=&REG,
008100 // PARM='&LNKPARM',COND=(5,LT,COB)
008410 //SYSLIB DD DISP=SHR,DSN=CEE.SCEELKED
008420 // DD DISP=SHR,DSN=IGY.V2R1M0.AIGYMOD1
008430 // DD DSN=&INDEX..SDFHLOAD,DISP=SHR
008500 //*SYSLMOD DD DSN=&PROGLIB,DISP=SHR
008600 //SYSUT1 DD UNIT=&WORK,DCB=BLKSIZE=1024,
008700 // SPACE=(1024,(200,20))
008800 //SYSPRINT DD SYSOUT=&OUTC
008900 //SYSLIN DD DSN=&&COPYLINK,DISP=(OLD,DELETE)
009000 // DD DSN=&&LOADSET,DISP=(OLD,DELETE)
009100 // DD DDNAME=SYSIN

_______________________________________________________________________________
CICS Training Material Revision 2.0
96
CICS Training Material
_______________________________________________________________________________
****** **************************** Bottom of Data ********

_______________________________________________________________________________
CICS Training Material Revision 2.0
97
CICS Training Material
_______________________________________________________________________________
JCL for generation of Physical Map

000001 //TRGxxxJB JOB ,,NOTIFY=&SYSUID


000002 // JCLLIB ORDER=(TRGXXX.COB.PROCLIB)
000003 //STEP01 EXEC PROC=ASMACL,MEM=MAPxxx
000004 //C.SYSIN DD DISP=SHR,DSN=TRGxxx.CICS.SRCLIB(&MEM)
000005 //L.SYSLMOD DD DISP=SHR,DSN=CICSTS13.TRG.MAPLOAD(&MEM)

****** **************************** Bottom of Data ****************************

Procedure ASMACL Used In Generation of Physical Map

000010 //ASMACL PROC


000240 //C EXEC PGM=ASMA90
000250 //SYSLIB DD DISP=SHR,DSN=SYS1.MACLIB
000251 // DD DISP=SHR,DSN=CICSTS13.CICS.SDFHMAC
000252 // DD DISP=SHR,DSN=CICSTS13.CICS.ADFHMAC
000260 //SYSUT1 DD DSN=&&SYSUT1,SPACE=(4096,(120,120),,,ROUND),
000270 // UNIT=SYSALLDA,DCB=BUFNO=1
000280 //SYSPRINT DD SYSOUT=*
000290 //SYSLIN DD DSN=&&OBJ,SPACE=(3040,(40,40),,,ROUND),
000300 // UNIT=SYSALLDA,DISP=(MOD,PASS),
000310 // DCB=(BLKSIZE=3040,LRECL=80,RECFM=FB,BUFNO=1)
000320 //L EXEC PGM=HEWL,PARM='MAP,LET,LIST',COND=(8,LT,C)
000330 //SYSLIB DD DISP=SHR,DSN=CICSTS13.CICS.SDFHLOAD
000331 //SYSLIN DD DSN=&&OBJ,DISP=(OLD,DELETE)
000340 // DD DDNAME=SYSIN
000370 //SYSUT1 DD DSN=&&SYSUT1,SPACE=(1024,(120,120),,,ROUND),
000380 // UNIT=SYSALLDA,DCB=BUFNO=1
000390 //SYSPRINT DD SYSOUT=*
****** **************************** Bottom of Data ****************************

JCL for generation of Symbolic Map

000001 //TRGxxxJB JOB ,,NOTIFY=&SYSUID


000002 // JCLLIB ORDER=(TRGXXX.COB.SRCLIB)
000003 //STEP01 EXEC PROC=ASMMAP,MEM=MAPxxx
000004 //C.SYSIN DD DISP=SHR,DSN=TRGxxx.CICS.SRCLIB(&MEM)
000005 //C.SYSLIN DD DISP=SHR,DSN=TRGxxx.MAP.COPYLIB(MAP1)
****** **************************** Bottom of Data ****************************
Note: Before submitting the above JCL check for TYPE=DSECT in DFHMDS macro in
BMS MAP ‘MAPxxx’.A symbolic map is a Copy Library member, which will be created in
TRGxxx.MAP.COPYLIB with the name MAP1.The Library member is to be included in
application program for defining the screen fields.

Procedure ASMMAP Used In Generation of Symbolic Map

000010 //ASMMAP PROC


000240 //C EXEC PGM=ASMA90
000250 //SYSLIB DD DISP=SHR,DSN=SYS1.MACLIB
000251 // DD DISP=SHR,DSN=CICSTS13.CICS.SDFHMAC
000252 // DD DISP=SHR,DSN=CICSTS13.CICS.ADFHMAC

_______________________________________________________________________________
CICS Training Material Revision 2.0
98
CICS Training Material
_______________________________________________________________________________
000260 //SYSUT1 DD DSN=&&SYSUT1,SPACE=(4096,(120,120),,,ROUND),
000270 // UNIT=SYSALLDA,DCB=BUFNO=1
000280 //SYSPRINT DD SYSOUT=*
000290 //SYSLIN DD DUMMY
****** **************************** Bottom of Data ****************************

_______________________________________________________________________________
CICS Training Material Revision 2.0
99
CICS Training Material
_______________________________________________________________________________

C. CICS COPYLIB MEMBERS

Two CICS Copy Library members which are commonly copied into the CICS application
programs are DFHEIBLK and DFHBMSCA which contain the Execute Interface Block(EIB)
and attribute characters respectively .

DFHEIBLK Member

The DFHEIBLK member is a set of field definitions of the Execute Interface Block .It is
copied automatically into the application programme by the CICS command translator and
COBOL Compiler. i.e Programmer don’t need to include COPY statement for DFHEIBLK as
‘COPY DFHEIBLK ‘ in his application program. When CICS activates the application
program,it places the proper value into the corresponding EIB fields and the values will be
updated as the program is executed.Some of the list of EIB fields included in the
DFHEIBLK are listed below.

Field Function Length Picture

EIBTIME TIME(0HHMMSS) 4 S9(7) COMP-3

Time of the day when the task is started and updated when the task is initiated.
May be updated by the program with the ASKTIME command

EIBDATE Day (00YYDDD) 4 S9(7) COMP-3

Date tge task started and updated when the task is initiated
May be updated by the program with the ASKTIME command

EIBTRNID Transaction Identifier 4 X(4)

EIBTASKN Task Number 4 S9(7) COMP-3

This number appears in trace table entries generated while the task is in control

EIBTRMID Terminal Identifier 4 X(4)

The symbolic terminal identifier of the terminal or its logical unit associated with the task
Updated when the task is initiated

EIBCPOSN Cursor Position 2 S9(4) COMP

The cursor address (position) on the screen associated with the last terminal or BMS
operation from a display device such as the 3270 type terminals.

EIBCALEN COMMAREA Length 2 S9(4) COMP

Length of the communication area passed to the application program from the previous
program, through LINK or XCTL command with the COMMAREA and LENGTH options
Contains zero when no communication area is passed
Updated when the program first executes within a task

EIBAID Attention Code 1 X(1)

_______________________________________________________________________________
CICS Training Material Revision 2.0
100
CICS Training Material
_______________________________________________________________________________

Attention identifier code identified with the last terminal


Updated when the program issues a RECEIVE command
Can be compared against the Standard Attention Identifier List (DFHAID) to check which
key is used as input
DFHAID list contains all the symbolic names for the control keys which are copied into the
working storage section before one can use symbolic names

EIBFN Function Code 2 X(2)

A code that identifies a last CICS command issued by the task


Updated when the service corresponding to the command has been completed whether or
not an error occurred
Used for debugging programs that have been aborted and any time a dump is requested.

EIBRCODE Response Code 6 X(6)

Response code returned by the last CICS command issued by the task.
Updated when the sevice corresponding to the command has been completed
Used for debugging similar to EIBFN

EIBDS Last Dataset 8 X(8)

The symbolic identifier of the last dataset referred to in a File Control command
Used for debugging programs aborted due to file errors

EIBNODAT No Application Data Receive Flag 1 X(1)

EIBRESP Internal Condition Error 4 X(4)


A unique decimal number corresponding to the exceptional condition was raised

EIBRESP2 Internal condition Error 4 X(4)


More detailed information that may help further explain why the exceptional condition was
raised

DFHBMSCA Member

An application programmer must issue the COPY statement in order to include the
member in program..The DFHBMSCA Copy Library member contains some of the following
list of character definitions and their characteristics.

Name Function Value


Chr Hex

DFHBMASK Autoskip ‘0’ F0


DFHBMUNP Unprotected 40
DFHBMUNN Unprotected numeric ‘&’ 50

_______________________________________________________________________________
CICS Training Material Revision 2.0
101
CICS Training Material
_______________________________________________________________________________
DFHBMPRO Protected ‘.’ 60
DFHBMBRY Bright ‘H’ C8
DFHUNIMD Unprotected,intensify,light pen
Detectable,MDT on ‘I’ C9
DFHUNNUM Unprotected,numeric,MDT on ‘J’ D1
DFHUNINT Unprotected,intensify,light pen
Detectable,MDT on ‘R’ D9

_______________________________________________________________________________
CICS Training Material Revision 2.0
102

Potrebbero piacerti anche