Académique Documents
Professionnel Documents
Culture Documents
CICS LEVEL II
MODULE 1
First Class presents an advanced course in CICS/VS for COBOL application programmers. The
course is designed to aid the application programmers. The course is designed to aid the
programmer in developing applications quickly and easily.
The Customer Information Control System, which is commonly referred to as CICS.
The new version of CICS:
_ offered its users a number of services which aided operating system efficiency.
_ shared resources in an efficient manner.
_ predefined resources for easy access.
_ provided only minimal user protection for efficiency.
CICS is a very efficient system but it is also a very complicated environment.
Computer professionals must design application programs to ensure the integrity of the data.
Third party tools are often used when developing programs to help destroyed.
CICS has been evolving for a number of years and it continues to change to meet today's high
on-line transaction volume.
Your mainframe computer's memory stores everything it needs to run the system and needs to
run the system and to run user applications.
The MVS operating system is used here for illustration purposes, however, other systems are
similar.
MVS/XA is divided into a number of regions. A region can be running a batch job, servicing a
single time sharing user or it could be running CICS.
If it's running CICS, it's servicing hundreds of users.
CICS contains different areas for storage. Some areas store:
_ CICS system software
_ CICS control tables
_ application programs
_ the user's working storage
Application programs never talk directly to the operating system. It is always done through CICS.
How many CICS regions do you think can run on a single machine?
The number of CICS regions is only limited by the resources available.
The number of terms are frequently used throughout this course. Here are four of them:
- task
- conversational mode
- pseudoconversational mode
- transaction
TASK
When the user enters a 1 - 4 character TRANSID at a terminal, a task is initiated.
The program associated with the TRANSID is loaded and executed.
As the program runs, it may acquire storage for execution purposes or for passing data.
When the program ends:
- storage disappears
- the task disappears
Do you think the program also disappears?
No. The program remains inactive but is written over if other users require space.
If the program needs to keep information for later use, it must be specifically saved.
A task can also span more than one program and/or subroutine.
When an EXEC CICS LINK statement is executed, control is passed to the linked program or
subroutine.
An EXEC CICS RETURN statement passes control back to the calling program and the subroutine
disappears.
What do you think happens when control is passed back to the program?
Execution continues from where the program left off. However, the program may choose to end
at that time.
We already know that a task can be started by entering a TRANSID. Do you think a task could be
started from another task?
Yes. By executing a START TRANSID command, a new task is initiated and the corresponding
program located.
If the new task is to start on the same terminal that initiated it, then it must wait until the current
task finishes executing.
Are the following statements (T)rue or (F)alse?
T - Control is passed back to a calling program when EXEC CICS RETURN is executed in the inked
program.
F - The task always terminates when a LINKed program finishes executing.
T - The START TRANSID command initiates a task from within a program.
CONVERSATIONAL MODE
When a task is initiated, the program uses the SEND command to relay output to the terminal.
The program then sits in memory, waiting for user input.
When the user types in the data and presses enter, the program's RECEIVE command accepts
the input.
This process of sending, waiting and receiving continues until the program and the task end.
PSEUDO CONVERSATIONAL MODE
In pseudoconversational mode, a task is initiated and output is sent the same as it was in
conversational mode.
However, this time the program does not sit in memory waiting for input. Instead, a RETURN
RANSID command stores information such as:
- Terminal ID
- TRANSID
When the user enters input, CICS detects the input and initiates the TRANSID which invokes the
program.
A new task is initiated and
- the program executes from the beginning.
- previously recorded data is read to determine where to start executing.
- the input data is processed.
- The task ends.
Input is RECEIVEd from the terminal.
Output is sent to the terminal. Output is likely sent to the terminal before the task ends.
This process of:
- task initiated
- program starts
- program reads input
- input processed
- output sent
- store TRANSID/environment information
- program ends
- task ends
continues until the user chooses to quit.
Complete the following statements:
Recall our task discussion. It stated that the program disappears when the task ends.
Do you think that Working Storage also disappears when the task ends?
When a task ends, Working Storage disappears so that the space can be used for another task.
Each time a program starts, it gets a fresh copy of working storage. (Module 4 discusses saving
working storage data between tasks.)
MODULE 2
BMS Features
- Attention Identifier Keys
- Cursor Position
- Attribute Override
You will want to use some special keys found on 3270-type terminals..
ATTENTION IDENTIFIER (AID) KEYS
The Attention Identifier Keys are:
The location of these keys on the keyboard varies depending on the model of CICS terminal you
have.
The key is usually on the left side of a 3270-type keyboard.
The rest of the Attention Identifier Keys are usually on the right side, or along the top row of the
keyboard.
When an Attention Identifier key is pressed, the program specified in the previous TRANSID is
started.
The program can then do different functions depending on which key is pressed.
PERS FIRST CLASS SYSTEMS 10/6/85
EMPLOYEE NO <>
FIRST NAME <>
LAST NAME <>
SALARY < $30000 >
ENTER> - INQUIRE - REWRITE - ADD - DELETE
- QUIT
For this CICS/VS program, and are all Attention identifier Keys that initiate the program, and tell it
to perform a certain task.
In order to write a program which uses Attention Identification Keys, you need to do two things to
the program.
1. Copy DFHAID into your working storage section.
2. Place conditional statements in your program to tell what action is to be taken when an
Attention Identification Key is pressed. The first step is to copy DFHAID into the WORKINGSTORAGE SECTION of your program. For example:
DATA DIVISION.
WORKING STORAGE SECTION.
01 EMPLOYEE-RECORD.
05 EMP-ID-NUMBER PIC X(05).
05 EMP-NAME PIC X(30).
05 EMP-DEPARTMENT PIC X(30).
05 SALARY PIC S9(05)V9(2).
05 FILLER PIC X(08).
COPY DFHAID.
COPY PERSM20.
PROCEDURE DIVISION.
Here is the WORKING- STORAGE code that would be copied in when you COPY DFHAID.
01
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
'.
02
02
02
02
02
DFHAID .
DFHNULL PIC X VALUE IS ' '.
DFHENTER PIC X VALUE IS QUOTE.
DFHCLEAR PIC X VALUE IS '!'.
DFHPEN PIC X VALUE IS '@'.
DFHOPID PIC X VALUE IS '#'.
DFHPA1 PIC X VALUE IS '$'.
DFHPA2 PIC X VALUE IS '%'.
DFHPA3 PIC X VALUE IS '^'.
DFHPF1 PIC X VALUE IS '&'.
DFHPF2 PIC X VALUE IS '*'.
DFHPF3 PIC X VALUE IS ''.
DFHPF4 PIC X VALUE IS ''.
DFHPF5 PIC X VALUE IS '.
DFHPF6 PIC X VALUE IS '?'.
DFHPF7 PIC X VALUE IS '
DFHPF8 PIC X VALUE IS ''.
DFHPF9 PIC X VALUE IS ''.
DFHPF10 PIC X VALUE IS ''.
DFHPF11 PIC X VALUE IS '='.
DFHPF12 PIC X VALUE IS ' '.
The DFHAID defines all the codes and gives them names like DFHCLEAR, so you don't have to
write the hex codes yourself. For example:
IF EIBAID = '%'
That means hex code.
EIBAID is a field in the Exec Interface Block. The fields in the EIB that we already know are:
EIBTRNID - Contains the TRANSID.
EIBCALEN - Contains the length of the communications area passed from the previous application
program.
EIBRCODE - Contains the return code after an error condition occurs.
EIBAID - Contains the Attention Identifier code associated with the last BMS input.
U - Update
A - Add
D - Delete
Q - Quit
Enter your choice ==>
The CHOICE input field is defined in the BMS macros to have the attributes IC, NORM, UNPROT,
and FSET.
The operator can only type one of five different letters: (I,U,A,D,Q)
If the operator makes a mistake, we could bring the error to the operator's attention by changing
the
attribute to bright.
This is called attribute override.
Indicate whether each question about symbolic maps is either (T)rue or (F)alse.
T - BMS macros are compiled 2 times: Once for a physical map, and once for a symbolic map.
T - A symbolic map contains only named fields.
T - The symbolic map is copied into the working storage section of your program.
Let's look at a named data field used for input in a BMS map.
DFHMDF POS=(19,25),LENGTH=25,ATTRB=(ASKIP,NORM),
INITIAL='PLEASE ENTER YOUR CHOICE:'
CHOICE DFHDMF POS=(19,52),LENGTH=01,ATTRB=(IC,UNPROT,NORM,FSET)
DFHMDF POS=(19,54),LENGTH=01,ATTRB=(ASKIP,NORM)
CHOICE is a named data field with a length of 1 and this field designed for INPUT.
01
05
05
05
05
10
05
01
05
05
05
MENUB1I.
FILLER PIC X(12).
CHOICEL PIC S9(01) COMP.
CHOICEF PIC X(01).
FILLER REDEFINES CHOICEF.
CHOICEA PIC X(01).
CHOICEI PIC X(01).
MENUB1O.
FILLER PIC X(12).
FILLER PIC X(03).
CHOICEO PIC X(01).
This is what the symbolic map looks like if CHOICE is the only named variable defined in the BMS
macros.
CHOICEL - contains input length.
ATTRIBUTE-COMBINATIONS.
ATTR-UNPROT PIC X VALUE ' '.
ATTR-UNPROT-FSET PIC X VALUE ' '.
ATTR-UNPROT-PEN-FSET PIC X VALUE ' '.
ATTR-UNPROT-BRT-PEN PIC X VALUE ' '.
ATTR-UNPROT-BRT-PEN-FSET PIC X VALUE ' '.
ATTR-UNPROT-DRK PIC X VALUE ' '.
ATTR-UNPROT-DRK-FSET PIC X VALUE '('.
ATTR-UNPROT-NUM PIC X VALUE ' '.
ATTR-UNPROT-NUM-FSET PIC X VALUE ' '.
ATTR-UNPROT-NUM-PEN PIC X VALUE ' '.
ATTR-UNPROT-NUM-PEN-FSET PIC X VALUE ' '.
ATTR-UNPROT-NUM-BRT-PEN PIC X VALUE ' '.
ATTR-UNPROT-NUM-BRT-PEN-FSET PIC X VALUE ' '.
ATTR-UNPROT-NUM-DRK PIC X VALUE '*'.
ATTR-UNPROT-NUM-DRK-FSET PIC X VALUE ')'.
ATTR-PROT PIC X VALUE '-'.
PERSONNEL INQUIRY
EMPLOYEE NUMBER < >
FIRST NAME < >
LAST NAME < >
DATE OF BIRTH < / / > SEX < >
D M Y M/F
If errors are typed into the employee number, date of birth or sex fields, we want the error to
turn BRIGHT on the screen.
Now you fill in the code to respond to operator errors.
IF EMPNOI < 10000
MOVE ATTR-UNPROT-BRT TO EMPNOA.
IF DAYI > 31
MOVE ATTR-UNPROT-BRT TO DAYA.
IF MONTHI > 12
MOVE ATTR-UNPROT-BRT TO MONTHA.
IF SEXI = 'M' OR 'F' NEXT SENTENCE
MOVE ATTR-UNPROT-BRT TO SEXA.
Often programmers do not highlight every error, they just highlight the first error on the screen.
This can be accomplished by placing an ELSE statement between each condition.
IF EMPNOI < 10000
MOVE ATTR-UNPROT-BRT TO EMPNOA
ELSE
IF DAYI > 31
MOVE ATTR-UNPROT-BRT TO DAYA
ELSE
IF MONTHI > 12
MOVE ATTR-UNPROT-BRT TO MONTHA
ELSE
IF SEXI = 'M' OR 'F' NEXT SENTENCE
MOVE ATTR-UNPROT-BRT TO SEXA.
If an operator makes an error when typing an input field, the field should be changed to BRIGHT.
Also, it would be helpful if the cursor automatically moved to the field in error.
We know how to change the field in error to bright, but how do we move the cursor to the field in
error?
This will be explained in the following screens.
Remember how the named fields of a BMS map are defined in WORKING-STORAGE?
Enter the correct letter at the end of the field name on the left to match the description on the
right.
CHOICEI ... contains input from the terminal.
CHOICEA ... contains the attributes of the field to be displayed.
CHOICEL ... contains the length of the input.
CHOICEO ... contains data to be output in this field.
CHOICEF ... indicates if the
CHOICEL reports the length of the input when receiving, but it also has a special cursor
positioning function when SENDING a map.
You can override the normal cursor positioning on a BMS map by moving a -1 into the field length
variable.
EXAMPLE:
MOVE -1 TO CHOICEL.
To use this for the field in error, we move -1 to the length field within an IF ... THEN statement:
EXAMPLE:
IF CHOICE = 'I' OR 'U' OR 'A' OR 'Q'
NEXT SENTENCE
ELSE
MOVE -1 TO CHOICEL.
You can code both an attribute override and cursor positioning.
This is coding for attribute override, changing error fields to BRT.
IF EMPNOI > 10000
MOVE ATTR-UNPROT-BRT TO EMPNOA
ELSE IF DAYI > 31
MOVE ATTR-UNPROT-BRT TO DAYA
ELSE IF MONTHI > 12
MOVE ATTR-UNPROT-BRT TO MONTHA
ELSE IF SEXI NOT = 'M' OR 'F'
MOVE ATTR-UNPROT-BRT TO SEXA
Let's add the code to move the cursor into the error field.
IF EMPNOI > 10000
MOVE ATTR-UNPROT-BRT TO EMPNOA
MOVE -1 TO EMPNOL
ELSE IF DAYI > 31
MOVE ATTR-UNPROT-BRT TO DAYA
MOVE -1 TO DAYL
ELSE IF MONTHI > 12
MOVE ATTR-UNPROT-BRT TO MONTHA
MOVE -1 TO MONTHL
ELSE IF SEXI NOT = 'M' OR 'F'
MOVE ATTR-UNPROT-BRT TO SEXA
MOVE -1 TO SEXL
Often a message is moved to a message field to explain the error to the operator.
IF EMPNOI > 10000
MOVE ATTR-UNPROT-BRT TO EMPNOA
_MOVE -1 TO EMPNOL
MOVE 'EMPLOYEE NUMBERS ARE BETWEEN 10000 AND99999' TO MESSAGEO
ELSE IF DAYI > 31
MOVE ATTR-UNPROT-BRT TO DAYA
MOVE 'THERE CAN BE ONLY 31 DAYS IN A MONTH' TO MESSAGEO
ELSE IF MONTHI > 12
MOVE ATTR-UNPROT-BRT TO MONTHA
MOVE 'THERE ARE ONLY TWELVE MONTHS IN A YEAR' TO MESSAGEO
ELSE IF SEXI NOT = 'M' OR 'F'
MOVE ATTR-UNPROT-BRT TO SEXA
MOVE 'PLEASE ENTER M OR F TO SEX' TO MESSAGEO
Now you know most of the things you would ever want to do with BMS maps.
When using maps a system error can occur and cause your program to ABEND.
This type of error is called a MAPFAIL condition.
A MAPFAIL condition occurs if an operator presses the key without having typed any input.
There are 2 ways to deal with a MAPFAIL condition...
Method 1:
In the DFHMDF macro, specify ATTR=FSET.
This ensures that the field is read, whether anything was typed or not.
Example:
CHOICE DFHMDF POS(20,15),LENGTH=0, ...*
ATTR=(IC,UNPROT,NORM,FSET)
Method 2:
In your program, use the IGNORE CONDITION command to avoid ABENDing the program, and
carry on.
Example:
Multiple maps
ACCUM
Overflow Processing
PAGING
CSPG
Let's begin with a review of macros to define a mapset holding a single map.
INV DFHMSD TYPE=...............
M1 DFHMDI SIZE=...............
DFHMDF POS=...............
DFHMDF POS=...............
MAPSET called 'INV'
MSD - Map Set Definition
MAP called 'M1'
MDI - Map Definition (Initial)
Map Field
MDF - Map Definition (Field)
You can also define more than one map within a single mapset.
INV DFHMSD TYPE=...............
M1 DFHMDI SIZE=...............
DFHMDF POS=...............
DFHMDF POS=...............
M2 DFHMDI SIZE=...............
DFHMDF POS=...............
Some installations may use a mapset to hold all maps for one application; others may use a
mapset to hold the maps for a single screen display.
Screens can be made of multiple maps.
__________________________________________________
A map can be placed at the top of the screen.
The middle section is a map or a collection of maps to display details.
A map is positioned at the bottom of the screen.
When you are using multiple maps on a screen, you are responsible for their positioning.
The positioning is defined in the parameters of the map definition (DFHMDI) macro.
M1 DFHMDI SIZE=(5,80),LINE=1,COLUMN=1
First, you specify the SIZE of the map in lines and columns. Then you can specify where each
map is positioned by using the LINE and COLUMN parameters.
Finally, you can specify whether the column position should be counted from the left or right of
the screen.
For example...
MAPA DFHMDI SIZE=(3,19),LINE=2,COLUMN=3,JUSTIFY=LEFT
MAPA DFHMDI SIZE=(3,10),LINE=2,COLUMN=3,JUSTIFY=RIGHT
If JUSTIFY=LEFT, the upper left corner of the map will be placed on LINE and COLUMN coordinates
which are counted from the LEFT.
If JUSTIFY=RIGHT, the upper right corner of the map will be placed on LINE and COLUMN
coordinates which are counted from the RIGHT.
So far, you've looked at map positions which are hard-coded in the definitions.
However, maps can also be displayed on a screen in positions relative to each other.
Look at the maps on the screen, then try to add a name to each map definition.
M1 M2
M3
M4
Altogether, the map definitions for this screen might look like this:
MAPSET1 DFHMDS ...
* ----------------------M1 DFHMDI SIZE=(2,4), JUSTIFY=FIRST
M2 DFHMDI SIZE=(2,19), LINE=SAME
M3 DFHMDI SIZE=(3,14), COLUMN=3, LINE=NEXT
M4 DFHMDI SIZE=(3,8), COLUMN=SAME, JUSTIFY=LAST
For positioning maps, the JUSTIFY parameter can replace the LINE parameter, the COLUMN
parameter.....or both.
Now that you've coded all the map definitions, how do you actually get them on the screen?
Each map is sent to the terminal screen with its own SEND command.
EXEC CICS SEND
MAPSET('TCOB10')
MAP('HMAP1')
FROM(HMAP1O)
ERASE
END-EXEC.
EXEC CICS SEND
MAPSET('TCOBM10')
MAP('DMAP2')
FROM(DMAP2O)
END-EXEC.
MAP('M3')
ACCUM
END-EXEC.
EXEC CICS SEND
PAGE
END-EXEC.
The SEND PAGE command can then be used to send the entire page to the terminal screen.
ACCUM - Collects maps in the page buffer.
SEND PAGE - Can send a page to the terminal.
ERASE - Can erase previous maps from a screen.
Overflow Processing
Again, one screen display is designed using three different maps ...
Product Num: 1111
Product Name: Widgits
Parts
0031 Handles Acme 1984
0032 Forks Acme 1983
1068 Dome Acme 1988
Instructions to continue ...
0031
0032
1068
1122
1234
1256
1279
1456
1784
1790
2122
... and the whole list of data available for map M2 won't fit on one screen.
In this case, you must build "pages" of detail information.
How would you do this?
First of all, you need to code the map definition somewhat differently.
M1 DFHMDI SIZE=(5,80),JUSTIFY=FIRST,HEADER=YES
M2 DFHMDI SIZE=(3,80) LINE=NEXT
M3 DFHMDI SIZE=(2,80),JUSTIFY=LAST,TRAILER=YES
Notice that JUSTIFY will still control position of the 3 maps.HEADER and TRAILER are used for
handling overflow.
------------------------PARTS
------------------------record 5
record 6
------------------------Instructions to
----------------------------TEMPORARY STORAGE ---Page 1
Page 2
Page 3
------------------------------------------Two final questions need to be answered before we leave this module.
How do you code an overflow routine to send pages to temporary storage instead of to the
terminal screen?
---Overflow routine---Send trailer
Send header
Send detail
----------------------------Actually, the only difference is a PAGING operand when sending maps.
How can you browse, delete, and manipulate pages which have been sent to temporary storage?
IBM supplies the CSPG transaction to browse, delete and manipulate pages. (Of course, you
could write your own code.)
CSPG is automatically initiated at the end of transactions which put pages into temporary
storage.
Mark the following statements (T)rue or (F)alse
F - CSPG is an IBM supplied transaction for handling overflow conditions.
F - The page buffer will reserve enough space for the largest detail map.
T - When a header map is sent to the page buffer, the page buffer is cleared.
CICS/XA LEVEL II MODULE 4
Temporary Storage Transient Data
When a CICS/VS program is terminated, all data in working storage is lost... unless a programmer
stores it for later.
You are probably already familiar with one way of storing data for later use EXEC CICS RETURN
TRANSID( )
COMMAREA(data-area)
LENGTH(data-value)
END-EXEC.
What operand would you have to include in the above command to specify the data AREA you
wish to pass?
The COMMAREA operand specifies a data area to pass to the next program. It is also included in
the LINK and XCTL commands.
RETURN TRANSID actually saves ONE record in temporary storage.
If you have more than a single record to save, you can use TEMPORARY STORAGE directly.
You can think of temporary storage as a scratch pad. Just as you write notes on a scratch pad for
later use you write data out to temporary storage for later use.
Temporary storage records are written into queues. A queue will hold as many records as you
want.
You can also use as many queues as you need. Temporary storage can pass data across tasks.
Data from one program can be put in temporary storage for later use. For example...
A map in working storage is presented to a user during the execution of a task.
The map is then written to temporary storage and the current task and working storage are
terminated.
When the user enters input, a new task and new working storage are created.
The program can check for modifications by comparing the data saved in temporay storage to
the current data content of the map.
WRITE
Here's an example of a WRITEQ TS command.
WORKING-STORAGE SECTION.
01 EMPLOYEE-RECORD.
05 EMP-ID-NUM PIC X(5).
05 EMP-NAME PIC X(30).
05 EMP-DEPT PIC X(15).
01 TS-ITEM PIC S9(2) COMP.
01 TS-QUEUE.
05 TS-TERMID PIC X(4).
05 TS-TRANSID PIC X(4).
.
EXEC CICS WRITEQ TS
QUEUE (TS-QUEUE)
FROM (EMPLOYEE-RECORD)
LENGTH (50)
ITEM (TS-ITEM)
END-EXEC.
QUEUE......names the TS queue where data is to be sent.
FROM.......specifies where the TS data comes FROM.
LENGTH.....specifies the length of the saved data.
ITEM.......is set to the record number within the Queue.
(You can rewrite a particular record.)
With CICS/VS it is possible for two users at different terminals to use the same program at the
same time. This could cause problems if the queue name is hard-coded (in quotes) in the
program. If the queue name is hard coded, the data from both users will be sent to the same
temporary storage queue. To get around this problem, we need a way to give each user a queue
and give each queue a unique name. A common naming convention uses a combination of
transaction id and terminal id.
WORKING-STORAGE SECTION.
01 EMPLOYEE-RECORD.
05 EMP-ID-NUM PIC X(05).
05 EMP-NAME PIC X(30).
05 EMP-DEPT PIC X(15).
01 TS-QUEUE.
05 TS-TERMID PIC X(04).
05 TS-TRANID PIC X(04).
.
.
PROCEDURE DIVISION.
MOVE EIBTRMID TO TS-TERMID.
MOVE EIBTRNID TO TS-TRANID.
.
.
EXEC CICS WRITEQ TS
QUEUE (TS-QUEUE)
FROM (EMPLOYEE-RECORD)
LENGTH (50)
END-EXEC.
In this example TS-QUEUE is the variable which will contain the queue name.
TS-QUEUE is declared in the WORKING-STORAGE SECTION. The first 4 bytes contain the
TERMINAL ID; the last 4 hold a TRANSACTION ID.
The Exec Interface Block (EIB) has the ID of the current transaction and the ID of the terminal
used.
In the PROCEDURE DIVISION, the information that we need is moved from the EIB into the
appropriate field.
Each terminal has its own ID, so when we concatenate it with transaction ID, we have a pretty
safe method of assigning unique names to temporary storage queues.
Temporary storage can be written to either main memory or auxiliary storage (disk).
Which do you think is used the most?
Auxiliary storage is usually used so main storage is not tied up. However, main storage can be
used to save small amounts of data (less than 200 bytes) which you need to access quickly.
REWRITE
REWRITE is another operand that you can use when you have modified a record already in
temporary storage. It updates the changed record in the temporary storage queue. The ITEM
parameter specifies which record is to be rewritten.
EXEC CICS WRITEQ TS
QUEUE (TS-QUEUE)
FROM (EMPLOYEE-RECORD)
LENGTH (50)
ITEM (TS-ITEM)
REWRITE
END-EXEC.
In the WRITEQ TS statement, you can specify which kind of storage you want with a
MAIN/AUXILIARY operand. AUXILIARY is the default.
So, for a quick review, let's assume that you've defined the WORKING-STORAGE SECTION of your
program as follows:
WORKING-STORAGE SECTION.
01 EMPLOYEE-RECORD.
05 EMP-ID-NUM PIC X(05).
05 EMP-NAME PIC X(30).
05 EMP-DEPT PIC X(15).
01 TS-QUEUE.
05 TS-TERMID PIC X(04).
05 TS-TRANID PIC X(04).
Fill in the blanks to complete a command which will write the EMPLOYEE-RECORD to a temporary
storage queue.
EXEC CICS WRITEQ TS
QUEUE (TS-QUEUE)
FROM (EMPLOYEE-RECORD)
LENGTH (50)
END-EXEC.
What operand would you include in the WRITEQ TS command when You have modified a record
and now you want to update that record in the TS queue.
You need the REWRITE operand.
READQ
The READQ TS command is used to read a record from a queue in temporary storage. The format
is as follows.
WORKING-STORAGE SECTION.
01 EMPLOYEE-RECORD.
05 EMP-ID-NUM PIC X(5).
05 EMP-NAME PIC X(30).
05 EMP-DEPT PIC X(15).
01 TS-QUEUE.
05 TS-TERMID PIC X(4).
05 TS-TRANSID PIC X(4).
.
.
EXEC CICS READQ TS
QUEUE (TS-QUEUE)
INTO (EMPLOYEE-RECORD)
LENGTH (TS-LENGTH)
ITEM (1)
END-EXEC.
Read record 1 from PAYROLL1. It is 50 bytes in length. Put it into EMPLOYEE.
MOVE 50 INTO REC-LEN.
:
EXEC CICS READQ TS
QUEUE ('PAYROLL1')
INTO (EMPLOYEE)
LENGTH (REC-LEN)
ITEM (1)
END-EXEC.
Notice that the value for the LENGTH operand is a variable. For READQ TS, LENGTH must be
coded as a variable or CICS will return an error code. If the record is shorter than the specified
length, CICS adjusts the variable accordingly. If the record is longer than the specified length,
CICS will truncate the record read. When you WRITE to a queue, the LENGTH value can be a
constant.
DELETEQ
When a temporary storage queue is no longer needed it should be deleted. Here is the command
which
allows you to do this.
EXEC CICS DELETEQ TS
QUEUE (TS-QUEUE)
END-EXEC.
The only thing you need to specify is the name of the queue you wish to delete. You can only
delete whole queues. It is important to note that there is no command that allows you to delete
individual records within a queue.
Why do you think deleting temporary storage queues which are no longer needed is so
important?
You must delete unused temporary storage queues because CICS/VS will not do it for you.
If you do NOT delete unused queues, all storage areas would be full of queues before too long.
Deleting them will free temporary storage areas for others to use.
You should now be familiar with RETURN TRANSID and TEMPORARY STORAGE for saving
data. There is a third way:
Transient data is like temporary storage in a number of ways.
First of all, temporary storage and transient data both have information stored in queues.
Secondly, temporary storage data and transient data can both be passed across tasks.
An application program could write data out to a transient data queue.
A print program could read the data from the queue and send it to the printer.
Difference between TD and TS
TEMPORARY STORAGE TRANSIENT DATA
Data is read randomly. Data must be read sequentially.
A data item can be read many times A data item can be read once.
and it remains in the queue until To reuse a record, the TD file
the entire queue is purged. must be closed and reopened.
Data can be changed. Data cannot be changed.
Temporary storage can be written Transient data items are always
to auxiliary or main storage. written to disk.
Temporary storage is a "holding Transient Data is ALWAYS
place" or "storage place" for data. associated with a destination.
Indicate whether each statement below is about TS (Temporary Storage) or TD (Transient Data):
Indirect destination
Remote destination
Extrapartition destination
Intrapartition destination
Let's look at the two most commonly used destinations.
EXTRAPARTITION
EXTRAPARTITION destinations are used for input / output outside of the CICS region.
For example:
In one CICS transaction, a new record is entered and the local data base is updated.
The transaction then stores the new record in a transient data queue.
In turn, the transient data is written to the associated external dataset.
At the end of the day, the external dataset is transmitted to head-office and used to update a
regional data base.
The DCT links the transient data queue and the external dataset information in the DCT is the
only way of getting at and using files which are external to CICS.
INTRAPARTITION
It is logical to think that an INTRAPARTITION destination is used for input and output within the
CICS system. This is partly true - but it is only part of the whole picture.
INTRAPARTITION transient data is used for intermediate storage. An amount of data is collected
in the data set before processing.
Before closing let us look at Transient data queue commands:
EXEC CICS WRITEQ TD
QUEUE(P001)
FROM(EMPLOYEE)
LENGTH(REC-LEN)
END-EXEC.
EXEC CICS READQ TD
QUEUE(P001)
INTO(EMPLOYEE)
LENGTH(REC-LEN)
END-EXEC.
EXEC CICS DELETEQ TD
QUEUE(P001)
END-EXEC.
Note that only INTRAPARTITION transient queues can be deleted.
1. Mark the following statements (T)rue or (F)alse:
F - Temporary storage is written in sets called files.
T - Temporary storage can be used to pass information across tasks.
F - Temporary Storage queue names must be defined in the DCT.
T - Temporary storage can be thought of as a scratch pad used to save data that will be used
later.
F - Temporary storage is often used to save short programs.
T - You can write as many records in a queue as you want.
2. Fill in the blanks to complete the command which will write EMPLOYEE-RECORD to
temporary storage.
WORKING-STORAGE SECTION.
01 EMPLOYEE-RECORD.
05 EMP-ID-NUM PIC X(05).
05 EMP-NAME PIC X(30).
05 EMP-DEPT PIC X(15).
01 TS-LENGTH S9(4) COMP VALUE +6.
01 TS-QUEUE.
05 TS-TERMID PIC X(04).
05 TS-TRANID PIC X(04).
.
.
PROCEDURE DIVISION.
MOVE EIBTRMID TO TS-TERMID.
MOVE EIBTRNID TO TS-TRANID.
.
.
EXEC CICS WRITEQ TS
QUEUE (TS-QUEUE)
FROM (EMPLOYEE-RECORD)
LENGTH (50)
END-EXEC.
3. In the last question you wrote the EMPLOYEE-RECORD data to temporary storage. Suppose you
wish to read this data back into EMPLOYEE-RECORD. Fill in the blanks so the code will do this.
WORKING-STORAGE SECTION.
01 EMPLOYEE-RECORD.
05 EMP-ID-NUM PIC X(05).
05 EMP-NAME PIC X(30).
05 EMP-DEPT PIC X(15).
01 TS-LENGTH S9(4) COMP VALUE +6
01 TS-QUEUE.
05 TS-TERMID PIC X(04).
05 TS-TRANID PIC X(04).
.
PROCEDURE DIVISION.
MOVE EIBTRMID TO TS-TERMID.
MOVE EIBTRNID TO TS-TRANID.
.
MOVE 50 TO TS-LENGTH.
EXEC CICS READQ TS
QUEUE (TS-QUEUE)
INTO (EMPLOYEE-RECORD)
LENGTH (TS-LENGTH)
ITEM (1)
END-EXEC.
4. Assume you no longer need the queue in temporary storage. Complete the code so you can
delete the temporary storage queue.
WORKING-STORAGE SECTION.
01 EMPLOYEE-RECORD.
05 EMP-ID-NUM PIC X(05).
05 EMP-NAME PIC X(30).
01 TERMINAL-USER-AREA.
Some of the variables contained in the EIB include ...
EIBTIME - contains the current time
EIBTRMID - contains the terminal ID
EIBCALEN - contains the COMMAREA length
... as well as a number of other pieces of information.
Where does CICS/VS get the information to put into the EIB?
The EIB is actually a selection of information found in various CICS/VS control blocks.
WORKING STORAGE.
LINKAGE SECTION.
01 DFHEIBLK.
PROCEDURE DIVISION.
These control blocks are small areas of main memory that CICS/VS uses to control its own
operation.
- Some control blocks stand by themselves
- Some are associated with terminals
- Some are associated with tasks
Let's take a closer look at control blocks and how they are used by CICS.
CSA - COMMON SYSTEM AREA
There is exactly one CSA (Common System Area) in memory at any given time.
It records which task is currently executing, and generally, the state of the system as a whole.
CWA -Common Work Area
The CWA (Common Work Area) is an extension of the CSA. It is an area set aside for use by the
individual installation in whatever way they like. Normally it contains security tables, and other
global data.
TCTUA (Terminal Control Table User Area)
There is usually a TCTUA (Terminal Control Table User Area) for each terminal connected to
CICS/VS. This installation-defined control block contains information such as user ID, the user's
security level and any other information the organization wants to keep from one task to the
next.
TCA - TASK CONTROL AREA
For every task running in the system, there is one TCA (Task Control Area) which contains
information about the execution environment. Some of the information it contains is related to
the running program and whether or not a terminal is connected to that program.
TWA - TASK WORK AREA
The TWA (Task Work Area) is an extension of the TCA. It can be used by programs within the task
to record data associated with the task. It is sometimes used to pass data between programs
within the same task instead of using the COMMAREA. This would be used by system utilities,
purchased software packages and various pre-command level COBOL programs (i.e. MACRO
level).
Lets see how many of those acronyms you remember.
CSA - Contains information about the program that is running, along with other global system
information.
TWA - Used by system utilities for inter-program communication within a task.
CWA - Contains installation-defined, global information.
TCTUA Can be used for organization defined user data such as user ID.
TCA - Records the state of a single TASK.
Now that you know what is kept in the control storage blocks, let's see how the data is
accessed ...
Suppose we want to determine if a particular user is allowed to update salary data. You would
need to know the user ID and the user's security level.
Which control block is most likely to be used to contain this information?
The TCTUA (Terminal Control Table User Area) contains all installation defined information.
Here's an example of a TCTUA definition coded in Working Storage.
01
05
05
05
05
TCTUA.
TCTUA-DEPARTMENT-CODE PIC X(04).
TCTUA-LOCATION PIC X(06).
TCTUA-OPERATOR-NAME PIC X(20).
TCTUA-SECURITY-LEVEL PIC 9.
The executing program can evaluate the data in these variables to determine if a particular user
is allowed to update salary data.
For example:
If the department code is PAYR (PAYROLL), and the security level is 3 or less, then the user is
allowed to update salary data.
Now, how do we get this information into our COBOL program? ...
The LINKAGE section is where we define all data areas which are not in our own working storage.
.LINKAGE SECTION..
01 DFHEIBLK.
01 DFHCOMMAREA PIC X.
01
05
05
05
05
TERMINAL-USER-AREA.
TCTUA-DEPARTMENT-CODE PIC X(04).
TCTUA-LOCATION PIC X(06).
TCTUA-OPERATOR-NAME PIC X(20).
TCTUA-SECUTITY-LEVEL PIC 9.
How does COBOL know that the TCTUA data is located in the TERMINAL-USER-AREA variable
definition?
The answer is: it doesn't. So, we have to go through a process known as ESTABLISHING
ADDRESSABILITY.
We'll look at the process of ESTABLISHING ADDRESSABILITY in a moment, but first ...
Are the following statements (T)rue or (F)alse?
F - CICS control block variables are defined in the Working Storage section of a COBOL program.
T - CICS control block variables are defined in COBOL programs.
T - Control block information can be accessed by a COBOL program.
ESTABLISHING ADDRESSABILITY
There are 2 steps to establishing addressability:
1. Find out where the block of storage is located in memory (i.e. its address).
2. Tell COBOL which item in the LINKAGE SECTION can be found at this address.
STEP 1 - LOCATE STORAGE BLOCK
CICS knows where the TCTUA for each terminal is located but your program doesn't (at least not
yet). The obvious thing to do is to ask CICS where it is!
The command to do this is ...
EXEC CICS ADDRESS
TCTUA (TERMINAL-USER-AREA-ADDR)
END-EXEC.
This command asks CICS to put the TCTUA address into TERMINAL-USER-AREA-ADDR.
STEP2 - IDENTIFY LINKAGE SECTION VARIABLES
Now that we know where the TCTUA is located, we have to add this variable to the LINKAGE
SECTION of our COBOL program.
LINKAGE SECTION.
01 DFHEIBLK.
01
01
05
05
DFHCOMMAREA PIC X.
ADDRESS-LIST.
ADDRESS-LIST-ADDR PIC S9(8) COMP.
TERMINAL-USER-AREA-ADDR PIC S9(8) COMP.
01
05
05
05
05
TERMINAL-USER-AREA.
TCTUA-DEPARTMENT-CODE PIC X(05).
TCTUA-LOCATION PIC X(06).
TCTUA-OPERATOR-NAME PIC X(20).
TCTUA-SECURITY-LEVEL PIC 9.
A new item, we'll call ADDRESS-LIST, contains the address of itself and ALL subsequent
01 items in the LINKAGE SECTION.
Notice the order of the LINKAGE SECTION code. The first entry is always DFHEIBLK.
CICS automatically adds this EIB description to your COBOL code. The next item coded is
DFHCOMMAREA. The ADDRESS-LIST is always coded in third position, immediately after
DFHCOMMAREA. Address list entries must be PIC S9(8)COMP. As soon as you put a value into an
ADDRESS-LIST variable, the corresponding 01 item is located.
ADDRESSABILITY is established and the information can be used.
ADDRESS-LIST.
ADDRESS-LIST-ADDR PIC S9(8) COMP.
TERMINAL-USER-AREA-ADDR PIC S9(8) COMP
TERMINAL-USER-AREA.
Let's put everything together, and see what our installation defined check on salary update looks
like ...
CHECK-SECURITY.
EXEC CICS ADDRESS
TCTUA (TERMINAL-USER-AREA-ADDR)
END-EXEC.
After the TCTUA address is loaded by a utility ...
IF TCTUA-DEPARTMENT-CODE = 'PAYR' AND TCTUA-SECURITY-LEVEL NOT > 3
MOVE 'Y' TO SALARY-UPDATE-ALLOWED
ELSE
MOVE 'N' TO SALARY-UPDATE-ALLOWED.
... the information is checked to see if the user's department code and security level are allowed
to update salaries.
Next, let's see how multiple control blocks are addressed.
01
05
05
05
05
ADDRESS-LIST.
ADDRESS-LIST-ADDR PIC S9(8) COMP.
TERMINAL-USER-AREA-ADDR PIC S9(8) COMP.
COMMON-WORK-AREA-ADDR PIC S9(8) COMP.
TASK-WORK-AREA-ADDR PIC S9(8) COMP.
01 TERMINAL-USER-AREA.
01 COMMON-WORK-AREA.
01 TASK-WORK-AREA.
PROCEDURE DIVISION.
EXEC CICS ADDRESS
TCTUA (TERMINAL-USER-AREA-ADDR)
CWA (COMMON-WORK-AREA-ADDR)
TWA (TASK-WORK-AREA-ADDR)
END-EXEC.
Recall that the first item coded in the ADDRESS-LIST is the address of that list. All other variables
must be coded in the same order as they appear in the LINKAGE SECTION.
Up to four (4) control block addresses can be accessed in one EXEC CICS ADDRESS statement.
A second EXEC CICS ADDRESS statement is required if more than four control block addresses
are accessed.
Remember that the EIB is entered into your COBOL program by the translator. The CICS
programmer is not concerned with locating the address of the EIB or COMMAREA.
ADDRESSABILITY to these control blocks is automatically provided by the translator.
Here we have the storage blocks defined in the LINKAGE SECTION.
LINKAGE SECTION.
01 DFHCOMMAREA PIC X.
01
05
05
05
ADDRESS-LIST.
ADDRESS-LIST-ADDR PIC S9(8) COMP.
TERMINAL-USER-AREA-ADDR PIC S9(8) COMP.
COMMON-WORK-AREA-ADDR PIC S9(8) COMP.
01 TERMINAL-USER-AREA.
05 TCTUA-DEPARTMENT-CODE PIC X(04).
01 COMMON-WORK-AREA.
05 CWA-GREGORIAN-DATE PIC 9(09).
So far, you've seen how CICS control blocks are defined and accessed.
Let's now take a look at establishing addressability to storage required by your application
program.
What if you have a situation where your COBOL program may or may not require access to a
large table?
.
WORKING STORAGE.
01 VARIABLES.
.
01 TABLE.
.
PROCEDURE DIVISION.
.
IF SALARY = MIN
.
ELSE
PERFORM LOAD-TABLE.
If the table is declared in Working Storage, space is allocated for the entire time the program is
running.
If the table isn't declared, space is not allocated and your program won't be able to access the
table.
How do you get the storage only when it is needed so you don't waste space?
The answer is: acquire it dynamically.
LINKAGE SECTION.
01 DFHCOMMAREA PIC X.
01 ADDRESS-LIST.
05 ADDRESS-LIST-ADDR PIC S9(8) COMP.
05 BLOCK-1-ADDR PIC S9(8) COMP.
01 BLOCK-1 PIC X(2500).
PROCEDURE DIVISION.
EXEC CICS GETMAIN
SET (BLOCK-1-ADDR)
LENGTH (2500)
END-EXEC.
CICS allows your program to dynamically acquire additional storage during execution.
GETMAIN
This GETMAIN statement:
- requests additional storage.
- stores the address pointer.
- defines the bytes required.
BLOCK-1-ADDR is defined in the ADDRESS-LIST and points to the storage block in the same way
CICS control blocks are defined.
LINKAGE SECTION.
01 DFHCOMMAREA PIC X.
01 ADDRESS-LIST.
05 ADDRESS-LIST-ADDR PIC S9(8) COMP.
05 BLOCK-1-ADDR PIC S9(8) COMP.
01
05
10
10
BLOCK-1.
BLOCK-1-TBL OCCURS 100.
VAR-1 PIC X(20).
VAR-2 PIC X(10).
PROCEDURE DIVISION.
EXEC CICS GETMAIN
SET (BLOCK-1-ADDR)
LENGTH (3000)
END-EXEC.
COMPUTE BLOCK-2-ADDR =
BLOCK-1-ADDR + 4096.
BLOCK-1 is a table which will dynamically GET storage from MAIN memory when it is required.
How many bytes do you think you should request for this array?
This table requires:
(20 + 10) x 100 = 3000 bytes of storage.
One GETMAIN statement can access a maximum of 64K. However, each address list variable can
only address a maximum of 4096 bytes.
If the array occurs 200 times, how many bytes do you now require?
You will need: (20 + 10) x 200 = 6000 bytes of storage.
This means that a second address list variable is needed to address the (6000 - 4096 = 1904)
bytes.
BLOCK-2-ADDR is then accessed by coding a COMPUTE statement.
The address of the remaining 1904 bytes is now located.
Code ALL the CICS statements and variables that dynamically acquire storage for the product
table.
(Make the first pointer TABLE-1-ADDR and the second TABLE-2-ADDR.)
01
05
05
05
ADDRESS-LIST.
ADDRESS-LIST-ADDR PIC S9(8) COMP.
TABLE-1-ADDR PIC S9(8) COMP.____
TABLE-2-ADDR PIC S9(8) COMP.
01
05
10
10
10
PROCEDURE DIVISION.
EXEC CICS GETMAIN
SET (TABLE-1-ADDR)
LENGTH (8000)
END-EXEC.
COMPUTE TABLE-2-ADDR = TABLE-1-ADDR + 4096.
EXEC CICS FREEMAIN (TABLE-1) END-EXEC.
When the 8000 bytes are no longer needed, they should be released so that CICS can reuse this
storage space. The FREEMAIN statement releases the block of storage acquired in a GETMAIN
statement.
Notice that the FREEMAIN statement names the block of storage being released. The pointer to
the storage block is not affected.
01 ADDRESS-LIST.
05 ADDRESS-LIST-ADDR PIC S9(8) COMP.
05 TABLE-1-ADDR PIC S9(8) COMP.
05 TABLE-15-ADDR PIC S9(8) COMP.
TABLE-1.
CLIENT-TBL OCCURS 300.
CLIENT-NAME PIC X(20).
CLIENT-ADDRESS PIC X(30).
CLIENT-INFO PIC X(200).
ADDRESS-LIST.
ADDRESS-LIST-ADDR PIC S9(8).
TCTUA-ADDR PIC S9(8).
TWA-ADDR PIC S9(8).
01 TCTUA.
.
.
01 TWA.
.
.
PROCEDURE DIVISION.
ADDRESS-LIST
SERVICE RELOAD .
Many programmers code the SERVICE RELOAD ADDRESS-LIST as the first line of their
PROCEDURE DIVISION so they don't forget to code this statement.
It is important to realize that SERVICE RELOAD is a COBOL statement; however, you will not find
it in your COBOL manuals.
This statement was added to the language to handle he problem of addressability and is
documented in
the CICS Programmer's Guide.
Now that you understand the concept of ADDRESSING, here is another way that it can be used.
Remember the file READ command?
EXEC CICS READ
DATASET ('EMPFILE')
RIDFLD (EMP-KEY)
INTO (EMP-RECORD)
END-EXEC.
The INTO option tells CICS where to put the record. What CICS actually does is ...
- allocate a block of storage in memory
- read the record into the storage block
- copy it into WORKING STORAGE
We can eliminate the "copy" step by defining EMP-RECORD in the LINKAGE SECTION, and asking
CICS where it is.
The SET option tells CICS to return the address of the just read record and put it into EMP-RECADDR.
LINKAGE SECTION
01 ADDRESS-LIST.
05 ADDRESS-LIST-ADDR ...
05 EMP-RECORD-ADDR ...
01 EMP-RECORD.
EXEC CICS READ
DATASET ('EMPFILE')
RIDFLD (EMP-KEY)
SET (EMP-RECORD-ADDR)
END-EXEC.
In which RECORD should EMP-REC-ADDR be defined?
The variable should be defined in the ADDRESS-LIST.
Here is some code which is meant to read a record, but not copy it into Working Storage. Fill in
the blanks, using the extension "-ADDR" where applicable.
LINKAGE SECTION.
01
05
05
05
01
01
05
05
ADDRESS-LIST.
ADDRESS-LIST-ADDR PIC S9(8)COMP.
TCTUA-ADDR PIC S9(8)COMP.
EMP-RECORD-ADDR PIC S9(8)COMP.
TCTUA PIC X(10).
EMP-RECORD.
EMP-NUMBER PIC X(10).
EMP-FNAME PIC X(15).
01 TERMINAL-USER-AREA.
05 TCTUA-DEPARTMENT-CODE PIC X(04).
01
05
10
10
10
TABLE-1.
PRODUCT-TBL OCCURS 1000.
PRODUCT-NO PIC X(10).
PRODUCE-NAME PIC X(24).
PRODUCT-PRICE PIC S9(4)V99.
PROCEDURE DIVISION.
EXEC CICS GETMAIN
SET (TABLE-1-ADDR)
END-EXEC.
What are Control Blocks used for?
Controlling the operations of a task
Assigning security to a terminal
Providing global installation data
Fill in the blanks to finish the following CICS COBOL segment.
LINKAGE SECTION.
.
.
01 ADDRESS-LIST.
05 ADDRESS-LIST-ADDR PIC S9(8) COMP.
05 TWA-ADDR PIC S9(8) COMP.
.
01 TWA.
05 TWA-FUNCTION PIC X(01).
05 TWA-USER PIC X(15).
.
PROCEDURE DIVISION.
.
EXEC CICS ADDRESS
TWA (TWA-ADDR)
END EXEC.
SERVICE RELOAD TWA.
What is the purpose of the SERVICE RELOAD statement?
To note an item's change of address
What variable is referred to in the SERVICE RELOAD statement?
The one whose address has changed
Indicate whether each of the following statements are (T)rue or (F)alse.
T - The SET option on a READ command saves space in main memory.
T - The INTO option of a READ command causes items to be copied into WORKING STORAGE.
T - The SET option makes programs more CPU efficient.
Complete this segment of CICS code to dynamically acquire storage.
LINKAGE SECTION.
01 ADDRESS-LIST.
05 ADDRESS-LIST-ADDR PIC S9(8) COMP.
05 A-TABLE-ADDR PIC S9(8) COMP.
01
05
10
10
A-TABLE.
TABLE-STORAGE OCCURS 100.
FIELD1 PIC X(20).
FIELD2 PIC X(10).
PROCEDURE DIVISION.
EXEC CICS GETMAIN
SET (A-TABLE-ADDR)
LENGTH (3000)
END-EXEC.
Which of the following LINKAGE SECTION coding is correct for dynamically acquiring storage in a
CICS COBOL program.
01 DFHCOMMAREA.
01
05
05
05
ADDRESS-LIST.
ADDRESS-LIST-ADDR
TCTUA-ADDR
TCA-ADDR
01 TCTUA.
01 TCA.
Most of the time, you will use CEMT to inquire (INQ) about the status of some resource on the
system or to (SET) the status of some resource.
By using CEMT we can get do following.
You
You
You
You
could
could
could
could
These are only a few ways in which CEMT can be used. It performs many other functions
as well...
INQUIRE about the TAsks(s) which are currently running.
Which task is suspended?
CEBR - Temporary Storage Browse
CEBR allows you to access data on a temporary storage queue.
With CEBR, queues can be
- browsed
- copied
- deleted
Now let's look at the commands available in the CEBR service transaction...
QUEUE xxxx - Names the queue you want to be current.
TERMINAL...- Changes the terminal part of a queue name.
LINE n.. - Displays LINE n on line 2 of the screen.
COLUMN n. - Moves the display to the n th queue column.
FIND /str - Finds the next occurrence of the specified string.
START
STATUS: COMMAND SYNTAX CHECK
EXEC CICS START
TRansid()
<>
<>
<>>>
<>
<>
<>
<>
:
S TRANSID MUST BE SPECIFIED
PF 1 HELP 2 HEX 3 END 4 EIB 5 VAR 6 USER 9 MSG
Up to this point, CECI and CECS are identical. CECS (Command Syntax) is a subset of CECI.
However, CECI can actually execute the commands.
Enter TRANSID(PAYR)
TRANSID(PAYR)
STATUS: COMMAND SYNTAX CHECK
EXEC CICS START
TRansid()
<>
<>
<>>>
<>
<>
<>
<>
CECI would now execute transaction PAYR.
CEBR is used to BRowse the temporary and transient queues.
CECI (Command Interpreter) is often used to try commands.
Use CEMT to INQuire about tasks and transactions, etc.
CECS (or CECI) can check and prompt for command syntax.
Let's continue with service transactions used for online resource definition.
As you know, resource definitions are stored in CICS tables.
The COMMAND LINE is mostly informational. Only the display number can be changed.
CEDF can remember up to 10 displays. By changing the display number, you can move backward
and forward through these. The most recent display is always numbered 00. The display
immediately before this is numbered -1.
What is the oldest possible display number?
-10 because CEDF can remember up to 10 displays.
The most recent display is always numbered 00.
The display immediately before this is numbered -1.
Normally, CEDF remembers only command displays.
The STATUS LINE gives the reason for CEDF's interruption of execution.
Here, execution was "interrupted" because CEDF is ready to begin.
CEDF interrupts execution
- at transaction initiation
- before and after every CICS command
- at program or task termination.
The interrupt conditions can be changed from the STOP CONDITIONS display.
This display can be reached by pressing the PF 9 key.
Overtyping the fields in the INFORMATION ARE is one of the most important ways
of interacting with CEDF.
When a field is overtyped, the new value is used in the execution of your program.
Most of the PF KEY menu below will already be familiar to you.
The ENTER key starts execution of the current transaction and changes the display to ...
THE COMMAND DISPLAY
The information area in this display contains
- the current command,
- its absolute address and line number,
- and the response condition (if any).
Notice that the status line indicates that execution of READQ TS is about to begin.
TRANSACTION: MENU PROGRAM: MENUP01 TASK NUMBER: 0000897 DISPLAY: 00
STATUS: COMMAND EXECUTION ABOUT TO BEGIN
EXEC CICS READQ TS
QUEUE ('AS10SECD')
INTO (' .)
LENGTH (200)
ITEM (1)
OFFSET:X'BCD074' LINE:00225 EIBFN=X'0A04'
RESPONSE: NORMAL
ENTER: CONTINUE
PF1 : UNDEFINED PF2 : SWITCH HEX/CHAR PF3 : END EDF SESSION
PF4 : SUPPRESS DISPLAYS PF5 : WORKING STORAGE PF6 : USER DISPLAY
PF7 : SCROLL BACK PF8 : SCROLL FORWARD PF9 : STOP CONDITIONS
When you are in the command display, you may overtype ...
A command. (The command can only be overwritten with NOP or NOOP to suppress command
execution.)
The WORKING STORAGE DISPLAY allows you to view and change the contents of Working
Storage.
You can move through Working Storage either by changing the start address or by using the
scroll keys.
Working Storage displays ...
-
It was mentioned earlier that CEDF allows you to set conditions for interrupting your transaction.
This is done from the STOP CONDITIONS DISPLAY.
Press PF9 now for the STOP CONDITIONS DISPLAY.
If you overtype fields in the STOP CONDITIONS display, CEDF will interrupt execution of your
transaction only when it finds one of the conditions you have set.
The current transaction will continue, but will not be monitored by CEDF.
You may use PF12 (ABEND USER TASK) to stop execution before you press PF3.
Are the following statements (T)rue or (F)alse?
CEDF is used for debugging COBOL commands. - F
CEDF can be used to browse Working Storage. - T
CEBR can be accessed from within CEDF. - T
1. Which one of the following could not be a CICS service transaction?
CEDC,CEOT,PAYR,CEDA
Ans : PAYR
2. Mark the following (T)rue or (F)alse:
T - A transient data queue must be copied into a temporary storage queue before it can be
browsed, etc. with CEBR.
T - CEBR is used to view the contents of a transient data queue without permanently destroying
it.
F - When a transient data queue is read into temporary storage, a copy of the data remains in
the transient data queue.
000210
000220*--------------------------------------------------000240
000250 GOBACK.
When the program is then compiled, the Compiler adds new line numbers to allow for the
additional lines.
00176 **000130 HIHO.
00177 **000131
00178 **000132 MOVE ZERO TO GOOSE-EGG.
00179 **000133
00180 **000134 COMPUTE GOOSE-EGG = 1 / GOOSE-EGG.
00181 **000135
00200 000200*--------------------------------------------------00201 ** *EXEC CICS RETURN END-EXEC.
00210 000210 MOVE ' 00020 ' TO DFHEIVO
00211 ** CALL 'DEFEI1' USING DFHEIVO.
00220 000220*--------------------------------------------------00240 000240
00250 000250 GOBACK.
-
- These are the EBCDIC columns from the left side of the PROGRAM STORAGE section we have
been looking at.
- As you can see, TCOBP01 appears near the top of this area: this is the PROGRAM STORAGE
section we need.
PROGRAM LOAD ADDRESS FROM DUMP
- The program load address for TCOBP01 is simply the first of the two addresses at the head of
this section.
What is the program load address for TCOBP01? 00350008
- To find the length of the CSECT, DFHECI, we need to look at the listing that was created when
the program was LINK-EDITED.
- We need the CONTROL SECTION section of this listing.
- DFHECI will be the first CSECT listed, and its length will be listed beside it.
What is the length of DFHECI? 48
CROSS REFERENCE TABLE
CONTROL SECTION
NAME ORIGIN LENGTH NAME LOCATION NAME
DFHECI 00 48
DFHEI1 8 DLZEI01
DLZEI04 8 DFHCBLI
TCOBP01 48 656
ILBOCOM0* 6A0 173
ILBOCOM 6A0
- These 4 words are the contents of the PSW or Program Status Word.
- The second word of the PSW always contains the address of the next instruction to be executed.
- This is part of the Procedure Division listing from the Compiler listing for our program.
- The command in line number 180 is the one which caused our program to ABEND.
Now, let's see how much you've learned.
- Let's take another look at the command which caused our program to ABEND.
00180 **000134 COMPUTE GOOSE-EGG = 1 / GOOSE-EGG.
- The ABEND code we found in the dump was ASRA. This is the code for a run-time system error.
- Since the ABENDing command involves division, it is likely that the ABEND was caused by an
attempt to divide by 0.
- Just to be sure (and to see how it's done), let's check the value of GOOSE-EGG in Working
Storage.
To check the value of GOOSE-EGG, we need to
1) find GOOSE-EGG's offset in WORKING STORAGE
2) find WORKING STORAGE in our ABEND dump, and
3) use GOOSE-EGG's offset to locate it in the dump.
This is the DATA DIVISION MAP (DMAP) from the compiler listing we saw earlier.
This gives us ...
O TCOBP01 10.37.30 JAN 26, 1991
_
O INTRNL NAME LVL SOURCE NAME BASE DISPL INTRNL NAME
DNM=1-035 01 STRANGE BL=1 000 DNM=1-035
O DNM=1-043 01 GOOSE-EGG BL=1 008 DNM=1-043
DNM=1-062 01 DFHLDVER BL=1 028 DNM=1-062
O DNM=1-080 01 DFHEID0 BL=1 036 DNM=1-080
DNM=1-097 01 DFHEIB0 BL=1 038 DNM=1-097
O DNM=1-114 01 DFHEICB BL=1 046 DNM=1-114
DNM=1-131 01 DFHEIV16 BL=1 048 DNM=1-131
... GOOSE-EGG'S offset or displacement ... and its BASE LOCATOR.
This tells us where we will find the base address from which this offset is calculated.
So GOOSE-EGG is located at an offset of 008 from the address in BASE LOCATOR 1.
- At the bottom of the DMAP ....
- is a section which defines the registers used as Base Locators.
Register 6 contains the address 00136980. 00136980
GOOSE-EGG is at an offset of 008 from this address. + 008
So GOOSE-EGG is located in address 00136988. 00136988
- The actual contents of Working Storage can be found in the TRANSACTION STORAGE sections of
an ABEND dump.
- These sections contain all the pieces of memory given to a task by CICS during its execution.
- Each section is labelled with the addresses it contains.
1. Indicate whether each of the following statement is either (T)rue or (F)alse.
F - COBOL programs which contain CICS commands must be compiled before they can be
translated.
T - The Link-Editing process produces a load module.
T - The ABEND code for a run-time system error is ASRA.
F - When an ABEND occurs, CICS automatically prints an ABEND dump.
T - The LABEL option in a HANDLE ABEND command transfers control to a specific line.
2. Complete the following ABEND command so that a dump labelled 'MESS' is produced.
EXEC CICS ABEND
ABCODE('MESS')
END EXEC
3. Write the HANDLE ABEND command which will transfer control to a program called CLEANUP.
EXEC CICS HANDLE ABEND
PROGRAM('CLEANUP')
END EXEC
4. For each of the resources below, select a number to match with where it can be located.
Program Load Address - Program storage section
Length of DFHECI - Control section (CSECT)
Line Number of ABENDing Command - Condensed Listing
Absolute Address of Next Command - PSW Word 2
5. You have collected the following information:
00502600 Program Load Address from Dump
00502950 Absolute Address of Next Command
40 Length of DFHECI
Using the above information, calculate the value of the following:
00502640 Actual Program Load Address
310 Relative Address of Next Command
CICS/XA LEVEL II MODULE 8
IMS DATA BASE CALLS
- Addressing IMS/VS data bases from CICS/VS
IMS/VS (Information Management System/Virtual Storage) is an IBM data base system. DL/I (Data
Language/I) is the IMS/VS data base manager which lets you create and access data bases.
CICS/VS allows you to access IMS/VS data bases using DL/I calls. This module shows us how, but
since it is intended for those already familiar with IMS/VS, thorough explanations for IMS/VS will
not be given.
If you are already familiar with IMS/VS it is possible that you used it with batch COBOL.
For review, let's take a look at a batch COBOL program which accesses an IMS/VS data base
using DL/I calls.
001 IDENTIFICATION DIVISION.
002 PROGRAM-ID. EXAMPLE.
003
004
005
006
007
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
009
010
011
012
013
014
015
016
017
018
019
020
01
05
05
05
05
05
EMPL-SEGMENT
EMPL-ID PIC X
EMPL-SURNAME PIC X(2
EMPL-GIVEN-NAME PIC X(2
EMPL-SALARY PIC S9
EMPL-DEPT-CODE PIC X
01
10
10
10
10
SSA-EMPL
FILLER PIC X(0
FILLER PIC X(1
SSA-EMPL-KEY PIC X(0
FILLER PIC X(
The first 4 lines of the code should look familiar to you. IMS/VS, like CICS/VS, only requires this
code for the IDENTIFICATION, ENVIRONMENT and DATA divisions. These lines are required for
both batch and CICS/VS programs.
Next, on line 7 of the WORKING- STORAGE SECTION, we define the variable 'GU '. It will be used
to pass data to a subroutine.
In this example, what value does the variable GU contain?
GU, plus two character spaces produce a four character function name to be passed.
Next, we code EMPL-SEGMENT. This field defines the IMS/VS data base layout. It
is included so our program has somewhere to store the segment accessed by IMS/VS.
Next comes the Segment Search Argument (SSA). It is used to identify the key to search for in
the IMS data base. We define it in this way in Working Storage so we can pass it in a call
statement.
So actually the SSA-EMPL field would contain:
EMPL (EMPLKEY = XXXXXX)
where XXXXXX would be the key we would search for in the data base.
If you wished to find the person with an EMPL-ID of 968758, in which field would you move this
value?
SSA-EMPL-KEY is where you would move the employee's ID.
001
002
003
004
005
006
007
IDENTIFICATION DIVISION.
PROGRAM-ID. EXAMPLE.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
009
010
011
012
013
01
05
05
05
05
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
PCB.
PCB-DBD-NAME PIC X(08).
PCB-SEG-LEVEL PIC X(02).
PCB-STATUS-CODE PIC X(02).
PCB-PROC-OPTIONS PIC X(04).
FILLER PIC S9(5) COMP.
PCB-SEGMENT-NAME PIC X(08).
PCB-KEY-LENGTH PIC S9(5) COMP.
FILLER PIC S9(5) COMP.
PCB-KEY-FEEDBACK PIC X(06).
Now for the LINKAGE SECTION. In a batch COBOL program that accesses IMS data bases, all you
code is the PCB or Program Communication Block.
This is used to transfer information between the data base system and your program.
034
035
036
037
038
039
040
041
PROCEDURE DIVISION.
ENTRY 'DLITCBL' USING PCB.
PERFORM GET-EMPL-SEGMENT.
GOBACK.
GET-EMPL-SEGMENT SECTION.
MOVE '968758' TO SSA-EMPL-KEY.
CALL 'CBLTDLI' USING
GU, PCB, EMPL-SEGMENT,
SSA-EMPL.
IF PCB-STATUS-CODE NOT = SPACES AND 'GE'
PERFORM ABEND.
FETCH-PSB-END.
EXIT.
This is the section which will access the IMS data base. In line 43 we move the key we will be
searching for into the SSA-EMPL-KEY field. Then we issue the DL/I call.
We will take a closer look at the call statement later in the module.
One of the fields in the PCB is PCB-STATUS-CODE. After a DL/I call this field tells us the status of
the call. If this field contains spaces, everything is fine. If it contains GE, it means that the
segment wasn't found. Anything else in this field would mean a problem. ABEND is a routine
which deals with the problem.
Here is the DL/I data base call statement. Note the order of the arguments.
CALL 'CBLTDLI' USING
GU, PCB, EMPL-SEGMENT,
SSA-EMPL.
The subroutine CBLTDLI is the interface between IMS/VS and your batch program.
The first argument is the variable which contains the name of the function to be performed. In
this example we are using GU or Get Unique segment function.
In which section did we find the field GU defined?
It is defined in the WORKING-STORAGE SECTION as follows:
WORKING-STORAGE SECTION.
01 GU PIC X(04) VALUE 'GU '.
The second argument is the PCB corresponding to the data base we wish to call.
Here's how it's defined in the LINKAGE SECTION.
LINKAGE SECTION.
01 PCB.
05 PCB-DBD-NAME PIC X(08).
05 PCB-SEG-LEVEL PIC X(02).
05 PCB-STATUS-CODE PIC X(02).
05 PCB-PROC-OPTIONS PIC X(04).
05 FILLER PIC S9(5) COMP.
05 PCB-SEGMENT-NAME PIC X(8).
05 PCB-KEY-LENGTH PIC S9(5) COMP.
05 FILLER PIC S9(5) COMP.
05 PCB-KEY-FEEDBACK PIC X(06).
The third argument specifies the field which will contain a retrieved segment. We define it in
WORKING-STORAGE as follows...
01
05
05
05
05
05
EMPL-SEGMENT.
EMPL-ID PIC X(06).
EMPL-SURNAME PIC X(20).
EMPL-GIVEN-NAME PIC X(20).
EMPL-SALARY PIC S9(7)V9(2).
EMPL-DEPT-CODE PIC X(04).
The fourth argument is the name of the Segment Search Argument we use to identify segments
of the DL/I data base. This is what it looks like in the WORKING-STORAGE SECTION.
01
05
05
05
05
SSA-EMPL.
FILLER PIC X(04) VALUE 'EMPL'.
FILLER PIC X(11) VALUE '(EMPLKEY = '.
SSA-EMPL-KEY PIC X(06).
FILLER PIC X(01) VALUE ')'.
GET-EMPL-SEGMENT SECTION.
MOVE EMPLNOI TO SSA-EMPL-KEY.
CALL 'CBLTDLI' USING
GU, PCB, EMPL-SEGMENT,
SSA-EMPL.
IF PCB-STATUS-CODE NOT = SPACES AND 'GE'
PERFORM ABEND.
FETCH-PSB-END.
EXIT.
This is from a CICS COBOL program. The only thing different, (besides the line numbers) is the
field we move to SSA-EMPL-KEY in line 184. In this example we move a variable which is defined
in the input map.
While the actual DL/I call to access the IMS data base is the same, a CICS COBOL program
requires more steps than a batch COBOL program.
In a batch program, the PCBs are available at the start of the program. In a CICS/VS program,
PCBs must be dynamically accessed. In order for us to access these PCBs, we must schedule the
PSB (Program Specification Block).
The Program Specification Block (PSB) contains one or more Program Communication Blocks
(PCB's). Remember the PCB describes the access requirements of each data base.
We'll talk about how we schedule a PSB in more detail, but before we do, let's look at how we set
up the WORKING-STORAGE SECTION and the LINKAGE SECTION in a CICS/VS application program.
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
IDENTIFICATION DIVISION.
PROGRAM-ID. EXAMPLE.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
COPY EXAM12.
01 GU PIC X(04) VALUE 'GU '.
01 GET-PSB-CODE PIC X(04) VALUE 'PCB '.
01 RELEASE-PSB-CODE PIC X(04) VALUE 'TERM'.
01 PSB-NAME PIC X(08).
01
05
05
05
05
05
EMPL-SEGMENT.
EMPL-ID PIC X(06)
EMPL-SURNAME PIC X(20)
EMPL-GIVEN-NAME PIC X(20)
EMPL-SALARY PIC S9(7)
EMPL-DEPT-CODE PIC X(04)
01
10
10
10
SSA-EMPL.
FILLER PIC X(04)
FILLER PIC X(11)
SSA-EMPL-KEY PIC X(06).
This part of the program should look familiar to you. It's very similar to the batch COBOL example
we looked at. We have added a few fields in lines 8 - 10 which will be used in DL/I calls.
In line 6 we copy the symbolic map into WORKING-STORAGE.
023 LINKAGE SECTION.
024
025 01 DFHEIBLK.
.
..
.
068 01 DFHCOMMAREA PIC X(100).
069
This part of the LINKAGE SECTION should also be familiar to you.
The DFHEIBLK is generated by the translator. The DFHCOMMAREA is a communication area.
Immediately after the DFHCOMMAREA is the ADDRESS-LIST.
Recall that it contains the address of itself and all subsequent 01 level entries in the LINKAGE
SECTION.
70
71
72
73
74
75
01
05
05
05
05
ADDRESS-LIST.
ADDRESS-LIST-ADDR
UIB-ADDR
PSB-ADDR
PCB-ADDR
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
COPY DLIUIB.
01 PSB.
05 PSB-PCB-ADDR OCCURS 4 PIC S9
01
05
05
05
05
05
05
05
05
05
PCB.
PCB-DBD-NAME PIC X(08).
PCB-SEG-LEVEL PIC X(02).
PCB-STATUS-CODE PIC X(02).
PCB-PROC-OPTIONS PIC X(04).
FILLER PIC S9(5) COMP.
PCB-SEGMENT-NAME PIC X(08).
PCB-KEY-LENGTH PIC S9(5) COMP.
FILLER PIC S9(5) COMP.
PCB-KEY-FEEDBACK PIC X(06).
Before you can use a PCB you must load its address into PCB-ADDR in the address list.
This must then be followed by a SERVICE RELOAD statement.
PCB-ADDR contains the address of the PCB as defined in line 81.
The PCB is defined the same as in a batch COBOL program.
Now for a quick review of the LINKAGE SECTION, answer the following questions.
ADDRESS-LIST is coded immediately after which 01 level entry?
The correct answer is DFHCOMMAREA. It looks like this:
01
01
05
05
05
05
Indicate which LINKAGE section 01 level entry each of these statements refers to. Use the
acronyms: UIB, PSB or PCB.
PSB - Contains the address of the PCBs
UIB - Contains the address of the PSB
UIB - Supplied by IBM and copied into your program
PCB - Describes access requirement for
a single data base to be accessed
Now lets examine the PROCEDURE DIVISION.
The missing lines might include code to send output to, and receive input from the terminal.
091
.
..
.
150
151
152
153
154
155
156
157
158
159
160
PROCEDURE DIVISION.
The PERFORM statements in lines 152-156 will accomplish these steps. We'll take a closer look at
each of these steps in a moment.
After we have accessed the data base all we have left to do is return to CICS/VS.
Fill in the blank so that this command will release our program.
The correct answer is RETURN. Now let's go back and look at the steps in accessing DL/I data
bases.
First, we'll look at PSB scheduling in more detail. FETCH-PSB is the section which does this.
In the batch program we used ENTRY 'DLITCBL'. In a CICS/VS program we schedule the PSB
instead.
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
FETCH-PSB SECTION.
MOVE 'BKSB01' TO PSB-NAME.
CALL 'CBLTDLI' USING
GET-PSB-CODE, PSB-NAME, UIB-ADDR.
IF UIBFCTR NOT = LOW-VALUES
PERFORM ABEND.
SERVICE RELOAD DLIUIB.
MOVE UIBPCBAL TO PSB-ADDR.
SERVICE RELOAD PSB.
MOVE PSB-PCB-ADDR (1) TO PCB-ADDR.
SERVICE RELOAD PCB.
FETCH-PSB-END.
EXIT.
BKSB01 is the name of the PSB we wish to use. Remember, the PSB is generated off-line using a
PSB generating utility program. We move this name into the field PSB-NAME so we can pass it in
a CALL statement.
This is the DL/I call to schedule the PSB.
GET-PSB-CODE is the name of the field which contains the value 'PCB' - - the function.
This was defined in WORKING STORAGE.
NOTE:
The function is PCB and not PSB like you might expect.
PSB-NAME contains the name of the PSB we wish to use.
What name would be in PSB-NAME in this example?
In line 164 we moved BKSB01 into PSB-NAME.
UIB-ADDR is the pointer which will be set to the address of UIB after the call is completed.
In the UIB is the field UIBPCBAL which contains the address of the PSB.
What we now have is the UIB-ADDR pointing to the UIB.
GET-EMPL-SEGMENT SECTION.
MOVE EMPLN0I TO SSA-EMPL-KEY.
CALL 'CBLTDLI' USING
GU, PCB, EMPL-SEGMENT,
SSA-EMPL.
IF PCB-STATUS-CODE NOT = SPACES AND 'GE'
PERFORM ABEND.
FETCH-PSB-END.
EXIT.
This is the section which actually accesses the data base. We won't say much about this section
because you have already seen it earlier in this module.
One thing worth mentioning is the functions you can perform besides GU. Other functions
include:
DLET GNP GHN ISRT
GN GHU GHNP REPL
If you use any of these, remember that you must assign it a variable name in Working Storage.
After we access the data base, the only thing left is to release the PSB.
196 RELEASE-PSB SECTION.
197
198 CALL 'CBLTDLI' USING RELEASE-PSB-CODE.
199
200 RELEASE-PSB-END
201 EXIT.
You should release the PSB when all DL/I operations are complete. This is so the PSB can be used
by other programs. Since you are allowed only one PSB at any given time, your releasing it will
allow you to access another PSB.
If you don't release the PSB, CICS/VS will do it for you when the task ends.
196
197
198
199
200
201
RELEASE-PSB SECTION.
CALL 'CBLTDLI' USING RELEASE-PSB-CODE.
RELEASE-PSB-END
EXIT.
Line 198 is the DL/I call to release the PSB. The field RELEASE-PSB-CODE contains the function
name 'TERM'.
Now you should have some idea of how to issue DL/I calls from a CICS/VS COBOL program.
To review, the steps in accessing DL/I data bases are ...
1. Issue a DL/I call to schedule the PSB and obtain PCB addresses.
2. Issue DL/I call(s) to access the data base and check results of the call.
3. Issue a DL/I call to release the PSB.
1. Indicate which call statement corresponds to each of the steps in accessing a DL/I database by
entering the appropriate letter in the blank.
Issue a DL/I call to schedule the PSB CALL 'CBLTDLI' USINGGET-PSB-CODE,PSB-NAME,UIB-ADDR.
Issue a DL/I call to access the required database CALL 'CBLTDLI' USING GU,PCB,EMPL-SEGMENT,SSA-EMPL.
Issue a DL/I call to release the PSB CALL 'CBLTDLI' USING RELEASE-PSB.
2. When scheduling a PSB what order are the following blocks accessed?
UIB,PSB,PCB
3. You wish to release a PSB. In the WORKING-STORAGE SECTION you have defined RELEASE-PSB
as follows:
01 RELEASE-PSB PIC X(04) VALUE 'TERM'.
Complete the DL/I called to release the PSB.
CALL 'CBLTDLI' USING RELEASE-PSB.
CICS/XA LEVEL II MODULE 9
DB2 and CICS
- Syntax
- Translate, Compile, Link-edit
- SQLCA
- Programming Aids
SQL commands are added to COBOL in much the same way that CICS commands are added. For
example:
-
EXEC CICS
READNEXT
FILE(PAYRROLL)
INTO(EMPLOYEE)
:
END-EXEC.
EXEC SQL
SELECT EMPNAME, EMPADDR
INTO :EMPNAME, :EMP-ADDR
FROM DSN8210.EMPTABLE
WHERE EMPNUM = :EMP-NUM
END-EXEC.
Now let's look at examples
of common SQL commands:
INSERT, UPDATE, DELETE, SELECT
INSERT
The SQL command INSERT is used to put records into a DB2 table.
Let's take a look at a typical example of an INSERT command.
MOVE '899' TO EMP-NUM.
MOVE 'JON DOE' INTO EMP-NAME.
MOVE '104 ST.' INTO EMP-ADDR.
EXEC SQL
INSERT INTO DSN210.EMPTABLE VALUES (:EMP-NUM, :EMP-NAME, :EMPADDR)
END-EXEC.
The SQL statement indicates that the record is inserted into a table called DSN210.EMPTABLE.
UPDATE
A record field is changed with UPDATE.
MOVE 819 TO EMP-NUM.
MOVE 33 TO EMP-AGE.
EXEC SQL
UPDATE DSN210.EMPTABLE
SET EMPAGE = :EMP-AGE
WHERE EMPNUM = :EMP-NUM
END-EXEC.
DELETE
You can delete a record from a table with the SQL DELETE command.
MOVE 720 TO EMP-NUM.
EXEC SQL
DELETE
FROM DSN210.EMPTABLE
WHERE EMPNUM = :EMP-NUM
END-EXEC.
SELECT
Record fields within a table can be read with the use of the SELECT statement.
MOVE 933 TO EMP-NUM.
EXEC SQL
SELECT EMPNAME, EMPADDR, EMPAGE
INTO :EMPNAME, :EMPADDR, :EMP-AGE
FROM DSN210.EMPTABLE
WHERE EMPNUM = :EMP-NUM
END-EXEC.
SQLCA
For a program to execute SQL statements the program must have an SQL communication area
(SQLCA).
DB2 uses the SQLCA to return information about the program execution.
For example:
- successful execution
- flags
- return codes
In a COBOL program the SQLCA is declared in the WORKING-STORAGE SECTION located in the
program's DATA DIVISION.
*----------------------COBOL PROGRAM
*----------------------:
::
DATA DIVISION.
WORKING-STORAGE SECTION.
::
EXEC SQL
INCLUDE SQLCA
END-EXEC.
::
:
As you know CICS commands must be translated into COBOL before the program can be
compiled.
*** COBOL PROGRAM ***
------------------------------------:
EXEC CICS
READNEXT
FILE(PAYRROLL)
INTO(EMPLOYEE)
LENGTH(REC-LEN)
RIDFLD(EMP-NUM)
END-EXEC.
:
OPEN-INPUT FILE-IN.
:
EXEC SQL
SELECT EMPNAME, EMPADDR, EMPAGE
INTO : EMPNAME, :EMP-ADDR, :EMP-AGE
FROM DSN8210.EMPTABLE
WHERE EMPNUM = :EMP-NUM
END-EXEC.
:
SQL statements must also be translated before the COBOL code can be compiled.
However, the SQL processing is just a bit different from CICS.
When SQL wants to perform some function on a DB2 table, DB2 does not want to interpret the
code every time it is used. So ...
The SQL statements must be put through a binding utility. This process translates the SQL into
a form (called a plan) which DB2 can understand immediately.
This plan is stored in DB2. A simple call to that plan is left within the COBOL code.
DB2 Interactive (DB2I)
As we close, take a brief look look at a useful DB2 utility - DB2 Interactive (DB2I)
________________________________________________________________
DB2PRIM DB2 MAIN MENU
OPTION ===>
1 - DB2I - SPUFI,DCLGEN,Program Prep,DB2 Commands,Utilities
2 - QMF - Query Management Facility for DB2FLEX
3 - QMF - Query Management Facility for DB2FIX
4 - DBEDIT - for DB2FLEX
5 - QMF Message Tool
6 - QMF - Query Management Facility for DB2DEVL
N NEWS - News and Information About DB2 Services
4BU Aa C1--MVS R 2 C 15 12:51 5/09/91
:
EXEC SQL
INCLUDE SQLCA
END-EXEC.
:
:
4. Number these operations in the correct order for creating a load module for a COBOL program
with CICS and SQL statements.
4
2
1
3
Link-edit.
Bind.
Translate.
Compile.