CICS
– Customer Information Control System
Task – The fundamental unit of work
scheduled by CICS such as Read from file, write to file, read from workstation,
write to workstation, initiate another task, call another function and so on.
In CICS terms, a task is an instance of a transaction. When a transaction is initiated, a task gets created by OS and process the data/input provided by user/terminal. A task gets ended once the process is completed.
A task can be viewed using CICS execute master terminal transaction (CEMT)
CEMT INQ TASK(task-id)
In CICS terms, a task is an instance of a transaction. When a transaction is initiated, a task gets created by OS and process the data/input provided by user/terminal. A task gets ended once the process is completed.
A task can be viewed using CICS execute master terminal transaction (CEMT)
CEMT INQ TASK(task-id)
Transaction – An entity to initiate/invoke a
task for execution. A transaction is 1 to 4 characters long.
A
transaction is a piece of processing initiated by single request, usually by
end user at a terminal.
A
single transaction will consist of one or more application programs that, when
run, will carry out the processing needed.
A transaction in CICS is a unit of work and is represented by a 4 character TRANSID. Generally, one transaction executes on or more programs.
A transaction in CICS is a unit of work and is represented by a 4 character TRANSID. Generally, one transaction executes on or more programs.
Program – Set of instructions to achieve
a task.
LUW (Logical unit of work) tells that the piece of work
should be done either completely or not done at all.
NON AID keys – Alphabets, numbers,
punctuation etc. CICS will NOT even know if user presses any NON AID key which
means it can’t detect NON AID keys when pressed.
AID Keys – Attention Identifier keys are
Function keys ( PF1 to PF24 ), Enter, CLEAR and PA1 to PA3 keys. CICS detect
only AID keys when pressed.
After
text is typed, CICS takes the control once user presses any AID key.
PA1
-> Alt + PF1
MDT –
Modified Data Tag
FRSET
– Flag ReSET
Control Programs –
CICS
nucleus is constructed by control programs
Terminal Control Program (TCP) is used to receive messages from
the terminal. It also maintains hardware communication requirements.
Task Control Program (KCP) is used to simultaneously
control the execution of tasks and its related properties. It also handles all
issues related to Multitasking.
Program Control Program (PCP) is used to locate and load
programs for execution. It transfers the control between two programs and at
the end, it returns the control to CICS.
File control Program (FCP) provides an application program
with the services like read, write, insert, update or delete records in a file.
Storage Control Program (SCP) is used to allocate or
de-allocate the memory in CICS region.
Control Tables –
The
control tables needs to be updated accordingly with application information for
the successful execution of CICS application program.
Terminal Control Table (TCT) contains the terminal IDs connected
to the current CICS region. Whenever we login to CICS terminal, an entry is
made in TCT.
Program control table (PCT) contains Transaction ID and the
program associated with it.
Processing Program table (PPT) contains the program name or
mapset name, task use counter, main storage address, load library address etc.
When CICS receives the transaction, corresponding program name is picked up
from PCT and gets loaded.
File Control Table (FCT) contains the information about
file names, file types, record length etc. All the files names used in CICS
must be declared in FCT.
How a transaction processing is
done?
Once
the user enters transaction ID(eg., TN01) on the CICS terminal, first
corresponding program name will be checked in PCT. Once the program is found in
PCT, it checks the main storage address/ Load library address to get the program
loaded into the memory for execution.
CICS system transactions -
CESN (CICS Execute SigNon) – This transaction is used to
sign on into the CICS region.
CEDA (CICS Execute Definition and
Administration)
– This transaction is used by CICS administrators to define CICS table entries
and other Admin activities.
CEMT (CICS Execute Master
Terminal) – Used
to inquire and update the status of CICS environments. This is also used to
load a new program, load a copy of the old program into CICS after changes to
program.
CECI (CICS Execute Command
Interpreter) –
Used to check the syntax of CICS commands. Here the command gets executed only
if the syntax is correct.
CEDF (CICS Execute Debug
Facility) – Used
for debugging the program step-by-step which helps finding the errors.
CEAC (CICS Execute Abend Codes) – Used to find the explanation
for the CICS abend codes.
CESF (CICS Execute Sign oFf) – Used to sign off from CICS
region.
Multitasking is a feature of OS where multiple tasks can execute simultaneously. CICS supports multitasking.
Multithreading is a feature of OS where multiple tasks (created by OS for several transactions) executes the same program but with different data. Here, each task gets different copy of the same program. Multithreading requires that all CICS application programs must be quasi-reetrant; that is, they must be serially reusable between entry and exit points.
Multithreading is a feature of OS where multiple tasks (created by OS for several transactions) executes the same program but with different data. Here, each task gets different copy of the same program. Multithreading requires that all CICS application programs must be quasi-reetrant; that is, they must be serially reusable between entry and exit points.
Reentrancy: The reentrant program does not modify by itself when it is reentered after an interruption by the OS.
The program should not be in modified state, when CICS starts using the copy of that program.
For instance, when CICS receives first request to process a program, it starts executing that program. If, at the same time CICS another request of higher priority then the first one, then CICS halts the processing of the first request and preserve its state ( all changed variable data, or changed application logic for the 1st request) in a separate storage area and initialize the program (to get fresh copy of that program), start executing the second request. Once it is done, it initializes the program again and restores its first request's state and start executing the request from where it has stopped.
Quasi-Reentrancy – A reentrant program in CICS environment.
BMS (BASIC MAPPING
SUPPORT)
BMS
helps to develop formatted screens which are used to communicate between
Terminal and CICS program.
MAP – It is a screen representation of a functionality where users can access it. A map can have name from 1 to 7 chars.
Example : A customer enquiry screen where bank employees/users can access to check customer details by providing customer number as input.
Example : A customer enquiry screen where bank employees/users can access to check customer details by providing customer number as input.
MAPSET – Collection of maps which are
link edited together to form a load module. It should have a PPT entry and can
have name from 1 to 7 chars.
CICS
provides BMS to make an application program device independent and format
independent.
BMS Macros:
DFHMSD – Used to define MAPSET and its
characteristics.
DFHMSD
– used to define a MAPSET or Generates MAPSET definition. MAPSET name is a load module name
which should have an entry in PPT.
Parameters:
TYPE -> used to define the map and
the type.
MAP-
Physical map is created
DSECT
– Symbolic map is created
&&SYSPARM
– Both Physical and Symbolic maps are created
Final
– end of the mapset coding.
MODE -> Specifies whether the
mapset is to be used for input, output or both.
IN –
For Input only
OUT –
For Output only
INOUT
– For both Input and Output
LANG -> Specifies the language of
the application program into which symbolic description maps in the mapset are
copied.
This
parameter will be coded only when DFHMSD TYPE=DSECT
STORAGE ->
AUTO
– Both Physical and Symbolic maps will use separate memory locations.
BASE
–
CTRL -> used to define device
control requests.
FREEKB
– to unlock keyboard
FRSET
– to reset MDT to zero status
ALARM
– To display alarm at screen display time
PRINT
– sends the map to printer
TERM – type -> ensure device
independence and need to be coded only when the terminal is not 3270.
TIOAPFX (Terminal Input Output Area
PreFiX) -> Specifies whether BMS should include filler in symbolic map.
TIOAPFX = YES – to reserve the prefix space of 12 bytes for BMS commands to access TIOA properly. It should always be used for command level application programs.
If TIOAPFX=YES is specified, all maps within the mapset have the filler
TIOAPFX = NO - default option. It specifies that filler should not be included in symbolic maps.
If TIOAPFX=YES is specified, all maps within the mapset have the filler
TIOAPFX = NO - default option. It specifies that filler should not be included in symbolic maps.
DFHMDI – Used to define a MAP within
the Mapset.
SIZE
=(Rows,Columns) - > specifies the size of the map to be displayed to the
user. The standard size is 24 rows 80 columns
LINE – Row number where the map actually starts
COLUMN – Column number where the map actually starts
JUSTIFY – specifies entire map or map fields are left or right justified.
CTRL,TIOAPFX
are same as DFHMSD
DFHMDF – used to define new field on
the map. We have to code DFHMDF macro for every field present on the map.
POS
(row, col) - specifies the position of the field on the map by specifying row
and col#.
INITIAL
specifies the initial value of the field. Same as value clause in cobol. i.e
FLDNAME contains value ‘I LOVE CICS’.
FLDNAME contains value ‘I LOVE CICS’.
LENGTH specifies the length of the field.
ASKIP means Auto skip.
Data cannot be entered in this field. The cursor skips to next field.
IC (Insert Cursor) specifies the cursor needs to be placed on this field when the map is displayed. If IC is specified more than once, the cursor is placed in the last field.
PROT specifies to protect this field from entering or editing the data
UNPROT specifies to unprotect the field to edit or enter the data
BRT displays the field with bright intensity
DARK displays the field with dark intensity
NORM specifies normal display
COLOR is used to specify the color for this field
PICIN, PICOUT are used to specify the length of data fields used as input/output. (used to specify the picture clause for input and output Cobol variables in the symbolic map)
Here is the complete BMS Macro Source Code for
the Customer Inquiry Screen, with all the DFHMSD, DFHMDI and DFHMDF Macros.
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
PRINT NOGEN
INQSET1 DFHMSD
TYPE=&SYSPARM,
X
LANG=COBOL,
X
MODE=INOUT,
X
TERM=ALL,
X
DSATTS=COLOR,
X
CTRL=FREEKB,
X
STORAGE=AUTO,
X
TIOAPFX=YES
INQMAP1 DFHMDI
SIZE=(24,80),
X
LINE=1,
X
COLUMN=1
DFHMDF POS=(1,1),
X
LENGTH=8,
X
ATTRB=(NORM,PROT),
X
COLOR=TURQUOISE,
X
INITIAL='CUSTINQ1'
DFHMDF POS=(1,32),
X
LENGTH=16,
X
ATTRB=(NORM,PROT),
X
COLOR=TURQUOISE,
X
INITIAL='Customer Inquiry'
TRANSID DFHMDF
POS=(1,76),
X
LENGTH=04,
X
ATTRB=(NORM,PROT),
X
COLOR=TURQUOISE,
X
INITIAL='INQ1'
DFHMDF POS=(3,01),
X
LENGTH=42,
X
ATTRB=(NORM,PROT),
X
COLOR=TURQUOISE,
X
INITIAL='Type a customer number. Then
press ENTER.'
DFHMDF POS=(5,01),
X
LENGTH=24,
X
ATTRB=(NORM,PROT),
X
COLOR=TURQUOISE,
X
INITIAL='Customer number. . . . .'
CUSTNO
DFHMDF POS=(5,26),
X
LENGTH=06,
X
ATTRB=(NORM,UNPROT),
X
COLOR=TURQUOISE,
X
INITIAL='______'
DFHMDF POS=(5,33),
X
LENGTH=01,
X
ATTRB=ASKIP
DFHMDF POS=(7,01),
X
LENGTH=24,
X
ATTRB=(NORM,PROT),
X
COLOR=TURQUOISE,
X
INITIAL='Name and Address . . . :'
LNAME
DFHMDF POS=(7,26),
X
LENGTH=30,
X
ATTRB=(NORM,PROT),
X
COLOR=TURQUOISE
FNAME
DFHMDF POS=(8,26),
X
LENGTH=20,
X
ATTRB=(NORM,PROT),
X
COLOR=TURQUOISE
ADDR
DFHMDF POS=(9,26),
X
LENGTH=30,
X
ATTRB=(NORM,PROT),
X
COLOR=TURQUOISE
CITY
DFHMDF POS=(10,26),
X
LENGTH=20,
X
ATTRB=(NORM,PROT),
X
COLOR=TURQUOISE
STATE
DFHMDF POS=(10,47),
X
LENGTH=02,
X
ATTRB=(NORM,PROT),
X
COLOR=TURQUOISE
ZIPCODE DFHMDF
POS=(10,50),
X
LENGTH=10,
X
ATTRB=(NORM,PROT),
X
COLOR=TURQUOISE
MESSAGE DFHMDF
POS=(23,01),
X
LENGTH=79,
X
ATTRB=(BRT,PROT),
X
COLOR=TURQUOISE
DFHMDF POS=(24,01),
X
LENGTH=20,
X
ATTRB=(NORM,PROT),
X
COLOR=TURQUOISE,
X
INITIAL='PF3=Exit PF12=Cancel'
DFHMSD TYPE=FINAL
END
CICS MAP
Physical Map
Physical
map is a load module in the load library which contains the information about
how the map should be displayed.
TYPE=MAP in MAPSET definition creates Physical map
A map without any values is considered as Physical map.
TYPE=MAP in MAPSET definition creates Physical map
A map without any values is considered as Physical map.
CUSTOMER MAINTENANCE CUST010
CUST ID : -------
CUST NAME :
ADDRESS:
ADDRESS LINE 1 :
ADDRESS LINE 2 :
ADDRESS LINE 3 :
CITY :
STATE :
LAST UPD DATE: BY
ENTER=INQUIRE PF1=HELP PF3=EXIT PF4=UPDATE
Physical
map is coded with BMS Macros. This is primarily used by CICS and ensures device
independence in the application program.
BMS
macros are assembled separately and link edited into the CICS load library
Symbolic Map
Symbolic
map is a copybook in the library which is used by CICS application program to
send and receive messages from the terminal.
TYPE=DSECT in MAPSET definition creates Symbolic map
Represents a variable portion of a map, that is an area where user can enter data.
Once the input is given, all the symbolic map variables get populated on to the screen to give the customer details as below:
TYPE=DSECT in MAPSET definition creates Symbolic map
Represents a variable portion of a map, that is an area where user can enter data.
Once the input is given, all the symbolic map variables get populated on to the screen to give the customer details as below:
CUSTOMER MAINTENANCE CUST010
CUST ID : 990123
CUST NAME : REDDY
ADDRESS:
ADDRESS LINE 1 : FLAT NO 990
ADDRESS LINE 2 : RD NO 46
ADDRESS LINE 3 : AREA 1
CITY : HYDERABAD
STATE : TELANGANA
LAST UPD DATE: 28/06/19 BY MAHY
ENTER=INQUIRE PF1=HELP PF3=EXIT PF4=UPDATE
Symbolic
map ensures device and format independence to the application program
Symbolic
map contains all the variable data which is copied into program’s working
storage section.
Symbolic
map is included in the program by using COBOL COPY statement.
If TYPE=&SYSPARM, both physical and symbolic maps are created.
If TYPE=&SYSPARM, both physical and symbolic maps are created.
SKIPPER and STOPPER fields:
Suppose
I have coded the length of a field as 10 which means ideally we are able to
enter the data on this field for up to 10 chars. But, when we display the map
and try to enter the data on the same field, it allows us to enter the data of
more than 10 chars. So, to avoid this situation we use skipper and stopper
fields.
Skipper
and stopper fields are unnamed fields with length of 1 which needs to be
specified after actual field.
Skipper
field – When we code the skipper field after an unprotected field and start
entering the value on the field, once the specified length is reached then
the cursor moves to the next unprotected field.
NUMBER
DFHMDF POS=(01,01),
LENGTH=5,
ATTRB=(UNPROT,IC)
DFHMDF POS=(01,07),
LENGTH=1,
ATTRB=(ASKIP)
Stopper
field – When stopper field is coded after an unprotected field and start
entering the value on this field, then once the limit is reached the cursor
stops its positioning.
NUMBER
DFHMDF POS=(01,01),
LENGTH=5,
ATTRB=(UNPROT,IC)
DFHMDF POS=(01,07),
LENGTH=1,
ATTRB=(PROT)
Attribute Byte:
The
attribute byte of any field stores information about the physical properties
of the field.
0&1
– determined by contents of bit 2 to 7
2&3
– Protection and shift
00 unprotected alphanumeric
01 unprotected numeric
10 protected stop
11 protected skip
4&5
– Intensity 00 – normal, 01 – normal, 10
– bright, 11- No display (dark)
6 –
Must be zero always
7 –
Modified data tag. 0- field has not been modified, 1- field has been modified.
Modified Data Tag (MDT):
A
flag which holds single bit and used to specify whether the data can be
transferred to the system or not. This is the last bit in attribute byte.
If
MDT = 0, the field is not modified and the data cannot be transferred.
If
MDT = 1, the field is modified and the data can be transferred
CICS hardware transmits only those fields to the program whose MDT is 1 using RECEIVE macro. If program needs more fields to process, those field's MDT needs to be set to 1 programmatically before sending them to terminal using SEND macro. In this case, even if user don't make any changes to those fields then their MDT will still be 1.
MDT is useful to avoid MAPFAIL error. If none of the fields are modified, then program tries to RECEIVE map with no updated fields which results to MAPFAIL error.
FSET in ATTRB (can be seen in field definition macro DFHMDF) sets the MDT to 1
To reset, use FRSET in CTRL (can be seen in Map definition Macro DFHMDI).
CICS hardware transmits only those fields to the program whose MDT is 1 using RECEIVE macro. If program needs more fields to process, those field's MDT needs to be set to 1 programmatically before sending them to terminal using SEND macro. In this case, even if user don't make any changes to those fields then their MDT will still be 1.
MDT is useful to avoid MAPFAIL error. If none of the fields are modified, then program tries to RECEIVE map with no updated fields which results to MAPFAIL error.
FSET in ATTRB (can be seen in field definition macro DFHMDF) sets the MDT to 1
To reset, use FRSET in CTRL (can be seen in Map definition Macro DFHMDI).
SEND MAP:
This
command sends output data to the terminal
EXEC CICS SEND
MAP('map-name')
MAPSET('mapset-name')
[FROM(data-area)]
[LENGTH(data_value)]
[DATAONLY]
[MAPONLY]
[CURSOR]
[ERASE/ERASEAUP]
[FREEKB]
[FRSET]
END-EXEC
Parameters
in SEND MAP
MAP –
Name of the map which we want to send
MAPSET
– Name of the mapset which contains the map
FROM
– specifies the data area containing the data to be processed
MAPONLY
– specifies that only default data from the map is to be written
DATAONLY
– specifies that only application program data is to be written
ERASE
– To erase the complete screen before displaying what we send to terminal
ERASEUP
– To erase the values in unprotected fields
FRSET
– Flag ReSET turns off the MDT in attribute byte of all the fields before placing the data which is sending.
CURSOR
– to specify the cursor position on the terminal. We move -1 to the L part of
the field and then send map to the terminal.
ALARM,FREEKB,PRINT
are same
FORMFEED
– Makes the printer to restore to the top of the next page before output is
printed.
Receive Map:
This
command is used to receive input from terminal.
EXEC CICS RECEIVE
MAP('map-name')
MAPSET('mapset-name')
[INTO(data-area)]
[FROM(data-area)]
[LENGTH(data_value)]
END-EXEC
Restricted
COBOL verbs:
File
i/o statements like READ, WRITE, REWRITE, CLOSE, OPEN, DELETE and START.
File
section and Environment division.
System
functions like ACCEPT, DATE/TIME
Verbs
like DISPLAY, MERGE, STOP RUN, GO BACK
Execute Interface Block (EIB):
EIB
lets the program communicate with the execute interface program which process
CICS commands. This contains terminal ID, time of day and response codes.
List
of fields in EIB
EIBAID
X(1) Aid key pressed
EIBCALEN
S9(4) COMP – Length of communication area
EIBDATE
S9(7) COMP-3 – Contains current system date
EIBTASKN
S9(7) COMP-3– Contains task number
EIBRCODE
X(6)– Return code of the last transaction
EIBTRMID
X(4)– contains terminal id
EIBTRNID
X(4)– contains transaction id
EIBTIME
S9(7) COMP-3– contains current system time
CICS programs classification
1. Non conversion programs: Human intervention is not required. All the required
inputs need to be provided before we start executing the program.
Example - Below program displays “Hello World” on the
terminal
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-MESSAGE PIC X(30).
PROCEDURE DIVISION.
********************************************************
* SENDING DATA TO SCREEN *
********************************************************
MOVE 'HELLO WORLD' TO WS-MESSAGE
EXEC CICS SEND TEXT
FROM (WS-MESSAGE)
END-EXEC
********************************************************
* TASK TERMINATES WITHOUT ANY INTERACTION FROM THE USER*
********************************************************
EXEC CICS RETURN
END-EXEC.
2. Conversion Programs: Sending a message to the terminal and receiving the
response from user is called conversation.
An online application allows conversation between user
and application by a pair of SEND and RECEIVE messages.
- First system sends data to the terminal and waits for the user response.
- The time required for the user to respond to this message is called think time which is very high.
- The user provides necessary input and presses AID key.
- The application processes the input and sends the output.
- The program loaded into the main storage until the task ends.
Drawback
– Think time is very high for conversion programs.
Pseudo-conversation program:
Here
the system will not wait for user response, instead terminates the transaction
once it sends data to the terminal. The transaction will be started again when
user presses any AID key.
After
termination, the system allocates resources used by this transaction to other
transactions which makes the best utilization of the resources.
COMMAREA is used to pass data between
tasks. We
declare WS-COMMAREA in working-storage section
DFHCOMMAREA is a special memory area
allocated by CICS to every task. This is used to pass data between programs
either of same transaction or different transactions. This should be
declared in linkage-section under 01 level. The length of both ws-commarea and
dfhcommarea must be same.
WORKING-STORAGE SECTION.
01 WS-COMMAREA.
05 WS-DATA PIC X(10).
LINKAGE SECTION.
01 DFHCOMMAREA.
05 LK-DATA PIC X(10).
RETURN statement:
The
two types are return statements are
1. Return statement without
condition, which terminates task and transaction.
EXEC CICS RETURN
END-EXEC
2. Return statement with condition,
When the return is issued with transaction id (TRNSID) statement, the control returns to CICS with the next transaction ID.
When the return is issued with transaction id (TRNSID) statement, the control returns to CICS with the next transaction ID.
EXEC CICS RETURN
TRNSID(‘TRANSID’),
[COMMAREA(WS-COMMAREA)]
END-EXEC
DFHAID is a CICS provided copybook
which contains pre-coded set of variables used by application programs. This
copybook can be included in the application program by the statement COPY
DFHAID.
Dynamically Modifying attributes
of a field:
To
modify the attributes of a field we must include CICS provided copybook
DFHATTR in the application program. The attribute can be chosen from the
list of variables in that copybook and moved to the symbolic variable suffixed
with A.
CICS File Handling
CICS
allows users to access files in
Random
order
Sequential
Order
Random access
Most
file accesses are random in online because the transactions are not batched and
sorted in any order.
The
commands used for random processing
READ command reads a record from a
file using primary key.
Syntax:
EXEC CICS READ
FILE('name')
INTO(data-area)
RIDFLD(data-area)
LENGTH(data-value)
KEYLENGTH(data-value)
END-EXEC.
FILE - name of the file which is of 8 characters long and should be enclosed in quotes. The file name should have an entry in FCT
INTO – a data-area (variable) into which record is to be read.
RIDFLD – contains key of the record that needs to read
LENGTH – the max number of characters that may be read into data-area specified
KEYLENGTH – Length of the key
Example:
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-STD-REC-LEN PIC S9(4) COMP.
01 WS-STD-KEY-LEN PIC S9(4) COMP.
01 WS-STD-REC-KEY PIC 9(3).
01 WS-STD-REC PIC X(70).
PROCEDURE DIVISION.
MOVE +70 TO WS-STD-REC-LEN.
MOVE ‘100’ TO WS-STD-REC-KEY.
MOVE 3 TO WS-STD-KEY-LEN.
EXEC CICS READ
FILE ('FL001')
INTO (WS-STD-REC)
LENGTH (WS-STD-REC-LEN)
RIDFLD (WS-STD-REC-KEY)
KEYLENGTH (WS-STD-KEY-LEN)
END-EXEC.
Read
command options:
GENERIC
is used when we doesn’t know the complete key value.
UPDATE specifies the record is to be obtained for update or deletion. Skipping this option assumes read-only.
EQUAL specifies that we need the record whose key matches exactly with the one specified in RIDFLD
GTEQ specifies that we want the first record whose key is greater than or equal to the key specified
EXEC CICS READ
FILE('name')
INTO(data-area)
RIDFLD(data-area)
LENGTH(data-value)
KEYLENGTH(data-value)
GENERIC
UPDATE
EQUAL
GTEQ
END-EXEC.
Read command exceptions
NOTOPEN
– file not open
NOTFND – Record not found in the dataset
FILENOTFOUND – No file name entry in FCT
LENGERR – Length of the record doesn’t match with the specified in the command
NOTAUTH – Not authorized to use the file
DUPKEY – If more than one record satisfy the condition of key
WRITE command is used to write new
records into a file
The
parameters are same as for read except that “Data records will be picked FROM
data area specified and writes into a file.
EXEC CICS WRITE
FILE(name)
FROM(data-area)
RIDFLD(data-area)
LENGTH(data-value)
KEYLENGTH(data-value)
END-EXEC.
Following is the example to write a record in
'FL001' file where Student-id is the primary key and a new record with 101
student id will be written in the file:
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-STD-REC-LEN PIC S9(4) COMP.
01 WS-STD-KEY-LEN PIC S9(4) COMP.
01 WS-STD-REC-KEY PIC 9(3).
01 WS-STD-REC PIC X(70).
PROCEDURE DIVISION.
MOVE +70 TO WS-STD-REC-LEN.
MOVE ‘101’ TO WS-STD-REC-KEY.
MOVE 3 TO WS-STD-KEY-LEN.
MOVE '101Mohtahim M TutorialsPoint' TO WS-STD-REC.
EXEC CICS WRITE
FILE ('FL001')
FROM (WS-STD-REC)
LENGTH (WS-STD-REC-LEN)
RIDFLD (WS-STD-REC-KEY)
KEYLENGTH (WS-STD-KEY-LEN)
END-EXEC.
Write command exceptions are same as read command exceptions
REWRITE command is used to modify
existing record in the file.
Before
REWRITE the record must be read with READ UPDATE command. The parameters are
same as write
EXEC CICS REWRITE
FILE (name)
FROM (data-area)
LENGTH (data-value)
END-EXEC.
Example
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-STD-REC-LEN PIC S9(4) COMP.
01 WS-STD-KEY-LEN PIC S9(4) COMP.
01 WS-STD-REC-KEY PIC 9(3).
01 WS-STD-REC PIC X(70).
PROCEDURE DIVISION.
MOVE +70 TO WS-STD-REC-LEN.
MOVE ‘101’ TO WS-STD-REC-KEY.
MOVE 3 TO WS-STD-KEY-LEN.
EXEC CICS READ
FILE ('FL001')
INTO (WS-STD-REC)
LENGTH (WS-STD-REC-LEN)
RIDFLD (WS-STD-REC-KEY)
KEYLENGTH (WS-STD-KEY-LEN)
UPDATE
END-EXEC.
MOVE '100Mohtahim M TutorialsPnt' TO WS-STD-REC.
EXEC CICS REWRITE
FILE ('FL001')
FROM (WS-STD-REC)
LENGTH (WS-STD-REC-LEN)
END-EXEC.
Rewrite command exceptions
NOTOPEN,
LENGERR, NOTAUTH
INVREQ
specifies rewrite without prior READ with UPDATE
NOSPACE
specifies no enough space in the dataset
DELETE command is used to delete a
record from a file.
Before
Delete, we have to READ the record with UPDATE
EXEC CICS DELETE
FILE('name')
RIDFLD(data-value)
END-EXEC.
Delete
command exceptions
NOTOPEN,
NOTFOUND, NOTAUTH, INVREQ, FILENOTFOUND
Sequential Access
STARTBR(START Browse) tells the CICS from where to
start reading the file.
FILE
and RIDFLD are same as READ.
Only
GTEQ and EQUAL are allowed.
File
browsing is strictly Read-Only, so UPDATE is not allowed.
Syntax:
EXEC CICS STARTBR
FILE ('name')
RIDFLD (data-value)
KEYLENGTH(data-value)
GTEQ/EQUAL/GENERIC
END-EXEC.
READNEXT is to proceed reading the record starting from first record and in sequence one by one
READPREV is to proceed reading the file
from backwards.
RIDFLD
contains the key of the record which is currently read.
Syntax:
EXEC CICS READNEXT/READPREV
FILE ('name')
INTO (data-value)
LENGTH (data-value)
RIDFLD (data-value)
END-EXEC
RESETBR resets the starting point of the
file in the middle of the browse
Syntax:
EXEC CICS RESETBR
FILE ('name')
RIDFLD (data-value)
GTEQ
END-EXEC.
ENDBR allows us to end the browse once
we finish reading the file sequentially
Syntax:
EXEC CICS ENDBR
FILE ('name')
END-EXEC.
CICS – Error Handling
RESP and RESP2:
Every EXEC-CICS gives a response back after execution. Using RESP, user can validate the response received before proceeding further. RESP should be coded in the command as below:
EXEC CICS RECEIVE MAP(MAP01)
MAPSET(MAP01S)
INTO(WS-MAP)
RESP(WS-RESPONSE)
END-EXEC
In EIB copybook. EIBRESP, EIBRESP2 contains details of an error.
CICS error handling commands are
Every EXEC-CICS gives a response back after execution. Using RESP, user can validate the response received before proceeding further. RESP should be coded in the command as below:
EXEC CICS RECEIVE MAP(MAP01)
MAPSET(MAP01S)
INTO(WS-MAP)
RESP(WS-RESPONSE)
END-EXEC
In EIB copybook. EIBRESP, EIBRESP2 contains details of an error.
CICS error handling commands are
Handle condition specifies the label (para) to
which control is to be passed when the condition arises. We must include the
name of the condition and a label to which control is to be passed.
It will NOT handle system abends like SOC4, SOC7 etc.
It will NOT handle system abends like SOC4, SOC7 etc.
Example:-
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
PROCEDURE DIVISION.
EXEC CICS HANDLE CONDITION
DUPKEY(X0000-DUPKEY-ERR-PARA)
NOTFND(X000-NOT-FOUND-PARA)
ERROR(X0000-GEN-ERR-PARA)
END-EXEC.
X0000-DUPKEY-ERR-PARA.
DISPALY 'Duplicate Key Found'.
X0000-NOT-FOUND-PARA.
DISPLAY 'Record Not Found'.
X0000-GEN-ERR-PARA.
DISPLAY 'General Error'.
As per the above program, if DUPKEY condition arises, then the control will be passed to X0000-DUPKEY-ERR-PARA
Handle Abend:
On abnormal termination of a task, it routes the errors to a specific program or a para given in HANDLE ABEND.
It also deactivates or reactivates previous HANDLE conditions.
It also deactivates or reactivates previous HANDLE conditions.
Example:
EXEC CICS HANDLE ABEND
PROGRAM(name)
LABEL(para-name)
CANCEL|RESET
END-EXEC
Program - program name to which control is to be passed
Label - para-name to which control is to be passed.
Cancel - to cancel the active HANDLE ABEND request
Reset - to set the previously cancelled HANDLE ABEND requests
Label - para-name to which control is to be passed.
Cancel - to cancel the active HANDLE ABEND request
Reset - to set the previously cancelled HANDLE ABEND requests
ABEND command terminates the task
abnormally. We can define user defined abend codes using this command
EXEC
CICS ABEND
ABCODE(code)
END-EXEC
Example:
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
PROCEDURE DIVISION.
EXEC CICS ABEND
ABCODE(D100)
END-EXEC.
Ignore condition: It is to instruct CICS that any exception(s) mentioned inside IGNORE CONDITION should be ignored and the program should give control to the next executable line of this condition.
Syntax:
EXEC
CICS IGNORE CONDITION
CONDITION(para)
END-EXEC
Example:
EXEC CICS
IGNORE CONDITION
MAPFAIL
END-EXEC
Example:
EXEC CICS
IGNORE CONDITION
MAPFAIL
END-EXEC
NOHANDLE option with any command specifies that no action to be taken for any exception condition occurs during the execution of that command
Syntax:
EXEC CICS SEND
program statements
NOHANDLE
END-EXEC.
Example
– Below program will not abend if the read statement fails
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
PROCEDURE DIVISION.
EXEC CICS READ
FILE('FILE1')
INTO(WS-FILE-REC)
RIDFLD(WS-STDID)
NOHANDLE
END-EXEC.
HANDLE AID: To handle the aid keys received and it is invoked after every RECEIVE command.
EXECCICS
HANDLE AID DFHENTR (PARA1) DFHPF1 (PARA2) ANYKEY (PARA3) END-EXEC |
Commands used for program control services
XCTL transfers control from one application program to another at the same logical level. It doesn’t
expect the control back (similar to goto statement).
Below
example transfers control to the program ‘prog2’ with 100 bytes of data
IDENTIFICATION DIVISION.
PROGRAM-ID. PROG1.
WORKING-STORAGE SECTION.
01 WS-COMMAREA PIC X(100).
PROCEDURE DIVISION.
EXEC CICS XCTL
PROGRAM ('PROG2')
COMMAREA (WS-COMMAREA)
LENGTH (100)
END-EXEC.
LINK transfers control from an application program at one logical level to an application program at next lower logical level.
IDENTIFICATION DIVISION.
PROGRAM-ID. PROG1.
WORKING-STORAGE SECTION.
01 WS-COMMAREA PIC X(100).
PROCEDURE DIVISION.
EXEC CICS LINK
PROGRAM ('PROG2')
COMMAREA (WS-COMMAREA)
LENGTH (100)
END-EXEC.
LOAD makes a copy of application program, table or map available to the invoking task.
EXEC
CICS LOAD
PROGRAM(‘name’)
END-EXEC
RELEASE releases the program, table or mapset which was previous loaded by LOAD command. This means releasing all the resources of the task.
EXEC
CICS RELEASE
PROGRAM(‘name’)
END-EXEC
RETURN command returns control from an application program either to an application program at next higher logical level, or to CICS.
EXEC CICS RETURN
PROGRAM ('name')
COMMAREA (data-value)
LENGTH (data-value)
END-EXEC.
Interval Control operations:
ASKTIME requests current date and time
or timestamp. This can later be moved to working-storage variable in the
program.
EXEC CICS ASKTIME
[ABSTIME(WS-TIMESTAMP)]
END-EXEC.
FORMATTIME formats the timestamp into the required format.
XEC CICS FORMATTIME
ABSTIME(WS-TIMESTAMP)
[YYDDD(WS-DATE)]
[YYMMDD(WS-DATE)]
[YYDDMM(WS-DATE)]
[DATESEP(WS-DATE-SEP)]
[TIME(WS-TIME)]
[TIMESEP(WS-TIME-SEP)]
END-EXEC.
Any transaction in the CICS region can access common work area and there is only one CWA for entire CICS region.
Transaction work area (TWA) is used to pass data between
application programs which belong to same transaction. TWA exists only during
the transaction.
Temporary Storage Queue (TSQ)
- A queue of records which are created, read and deleted by different tasks or programs in the same CICS region.
- A record within a TSQ is identified by item number and can be read sequentially or directly.
- The records in the TSQ are accessible until the TSQ is explicitly deleted.
- The TSQs may be written in main storage or auxiliary storage in DASD.
- TSQs can be accessed by programs and transactions from the same CICS region.
WRITEQ TS allows you to write records into
a TSQ.
If no
such queue exists, one will be created and writes records into it.
TSQ
is identified by queue ID 1-8 bytes.
EXEC CICS WRITEQ TS
QUEUE ('queue-name')
FROM (queue-record)
[LENGTH (queue-record-length)]
[ITEM (item-number)]
[REWRITE]
[MAIN /AUXILIARY]
END-EXEC.
QUEUE
specifies the name of the TSQ.
FROM specifies the record to be written into the queue
LENGTH specifies length of the record
ITEM specifies the item number to be assigned to the record
REWRITE is used to update the existing record in the queue
MAIN/AUXILIARY option is used to store record in MAIN/AUXILIARY
AUXILIARY is default
READQ TS allows you to read the data in
TSQ
EXEC CICS READQ TS
QUEUE ('queue-name')
INTO (queue-record)
[LENGTH (queue-record-length)]
[ITEM (item-number)]
[NEXT]
END-EXEC.
NEXT specifies the next logical data item to be read
DELETEQ TS allows you to delete an entire
TSQ
EXEC CICS DELETEQ TS
QUEUE ('queue-name')
END-EXEC.
Transient Data Queue (TDQ) is the queue which can be
created and delete quickly.
The
contents in the Queue can be read only once as they get destroyed after read is
performed.
Allows
only sequential access.
TDQ
identified by 1 to 4 char name called destinationID which must be registered in
DCT (Destination control table).
Intrapartition
TDQ – Allows
sequential access and once the record is read, it is deleted from queue.
Extrapartition
TDQ – Once the
record is read, record is not deleted from the queue.
WRITEQ TD –
used to write into TDQ and they are always written to a file
EXEC CICS WRITEQ TD
QUEUE ('queue-name')
FROM (queue-record)
[LENGTH (queue-record-length)]
END-EXEC.
READQ TD – used to read the TDQ
EXEC CICS READQ TD
QUEUE ('queue-name')
INTO (queue-record)
[LENGTH (queue-record-length)]
END-EXEC.
DELETEQ TD – used to delete the TDQ
EXEC CICS DELETEQ TD
QUEUE ('queue-name')
END-EXEC
No comments:
Post a Comment