CICS Application Programming Guide
CICS Application Programming Guide
SC34-6433-00
CICS Transaction Server for z/OS
SC34-6433-00
Note!
Before using this information and the product it supports, be sure to read the general information under “Notices” on page
699.
Contents v
| Channels in LINK and XCTL commands . . . . . . . . . . . . . . 157
Program storage . . . . . . . . . . . . . . . . . . . . . . . 158
Temporary storage . . . . . . . . . . . . . . . . . . . . . . 158
Intrapartition transient data . . . . . . . . . . . . . . . . . . . 159
GETMAIN SHARED command . . . . . . . . . . . . . . . . . 160
Your own data sets . . . . . . . . . . . . . . . . . . . . . . 160
Lengths of areas passed to CICS commands . . . . . . . . . . . . . 161
LENGTH options . . . . . . . . . . . . . . . . . . . . . . . 161
Journal records . . . . . . . . . . . . . . . . . . . . . . . 161
Data set definitions . . . . . . . . . . . . . . . . . . . . . . 161
Recommendation . . . . . . . . . . . . . . . . . . . . . . 161
Minimizing errors . . . . . . . . . . . . . . . . . . . . . . . . 162
Protecting CICS from application errors . . . . . . . . . . . . . . 162
Testing applications . . . . . . . . . . . . . . . . . . . . . . 162
Non-terminal transaction security . . . . . . . . . . . . . . . . . . 163
Contents vii
Affinity transaction groups . . . . . . . . . . . . . . . . . . . 245
Relations and lifetimes . . . . . . . . . . . . . . . . . . . . 245
Contents ix
Templates in CICS files, z/OS UNIX System Services HFS files, temporary
storage, or transient data . . . . . . . . . . . . . . . . . . . 323
Creating templates in exit programs . . . . . . . . . . . . . . . . 324
Programming with documents and document templates . . . . . . . . . 325
Symbols and symbol lists . . . . . . . . . . . . . . . . . . . 325
Setting symbol values . . . . . . . . . . . . . . . . . . . . . 326
Embedded template commands . . . . . . . . . . . . . . . . . 328
Using templates in your application . . . . . . . . . . . . . . . . 329
The lifespan of a document . . . . . . . . . . . . . . . . . . . 330
Constructing a document . . . . . . . . . . . . . . . . . . . . 332
Using Bookmarks . . . . . . . . . . . . . . . . . . . . . . 334
Code page conversion for documents . . . . . . . . . . . . . . . 335
Contents xi
Hardware print key . . . . . . . . . . . . . . . . . . . . . . 415
BMS screen copy . . . . . . . . . . . . . . . . . . . . . . 415
Contents xiii
Building logical messages . . . . . . . . . . . . . . . . . . . . 503
The SEND PAGE command . . . . . . . . . . . . . . . . . . . 504
RETAIN and RELEASE . . . . . . . . . . . . . . . . . . . . . 504
The AUTOPAGE option . . . . . . . . . . . . . . . . . . . . . 506
Terminal operator paging: the CSPG transaction . . . . . . . . . . . . 506
Logical message recovery . . . . . . . . . . . . . . . . . . . . 507
Contents xv
User-key applications . . . . . . . . . . . . . . . . . . . . . 582
CICS-key applications . . . . . . . . . . . . . . . . . . . . . 582
Using transaction isolation . . . . . . . . . . . . . . . . . . . . 585
MVS subspaces . . . . . . . . . . . . . . . . . . . . . . . . 587
Subspaces and basespaces for transactions . . . . . . . . . . . . 587
The common subspace and shared storage . . . . . . . . . . . . . 588
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . 673
The CICS Transaction Server for z/OS library . . . . . . . . . . . . . 673
The entitlement set . . . . . . . . . . . . . . . . . . . . . . 673
PDF-only books . . . . . . . . . . . . . . . . . . . . . . . 673
Other CICS books . . . . . . . . . . . . . . . . . . . . . . . 675
Books from related libraries . . . . . . . . . . . . . . . . . . . . 675
DL/I . . . . . . . . . . . . . . . . . . . . . . . . . . . 675
DB2 . . . . . . . . . . . . . . . . . . . . . . . . . . . 675
Screen definition facility II (SDF II) . . . . . . . . . . . . . . . . 675
Common programming interface . . . . . . . . . . . . . . . . . 676
Common user access . . . . . . . . . . . . . . . . . . . . . 676
Programming languages . . . . . . . . . . . . . . . . . . . . 676
Teleprocessing Network Simulator (TPNS) . . . . . . . . . . . . . 676
Language Environment: . . . . . . . . . . . . . . . . . . . . 676
Miscellaneous books . . . . . . . . . . . . . . . . . . . . . 677
Contents xvii
Determining if a publication is current . . . . . . . . . . . . . . . . 677
Accessibility . . . . . . . . . . . . . . . . . . . . . . . . . 679
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . 681
Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . 699
Trademarks. . . . . . . . . . . . . . . . . . . . . . . . . . 700
Notes on terminology
API refers to the CICS command-level application programming interface unless
otherwise stated.
ASM is sometimes used as the abbreviation for assembler language.
™
MVS refers to the operating system, which can be either an element of z/OS® ,
OS/390®, or MVS/Enterprise System Architecture System Product
(MVS/ESA™ SP™).
VTAM®
refers to ACF/VTAM.
In the sample programs described in this book, the dollar symbol ($) is used as a
national currency symbol and is assumed to be assigned the EBCDIC code point
X’5B’. In some countries a different currency symbol, for example the pound symbol
(£), or the yen symbol (¥), is assigned the same EBCDIC code point. In these
countries, the appropriate currency symbol should be used instead of the dollar
symbol.
Guidance for the use of object oriented programming languages and techniques is
not included in this book. For guidance on developing application programs using
the Java language, see Java Applications in CICS, and for guidance on using the
CICS OO classes, see CICS C++ OO Class Libraries.
Changes have been made to titles and headings throughout the book, to make
them more meaningful, particularly when the book is explored online in the CICS
Information Center. Links and cross references have been improved.
v Part 1, Writing CICS applications, has been expanded to include an introduction
to basic CICS concepts and an application development roadmap. See “CICS
programming roadmap” on page 7.
© Copyright IBM Corp. 1989, 2005 xxi
v Part 2 in the previous edition, Object Oriented programming in CICS, has been
removed. For guidance on developing application programs using the Java
language, see the Java Applications in CICS component of the CICS Information
Center, and for guidance on using the CICS OO classes, see CICS C++ OO
Class Libraries.
v A new part 2 has been introduced, to bring together all information needed to
translate and compile CICS applications. Chapters describing the installation of
CICS programs and maps have been moved here from the CICS System
Definition Guide.
v Part 3, Application design, now separates general application design concepts,
see Chapter 11, “Application design,” on page 139, from application design for
performance, see Chapter 12, “Design for performance,” on page 165.
v BMS has been restructured into separate chapters, to form a new Part 6.
v The previous Appendix 1, mapping EXEC CICS commands to obsolete CICS
macros has been removed.
CICS applications can also take the form of Enterprise JavaBeans™. You can find
out more about this form of programming in Java Applications in CICS in the CICS
Information Center.
You should note that the term transaction is now used extensively in the IT
industry to describe a unit of recovery or what CICS calls a unit of work. This is
typically a complete operation that is recoverable; it can be committed or backed
out as an entirety as a result of programmed command or system failure. In many
cases the scope of a CICS transaction is also a single unit of work, but you should
be aware of the difference in meaning when reading CICS documentation.
This book describes the use of the CICS command level programming interface,
’EXEC CICS’, that can be used in COBOL, C, C++, PL/I or assembler programs.
These commands are defined in detail in the CICS Application Programming
Reference.
Programming in Java with the JCICS class library is described in the Java
Applications in CICS component of the CICS Information Center.
Programming in C++ with the CICS C++ classes is described in the CICS C++ OO
Class Libraries documentation.
For information about writing Web applications to process HTTP/1.0 requests and
responses, see the CICS Internet Guide.
For further guidance on language use with CICS, see Chapter 4, “Programming in
COBOL,” on page 21, Chapter 5, “Programming in C and C++,” on page 43,
Chapter 6, “Programming in PL/I,” on page 53..
CICS allows you to use SQL statements, DLI requests, CPI statements, and the
CICS Front End Programming Interface (FEPI) commands in your program as well
as CICS commands. You need to consult additional manuals for information:
v SQL Reference manual and the Application Programming and SQL Guide (for
SQL)
v Application Programming:EXEC DLI Commands manual and the Application
Programming: DL/I Calls manual (for DL/I)
v IBM SAA: CPI Reference manual and the SAA Common Programming Interface
for Resource Recovery Reference manual (for CPI)
v CICS Front End Programming Interface User’s Guide (for programming
information about FEPI commands)
You can write many application programs using the CICS command-level interface
without any knowledge of, or reference to, the fields in the CICS control blocks and
storage areas. However, you might need to get information that is valid outside the
local environment of your application program.
You can use the ADDRESS and ASSIGN commands to access such information.
For programming information about these commands, see the CICS Application
Programming Reference manual.
When using the ADDRESS and ASSIGN commands, various fields can be read but
should not be set or used in any other way. This means that you should not use
© Copyright IBM Corp. 1989, 2005 5
any of the CICS fields as arguments in CICS commands, because these fields may
be altered by the EXEC interface modules.
Translation
Most compilers (and assemblers) cannot process CICS commands directly. This
means that an additional step is needed to convert your program into executable
code. This step is called translation, and consists of converting CICS commands
into the language in which the rest of the program is coded, so that the compiler (or
assembler) can understand them.
Some compilers now contain integrated translators that can interpret CICS
commands and convert them automatically to calls to CICS service routines. If you
use one of these compilers, you do not need to perform the translation tasks
described in “The translation process” on page 69.
CICS provides a translator program for each of the languages in which you may
write, to handle both EXEC CICS and EXEC DLI statements.
Translator Options
You can specify a number of options for the translation process, and you may need
to do this for certain types of programs. If you are using EXEC DLI, for example,
you need to tell the translator this fact. “Using a CICS translator” on page 73
explains how to specify options, and “Defining translator options” on page 74
defines the options available.
The output structure remains accessible as long as the TCB under which the
request was issued has not terminated and DFH3QSS itself is still present in virtual
storage. Any change of execution state ( such as PSW key, ASC-mode, AMODE or
cross-memory environment ) might affect the availability of the CICS API. Registers
are preserved.
The CICS programming guidance documentation requires that your CICS system is
using the services of Language Environment, which provides a common runtime
environment for IBM® implementations of assembler and those high-level languages
(HLLs) supported by CICS, namely COBOL, PL/I, C, and C++.
Language libraries, other than the Language Environment libraries, should not be
present in your CICS startup JCL. If, perhaps for commonality with other CICS
systems, the JCL for your CICS startup job includes other language libraries, the
Language Environment libraries must be above all the other language libraries in
the JCL concatenations of the CICS startup job for both STEPLIB and DFHRPL.
This ensures that the programs are processed by Language Environment.
| CICS supports application programs compiled using compilers that are supported
| by Language Environment. This includes Language Environment-conforming
| application programs compiled by fully-conforming compilers, and non-Language
| Environment-conforming application programs that can execute under Language
| Environment in compatibility mode. The exception to this rule is for application
| programs compiled with the following non-Language Environment-conforming
| compilers, which are supported by Language Environment but not by CICS:
| v OS PL/1 Versions 1 and 2
| v C/370 V1 and V2
| For a list of compilers that are supported in this release of CICS Transaction Server
| for z/OS, see the CICS Release Guide.
When modifying existing application programs, or writing new programs, you must
use a compiler supported by Language Environment. This requires that your
application programs must be link-edited using the Language Environment
SCEELKED library, and this in turn means that the resulting application load module
can execute only under Language Environment.
| Note: Support for OS/VS COBOL programs is now withdrawn. These programs,
| which had runtime support in CICS Transaction Server for z/OS Version 2,
| cannot run under CICS Transaction Server for z/OS Version 3. OS/VS
| COBOL programs must be upgraded to a supported level of COBOL, and
| recompiled against a level of COBOL compiler supported by CICS.
| Appendix B, “Migration for OS/VS COBOL programs,” on page 669 provides
| assistance with converting OS/VS COBOL programs to a supported level of
| COBOL.
For further information about the details of these services, see the z/OS:
Language Environment Programming Guide. For information about the syntax
required to call any of the services, see the z/OS: Language Environment
Programming Reference.
CICS condition and AID handling
Language Environment condition handling does not alter the behavior of
applications that use CICS HANDLE CONDITION or HANDLE AID commands.
Language Environment is not involved in the handling of CICS-defined
exception conditions, which are raised and handled only by CICS. Similarly, AID
detection is a CICS function unaffected by Language Environment .
Abend handling
Language Environment Abend handling depends on the use of CICS HANDLE
ABEND. See “Using Language Environment Abend-handling”for details.
Storage
Language Environment uses storage obtained from CICS for each run-unit. See
“Managing Language Environment storage” on page 12 for information about
CICS parameters to control this.
Message and dump destinations
When the CEEMOUT (dispatch a message) and CEE3DMP (generate dump)
services are running under CICS, both the messages and dumps are sent to a
transient data queue called CESE, and not to their usual destinations. These
usual destinations are the ddname specified in the MSGFILE runtime option for
messages and the ddname given in the fname argument of the CEE3DMP
service for dumps. CICS ignores both of these ddnames.
If you write your own user-written Language Environment condition handler (other
than in COBOL), you can use most CICS commands, provided they are coded with
a NOHANDLE, RESP or RESP2 option, to prevent further conditions being raised
during execution of the condition handler. The only commands you cannot use are
the following, which must not appear in either the condition handler or any program
it calls:
v ABEND
v HANDLE ABEND
v HANDLE AID
v HANDLE CONDITION
v IGNORE CONDITION
v POP HANDLE
v PUSH HANDLE
Unless you use the NOLINKAGE translator option (see “NOLINKAGE” on page 80),
do not use the CICS translator to translate a COBOL user-written condition handler
that you have registered for a routine using the CEEHDLR service. This is because
the CICS translator adds two extra arguments to the PROCEDURE DIVISION
header of the COBOL program, the EXEC Interface Block (EIB) and the
COMMAREA. These arguments do not match the arguments passed by Language
Environment. A COBOL condition handler cannot, therefore, contain any CICS
commands.
For full details of the required interface to any Language Environment condition
handling routine, see the z/OS: Language Environment Programming Guide.
If you specify RUWAPOOL=NO, at the start of each CICS link level, CICS issues a
GETMAIN for this storage and passes it to Language Environment to use for its
control blocks and for storage areas such as STACK, LIBSTACK, and HEAP. The
storage is acquired in the default key specified on the transaction. The storage is
freed (using FREEMAIN) when the program terminates.
If you specify RUWAPOOL=YES, the first run of a transaction is the same as with
RUWAPOOL=NO, but CICS keeps a history of the total storage for RUWAs that is
requested to run the transaction. This means that when the transaction is run again,
CICS issues a single GETMAIN for the total storage (and a single FREEMAIN at
task end), creating a RUWAPOOL. If the transaction follows the same path, CICS
allocates the storage from the RUWAPOOL, and no further GETMAIN has to be
Assembler subroutines called from an HLL program are fairly straightforward and
not uncommon. A subroutine called from one HLL but written in another needs
much more careful consideration and involves what is called interlanguage
communication (ILC). Language Environment defines an ILC application as one
built of two or more HLLs and, optionally, assembler. See z/OS Language
Environment Writing Interlanguage Communication Applications for full details on
this subject.
Language Environment dictates that if there is any ILC within a run unit under
CICS, each compile unit must be compiled with a Language Environment-
conforming compiler. CICS supports three HLLs: C/C++, COBOL, and PL/I. We
consider the interfaces in pairs. If your application contains only two HLLs, consult
the appropriate section. If your application contains all three HLLs, consult those
sections corresponding to each of the interfaces within your application.
C/C++ and COBOL
The conditions under which Language Environment supports ILC between
routines written in C/C++ and COBOL depend on the following:
v Whether the language is C or C++
v Which COBOL compiler is being used and whether or not DLL is specified as
a compiler option
v Whether the call is static or dynamic
v Whether the function being invoked is within the module or exported from a
DLL
v Whether or not the program is reentrant
v What, if any, #pragma linkage statement you have in your C program
v Whether your C program exports functions or variables
v What, if any, extern statement you have in your C++ program
The results of all this are specified in five tables in z/OS Language Environment
Writing Interlanguage Communication Applications; you should consult this book
if your application mixes C/C++ and COBOL.
Note: For assembler to call C or C++, you must include the following
statement:
C #pragma linkage(,OS)
C++ extern "OS"
You should define all potential DLL executable modules as PROGRAM resources to
CICS.
DLL support is available for applications under CICS where the code has been
compiled using any of the compilers listed in the z/OS Language Environment
Programming Guide. See that manual for more information on building and using
DLLs.
Note: There is no source code mechanism that allows the setting of runtime
options within COBOL programs or within C++ programs.
6. In the Language Environment options specified in a debugging profile. For more
information, see “Debugging profiles” on page 656.
In most installations, the first method in the list above is not available to application
programmers, and the second is often not available. However, application
programmer can use the last two methods. They are in effect equivalent (some of
the newer compilers, for example VisualAge for PL/I, make them equivalent by
generating a CEEUOPT CSECT when PLIXOPT is declared). Choose either
methods 3 or method 4; do not attempt to use both methods. For details of
generating a CEEUOPT CSECT to link with your application, see z/OS Language
Environment Customization.
Notes:
1. Both CEEDOPT and CEEROPT are able to set any option so that it cannot be
overridden by a later specification.
2. Under CICS many of the Language Environment option settings are ignored.
These are all the Fortran-only options plus the following:
| This can be assembled and linkedited into a into a load module and then the
| CEEUOPT load module linkedited together with any language program
| supported by Language Environment as explained above.
| Alternatively for C and C++ programs, add the following statement at the start of
| the program source before any other C statements:
| #pragma runopts(ENVAR(CICSVAR=THREADSAFE))
| For PL/I programs add the following statement following the PL/I MAIN
| procedure statement:
| DCL PLIXOPT CHAR(25) VAR STATIC EXTERNAL INIT(’ENVAR(CICSVAR=THREADSAFE)’);
Finally, be aware that , after all the above changes, there are two exits that are
called in the following order and both of these can change some of the options as
follows:
1. By setting the CEEAUE_A_OPTION return parameter of the CEEBXITA
Language Environment user exit (apart from the LIBRARY, RTLS, STACK, and
VERSION options).
2. In the storage tuning user exit, CEECSTX, the options STACK, LIBSTACK,
HEAP, ANYHEAP, and BELOWHEAP can be set.
The storage tuning exit, like the CEEROPT CSECT, is region wide, but CEEBXITA
is linked into every program. Language Environment calls CEEBXITA the assembler
exit because, like CEECSTX, it is invoked before the environment is fully
established and must therefore be coded in assembler.
For more details on both CEEBXITA and CEECSTX see z/OS Language
Environment Customization.
Something similar happens when a CICS XCTL command is executed. In this case
we do not get a child enclave, but the existing enclave is terminated and then
reinitialized with the runtime options determined for the new program. The same
performance considerations apply.
CEEBXITA coding
If you write your own version of CEEBXITA, you must write it in assembler. You can
use all CICS commands except the ones listed here, provided you specify the
NOHANDLE, RESP or RESP2 option, to prevent conditions being raised during the
execution of the exit. These are the commands that cannot be used within
CEEBXITA, or any routines called by CEEBXITA:
v ABEND
v HANDLE ABEND
v HANDLE AID
v HANDLE CONDITION
v IGNORE CONDITION
v POP HANDLE
v PUSH HANDLE
For more information about how to specify Language Environment runtime options
and also for their meanings, see z/OS Language Environment Programming
Reference.
Ordinary Language Environment coding rules apply to CEEBINT, and you can write
it in C, C++, PL/I, or Language Environment-conforming assembler. CEEBINT
For more information on the High Level Language user exit, CEEBINT, see the
z/OS Language Environment Programming Guide.
All references to COBOL in CICS Transaction Server for z/OS, Version 3 Release 1
documentation imply the use of a supported Language Environment-conforming
compiler such as Enterprise COBOL for z/OS and OS/390, unless specifically stated
otherwise.
Note
| Runtime support for OS/VS COBOL is withdrawn in CICS Transaction Server
| for z/OS Version 3.
CICS does not provide translate and compile time support for old non-Language
Environment-conforming compilers. These compilers and their runtime libraries are
now out of service. See “Conversion to Enterprise COBOL” on page 669 for
information about conversion of programs compiled with unsupported compilers.
Programming restrictions
This section describes COBOL language elements that you cannot use under CICS,
or whose use is restricted or can cause problems under CICS.
There are some considerations associated with the use of a VS COBOL II compiler:
Re-linking VS COBOL II programs
If object modules are not available for re-linking existing VS COBOL II programs
to run under Language Environment, a sample job stream for performing the
task is provided in the IGZWRLKA member of the SCEESAMP sample library.
CICS stub
Although VS COBOL II programs linked with the old CICS stub, DFHECI, run
CBLPSHPOP option
The CBLPSHPOP runtime option controls whether Language Environment
automatically issues an EXEC CICS PUSH HANDLE command during initialization
and an EXEC CICS POP HANDLE command during termination whenever a
COBOL subroutine is called.
The ADDRESS special register holds the address of a record defined in the
LINKAGE SECTION with level 01 or 77. This register can be used in the SET
Figure 2 shows the use of ADDRESS special registers in COBOL. If the records in
the READ or REWRITE commands are of fixed length, no LENGTH option is
required. This example assumes variable-length records. After the read, you can get
the length of the record from the field named in the LENGTH option (here,
LRECL-REC1). In the REWRITE command, you must code a LENGTH option if you
want to replace the updated record with a record of a different length.
WORKING-STORAGE SECTION.
77 LRECL-REC1 PIC S9(4) COMP.
LINKAGE SECTION.
01 REC-1.
02 FLAG1 PIC X.
02 MAIN-DATA PIC X(5000).
02 OPTL-DATA PIC X(1000).
01 REC-2.
02 ...
PROCEDURE DIVISION.
EXEC CICS READ UPDATE...
SET(ADDRESS OF REC-1)
LENGTH(LRECL-REC1)
END-EXEC.
IF FLAG1 EQUAL X’Y’
MOVE OPTL-DATA TO ...
.
.
.
EXEC CICS REWRITE...
FROM(REC-1)
END-EXEC.
The identifier is the name of a COBOL data area that must contain the name of
the called subprogram.
For information about the performance implications of using each of these methods
to call a subprogram, see the Enterprise COBOL for z/OS and OS/390:
Programming Guide, and the IBM Enterprise COBOL Version 3 Release 1
Performance Tuning Paper. The White Paper is available on the Web at
www.ibm.com/software/ad/cobol/library
COBOL programs can call any language programs statically or dynamically. LINK or
XCTL are not required for inter-language communication, unless you wish to use
CICS functions such as COMMAREA. See Language Environment Writing Inter
Language Communication Applications for guidance on mixing languages under
Language Environment control.
“Rules for calling subprograms” on page 29 gives the rules governing the use of the
three ways to call a subprogram. This information refers to CICS application logical
levels. Each LINK command creates a new logical level, the called program being
at a level one lower than the level of the calling program (CICS is taken to be at
level 0). Figure 3 on page 32 shows logical levels and the effect of RETURN
commands and CALL statements in linked and called programs.
The term run unit is used in Figure 3 on page 32. A run unit is a running set of one
or more programs that communicate with each other by COBOL static or dynamic
CALL statements. In a CICS environment, a run unit is entered at the start of a
CICS task, or invoked by a LINK or XCTL command. A run unit can be defined as
the execution of a program defined by a PROGRAM resource definition, even
though for dynamic CALL, the subsequent PROGRAM definition is needed for the
called program. When control is passed by a XCTL command, the program
receiving control cannot return control to the calling program by a RETURN
command or a GOBACK statement, and is therefore not a subprogram.
The terms ’translator’ and ’translation’ in “Rules for calling subprograms” on page
29 refer to the separate translator. This step is not required if a compiler with an
integrated translator is used.
Translation
LINK
The linked subprogram must be translated if it, or any subprogram invoked from
it, contains CICS function.
Static and Dynamic COBOL CALL
The called subprogram must be translated if it contains CICS commands or
references to the EXEC interface block (DFHEIBLK) or to the CICS
communication area (DFHCOMMAREA).
Compilation
(You must always use the NODYNAM compiler option (the default) when you
compile a COBOL program that is to run with CICS, even if the program issues
dynamic calls.)
Link-editing
LINK
The linked subprogram must be compiled and link-edited as a separate
program.
Static COBOL CALL
The called subprogram must be link-edited with the calling program to form a
single load module (but the programs can be compiled separately). This can
produce large program modules, and it also stops two programs that call the
same program from sharing a copy of that program.
Dynamic COBOL CALL
The called subprogram must be compiled and link-edited as a separate load
module. It can reside in the link pack area or in a library that is shared with
other CICS and non-CICS regions at the same time.
Language of subprogram
LINK, Static and Dynamic COBOL CALL
Any language supported by CICS.
Contents of subprogram
The contents of any called or linked subprogram can be any function supported by
CICS for the language (including calls to external databases, for example, DB2®
and DL/I) with the exception that an assembler language subprogram cannot CALL
a lower level subprogram.
Storage
LINK
On each entry to the linked subprogram, a new initialized copy of its
WORKING-STORAGE SECTION is provided, and the run unit is reinitialized (in
some circumstances, this can cause a performance degradation).
Location of subprogram
LINK
Can be remote.
Static and Dynamic COBOL CALL
Must be local.
A main, or level 1 program can use the COBOL GOBACK or STOP RUN
statements, or the CICS RETURN command to terminate and return to CICS. It can
use a COBOL CALL statement to call a subprogram at the same logical level (level
1), or a CICS LINK command to call a subprogram at a lower logical level. A called
subprogram at level 1 can return to the caller using the COBOL GOBACK
statement, or can terminate and return to CICS using EXEC CICS RETURN.
See “Application program logical levels” on page 562 for more information about
program logical levels.
CICS Level
0
Program U
GOBACK
...
STOP RUN
...
EXEC CICS RETURN
Run ... Level
Unit CALL Program V 1
A ... GOBACK
... ...
... EXEC CICS RETURN
EXEC CICS LINK
...
Program W
GOBACK
...
STOP RUN
Run ...
Unit EXEC CICS RETURN
B ...
CALL Program X
... GOBACK
... ...
... EXEC CICS RETURN
EXEC CICS XCTL
... Level
2
Program Y
CALL Program Z
... GOBACK
... ...
GOBACK STOP RUN
Run ... ...
Unit STOP RUN EXEC CICS RETURN
C ...
EXEC CICS RETURN
Figure 3. Flow of control between COBOL programs, run units, and CICS
# The COBOL2 option is the default. It does not have the same effect on the
# translator as it did in CICS Transaction Server for z/OS, Version 2 Release 1 and
# earlier releases. COBOL2 instructs the translator to translate as COBOL3, but in
# addition to include declarations of temporary variables for use in EXEC CICS and
# EXEC DLI requests.
# Choose the COBOL2 option if you are re-translating old programs which were
# written in such a way that they require the use of temporary variables. In particular,
# note that the use of temporary variables might circumvent errors that would
# normally occur when an argument value in a program is incorrectly defined. The
# COBOL2 option in CICS Transaction Server for z/OS, Version 2 Release 1 and
# earlier releases provided declarations of temporary variables. Because of this
# feature, incorrect definitions of argument values might be present, but not
# noticeable at runtime, in programs that were originally translated with the COBOL2
# option in earlier releases of CICS Transaction Server. Translating these programs
# with the COBOL3 option can reveal these errors for the first time. To assist with
# migration to the newer releases of CICS, you may use the new COBOL2 option to
# continue to circumvent the errors in the programs, rather than correcting them.
# If you are confident that your program do not need the translator’s temporary
# variables, you may use COBOL3, which results in smaller working storage. The
# COBOL3 option includes all features of the older COBOL2 and ANSI85 translator
# options, except for declarations of temporary variables.
# Note: COBOL2 and COBOL3 are mutually exclusive. If you specify both options by
# different methods, the COBOL3 option is always used, regardless of where
# the two options have been specified. If this happens, the translator issues a
# warning message.
# The following topics describe specific translator action that is taken when the
# COBOL3 option is used. Processing with the COBOL2 option is the same in all
# respects, except for declarations of temporary variables.
For information about translating your program and preparing it for execution, see
Chapter 8, “Translation and compilation,” on page 67.
Translator action
The translator listing and output preserve the case of COBOL text as entered.
The translator does not translate lower case text into upper case. Some names in
COBOL text, for example file names and transaction IDs, must match with
externally defined names. Such names must always be entered in the same case
as the external definition.
Translator action
If you process your COBOL source statements with the CICS-supplied translator,
the translator accepts REPLACE statements but does not translate text between
pseudo-text delimiters, with the exception of CICS built-in functions (DFHRESP and
DFHVALUE), which are translated wherever they occur. CICS commands should
not be placed between pseudo-text delimiters.
If you use the integrated translator, the translator accepts REPLACE statements
and does translate text between pseudo-text delimiters. CICS commands can be
placed between pseudo-text delimiters.
Batch compilation
Separate COBOL programs can be compiled together as one input file. An END
PROGRAM header statement terminates each program and is optional for the last
program in the batch.
Translator action
The translator accepts separate COBOL programs in a single input file, and
interprets END PROGRAM header statements.
Translator options specified as parameters when invoking the translator are in effect
for the whole batch, but can be overridden for a unit of compilation by options
specified in the CBL or PROCESS card that initiates the unit.
The options for a unit of compilation are determined according to the following order
of priority:
| 1. Options fixed as installation non-user-modifiable options.
2. Options specified in the CBL or PROCESS card that initiates the unit.
3. Options specified when the translator is invoked.
4. Default options.
3. In PROC1, change the name and disposition of the compiler output data set
&&LOADSET. At least remove the initial && from the data set name and change
the disposition to CATLG. The SYSLIN statement should then read:
//SYSLIN DD DSN=LOADSET,DISP=(NEW,CATLG),
// UNIT=&WORK,SPACE=(80,(250,100))
4. Run PROC1.
.................
....program a....
.................
NAME PROGA(R)
.................
.................
....program b....
.................
.................
NAME PROGB(R)
.................
....program c....
.................
NAME PROGC(R)
5. Edit the compiler output in the data set LOADSET to add the INCLUDE and
ORDER statements as shown in Figure 5 on page 37. If you use large numbers
of programs in batches, you should write a simple program or REXX EXEC to
insert the ORDER and INCLUDE statements.
6. In PROC2, add a DD statement for the library that includes the CICS stub. The
standard name of this library is CICSTS31.CICS.SDFHLOAD. The INCLUDE
statement for the stub refers to this library by the DD name. In Figure 5 on page
37, it is assumed you have used the DD name SYSLIB ( or concatenated this
library to SYSLIB). The suggested statement is:
//SYSLIB DD DSN=CICSTS31.CICS.SDFHLOAD,
// DISP=SHR
7. In PROC2, replace the SYSLIN concatenation with the single statement:
//SYSLIN DD DSN=LOADSET,
// DISP=(OLD,DELETE)
In this statement it is assumed that you have renamed the compiler output data
set LOADSET.
8. Run PROC2.
Note: You are recommended to use the DFHELII stub, but DFHECI is still supplied,
and can be used.
Nested programs
v COBOL programs can contain COBOL programs.
v Contained programs are included immediately before the END PROGRAM
statement of the containing program.
v A contained program can also be a containing program, that is, it can itself
contain other programs.
v Each contained or containing program is terminated by an END PROGRAM
statement.
For an explanation of valid calls to nested programs and of the COMMON attribute
of a nested program, see the Enterprise COBOL for z/OS and OS/390:
Customization Guide.
Existing or modified programs will require appropriate modification for use with the
CICS integrated translator. If modification is difficult the user should continue to use
separate translation and compilation.
Translator action
The CICS translator treats top-level and nested programs differently.
Recognition of nested programs: The translator interprets that the input source
starts with a top-level program if the first non-comment record is any of the
following:
v IDENTIFICATION DIVISION statement
v CBL card
v PROCESS card
If the first record is none of these, the translator treats the input as part of the
PROCEDURE DIVISION of a nested program. The first CBL or PROCESS card
indicates the start of a top-level program and of a new unit of compilation. Any
IDENTIFICATION DIVISION statements that are found before the first top-level
program indicate the start of a new nested program.
The practical effect of these rules is that nested programs cannot be held in
separate files and translated separately. A top-level program and all its directly- and
indirectly- contained programs constitute a single unit of compilation and should be
submitted together to the translator.
PROGRAM W
IDENTIFICATION DIVISION.
PROGRAM-ID. W.
.
.
PROCEDURE DIVISION.
.
.
CALL Z.
.
.
CALL Y USING DFHEIBLK COMMAREA.
.
.
CALL X USING DFHEIBLK COMMAREA.
.
.
IDENTIFICATION DIVISION.
PROGRAM-ID. X.
.
.
PROCEDURE DIVISION USING DFHEIBLK DFHCOMMAREA
.
.
CALL Z.
.
.
CALL Y USING DFHEIBLK COMMAREA.
.
.
END PROGRAM X.
IDENTIFICATION DIVISION.
PROGRAM-ID. Y IS COMMON.
.
.
PROCEDURE DIVISION USING DFHEIBLK DFHCOMMAREA.
.
.
CALL Z.
.
.
EXEC CICS...
.
.
END PROGRAM Y.
IDENTIFICATION DIVISION.
PROGRAM-ID. Z IS COMMON.
.
.
PROCEDURE DIVISION.
.
.
END PROGRAM Z.
END PROGRAM W.
Translator action
The translator accepts reference modification wherever the name of a character
variable is permitted in a COBOL program or in an EXEC CICS command.
Global variables
The GLOBAL variable storage class is supported. A variable defined with the
GLOBAL variable storage class in a top-level program (see “Translator action” on
page 37) can be referred to in any of its nested programs, whether directly or
indirectly contained.
Translator action
The translator accepts the GLOBAL keyword.
Translator action
The translator accepts the use in COBOL statements of a separator comma or a
separator semicolon wherever a space can be used. For example, the translator
accepts the statement:
IDENTIFICATION; DIVISION
The translator does not support the use of the separator comma and separator
semicolon as delimiters in EXEC CICS commands. The only acceptable word
delimiter in an EXEC CICS command continues to be a space.
Note: In general, the compiler does not accept the use of figurative constants and
symbolic characters as arguments in CALL statements. For this reason, do
not use figurative constants or symbolic constants in EXEC CICS
commands, which are converted into CALL statements by the translator.
There is one exception to this restriction: a figurative constant is acceptable
in an EXEC CICS command as an argument to pass a value if it is of the
correct data type. For example, a numeric figurative constant can be used in
the LENGTH option.
Translator action
OOCOBOL implements the same translator action as COBOL3, as described in
“Using the COBOL2 and COBOL3 translator options” on page 33. In addition:
v The translator considers each class to be a separate unit of compilation.
v The translator does not monitor correct use of syntax. It makes the following
assumptions about a user program:
– Classes and methods are correctly terminated.
– A class encapsulates only methods.
– Methods do not encapsulate anything else.
– A unit of compilation contains either a class or a program.
v The translator rejects any EXEC statements that appear in the PROCEDURE
DIVISION of a class.
v The translator checks that a DATA DIVISION statement and a
WORKING-STORAGE SECTION both exist in a class definition.
C++ applications can also use the CICS C++ OO classes to access CICS services,
instead of the EXEC CICS interface. See the CICS C++ OO Class Libraries
manual, for more information about this interface.
The EIB declarations are enclosed in #ifndef and #endif lines, and are included
in all translated files. The C or C++ compiler ignores duplicated declarations.
The inserted code contains definitions of all the fields in the EIB, coded in C
and C++.
Fetch function
Language Environment-conforming programs support the fetch() and release()
functions. Modules to be fetched must be defined as PROGRAM resources to
CICS, either explicitly or implicitly through autoinstall.
System function
CICS does not support the system() function, but two CICS commands, LINK
and XCTL, provide equivalent function.
Macros
C and C++ do not support the use of CICS commands in macros.
Clock function
The clock() function returns a value (time_t) of -1.
Locale functions
All locale functions are supported for locales that have been defined in the
CSD. CSD definitions for the IBM-supplied locales are provided in member
CEECCSD of the SCEESAMP library. The setlocale() function returns NULL if
the locale is not defined.
Debugging functions
The dump functions csnap(), cdump(), and ctrace() are supported. The output is
sent to the CESE transient data queue. The dump cannot be written if the
queue does not have a sufficient record length (LRECL). An LRECL of at least
161 is recommended.
iscics function
If you are adapting an existing program or writing a new program that is
designed to run outside CICS as well as under CICS, the iscics() function may
prove useful. It returns a non-zero value if your program is currently running
under CICS, or zero otherwise. This function is an extension to the C library.
Restrictions
The following lists describe some of the restrictions that exist with C or C++
| MVS has a standard subroutine calling convention which can be traced back to the
| early days of System/360. This convention was optimized for an environment in
| which subroutines were more complex, there were relatively few of them, and they
| were invoked relatively infrequently. Object oriented programming conventions have
| changed this. Subroutines have become simpler but they are numerous, and the
| frequency of subroutine invocations has increased by orders of magnitude. This
| change in the size, numbers, and usage pattern, of subroutines made it desirable
| that the system overhead involved be optimized. XPLink is the result of this
| optimization.
|
| PLEASE NOTE!
| For z/OS 1.4 and above, and CICS TS 3.1 and above, the advice here that
| you CAN use the XPLINK compiler option with CICS application programs,
| overrides advice in z/OS and Language Environment manuals to the contrary.
| z/OS and Language Environment manuals for C and C++ advise you that the
| XPLINK compiler option is not available to CICS application programs,
| because that used to be the case. Although these manuals are now being
| changed, you may be working with a copy of one of these manuals produced
| before this change.
|
|
| To use XPLink, your C or C++ application code must be re-entrant and threadsafe.
| The same code instance can be executing on more than one MVS TCB and,
| An XPLink object can invoke a non-XPLink object using either the EXEC CICS
| interface or the Language Environment interface.
| A non-XPLink object can only invoke an XPLink object using the EXEC CICS
| interface. Use of the Language Environment interface for such invocations is not
| supported.
| .
Other languages, such as COBOL and PL/I, usually pass their arguments by
reference, which means that the compiler passes a list of addresses pointing to the
arguments to be passed. This is the call interface supported by CICS. To pass an
argument by reference, you prefix the variable name with &, unless it is already a
pointer, as in the case when an array is being passed.
As part of the build process, the compiler may convert arguments from one data
type to another. For example, an argument of type char may be converted to type
short or type long.
When you send values from a C or C++ program to CICS, the translator takes the
necessary action to generate code that results in an argument list of the correct
format being passed to CICS. The translator does not always have enough
information to enable it to do this, but in general, if the argument is a
single-character or halfword variable, the translator makes a precall assignment to a
variable of the correct data type and passes the address of this temporary variable
in the call.
When you receive data from CICS, the translator prefixes the receiving variable
name with &, which causes the C or C++ compiler to pass it values by reference
rather than by value (with the exception of a character string name, which is left
unchanged). Without the addition of &, the compiler would copy the receiving
variable and then pass the address of the copy to CICS. Any promotion occurring
during this copying could result in data returned by CICS being lost.
Table 2 shows the rules that apply when passing values as arguments in EXEC
CICS commands.
Table 2. Rules for passing values as arguments in EXEC CICS commands
Data type Usage Coding the argument
Character literal Data-value (Sender) The user must specify the character literal
directly. The translator takes care of any
required indirection.
Character variable Data-area (Receiver) The user must specify a pointer to the
(char) variable, possibly by prefixing the variable
name with &.
Character variable Data-value (Sender) The user must specify the character variable
(char) directly. The translator takes care of any
required indirection.
Character string literal Name (Sender) The user can either code the string directly
as a literal string or use a pointer which
points to the first character of the string.
Character string Data-area (Receiver) Whether receiving or sending, the argument
variable Name (Sender) should be the name of the character array
containing the string—the address of the
first element of the array.
or by passing the EIB address or particular fields therein as arguments to the CALL
statement that invokes the external procedure.
The codeset may also be specified in a pragma filetag compiler directive at the
start of the application program. The CICS translator scans for the presence of this
directive, but currently CICS provides support only for the default IBM-1047 and for
the codeset for Germany, IBM-273
For example, if the program has been prepared with an editor using the codeset
specific to Germany, it should begin with the following directive:
??=pragma filetag ("IBM-273")
The presence of the pragma filetag implies that the program is compiled with the
IBM C for MVS/ESA compiler.
Programming in C++
C++ supports object-oriented programming and you can use this language in the
same way as you would use the C language. You must specify that the translator is
to translate C++ using the CPP option.
C++ programs must also be defined with the LANGUAGE(LE370) option. See
Chapter 3, “Language Environment,” on page 9 for information about this
environment.
Restrictions
C++ uses ‘//’ for single line comments. Do not put a comment in the middle of an
EXEC CICS command. For instance, this example does not work:
EXEC CICS SEND TEXT FROM(errmsg)
LENGTH(msglen) // Send error message to screen
RESP(rcode)
RESP2(rcode2);
If you are converting a program that was previously compiled with a non-Language
Environment conforming compiler, you must ensure that neither NOSTAE nor
NOSPIE is specified in a plixopt string, because this will cause Language
Environment to set TRAP (OFF). TRAP (ON) must be in effect for applications to
run successfully.
There are some restrictions on the PL/I for MVS & VM statements that can be used
in a fetched procedure. These restrictions are described in PL/I MVS & VM
Language Reference.. Many of the restrictions have been removed with VisualAge
PL/I. See the VisualAge PL/I for OS/390 Compiler and Run-Time Migration Guide.
No special considerations apply to the use of FETCH when both the fetching and
the fetched programs have the same AMODE attribute. Language Environment,
however, also supports the fetching of a load module that has an AMODE attribute
different to the program issuing the FETCH. In this case, Language Environment
performs the AMODE switch, and the following constraints apply:
v If any fetched module is to execute in 24-bit addressing mode, the fetching
module must have the RMODE(24) attribute regardless of its AMODE attribute.
v Any variables passed to a fetched routine must be addressable in the AMODE of
the fetched procedure.
The INCLUDE statement for the object modules must come immediately after
the CHANGE statement and there is also a requirement under Language
Environment that the main program must be included before any subroutines.
(This requirement did not exist for modules produced by non-conforming
compilers.) For Enterprise PL/I programs that are compiled with
OPTIONS(FETCHABLE), the binder ENTRY statement must be the name of the
PROCEDURE.
Re-link utility for PL/I
If you have only the load module for a CICS program compiled by a
non-conforming compiler, there is a file of linkage editor input, IBMWRLKC,
specifically for CICS programs, located in the sample library SCEESAMP, to
replace OS PL/I library routines in a non-conforming executable program with
Language Environment routines. For more information about using IBMWRLKC,
see the PL/I MVS & VM V1R1.1 Compiler & Runtime Migration Guide.
Abend codes
If a CICS PL/I program abends under Language Environment , your CICS
abend handlers are given a Language Environment abend code, rather than a
PL/I abend code. To avoid changing your programs, you can modify the sample
user condition handler, CEEWUCHA, supplied by Language Environment in the
SCEESAMP library. This user condition handler can be made to return PL/I
abend codes instead of the Language Environment codes. Use the USRHDLR
runtime option to register it to do this. For details of this option see the z/OS
Language Environment Programming Guide.
For more guidance information about using access registers, see the z/OS:
MVS Programming: Extended Addressability Guide.
Conformance governs the use of assembler programs by call from an HLL program.
Both conforming and non-conforming assembler subroutines may be called either
statically or dynamically from C or C++, COBOL or PL/I. However, there are
differences in register conventions and other requirements for the two types. These
are described below. Rules for mixing languages, including assembler, are
discussed in “Mixing languages in Language Environment” on page 13.
| Conforming MAIN programs
| If you are coding a new assembler MAIN program that you want to conform to
| the Language Environment interface or if your assembler routine calls
| Language Environment services, observe the following:
| v Use the macros provided by Language Environment. For a list of these
| macros, see the z/OS Language Environment Programming Guide.
| v Ensure that the CEEENTRY macro contains the option MAIN=YES. (
| MAIN=YES is the default).
| v Translate your assembler routine with *ASM XOPTS( LEASM) or, if it
| contains CICS commands, with *ASM XOPTS( LEASM NOPROLOG
| NOEPILOG).
| Conforming sub-routines programs
| If you are coding a new assembler sub-routine that you want to conform to the
| Language Environment interface or if your assembler routine calls Language
| Environment services, observe the following:
Note: CICS does not allow the use of HANDLE ABEND LABEL in Assembler
programs that do not use DFHEIENT and DFHEIRET. Assembler programs
that use the Language Environment stub CEESTART should either use
HANDLE ABEND PROGRAM or a Language Environment service such as
CEEHDLR. See “Using Language Environment Abend-handling” on page 11
for information about CEEHDLR.
For more information or for explanations of the terms used in this section see the
chapter on ″Assembler Considerations″ in the z/OS Language Environment
Programming Guide.
For example, the PL/I program in file PLITEST PLI calls the assembler language
program ASMPROG, which is in file ASMTEST ASSEMBLE. The PL/I program
passes three parameters to the assembler language program, the EIB, the
COMMAREA, and a message string.
PLIPROG:PROC OPTIONS(MAIN);
DCL ASMPROG ENTRY EXTERNAL;
DCL COMA CHAR(20), MSG CHAR(14) INIT(’HELLO FROM PLI’);
CALL ASMPROG(DFHEIBLK,COMA,MSG);
EXEC CICS RETURN;
END;
The assembler language program performs an EXEC CICS SEND TEXT command,
which displays the message string passed from the PL/I program.
DFHEISTG DSECT
MSG DS CL14
MYRESP DS F
ASMPROG CSECT
L 5,8(1)
L 5,0(5)
MVC MSG,0(5)
EXEC CICS SEND TEXT FROM(MSG) LENGTH(14) RESP(MYRESP)
END
You can use JCL procedures supplied by CICS to compile and link the application,
as follows:
1. Assemble and link ASMTEST using the DFHEITAL procedure:
//ASMPROG EXEC DFHEITAL
//TRN.SYSIN DD *
.... program source ...
/*
//LKED.SYSIN DD *
NAME ASMTEST(R)
/*
2. Compile and link PLITEST using the DFHYITPL procedure, and provide linkage
editor control statements that include the ASMTEST load module created by the
DFHEITAL procedure:
//PLIPROG EXEC DFHYITPL
//TRN.SYSIN DD *
.... program source ...
/*
Note: Step 2 assumes that the ASMTEST load module created by DFHEITAL was
stored in a library included in the SYSLIB dataset concatenation.
The load module created by the DFHYITPL procedure includes both the DFHEAI
stub (included by DFHEITAL) and the DFHELII stub (included by DFHYITPL). This
causes the linkage editor or binder program to issue a warning message because
both stubs contain an entry point named DFHEII. This message can be ignored.
If you are writing your own JCL, you only need to include the DFHELII stub,
because this contains the entry points needed for all languages.
Modern compilers can use the integrated CICS translator approach, where the
compiler interfaces with CICS at compile time to interpret CICS commands and
convert them automatically to calls to CICS service routines. If you use the
integrated CICS translator approach then many of the translation tasks described in
“The translation process” on page 69 are done at compile time for you, and you do
not need to execute the additional translator step.
| The releases of the COBOL and PL/I compilers which support the CICS integrated
| translator are listed in the CICS Release Guide. If you use any other compiler,
| including Assembler, you will need to translate your program in the traditional way
| described in Chapter 8, “Translation and compilation.”
To use the integrated CICS translator for PL/I you must specify the compiler option
SYSTEM(CICS).
To use the integrated CICS translator for COBOL the compiler options CICS, LIB,
NODYNAM, and RENT must be in effect. You cannot use SIZE(MAX) when
compiling large programs using CICS statements. Storage must be left in the user
region for integrated CICS translator services.
If you are running DB2 Version 7 or later and preparing a COBOL program using a
compiler with integrated translator, the compiler also provides an SQL statement
coprocessor (which produces a DBRM), so you do not need to use a separate DB2
precompiler. See the CICS DB2 Guide and the DB2 for OS/390 and z/OS
Application Programming and SQL Guide for more information on using the SQL
statement coprocessor.
For more information on specifying PL/I compiler options see the Enterprise PL/I for
z/OS and OS/390 Programming Guide.
To specify CICS translator options when using the COBOL compiler specify the
compiler option, CICS, with the translator options enclosed in apostrophes and
inside parenthesis. For example:
CICS(’opt1 opt2 optn ...’)
Note: The XOPTS translator option must be changed to the CICS compiler option.
XOPTS is not accepted when using the integrated CICS translator.
For more information on specifying COBOL compiler options see the Enterprise
COBOL for z/OS and OS/390: Programming Guide.
For a description of all of the translator options see “Defining translator options” on
page 74.
Many of the translator options, such as those associated with translator listings, do
not apply when using the integrated CICS translator. These options, if specified, are
ignored. The EXCI option is not supported, the CICS option is assumed. For
COBOL the OOCOBOL option is assumed.
The translator options that can be used effectively with the integrated CICS
translator are:
For compilers with integrated translators, the compilers interface with CICS to
handle both EXEC CICS and EXEC DLI statements.
A language translator reads your source program and creates a new one; most
normal language statements remain unchanged, but CICS commands are
translated into CALL statements of the form required by the language in which you
are coding. The calls invoke CICS-provided “EXEC” interface modules, which later
get link-edited into your load module, and these in turn invoke the requested
services at execution time.
There are three steps: translation, compilation (assembly), and link-edit. Figure 10
on page 70 shows these 3 steps.
CICS
Translation
Command- SYSPRINT
level (translator
language listing)
translator SYSPUNCH
(translated
source
program)
High-level High-level
language language
Compilation compiler compiler (or
(assembly) (or assembler) assembler)
listing
Object
module
Link-editor
Link-editor listing
Link Edit
Load
library
The translators for all languages use one input and two output files:
SYSIN (Translator input) is the file that contains your source program.
If the SYSIN file is defined as a fixed blocked data set, the maximum record
length that the data set can possess is 80 bytes. Passing a fixed blocked
data set with a record length of greater than 80 bytes to the translator
results in termination of translator execution. If the SYSIN file is defined as
a variable blocked data set, the maximum record length that the data set
can possess is 100 bytes. Passing a variable blocked data set with a record
length greater than 100 bytes to the translator causes the translator to stop
with an error.
SYSPUNCH
(Translated source) is the translated version of your source code, which
becomes the input to the compile (assemble) step. In this file, your source
has been changed as follows:
v The EXEC interface block (EIB) structure has been inserted.
v EXEC CICS, EXEC CPSM and EXEC DLI commands have been turned
into function call statements.
Note: If you use EXEC SQL, you need additional steps to translate the SQL
statements and bind; see the Application Programming and SQL Guide for
information about these extra steps.
CICS provides a procedure to execute these steps in sequence for each of the
languages it supports. “Using the CICS-supplied procedures to install application
programs” on page 106 describes how to use these procedures, and exactly what
they do.
You can control the translation process by specifying a number of options. For
example, if your program uses EXEC DLI calls, you need to tell the translator.
The translator may produce error messages, and it is as important to check these
messages as it is to check the messages produced by the compiler and link-editor.
See “The CICS-supplied translators” on page 72 for the location of these
messages.
EXEC commands are translated into CALL statements that invoke CICS interface
modules. These modules get incorporated into your object module in the link-edit
step, and you see them in your link-edit output listing. You can read more about
these modules in “The CICS-supplied interface modules” on page 86.
Assembler DFHEAP1$
C DFHEDP1$
COBOL DFHECP1$
PL/I DFHEPP1$
If you use CALL, specify PREPROC as the entry point name to call the translator.
If you omit an applicable entry, the translator uses the standard DD name. If you
use a DD name less than 8 bytes long, fill the field with blanks on the right. You can
omit an entry by placing X'FF' in the first byte. You can omit entries at the end of
the list entirely.
The translator options you can choose are listed in “Defining translator options” on
page 74. You can specify your choices in one of two ways:
v List them as suboptions of the XOPTS option on the statement that the compiler
(assembler) provides for specifying options. These statements are:
Language Statement
COBOL CBL
COBOL PROCESS
C #pragma
C++ #pragma
PL/I * PROCESS
Assembler *ASM or *PROCESS¹
v List your options in the PARM operand of the EXEC job control statement for the
translate step. Most installations use catalogued procedures to translate, compile
(assemble) and link CICS programs, and therefore you specify this PARM field in
the EXEC job control statement that invokes the procedure.
For example, if the name of the procedure for COBOL programs is DFHYITVL,
and the name of the translate step within is TRN, you set translator options for a
COBOL program with a statement such as this one:
// EXEC DFHEITCL,PARM.TRN=(VBREF,QUOTE,SPACE(2),NOCBLCARD)
If you specify an option by one method and the same option or an option that
conflicts by the other method, the specifications in the language statement override
those in the EXEC statement. Similarly, if you specify multiple values for a single
option or options that conflict on either type of statement, the last setting takes
precedence. Except for COBOL programs, these statements must precede each
source program; there is no way to batch the processing of multiple programs in
other languages.
Translator options may appear in any order, separated by one or more blanks or by
a comma. If you specify them on the language statement for options, they must
appear in parentheses following the XOPTS parameter, because other options are
ignored by the translator and passed through to the compiler. The following COBOL
example shows both translator and compiler options being passed together:
CBL LIB XOPTS(QUOTE SPACE(2))
(For compatibility with previous releases, the keyword CICS can be used as an
alternative to XOPTS, except when you are translating batch EXEC DLI programs.)
Remember, if you alter the default margins for C or C++ #pragma card processing
using the PARM operand, the sequence margins should be altered too. You can do
this using the NOSEQUENCE option.
Notes:
1. For assembler programs, *ASM statements contain translator options only. They
are treated as comments by the assembler. *PROCESS statements can contain
translator or assembler options for the High Level assembler, HLASM.
2. Translator and assembler options must not coexist on the same *PROCESS
statement.
3. *PROCESS and *ASM statements must be at the beginning of the input and no
assembler statements must appear before them. This includes comments and
statements such as “PRINT ON” and “EJECT”. Both *PROCESS and *ASM
statements can be included, in any order.
4. *PROCESS statements containing only translator options contain information for
the translator only and are not passed to the assembler
5. *PROCESS statements containing assembler options are placed in the
translated program.
If your installation uses the CICS-provided procedures in the distributed form, the
default options are used. These are explicitly noted in the following option
descriptions. You can tell which options get used by default at your installation by
looking at the SYSPRINT translator listing output from the translate step (see “The
CICS-supplied translators” on page 72). If you want an option that is not the default,
you must specify it, as described in “Using a CICS translator” on page 73.
APOST indicates that literals are delineated by the apostrophe (’). This is the
default—QUOTE is the alternative. The same value must be specified for the
translator step and the following compile step.
Note: COBOL for MVS & VM and later compilers can use either apostrophes or
quotes or both in the same program, and this option is not so important for
these compilers.
CBLCARD
(COBOL only) Abbreviation: CBL
CBLCARD specifies that the translator is to generate a CBL statement. This is the
default—the alternative is NOCBLCARD.
CICS
CICS specifies that the translator is to process EXEC CICS commands. It is the
default specification in the translator. CICS is also an old name for the XOPTS
keyword for specifying translator options, which means that you can specify the
CICS option explicitly either by including it in your XOPTS list or by using it in place
of XOPTS to name the list. The only way to indicate that there are no CICS
commands is to use the XOPTS keyword without the option CICS. You must do this
in a batch DL/I program using EXEC DLI commands. For example, to translate a
batch DL/I program written in assembler language, specify:
*ASM XOPTS(DLI)
# COBOL2
# (COBOL only) Abbreviation: CO2
# COBOL2 specifies that the translator is to generate temporary variables for use in
# the translated EXEC statements. In all other respects, the program is translated in
# the same manner as with the “COBOL3” option. COBOL2 and COBOL3 are
# mutually exclusive. COBOL2 is the default for COBOL.
# Note: If you specify COBOL2 and COBOL3 by different methods, the COBOL3
# option is always used, regardless of where the two options have been
# specified. If this happens, the translator issues a warning message.
COBOL3
(COBOL only) Abbreviation: CO3
COBOL3 specifies that the translator is to translate programs that are Language
Environment-conforming. COBOL3 and COBOL2 are mutually exclusive. “Using the
COBOL2 and COBOL3 translator options” on page 33 explains how the translator
treats specific coding situations. Chapter 3, “Language Environment,” on page 9
explains what Language Environment-conforming compilers are available.
CPSM
CPSM specifies that the translator is to process EXEC CPSM commands. The
alternative is NOCPSM, which is the default.
DBCS
(COBOL only)
DBCS specifies that the source program may contain double-byte characters. It
causes the translator to treat hexadecimal codes X'0E' and X'0F' as shift-out (SO)
and shift-in (SI) codes, respectively, wherever they appear in the program.
For more detailed information about how to program in COBOL using DBCS, see
the section on DBCS character strings in Enterprise COBOL for z/OS and OS/390:
Language Reference.
DEBUG
(COBOL, C, C++, and PL/I only)
DEBUG instructs the translator to produce code that passes the line number
through to CICS for use by the execution diagnostic facility (EDF). DEBUG is the
default—NODEBUG is the alternative.
DLI
DLI specifies that the translator is to process EXEC DLI commands. You must
specify it with the XOPTS option, that is, XOPTS(DLI).
EDF
EDF specifies that the execution diagnostic facility is to apply to the program. EDF
is the default—the alternative is NOEDF.
EPILOG
(Assembler language only)
EPILOG® specifies that the translator is to insert the macro DFHEIRET at the end
of the program being translated. DFHEIRET returns control from the issuing
program to the program which invoked it. If you want to use any of the options of
the RETURN command, you should use RETURN and specify NOEPILOG.
EXCI
EXCI specifies that the translator is to process EXEC API commands for the
External CICS Interface (EXCI). These commands must be used only in batch
programs, and so the EXCI translator option is mutually exclusive to the CICS
translator option, or any translator option that implies the CICS option. An error
message is produced if both CICS and EXCI are specified, or EXCI and a translator
option that implies CICS are specified.
FEPI
FEPI allows access to the FEPI API commands of the CICS Front End
Programming Interface (FEPI). FEPI is only available if you have installed the CICS
Front End Programming Interface. The alternative is NOFEPI. FEPI commands and
design are described in the CICS Front End Programming Interface User’s Guide.
FLAG (I, W, E, or S)
(COBOL, C, C++, and PL/I only) Abbreviation: F
FLAG specifies the minimum severity of error in the translation which requires a
message to be listed.
I All messages.
W (Default) All except information messages.
E All except warning and information messages.
S Only severe and unrecoverable error messages.
GDS
(C, C++, and assembler language only)
GDS specifies that the translator is to process CICS GDS (generalized data stream)
commands. For programming information about these commands, see the CICS
Application Programming Reference manual.
GRAPHIC
(PL/I only)
GRAPHIC specifies that the source program may contain double-byte characters. It
causes the translator to treat hexadecimal codes X'0E' and X'0F' as shift-out (SO)
and shift-in (SI) codes, respectively, wherever they appear in the program.
It also prevents the translator from generating parameter lists that contain the
shift-out and shift-in values in hexadecimal form. Wherever these values would
ordinarily appear, the translator expresses them in binary form, so that there are no
unintended DBCS delimiters in the data stream that the compiler receives.
If the compiler you are using supports DBCS, you need to prevent unintended
shift-out and shift-in codes, even if you are not using double-byte characters. You
can do this by specifying the GRAPHIC option for the translator, so that it does not
create them, or by specifying NOGRAPHIC on the compile step, so that the
compiler does not interpret them as DBCS delimiters.
For more detailed information about how to program in PL/I using DBCS, see the
relevant language reference manual.
| LEASM
| (Assembler only)
| For an example of an assembler program translated using the LEASM option see
| “EXAMPLE Assembler language PROGRAM using LEASM” on page 89.
LENGTH
(COBOL, Assembler and PL/I only)
LENGTH instructs the translator to generate a default length if the LENGTH option
is omitted from a CICS command in the application program. The alternative is
NOLENGTH.
LINECOUNT(n)
Abbreviation: LC
LINKAGE
(COBOL only) Abbreviation: LIN
This means that the translator will insert a USING DFHEIBLK DFHCOMMAREA
statement in the PROCEDURE DIVISION, if one does not already exist, and will
ensure that the LINKAGE SECTION (creating one if necessary) contains definitions
for DFHEIBLK and DFHCOMMAREA.
The LINKAGE option has no effect on the translation of classes and methods.
MARGINS(m,n[,c])
(C, C++, and PL/I only) Abbreviation: MAR
MARGINS specifies the columns of each line or record of input that contain
language or CICS statements. The translator does not process data that is outside
these limits, though it does include it in the source listings.
The default for C and C++ is MARGINS(1,72,0) for fixed-length records, and for
variable-length records it is the same as the record length (1,record length,0). The
default for PL/I is MARGINS(2,72,0) for fixed-length records, and
MARGINS(10,100,0) for variable-length records.
NATLANG(EN or KA)
NATLANG specifies what language is to be used for the translator message output:
EN (Default) English.
KA Kanji.
(Take care not to confuse this option with the NATLANG API option.)
NOCBLCARD
(COBOL only)
NOCBLCARD specifies that the translator is not to generate a CBL statement. The
compiler options that CICS requires are specified by the DFHYITVL procedure. You
should ensure that RENT, NODYNAM, and LIB are specified..
NOCPSM
NOCPSM specifies that the translator is not to process EXEC CPSM commands.
This is the default—the alternative is CPSM.
NODEBUG
(COBOL, C, C++, and PL/I only)
NODEBUG instructs the translator not to produce code that passes the line number
through to CICS for use by the execution diagnostic facility (EDF).
NOEPILOG
(Assembler language only)
NOEPILOG instructs the translator not to insert the macro DFHEIRET at the end of
the program being translated. DFHEIRET returns control from the issuing program
to the program which invoked it. If you want to use any of the options of the EXEC
CICS RETURN command, you should use EXEC CICS RETURN and specify
NOEPILOG. NOEPILOG prevents the translator inserting the macro DFHEIRET.
The alternative is EPILOG, which is the default. (See the CICS Application
Programming Reference manual for programming information about the DFHEIRET
macro.)
NOFEPI
NOFEPI disallows access to the FEPI API commands of the CICS Front End
Programming Interface (FEPI). NOFEPI is the default—the alternative is FEPI.
NOLENGTH
(COBOL, Assembler and PL/I only)
NOLENGTH instructs the translator not to generate a default length if the LENGTH
option is omitted from a CICS command in the application program. The default is
LENGTH.
NOLINKAGE
(COBOL only)
NOLINKAGE requests the translator not to modify the LINKAGE SECTION and
PROCEDURE DIVISION statements to supply missing DFHEIBLK and
DFHCOMMAREA statements, or insert a definition of the EIB structure in the
LINKAGE section..
This means that you can provide COBOL copybooks to define a COMMAREA and
use the EXEC CICS ADDRESS command.
NONUM
(COBOL only)
NONUM instructs the translator not to use the line numbers appearing in columns
one through six of each line of the program as the line number in its diagnostic
messages and cross-reference listing, but to generate its own line numbers.
NONUM is the default—the alternative is NUM.
NOOPSEQUENCE
(C, C++, and PL/I only) Abbreviation: NOS
NOOPTIONS
Abbreviation: NOP
NOOPTIONS instructs the translator not to include a list of the options used during
this translation in its output listing.
NOPROLOG
(Assembler language only)
NOSEQ
(COBOL only)
NOSEQ instructs the translator not to check the sequence field of the source
statements, in columns 1-6. The alternative, SEQ, is the default. If SEQ is specified
and a statement is not in sequence, it is flagged.
NOSEQUENCE
(C, C++, and PL/I only) Abbreviation: NSEQ
NOSEQUENCE specifies that statements in the translator input are not sequence
numbered and that the translator must assign its own line numbers.
NOSOURCE
NOSOURCE instructs the translator not to include a listing of the translated source
program in the translator listing.
NOSPIE
NOSPIE prevents the translator from trapping irrecoverable errors; instead, a dump
is produced. You should use NOSPIE only when requested to do so by the IBM
support center.
NOVBREF
(COBOL, C, C++ and PL/I only)
NUM
(COBOL only)
OOCOBOL
(OO COBOL only) Abbreviation: OO
are recognized but their correct usage is not monitored. The translator considers
each class as a separate unit of compilation. This option implies the COBOL3
option.
OPMARGINS(m,n[,c])
(C, C++ and PL/I only) Abbreviation: OM
OPMARGINS specifies the translator output margins, that is, the margins of the
input to the following compiler. Normally these are the same as the input margins
for the translator. For a definition of input margins and the meaning of “m”, “n”, and
“c”, see MARGINS. The default for C and C++ is OPMARGINS(1,72,0) and for PL/I,
the default is OPMARGINS(2,72,0).
The maximum “n” value allowable for the OPMARGINS option is 80. The output
from the translator is always of a fixed-length record format.
If the OPMARGINS option is used to set the output from the translator to a certain
format, it may be necessary to change the input margins for the compiler being
used. If the OPMARGINS value is allowed to default this is not necessary.
OPSEQUENCE(m,n)
(C, C++, and PL/I only) Abbreviation: OS
OPSEQUENCE specifies the position of the sequence field in the translator output
records. For the meaning of “m” and “n”, see SEQUENCE. The default for C and
C++ is OPSEQUENCE(73,80) for fixed-length records and NOOPSEQUENCE for
variable-length records. For PL/I, the default is OPSEQUENCE(73,80) for both
types of records.
OPTIONS
Abbreviation: OP
OPTIONS instructs the translator to include a list of the options used during this
translation in its output listing.
PROLOG
(Assembler language only)
PROLOG instructs the translator to insert the macros DFHEISTG, DFHEIEND, and
DFHEIENT into the program being assembled. These macros define local program
storage and execute at program entry. (See the CICS Application Programming
QUOTE
(COBOL only) Abbreviation: Q
QUOTE indicates that literals are delineated by the double quotation mark (”). The
same value must be specified for the translator step and the following compiler
step.
The CICS-supplied COBOL copybooks use APOST, the default, instead of QUOTE.
Note: COBOL for MVS & VM and later compilers can use either apostrophes or
quotes or both in the same program, and this option is not so important for
these compilers.
SEQ
(COBOL only)
SEQ instructs the translator to check the sequence field of the source statements,
in columns 1-6. SEQ is the default—the alternative is NOSEQ. If a statement is not
in sequence, it is flagged.
SEQUENCE(m,n)
(C, C++, and PL/I only) Abbreviation: SEQ
The sequence number field must not exceed eight characters and must not overlap
the source program (as specified in the MARGINS option).
SOURCE
Abbreviation: S
SP
SP must be specified for application programs that contain special (SP) CICS
commands or they will be rejected at translate time. These commands are
ACQUIRE, COLLECT, CREATE, DISABLE, DISCARD, ENABLE, EXTRACT,
SPACE(1 or 2 or 3)
(COBOL only)
SPACE indicates the type of spacing to be used in the output listing: SPACE(1)
specifies single spacing, SPACE(2) double spacing, and SPACE(3) triple spacing.
SPACE(3) is the default.
SPIE
SPIE specifies that the translator is to trap irrecoverable errors. SPIE is the
default—the alternative is NOSPIE.
SYSEIB
SYSEIB indicates that the program is to use the system EIB instead of the
application EIB. The SYSEIB option allows programs to execute CICS commands
without updating the application EIB, making that aspect of execution transparent to
the application. However, this option imposes restrictions on programs using it, and
should be used only in special situations. A program translated with the SYSEIB
option must:
v Execute in AMODE(31), as the system EIB is assumed to be located in
“TASKDATALOC(ANY)” storage.
v Obtain the address of the system EIB using the ADDRESS EIB command (if the
program is translated with the SYSEIB option, this command automatically
returns the address of the system EIB).
v Be aware that the use of the SYSEIB option implies the use of the NOHANDLE
option on all CICS commands issued by the program. (Commands should use
the RESP option as required.)
VBREF
(COBOL, C, C++, and PL/I only)
If you are using a separate translator and the source within any copybook contains
CICS commands, you must translate it separately before translation and compilation
of the program in which it will be included. If you are using the integrated CICS
translator and the source within any copybook contains CICS commands, you do
not have to translate it separately before compilation of the program in which it will
be included.
The external program must always be passed through the CICS translator, or
compiled with a compiler that has an integrated CICS translator, even if all the
CICS commands are in included copybooks.
The CICS-supplied stub routines work with an internal programming interface, the
CICS command-level interface, which is never changed in an incompatible way.
Consequently, these stub modules are upward and downward compatible, and
CICS application modules never need to be re-linked to include a later level of any
of these stubs.
With the exception of DFHEAI0, these stubs all provide the same function, which is
to provide a linkage from EXEC CICS commands to the required CICS service. The
stubs make this possible by providing various entry points that are called from the
translated EXEC CICS commands, and then executing a sequence of instructions
that pass control to the EXEC interface function of CICS.
DFHELII contains multiple entry points, most of which provide compatibility for very
old versions of the CICS PL/I translator. It contains the entries DFHEXEC (for C
and C++ application programs), DFHEI1 (for COBOL and assembler), and DFHEI01
(for PL/1).
Each of these stubs begins with an 8 byte eyecatcher in the form DFHYxnnn,
where x indicates the language supported by the stub (for example, A represents
assembler, and I indicates that the stub is language independent), and nnn
indicates the CICS release from which the stub was included. The letter Y in the
eyecatcher indicates that the stub is read-only. Stubs supplied with very early
releases of CICS contained eyecatchers in the form DFHExxxx in which the letter E
denotes that the stub is not read-only.The eyecatcher for DFHELII in CICS
Transaction Server for z/OS, Version 3 Release 1 is DFHYI640.
The eyecatcher can be helpful if you are trying to determine the CICS release at
which a CICS application load module was most recently linked.
COBOL
Each EXEC command is translated into a COBOL CALL statement that refers to the
entry DFHEI1.
The reference to DFHEI1 is resolved by the inclusion of the DFHELII stub routine in
the linkage editor step of the CICS-supplied procedures such as DFHYITVL or
DFHZITCL.
PL/I
When translating PL/I programs each EXEC command generates a call to the entry
point DFHEI01. This is done using a variable entry point DFHEI0 that is associated
with the entry DFHEI01. The translator enables this by inserting the following
statements near the start of each translated program:
DCL DFHEI0 ENTRY VARIABLE INIT(DFHEI01) AUTO;
DCL DFHEI01 ENTRY OPTIONS(INTER ASSEMBLER);
The translator creates a unique entry name based on DFHEI0 for each successfully
translated EXEC command. The following example shows the output generated by
the translator when processing a simple EXEC CICS RETURN command:
/* EXEC CICS RETURN TRANSID(NEXT) */
DO;
DCL DFHENTRY_B62D3C38_296F2687 BASED(ADDR(DFHEI0)) OPTIONS(INTER ASSEM
BLER) ENTRY(*,CHAR(4));
CALL DFHENTRY_B62D3C38_296F2687(’xxxxxxxxxxxxxxxxx’ /* ’0E 08 80 00 03
00 00 10 00 F0 F0 F0 F0 F0 F0 F1 F0 ’X */, NEXT);
END;
The reference to DFHEI01 is resolved by the inclusion of the DFHELII stub routine
in the linkage editor step of one of the CICS-supplied procedures such as
DFHYITPL.
C and C++
In a C and C++, each EXEC CICS command is translated by the command
translator into a call to the function DFHEXEC. The translator enables this by
inserting the following statements near the start of each translated program:
#pragma linkage(DFHEXEC,OS) /* force OS linkage */
void DFHEXEC(); /* function to call CICS */
The following example shows the output generated by the translator when
processing a simple EXEC CICS RETURN command:
/* EXEC CICS RETURN */
{
DFHEXEC( "\x0E\x08\x00\x2F\x00\x00\x10\x00\xF0\xF0\xF0\xF0\xF1\xF8\xF0\xF0");
}
Assembler language
Each EXEC command is translated into an invocation of the DFHECALL macro.
The following example shows the output generated by the translator when
processing a simple EXEC CICS RETURN command:
* EXEC CICS RETURN
DFHECALL =X’0E0800000800001000’
The assembly of the DFHECALL macro invocation shown above generates code
that builds a parameter list addressed by register 1, loads the address of entry
DFHEI1 in register 15, and issues a BALR instruction to call the stub routine.
DS 0H
LA 1,DFHEITPL
LA 14,=x’0E08000008001000’
ST 14,0(,1)
OI 0(1),x’80’
L 15,=V(DFHEI1)
BALR 14,15
The reference to DFHEI1 is resolved by the inclusion of the DFHEAI stub routine in
the linkage editor step of one of the CICS-supplied procedures such as DFHEITAL.
The eyecatcher for DFHEAI in CICS Transaction Server for z/OS, Version 3
Release 1 is DFHYA640, with the release numbers indicating this stub was supplied
with CICS Transaction Server for z/OS, Version 3 Release 1.
The DFHEAI0 stub for assembler application programs is included by the automatic
call facility of the linkage editor or binder utility. It is called by code generated by the
DFHEIENT and DFHEIRET macros to obtain and free, respectively, an assembler
application program’s dynamic storage area. This stub is required only in assembler
application programs; there are no stubs required or supplied to provide an
equivalent function for programs written in the high level languages.
|
| Figure 11. a simple CICS assembler program.
|
|
| Figure 12. the Translated assembled version (Part 1 of 8)
|
|
An application program generally means any user program that uses the CICS
command-level application programming interface (API). Such programs can also
use:
v SQL statements
v DLI requests
v Common programming interface (CPI) statements
v SAA Resource Recovery statements
v External CICS interface commands
Note: If you are developing application programs to use the CICS dynamic
| transaction routing facility, use the CICS Interdependency Analyzer to detect
whether the programs are likely to cause intertransaction affinity. See
Chapter 15, “Affinity,” on page 219 for a description of intertransaction
affinity.
References to the CSA or to the TCA are not allowed. You can specify YES for the
system initialization parameter DISMACP to cause CICS to disable any transaction
whose program invokes an obsolete CICS macro or references the CSA or the
TCA.
A command-level program can reside above 16MB, and address areas above
16MB. The program can contain EXEC CICS, EXEC DLI, and CALL DL/I
commands.
If you do not specify any AMODE or RMODE attributes for your program, MVS
assigns the system defaults AMODE(24) and RMODE(24). To override these
defaults, you can specify AMODE and RMODE in one or more of the following
places. Assignments in this list overwrite assignments later in the list.
1. On the link-edit MODE control statement:
MODE AMODE(31),RMODE(ANY)
2. Either of the following:
a. In the PARM string on the EXEC statement of the link-edit job step:
//LKED EXEC PGM=IEWL,PARM=’AMODE(31),RMODE(ANY),..’
b. On the LINK TSO command, which causes processing equivalent to that of
the EXEC statement in the link-edit step.
3. On AMODE or RMODE statements within the source code of an assembler
program. (You can also set these modes in COBOL by means of the compiler
options; for information about COBOL compiler options, see the relevant
application programming guide for your COBOL compiler.)
The following example shows link-edit control statements for a program coded to
31-bit standards:
//LKED.SYSIN DD *
MODE AMODE(31),RMODE(ANY)
NAME anyname(R) ("anyname" is your load module name)
/*
//
If there is not enough storage for a task to load a program, the task is suspended
until enough storage becomes available. If any of the DSAs get close to being short
on storage, CICS frees the storage occupied by programs that are not in use. (For
more information about the dynamic storage areas in CICS, see the CICS System
Definition Guide.)
Instead of making RMODE(24) programs resident, you can make them non-resident
and use the library lookaside (LLA) function. The space occupied by such a
program is freed when its usage count reaches zero, making more virtual storage
available. LLA keeps its library directory in storage and stages (places) copies of
LLA-managed library modules in a data space managed by the virtual lookaside
facility (VLF). CICS locates a program module from LLA’s directory in storage,
rather than searching program directories on DASD. When CICS requests a staged
module, LLA gets it from storage without any I/O.
For information about installing CICS modules in the LPA, see the CICS Transaction
Server for z/OS Installation Guide.
Programs that are not eligible to reside above 16MB, and are read-only, can reside
in the CICS read-only DSA (RDSA) below 16MB. Therefore, to be eligible for the
RDSA, programs must be:
v Properly written to read-only standards
v Link-edited with the RENT attribute
Assembler
If you want CICS to load your assembler programs in the ERDSA, assemble and
link-edit them with the following options:
1. The RENT assembler option
2. The link-edit RENT attribute
3. The RMODE(ANY) residency mode
Note: If you specify these options, ensure that the program is truly read-only (that
is, does not modify itself in any way—for example, by writing to static
storage), otherwise storage exceptions occur. The program must also be
written to 31-bit addressing standards. See the CICS Problem Determination
Guide for some possible causes of storage protection exceptions in
programs resident in the ERDSA.
For example:
//ASMPROG JOB 1,user_name,MSGCLASS=A,CLASS=A,NOTIFY=userid
//EITAL EXEC DFHEITAL,
.
Note: The CICS EXEC interface module for assembler programs (DFHEAI)
specifies AMODE(ANY) and RMODE(ANY). However, because the
assembler defaults your application to AMODE(24) and RMODE(24), the
resulting load module also becomes AMODE(24) and RMODE(24).
C and C/++
If you want CICS to load your C and C++ programs into the ERDSA, compile and
link-edit them with:
1. The RENT compiler option.
The following sample job statements show the LNKPARM parameter with the RENT
option added:
//CPROG JOB 1,user_name,MSGCLASS=A,CLASS=A,NOTIFY=userid
//YITDL EXEC DFHYITDL,
.
(other parameters as necessary)
.
// LNKPARM=’LIST,MAP,LET,XREF,RENT’
You also need to specify the reentrant attribute to link-edit. The CICS-supplied
procedure, DFHYITVL, has a LNKPARM parameter that specifies a number of
link-edit options. To link-edit an ERDSA-eligible program, override this parameter
from the calling job, and add RENT to any other options you require. For example:
//COBPROG JOB 1,user_name,MSGCLASS=A,CLASS=A,NOTIFY=userid
//YITVL EXEC DFHYITVL,
.
(other parameters as necessary)
.
// LNKPARM=’LIST,XREF,RENT’
PL/I
CICS PL/I programs are generally eligible for the ERDSA, provided they do not
change static storage. The following requirements are enforced, either by CICS or
PL/I:
v The required REENTRANT option is included automatically, by the CICS
translator, on the PL/I PROCEDURE statement.
v The PL/I compiler automatically generates code that conforms to 31-bit
addressing standards.
v The CICS EXEC interface module for PL/I (DFHELII) is link-edited with
AMODE(31) and RMODE(ANY). Therefore, your program is link-edited as
AMODE(31) and RMODE(ANY) automatically when you include the CICS EXEC
interface stub, see “The CICS-supplied interface modules” on page 86.
You also need to specify the reentrant attribute to the link-edit. The CICS-supplied
procedure, DFHYITPL, has a LNKPARM parameter that specifies a number of
link-edit options. To link-edit an ERDSA-eligible program, override this parameter
from the calling job, and add RENT to any other options you require. For example:
//PLIPROG JOB 1,user_name,MSGCLASS=A,CLASS=A,NOTIFY=userid
//YITPL EXEC DFHYITPL,
.
(other parameters as necessary)
.
// LNKPARM=’LIST,XREF,RENT’
Note: Do not specify the RENT attribute on the link-edit step unless you have
ensured the program is truly read-only (and does not, for example, write to
static storage), otherwise storage exceptions will occur. See the CICS
The DFHMAPS procedure writes the symbolic map set output to the library
specified on the DSCTLIB parameter, which defaults to the
CICSTS31.CICS.SDFHMAC library. If you want to include symbolic map sets in a
user copy library:
v Specify the library name by the DSCTLIB=name operand on the EXEC statement
for the DFHMAPS procedure used to install physical and symbolic map sets
together.
v Include a DD statement for the user copy library in the SYSLIB concatenation of
the job stream used to assemble and compile the application program.
If you choose to let the DFHMAPS procedure write the symbolic map sets to the
CICSTS31.CICS.SDFHMAC library (the default), include a DD statement for the
CICSTS31.CICS.SDFHMAC library in the SYSLIB concatenation of the job
stream used to compile the application program. This is not necessary for the
DFHEITAL procedure used to assemble assembler-language programs, because
these jobs already include a DD statement for the CICSTS31.CICS.SDFHMAC
library in the SYSLIB concatenation.
v For PL/I, specify a library that has a block size of 32760 bytes. This is necessary
to overcome the blocksize restriction on the PL/I compiler.
For more information about installing map sets, see Chapter 10, “Installing map sets
and partition sets,” on page 125. For information about writing programs to use
BMS services, seeChapter 31, “Basic mapping support,” on page 449.
Each procedure has a name of the form DFHwxTyL, where the variables w, x, and
y depend on the type of program (EXCI batch or CICS online), the type of compiler,
and the programming language. Using the preceding naming convention, the
procedure names are given in Table 7 on page 107.
Notes:
1. DFHYITEL may also be used for C as long as you specify the correct name of
the C compiler on the COMPILER parameter.
# 2. The output library for the generated module is a PDSE (not a PDS).
# 3. DFHZITCL is the recommended procedure for compiling COBOL modules,
# because it uses the version of the Enterprise COBOL compiler which includes
# the integrated CICS translator.
# 4. DFHZITPL is the recommended procedure for compiling PL/I modules as it uses
# the version of the Enterprise PL/I compiler which includes the integrated CICS
# translator.
# 5. For programs that issue EXEC DLI commands in a batch environment under
# Language Environment (IMS routines), use the following special procedures:
# DFHYBTPL
# PL/I application programs
# DFHYBTVL
# COBOL application programs
Note: If you are using DFHXITPL, the SYSLMOD DD statement in the binder step
must refer to a PDSE (not a PDS as for the older PL/I compilers).
In this COBOL example, the symbolic parameter STUB defaults to DFHEILID. The
DFHEILID member contains the statement INCLUDE SYSLIB(DFHELII).
The supplied procedures for PL/I and C also refer to DFHEILID, which means that
the DFHELII stub is used.
Warning messages may appear during the link-edit step, indicating DUPLICATE
definitions for the DFHEI1 entry. You may ignore these messages.
For more information about link-edit requirements, see “Using your own job
streams” on page 119.
You can use the sample job control statements shown in Figure 13 on page 109 to
process application programs written in assembler language. In the procedure
name, “x” depends on whether your programs are CICS application programs or
EXCI batch programs. For the names of the CICS-supplied procedures, see Table 7
on page 107
Figure 13. Sample job control statements to call the DFHExTAL procedures
Notes:
1 If you are installing a program into either of the read-only DSAs, see “Running
application programs in the RDSAs” on page 103 for more details.
If you are installing a program that is to be used from the LPA, add:
v RENT to the PARM options in the EXEC statement for the ASM step of the
DFHEITAL procedure
v RENT and REFR options to the LNKPARM parameter on the call to the
DFHEITAL procedure
(See “Running applications in the link pack area” on page 102.)
2 For information about the translator options you can include on the XOPTS
statement, see “Defining translator options” on page 74.
Figure 14 on page 110 shows the Assembler source program processed by the
command level translator to produce a translator listing and an output file. This
output file is then processed by the Assembler, with reference to CICS.SDFHMAC,
to produce an assembler listing and a further output file.This output file is then
processed by the linkage editor, with reference to CICS.SDFHLOAD to produce a
linkage editor listing and a load module that is stored in CICS.SDFHLOAD.
Translator
Command-level listing
language translator
Intermediate
storage
Assembly
Assembler listing
CICS.
SDFHMAC
Intermediate
storage
Linkage Editor
Linkage Editor listing
CICS.
SDFHLOAD
CICS.
SDFHLOAD
Figure 14. Installing assembler language programs using the DFHEITAL procedure
Translator
Command-level
listing
CICS. language translator
SDFHLOAD
Intermediate
storage
DFHBMSCA
DFHAID Compiler
High-level listing
CICS. language compiler
SDFHCOB
or SDFHPL1 DFHEILIC
DFHEILIP
Intermediate
storage
DFHECI
DFHEPI Linkage Editor
Linkage Editor listing
CICS.
SDFHLOAD
DFHPL1OI
SYS1.PLIBASE CICS.
or COBLIB SDFHLOAD
Figure 16. Sample job control statements to call the DFHYITVL or DFHYXTVL procedures
To use the procedure DFHZITCL to invoke the integrated translator, you can use
the job control statements shown in Figure 17:
Figure 17. Sample job control statements to use the DFHZITCL procedure
Compiler options:
To compile a COBOL program, you need the compiler options RENT, NODYNAM,
and LIB.
If you use the translator option, CBLCARD (the default), the CICS translator
automatically generates a CBL statement containing these options. You can prevent
the generation of a CBL or PROCESS card by specifying the translator option
NOCBLCARD.
The PARM statement of the COB step in the CICS-supplied COBOL procedures
specifies values for the compiler options. For example,
//COB EXEC PGM=IGYCRCTL,REGION=®,
// PARM=’NODYNAM,LIB,OBJECT,RENT,APOST,MAP,XREF’
Note: If you specify CICS translator options for the integrated translator in the
PARM string, you need double apostrophes as shown in this example. If,
however, you specify the options in your source program, you need single
apostrophes (for example, you might have CBL CICS(’COBOL3,SP’) APOST as
the CBL statement in your source program.
The CICS-supplied COBOL procedures do not specify values for the SIZE and BUF
options. The defaults are SIZE=MAX, and BUF=4K. SIZE defines the amount of
virtual storage available to the compiler, and BUF defines the amount of dynamic
storage to be allocated to each compiler buffer work file. You can change these
options with a PARM.COB parameter in the EXEC statement that invokes the
procedure. For example:
EXEC PROC=procname,PARM.COB=’SIZE=512K,BUF=16K,.,.,.’
You can change compiler options by using any of the following methods:
v By overriding the PARM statement defined on the COB step of the
CICS-supplied COBOL procedures.
If you specify a PARM statement in the job that calls the procedure, it overrides
all the options specified in the procedure JCL. Ensure that all the options you
want are specified in the override, or in a CBL statement.
v Specifying a CBL statement at the start of the source statements in the job
stream used to call the the CICS-supplied COBOL procedures.
v The COBOL installation defaults macro, IGYCOPT. This is needed if you do not
use a CBL statement (that is, you have specified the translator option
NOCBLCARD).
2 If you have no input for the translator, you can specify DD DUMMY instead of DD *.
However, if you specify DD DUMMY, also code a suitable DCB operand. (The
translator does not supply all the data control block information for the SYSIN data
set.)
3 If the stand-alone translator supplied with CICS TS is used, the translator
options on the XOPTS statement override similar options in the CICS-supplied
COBOL procedures.
For information about the translator options you can include on the XOPTS
statement, see “Defining translator options” on page 74.
When the integrated CICS translator is used, the COBOL compiler recognizes only
the keyword CICS for defining translator options, not XOPTS.
4 You can ignore weak external references unresolved by the link-edit.
If you are installing a program into either of the read-only DSAs, see “Running
application programs in the RDSAs” on page 103 for more details.
If you are installing a program that is to be used from the LPA, add the RENT and
REFR options to the LNKPARM parameter on the call to the CICS-supplied COBOL
procedures. (See “Running applications in the link pack area” on page 102.)
For more information about preparing PL/I programs, see the PL/I Programming
Guide.
In the procedure name, the value of “x” depends on whether it is a CICS application
program or an EXCI batch program. For the names of the CICS-supplied
procedures, see Table 7 on page 107.
Figure 18. Sample job control statements to call the DFHYxTPL procedures
1 The PL/I COUNT runtime option is not supported by Language Environment.
The REPORT option is replaced by the RPTSTG and RPTUPTS Language
Environment options. See the z/OS Language Environment Migration Guide.
2 If you have no input for the translator, you can specify DD DUMMY instead of DD *.
However, if you specify DD DUMMY also code a suitable DCB operand. (The translator
does not supply all the data control block information for the SYSIN data set.)
Ignore the message from the PL/I compiler: “IEL0548I PARAMETER TO MAIN
PROCEDURE NOT VARYING CHARACTER STRING”.
Warning messages may appear from the PL/I compiler stating that arguments and
parameters do not match for calls to procedure DFHxxxx. These messages indicate
that arguments specified in operands to CICS commands may not have the correct
data type. Carefully check all fields mentioned in these messages, especially
receiver fields.
4 If you include the CALL PLIDUMP statement in an application program, output
goes to the CESE transient data destination. The CICS supplied resource definition
group, in the CSD, DFHDCTG, contains an entry for CPLD.
If you are installing a program into either of the read-only DSAs, see “Running
application programs in the RDSAs” on page 103 for more details.
If you are installing a program that is to be used from the LPA, add the RENT and
REFR options to the LNKPARM parameter on the call to the DFHYxTPL procedure.
(See “Running applications in the link pack area” on page 102 for more
information.)
Figure 19. Sample job control statements to use the DFHZITPL procedure
The DFHZITPL procedure includes the following compiler options to indicate that
you want the compiler to invoke the translator:
PLIPARM=(’SOURCE,OPTIONS,SYSTEM(CICS),PP(CICS)’)
High-level language
source
Translator
Command-level
listing
CICS. language translator
SDFHLOAD
Intermediate
storage
High-level Compiler
EDC.V1R2M0 DFHBMSCA language compiler listing
SEDCHDRS DFHAID
SEDCMSGS
(EDCMSGE)
Intermediate
storage
Pre-linkage
Pre-linkage editor
EDC.V1R2M0 editor listing
SEDCLINK
SEDCCOMP
SEDCMSGS
(EDCMSGE)
EDC.V2R2M1 Intermediate
SIBMLINK storage
DFHEILID
DFHELII
Linkage Editor
Linkage Editor listing
CICS.
SDFHLOAD
EDC.V1R2M0
SEDCBASE
EDC.V2R2M1 CICS.
SIBMBASE SDFHLOAD
# Note: When you choose the XPLINK compiler option, there is no pre-link step in
# the diagram above.
Before you can install any C programs, you must have installed the C library and
compiler and generated CICS support for C. (See the CICS Transaction Server for
z/OS Installation Guide.)
You can code compiler options by using the parameter override (PARM.C) in the
EXEC statement that invokes the procedure, or on a ~pragma options directive.
2 If you have no input for the translator, you can specify DD DUMMY instead of DD *.
However, if you specify DD DUMMY, also code a suitable DCB operand. (The
translator does not supply all the data control block information for the SYSIN data
set.)
3 Translator options: For information about the translator options you can
include on the XOPTS statement, see “Defining translator options” on page 74 .
4 If you are installing a program into either of the read-only DSAs, see “Running
application programs in the RDSAs” on page 103 for more details.
If you are installing a program that is to be used from the LPA, add the RENT and
REFR options to the LNKPARM parameter on the call to the DFHYxTzL procedure.
(See “Running applications in the link pack area” on page 102 for more
information.)
The rest of this section summarizes the important points about the translator and
each of the main categories of program. For simplicity, the following discussion
states that you load programs into CICSTS31.CICS.SDFHLOAD or IMS™.PGMLIB.
In fact, you can use any libraries, but only when they are either included in the
DFHRPL library concatenation in the CICS job stream, or included in the STEPLIB
library concatenation in the batch job stream (for a stand-alone IMS batch program).
Note: The IMS libraries referred to in the job streams are identified by IMS.libnam
(for example IMS.PGMLIB). If you use your own naming convention for IMS
libraries, please rename the IMS libraries accordingly.
Translator requirements
The CICS translator requires a minimum of 256KB of virtual storage. You may need
to use the translator options CICS and DLI.
Figure 23 on page 121 shows sample JCL and an inline procedure, based on the
CICS-supplied procedure DFHYITVL, that can be used to install COBOL application
programs. The procedure does not include the COPYLINK step and concatenation
of the library member DFHEILID that contains the INCLUDE statement for the
required interface module (as included in the DFHYITVL procedure). Instead, the
JCL provides the following INCLUDE statement:
INCLUDE SYSLIB(DFHELII)
If this statement was not provided, the link-edit would return an error message for
unresolved external references, and the program output would be marked as not
executable.
//TRN.SYSIN DD *
//* .
//* . Application program
//* .
//*
//LKED.SYSIN DD *
INCLUDE SYSLIB(DFHELII)
NAME anyname(R)
//*
//MYYITVL PROC SUFFIX=1$, Suffix for translator module
// INDEX=’CICSTS31.CICS’, Qualifier(s) for CICS libraries
// PROGLIB=’CICSTS31.CICS.SDFHLOAD’, Name of o/p library
// DSCTLIB=’CICSTS31.CICS.SDFHCOB’, Private macro/dsect
// AD370HLQ=’SYS1’, Qualifier(s) for AD/Cycle compiler
// LE370HLQ=’SYS1’, Qualifier(s) for Language Environment libraries
// OUTC=A, Class for print output
// REG=4M, Region size for all steps
// LNKPARM=’LIST,XREF’, Link edit parameters
// WORK=SYSDA Unit for work datasets
//*
//STEPLIB DD DSN=&INDEX..SDFHLOAD,DISP=SHR
//SYSPRINT DD SYSOUT=&OUTC
//SYSPUNCH DD DSN=&&SYSCIN,
// DISP=(,PASS),UNIT=&WORK,
// DCB=BLKSIZE=400,
// SPACE=(400,(400,100))
//*
//COB EXEC PGM=IGYCRCTL,REGION=®,
// PARM=’NODYNAM,LIB,OBJECT,RENT,RES,APOST,MAP,XREF’
//STEPLIB DD DSN=&AD370HLQ..SIGYCOMP,DISP=SHR
//SYSLIB DD DSN=&DSCTLIB,DISP=SHR
// DD DSN=&INDEX..SDFHCOB,DISP=SHR
// DD DSN=&INDEX..SDFHMAC,DISP=SHR
// DD DSN=&INDEX..SDFHSAMP,DISP=SHR
//SYSPRINT DD SYSOUT=&OUTC
//SYSIN DD DSN=&&SYSCIN,DISP=(OLD,DELETE)
//SYSLIN DD DSN=&&LOADSET,DISP=(MOD,PASS),
// UNIT=&WORK,SPACE=(80,(250,100))
//SYSUT1 DD UNIT=&WORK,SPACE=(460,(350,100))
//SYSUT2 DD UNIT=&WORK,SPACE=(460,(350,100))
//SYSUT3 DD UNIT=&WORK,SPACE=(460,(350,100))
//SYSUT4 DD UNIT=&WORK,SPACE=(460,(350,100))
//SYSUT5 DD UNIT=&WORK,SPACE=(460,(350,100))
//SYSUT6 DD UNIT=&WORK,SPACE=(460,(350,100))
//*
//LKED EXEC PGM=IEWL,REGION=®,
// PARM=’&LNKPARM’,COND=(5,LT,COB)
//SYSLIB DD DSN=&INDEX..SDFHLOAD,DISP=SHR
// DD DSN=&LE370HLQ..SCEELKED,DISP=SHR
//SYSLMOD DD DSN=&PROGLIB,DISP=SHR
//SYSUT1 DD UNIT=&WORK,DCB=BLKSIZE=1024,
// SPACE=(1024,(200,20))
//SYSPRINT DD SYSOUT=&OUTC
//SYSLIN DD DSN=&©LINK,DISP=(OLD,DELETE)
// DD DSN=&&LOADSET,DISP=(OLD,DELETE)
// DD DDNAME=SYSIN
//PEND
//*
Note: For a program that does not use CICS commands and is only invoked by
a running transaction (and never directly by CICS task initiation), no
translator step is needed.
2. The interface module, DFHDLIAI, is automatically included by the link-edit. If
you use an INCLUDE statement in the link-edit input, place it after the object
deck.
3. Include the module DLIUIB.
If your program uses BMS maps, you need to create the maps. The traditional
method for doing this is to code the map in BMS macros and assemble these
macros. You actually do the assembly twice, with different output options.
v One assembly creates a set of definitions. You copy these definitions into your
program using the appropriate language statement, and they allow you to refer to
the fields in the map by name.
v The second assembly creates an object module that is used when your program
actually executes.
BMS macro
statements Ty p e =
Assembler
defining DSECT Copy
map set library
Ty p e = Assembler
MAP listing
Assembler
Assembler
listing
Link edit
Object Link Editor listing
module
library
CICS load
library
Whatever way you produce maps, you need to create a map before you compile
(assemble) any program that uses it. In addition, if you change the map, you
CICS also supports the definition of BMS map sets and partition sets interactively
by using licensed programs such as the IBM Screen Definition Facility II (SDF II),
program number 5665-366. For more information about SDF II, see the Screen
Definition Facility II Primer for CICS/BMS Programs and Screen Definition Facility II
General Information manuals.
For information about writing programs to use BMS services, see Chapter 31,
“Basic mapping support,” on page 449.
CICS loads BMS map sets and partition sets above the 16MB line if you specify the
residency mode for the map set or partition set as RMODE(ANY) in the link-edit
step. If you are using either map sets or partition sets from earlier releases of CICS,
you can load them above the 16MB line by link-editing them again with
RMODE(ANY). For examples of link-edit steps specifying RMODE(ANY), see the
sample job streams in this chapter.
Physical map sets must be cataloged in the CICS load library. Symbolic description
map sets can be cataloged in a user copy library, or inserted directly into the
application program itself.
The map set definition macros are assembled twice; once to produce the physical
map set used by BMS in its formatting activities, and once to produce the symbolic
description map set that is copied into the application program.
Map sets can be assembled as either unaligned or aligned (an aligned map is one
in which the length field is aligned on a halfword boundary). Use unaligned maps
except in cases where an application package needs to use aligned maps.
The SYSPARM value alone determines whether the map set is aligned or
unaligned, and is specified on the EXEC PROC=DFHMAPS statement. The
SYSPARM operand can also be used to specify whether a physical map set or a
symbolic description map set (DSECT) is to be assembled, in which case it
overrides the TYPE operand. If neither operand is specified, an unaligned DSECT is
generated.
The TYPE operand of the DFHMSD macro can only define whether a physical or
symbolic description map set is required.
For the possible combinations of operands to generate the various types of map
set, see Table 8.
Table 8. SYSPARM and DFHMSD operand combinations for map assembly
Type of map set SYSPARM operand of EXEC TYPE operand of
DFHMAPS statement DFHMSD macro
Aligned symbolic A Not specified
description map A DSECT
set (DSECT) ADSECT Any (takes SYSPARM)
Aligned A MAP
physical map set AMAP Any (takes SYSPARM)
Unaligned Not specified Not specified
symbolic Not specified DSECT
description map DSECT Any (takes SYSPARM)
set (DSECT)
Unaligned Not specified MAP
physical map set MAP Any (takes SYSPARM)
The physical map set indicates whether it was assembled for aligned or unaligned
maps. This information is tested at execution time, and the appropriate map
alignment used. Thus aligned and unaligned map sets can be mixed.
Macro statements
defining the map set
Assembly
Assembler
listing
CICS.
SDFHMAC
Linkage
Editor
input
(object)
CICS.
SDFHLOAD
Figure 26 gives an example job stream for the assembly and link-editing of physical
map sets.
1 For halfword-aligned length fields, specify the option SYSPARM(AMAP) instead
of SYSPARM(MAP).
2 Physical map sets are loaded into CICS-key storage, unless they are link-edited
with the RMODE(ANY) and RENT options. If they are link-edited with these options,
they are loaded into key-0 protected storage, provided that RENTPGM=PROTECT
is specified on the RENTPGM initialization parameter. However, it is recommended
that map sets (except for those that are only sent to 3270 or LU1 devices) should
not be link-edited with the RENT or the REFR options because, in some cases,
CICS modifies the map set. Generally, use the RENT or REFR options for map sets
that are only sent to 3270 or LU1 devices.For more information about the storage
protection facilities available in CICS, see the CICS System Definition Guide.
3 The MODE statement specifies whether the map set is to be loaded above
(RMODE(ANY)) or below (RMODE(24)) the 16MB line. RMODE(ANY) indicates that
CICS can load the map set anywhere in virtual storage, but tries to load it above
the 16MB line, if possible.
4 Use the NAME statement to specify the name of the physical map set that BMS
loads into storage. If the map set is device-dependent, derive the map set name by
appending the device suffix to the original 1- to 7-character map set name used in
the application program. The suffixes to be appended for the various terminals
supported by CICS BMS depend on the parameter specified in the TERM or
SUFFIX operand of the DFHMSD macros used to define the map set. For
programming information giving a complete list of map set suffixes, see the CICS
Application Programming Reference manual.
To use a physical map set, you must define and install a resource definition for it.
You can do this either by using the program autoinstall function or by using the
CEDA DEFINE MAPSET and INSTALL commands. as described in “Defining
programs, map sets, and partition sets to CICS” on page 134.
Macro statements
defining the
symbolic map
Assembly
Assembler listing
CICS.
SDFHMAC
SYSPUNCH
Figure 27. Installing symbolic description map sets using the DFHASMVS procedure
When a symbolic description is prepared under the same name for more than one
programming language, a separate copy of the symbolic description map set must
be placed in each user copy library. You must ensure that the user copy libraries
are correctly concatenated with SYSLIB.
You need only one symbolic description map set corresponding to all the different
suffixed versions of the physical map set. For example, to run the same application
on terminals with different screen sizes, you would:
1. Define two map sets each with the same fields, but positioned to suit the screen
sizes. Each map set has the same name but a different suffix, which would
match the suffix specified for the terminal.
2. Assemble and link-edit the different physical map sets separately, but create
only one symbolic description map set, because the symbolic description map
set would be the same for all physical map sets.
You can use the sample job stream in Figure 28 to obtain a listing of a symbolic
description map set. It applies to all the programming languages supported by
CICS.
If you want to assemble symbolic description map sets in which length fields are
halfword-aligned, change the EXEC statement of the sample job in Figure 28 to the
following:
//ASSEM EXEC PROC=DFHASMVS,PARM.ASSEM=’SYSPARM(ADSECT)’
To store a symbolic description map set in a private copy library, use job control
statements similar to the following:
//SYSPUNCH DD DSN=USER.MAPLIB.ASM(map set name),DISP=OLD
//SYSPUNCH DD DSN=USER.MAPLIB.COB(map set name),DISP=OLD
//SYSPUNCH DD DSN=USER.MAPLIB.PLI(map set name),DISP=OLD
1
Macro statements
defining the map set
2
Assembly
Assembler listing
CICS.
SDFHMAC
Linkage
Editor
input
(object)
3
Linkage Editor Linkage Editor
CICS. listing
SDFHLOAD
4
Macro statements Assembler
defining the map set
CICS.
SDFHMAC
Figure 29. Installing a physical map set and a symbolic description map set together
Note: The RMODE statement specifies whether the map set is to be loaded above
(RMODE=ANY) or below (RMODE=24) the 16MB line. RMODE=ANY
indicates that CICS can load the map set anywhere in virtual storage, but
tries to load it above the 16MB line, if possible.
The DFHMAPS procedure produces map sets that are not halfword-aligned. If you
want the length fields in input maps to be halfword-aligned, you have to code A=A
on the EXEC statement. In the sample job in Figure 30, change the EXEC
statement to:
//ASSEM EXEC PROC=DFHMAPS,MAPNAME=mapsetname,A=A
This change results in the SYSPARM operands in the assembly steps being altered
to SYSPARM(AMAP) and SYSPARM(ADSECT) respectively.
The DFHMAPS procedure directs the symbolic description map set output
(SYSPUNCH) to the CICSTS31.CICS.SDFHMAC library. Override this by specifying
DSCTLIB=name on the EXEC statement, where “name” is the name of the chosen
user copy library.
1 A partition set is loaded into CICS-key storage, unless it is link-edited with the
RMODE(ANY) and RENT options. If it is link-edited with these options, it is loaded
into key-0 protected storage, provided that RENTPGM=PROTECT is specified on
the RENTPGM initialization parameter.
For more information about the storage protection facilities available in CICS, see
the CICS System Definition Guide.
2 The MODE statement specifies whether the partition set is to be loaded above
(RMODE(ANY)) or below (RMODE(24)) the 16MB line. RMODE(ANY) indicates that
CICS can load the partition set anywhere in virtual storage, but tries to load it above
the 16MB line, if possible.
3 Use the NAME statement to specify the name of the partition set which BMS
loads into storage. If the partition set is device-dependent, derive the partition set
name by appending the device suffix to the original 1- to 7-character partition set
name used in the application program. The suffixes that BMS appends for the
various terminals depend on the parameter specified in the SUFFIX operand of the
DFHPSD macro that defined the partition set.
For programming information giving a complete list of partition-set suffixes, see the
CICS Application Programming Guide.
To use a partition set, you must define and install a resource definition for it. You
can do this either by using the program autoinstall function or by using the CEDA
DEFINE PARTITIONSET and INSTALL commands, as described in the CICS
Resource Definition Guide.
For information about defining programs to CICS, see the CICS Resource Definition
Guide.
The programming models implemented in CICS are inherited from those designed
for 3270s, and exhibit many of the characteristics of conversational,
terminal-oriented applications. There are basically three styles of programming
model:
v Terminal-initiated, that is, the conversational model
v Distributed program link (DPL), or the RPC model
v START, that is, the queuing model.
Once initiated, the applications typically use these and other methods of continuing
and distributing themselves, for example, with pseudoconversations, RETURN
IMMEDIATE or DTP. The main difference between these models is in the way that
they maintain state ( for example, security), and hence state becomes an integral
part of the application design. This presents the biggest problem when you attempt
to convert to another application model.
Processor speeds, even allowing for accessing data sets, are considerably faster
than terminal transmission times, which are considerably faster than user response
times. This is especially true if users have to think about the entry or have to enter
many characters of input. Consequently, conversational transactions tie up storage
and other resources for much longer than nonconversational transactions.
No transaction exists for the terminal from the time a response is written until the
user sends the next input and CICS starts the next transaction to respond to it.
Information that would normally be stored in the program between inputs is passed
from one transaction in the sequence to the next using the COMMAREA or one of
the other facilities that CICS provides for this purpose. (See Chapter 13, “Sharing
data across transactions,” on page 183 for details.)
There are two major issues to consider in choosing between conversational and
pseudoconversational programming.
v The effect of the transaction on contention resources, such as storage and
processor usage. Storage is required for control blocks, data areas, and
programs that make up a transaction, and the processor is required to start,
process, and terminate tasks. Conversational programs have a very high impact
on storage, because they last so long, relative to the sum of the transactions that
make up an equivalent pseudoconversational sequence. However, there is less
processor overhead, because only one transaction is initiated instead of one for
every input.
v The effect on exclusive-use resources, such as records in recoverable data
sets, recoverable transient data queues, enqueue items, and so on. Again, a
conversational transaction holds on to these resources for much longer than the
corresponding sequence of nonconversational transactions. From this point of
CICS ensures that changes to recoverable resources (such as data sets, transient
data, and temporary storage) made by a unit of work (UOW) are made completely
or not at all. A UOW is equivalent to a transaction, unless that transaction issues
SYNCPOINT commands, in which case a UOW lasts between syncpoints. For a
more detailed description of syncpoints and UOWs, see the CICS Recovery and
Restart Guide.
For example, if one user tries to update a particular record in a recoverable data
set, and another user tries to do so before the first one finishes, the second user’s
transaction is suspended. This has advantages and disadvantages. You would not
want the second user to begin updating the record while the first user is changing it,
because one of them is working from what is about to become an obsolete version
of the record, and these changes erase the other user’s changes. On the other
hand, you also do not want the second user to experience the long, unexplained
wait that occurs when that transaction attempts to READ for UPDATE the record
that is being changed.
If you use pseudoconversational transactions, however, the resources are only very
briefly unavailable (that is, during the short component transactions). However,
unless all recoverable resources can be updated in just one of these transactions,
recovery is impossible because UOWs cannot extend across transactions. So, if
you cannot isolate updates to recoverable resources in this way, you must use
conversational transactions.
The primary mechanism for initiating tasks, however, is unsolicited input. When a
user transmits input from a terminal which is not the principal facility of an existing
task, CICS creates a task to process it. The terminal that sent the input becomes
the principal facility of the new task.
Principal facility
CICS allows a task to communicate directly with only one terminal, namely
its principal facility. CICS assigns the principal facility when it initiates the
task, and the task “owns” the facility for its duration. No other task can use
that terminal until the owning task ends. If a task needs to communicate
with a terminal other than its principal facility, it must do so indirectly, by
creating another task that has the terminal as its principal facility. This
requirement arises most commonly in connection with printing, and how you
can create such a task is explained in “Using CICS printers” on page 409.
Notes:
1. You can specify a terminal destination other than your principal facility in
a SEND command if the destination is under TCAM control, an apparent
Unsolicited inputs from other systems are handled in the same way: CICS creates a
task to process the input, and assigns the conversation over which the input arrived
as the principal facility. (Thus a conversation with another system may be either a
principal or alternate facility. In the case where a task in one CICS region initiates a
conversation with another CICS region, the conversation is an alternate facility of
the initiating task, but the principal facility of the partner task created by the
receiving system. By contrast, a terminal is always the principal facility.)
Alternate facility
Although a task may communicate directly with only one terminal, it can
also establish communications with one or more remote systems. It does
this by asking CICS to assign a conversation with that system to it as an
alternate facility. The task “owns” its alternate facilities in the same way
that it owns its principal facility. Ownership lasts from the point of
assignment until task end or until the task releases the facility.
Not all tasks have a principal facility. Tasks that result from unsolicited input always
do, by definition, but a task that comes about from automatic task initiation may or
may not need one. When it does, CICS waits to initiate the task until the requested
facility is available for assignment to the task.
Which transaction?
Having received an unsolicited input, how does CICS decide what to do with it?
That is, what transaction should the task created to process it execute? The short
answer is that the previous task with the same principal facility usually tells CICS
what transaction to execute next just before it ends, by the TRANSID option on its
final RETURN. This is almost always the case in a pseudoconversational
transaction sequence, and usually in menu-driven applications as well. Failing that,
and in any case to get a sequence started, CICS interprets the first few characters
of the input as a transaction code. However, it is more complicated than that; the
exact process goes as follows. The step numbers indicate the order in which the
tests are made and refer to Figure 33 on page 144, a diagram of this logic.
No
6
Initiate
Yes PA, PF, LPA, Yes TASKREQ= Yes
transaction
3270?
or OPID? specified? specified by
* term input AID
No No
No
7
Terminal Initiate
Yes
input begins transaction
specified by
with tranid? * terminal input
Note: This logic for deciding which transaction to execute applies only to tasks
initiated to process unsolicited inputs. For automatic transaction initiation, the
transaction is always known. You specify it in the TRANSID option when you
create a task with a START or RETURN IMMEDIATE. Similarly, you specify
what transaction should be used to process a transient data queue in the
queue definition. Tasks created to route messages always execute the
CICS-supplied transaction CSPG.
When separating the business and presentation logic, you need to consider the
following:
v Avoid affinities between the two parts of the application.
v Be aware of the DPL-restricted API; see CICS Application Programming
Reference for details.
v Be aware of hidden presentation dependencies, such as EIBTRMID usage.
Figure 34 illustrates a simple CICS application that accepts data from an end user,
updates a record in a file, and sends a response back to the end user. The
transaction that runs this program is the second in a pseudoconversation. The first
transaction has sent a BMS map to the end user’s terminal, and the second
transaction reads the data with the EXEC CICS RECEIVE MAP command, updates
the record in the file, and sends the response with the EXEC CICS SEND MAP
command.
The EXEC CICS RECEIVE and EXEC CICS SEND MAP commands are part of the
transaction’s presentation logic, while the EXEC CICS READ UPDATE and EXEC
CICS REWRITE commands are part of the business logic.
..
EXEC CICS RECEIVE MAP
..
EXEC CICS READ UPDATE
..
EXEC CICS REWRITE
..
EXEC CICS SEND MAP
..
..
EXEC CICS RECEIVE MAP
..
EXEC CICS LINK..
..
EXEC CICS SEND MAP
..
Once the business logic of a transaction has been isolated from the presentation
logic and given a communication area interface, it is available for reuse with
different presentation methods. For example, you could use Distributed Program
Link (DPL) to implement a two-tier model, or CICS Web support with the CICS
business logic interface, where the presentation logic is HTTP-based.
Multithreading requires that all CICS application programs be quasi- reentrant; that
is, they must be serially reusable between entry and exit points. CICS application
programs using the EXEC CICS interface obey this rule automatically. For COBOL,
C, and C++ programs, reentrancy is ensured by a fresh copy of working storage
being obtained each time the program is invoked. You should always use the RENT
option on the compile or pre-link utility even for C and C++ programs that do not
have writable statics and are naturally reentrant. Temporary variables and
DFHEIPTR fields inserted by the CICS translator are usually defined as writable
static variables and require the RENT option. For these programs to stay reentrant,
variable data should not appear as static storage in PL/I, or as a DC in the program
CSECT in assembler language.
As well as requiring that your application programs are compiled and link-edited as
reentrant, CICS also identifies programs as being either quasi-reentrant or
threadsafe. These attributes are discussed in the following sections.
For example, application programs could modify their executable code, or the
variables defined within the program storage, but these changes must be undone,
or the code and variables reinitialized, before there is any possibility of the task
losing control and another task executing the same program.
To ensure that programs cannot interfere with each others working storage, CICS
obtains a separate copy of working storage for each execution of an application
program. Thus, if a user application program is in use by 11 user tasks, there are
11 copies of working storage in the appropriate dynamic storage area (DSA).
Note: The CICS QR TCB provides protection through exclusive control of global
resources only if all user tasks that access those resources run under the
QR TCB. It does not provide automatic protection from other tasks that
execute concurrently under another (open) TCB.
To make your program’s application logic threadsafe, ensure that it uses appropriate
serialization techniques when accessing shared resources. For most resources,
such as files, transient data queues, temporary storage queues, and DB2 tables,
CICS processing automatically ensures access in a threadsafe manner. As
described above, some of the CICS commands that operate on these resources are
coded to use appropriate serialization techniques that allow them to execute on
open TCBs (that is, they are threadsafe commands). Where this is not the case,
CICS ensures threadsafe processing by forcing a switch to the QR TCB, so that
access to the resources is serialized regardless of the behaviour of the command.
However, for any other resources which are accessed directly by user programs,
such as shared storage, it is the responsibility of the user program to ensure
threadsafe processing.
Typical examples of shared storage are the CICS CWA, the global work areas for
global user exits, and storage acquired explicitly by the application program with the
shared option. You can check whether your application programs use these types of
shared storage by looking for occurrences of the following EXEC CICS commands:
v ADDRESS CWA
v EXTRACT EXIT
v GETMAIN SHARED
Although some of these commands are themselves threadsafe, they all give access
to global storage areas, so the application logic that follows these commands and
The load module scanner utility includes a sample table, DFHEIDTH, to help you
identify whether the application logic in your existing application programs is
threadsafe. DFHEIDTH contains the filter set for CICS commands that give access
to shared storage. The use of these commands could make a program not
threadsafe, unless it has the necessary synchronization logic in place to ensure
serialization and prevent concurrent update.
Note: When identifying programs that use shared resources, you should also
include any program that modifies itself. Such a program is effectively
sharing storage and should be considered at risk.
Techniques that you can use to provide threadsafe processing when accessing a
shared resource are as follows:
v Retry access, if the resource has been changed concurrently by another
program, using the compare and swap instruction.
v Enqueue on the resource, to obtain exclusive control and ensure that no other
program can access the resource, using:
– An EXEC CICS ENQ command, in an application program
– An XPI ENQUEUE function call to the CICS enqueue (NQ) domain, in a
global user exit program
– An MVS service such as ENQ (in an open API task-related user exit only
when L8 TCBs are enabled for use). Note that the use of MVS services in an
application which can execute under the QR TCB might result in performance
degradation due to the TCB being placed in a wait.
v Perform accesses to shared resources only in a program that is defined as
quasi-reentrant, by linking to the quasi-reentrant program using the EXEC CICS
LINK command.
This technique applies to threadsafe application programs and open API
task-related user exits only. A linked-to program defined as quasi-reentrant runs
under the QR TCB and can take advantage of the serialization provided by CICS
quasi-reentrancy. Note that even in quasi-reentrant mode, serialization is
provided only for as long as the program retains control and does not wait (see
“Quasi-reentrant application programs” on page 147 for more information).
v Place all transactions that access the shared resource into a restricted
transaction class (TRANCLASS), one that is defined with the number of active
tasks specified as MAXACTIVE(1).This last approach effectively provides a very
coarse locking mechanism, but may have a severe impact on performance.
Note: Although the term threadsafe is defined in the context of individual programs,
a user application as a whole can only be considered threadsafe if all the
When an EXEC CICS LINK command is used to link from one program to another,
the program link stack level is incremented. However, a routine that is statically
called, or dynamically called, does not involve passing through the CICS command
level interface, and so does not cause the program link stack level to be
incremented. With Cobol routines, for a static call, a simple branch and link is
involved to an address that is resolved at linkedit time. For a dynamic call, although
there is a program definition involved, this is required only to allow Language
Environment to load the program. After that, a simple branch and link is executed.
So when a routine is called by either of these methods, CICS does not regard this
as a change of program. The program that called the routine is still considered to
be executing, and so the program definition for that program is still considered to be
the current one.
| OPENAPI programs
| OPENAPI programs (that is, those defined in the resource definition with the
| OPENAPI attribute) are invoked on an open L8 or L9 mode TCB (depending on the
| EXECKEY attribute) instead of the main CICS QR TCB.
The default for this parameter is FORCEQR=NO, which means that CICS honors
the CONCURRENCY attribute on your program resource definitions. As a
temporary measure, while you investigate and resolve problems connected with
threadsafe-defined programs, you can set FORCEQR=YES. Remember to change
this back to FORCEQR=NO when you are ready for your programs to resume use
of open TCBs under the OTE.
Non-reentrant programs
There is nothing to prevent non-reentrant application programs being executed by
CICS. However, such an application program would not provide consistent results in
a multi-threading environment.
For information about RELOAD(YES), see the CICS Resource Definition Guide.
CICS/ESA® loads any program link-edited with the RENT attributes into a CICS
read-only dynamic storage area (DSA). CICS uses the RDSA for RMODE(24)
programs, and the ERDSA for RMODE(ANY) programs.By default, the storage for
these DSAs is allocated from read-only key-0 protected storage, protecting any
modules loaded into them from all except programs running in key-zero or
supervisor state.(If CICS initializes with the RENTPGM=NOPROTECT system
initialization parameter, it does not use read-only key-0 storage, and use CICS-key
storage instead.)
For more information about CICS DSAs, refer to the CICS System Definition Guide.
All of these areas are main storage facilities and come from the same basic
source—the dynamic storage areas (DSAs) and extended dynamic storage areas
(EDSAs). None of them is recoverable, and none can be protected by resource
security keys. They differ, however, in accessibility and duration, and therefore each
meets a different set of storage needs.
Processor overhead associated with using the TWA is minimal. You do not need a
GETMAIN command to access it, and you address it using a single ADDRESS
command. The TASKDATAKEY option governs whether the TWA is obtained in
CICS-key or user-key storage. (See Chapter 46, “Storage control,” on page 575 for
a full explanation of CICS-key and user-key storage.) The TASKDATALOC option of
the transaction definition governs whether the acquired storage can be above the
16MB line or not.
The TWA is suitable for quite small data storage requirements and for larger
requirements that are both relatively fixed in size and are used more or less for the
duration of the transaction. Because the TWA exists for the entire transaction, a
large TWA size has much greater effect for conversational than for
nonconversational transactions.
User storage
User storage is available to all the programs in a transaction, but some effort is
required to pass it between programs using LINK or XCTL commands. Its size is
not fixed, and it can be obtained (using GETMAIN commands) just when the
transaction requires it and returned as soon as it is not needed. Therefore, user
storage is useful for large storage requirements that are variable in size or are
shorter-lived than the transaction.
See Chapter 46, “Storage control,” on page 575 for information about how
USERDATAKEY and CICSDATAKEY override the TASKDATAKEY option of the
GETMAIN command.
The SHARED option of the GETMAIN command causes the acquired storage to be
retained after the end of the task. The storage can be passed in the communication
area from one task to the next at the same terminal. The first task returns the
address of the communication area in the COMMAREA option of the RETURN
command. The second task accesses the address in the COMMAREA option of the
ADDRESS command. You must use the SHARED option of the GETMAIN
command to ensure that your storage is in common storage.
CICS ensures that any COMMAREA is addressable by the program that receives it,
by copying below the 16MB line and/or to the USERKEY storage where necessary,
depending on the addressing mode and EXECKEY attributes of the receiving
program. See Chapter 46, “Storage control,” on page 575 for more information
about EXECKEY.
Temporary storage
Temporary storage is the primary CICS facility for storing data that must be
available to multiple transactions.
Data items in temporary storage are kept in queues whose names are assigned
dynamically by the program storing the data. A temporary storage queue containing
multiple items can be thought of as a small data set whose records can be
addressed either sequentially or directly, by item number. If a queue contains only a
single item, it can be thought of as a named scratch-pad area.
Temporary storage data sharing means that main or auxiliary storage can be
replaced by one or more temporary storage pools.
Note that if the QNAME option matches the prefix of an installed TSMODEL
resource definition, the MAIN or AUXILIARY value specified in the TSMODEL takes
precedence over that specified in the command.
See the CICS Resource Definition Guide for more information about the use of
TSMODELs to define temporary storage queues.
The addition of temporary storage data sharing gives another type of temporary
storage queue that can be supported concurrently. These temporary storage queues
can be defined as local, remote, or shared, and they can be stored in TS pools in
the coupling facility.
You can use transient data for many of the purposes for which you would use
auxiliary temporary storage, but there are some important differences.
v Transient data does not have the same dynamic characteristics as temporary
storage. Unlike temporary storage queues, transient data queues cannot be
LENGTH options
In COBOL, C, C++, PL/I, and assembler language, the translator deals with lengths.
See the CICS Application Programming Reference manual for programming
information, including details of when you need to specify the LENGTH option. You
should not let the length specified in CICS command options exceed 24KB, if
possible.
Many commands involve the transfer of data between the application program and
CICS. In all cases, the length of the data to be transferred must be provided by the
application program.
In most cases, the LENGTH option must be specified if the SET option is used; the
syntax of each command and its associated options show whether this rule applies.
There are options on the WAIT EXTERNAL command and a number of QUERY
SECURITY commands that give the resource status or definition. CICS supplies the
values associated with these options, hence the name, CICS-value data areas. The
options are shown in the syntax of the commands with the term “cvda” in
parentheses. For programming information about CVDAs, see the CICS Application
Programming Reference manual.
For journal commands, the restrictions apply to the sum of the LENGTH and
PFXLENG values. (See “Journaling” on page 253.)
Journal records
For journal records, the journal buffer size may impose a limit lower than 64KB.
Note that the limit applies to the sum of the LENGTH and PFXLENG values.
Recommendation
For any command in any system, 24KB is a good working limit for LENGTH
specifications. Subject to user-specified record and buffer sizes, this limit is
unlikely either to cause an error or to place a constraint on applications.
You will probably not find a 24KB limit too much of a hindrance; online programs do
not often handle such large amounts of data, for the sake of efficiency and
response time.
Note: The value in the LENGTH option should never exceed the length of the data
area addressed by the command.
What often happens is that, when two application systems that run perfectly by
themselves are run together, performance goes down and you begin experiencing
“lockouts” or waits. The scope of each system has not been defined well enough.
Testing applications
The following general rules apply to testing applications:
v Do not test on a production CICS system—use a test system, where you can
isolate errors without affecting “live” databases.
v Have the testing done by someone other than the application developer, if
possible.
v Document the data you use for testing.
v Test your applications several times. See Chapter 49, “Testing applications,” on
page 601 for more information about testing applications.
v Use the CEDF transaction for initial testing. See Chapter 50, “Execution
diagnostic facility (EDF),” on page 605 for more information about using CEDF.
v Use stress or volume testing to catch problems that may not arise in a
single-user environment. Teleprocessing Network Simulator (TPNS, licensed
program number 5740-XT4) is a good tool for doing this.
TPNS is a telecommunications testing package that enables you to test and
evaluate application programs before you install them. You can use TPNS for
testing logic, user exit routines, message logging, data encryption, and
device-dependencies, if these are used in application programs in your
organization. It is useful in investigating system performance and response times,
stress testing, and evaluating TP network design. For further information, see the
TPNS General Information manual.
v Test whether the application can handle correct data and incorrect data.
v Test against complete copies of the related databases.
v Consider using multiregion operation. (See the CICS Intercommunication Guide
for more information.)
v Before you move an application to the production system, it is a good idea to run
a final set of tests against a copy of the production database to catch any errors.
Assembler language programs (if not addressing data areas properly) can be
harder to identify because they can alter something that affects (and abends)
another transaction.
For more information about solving a problem, see the CICS Problem Determination
Guide.
Also, resource security checking can now be carried out for PLT programs that are
run during CICS shutdown. PLT shutdown programs execute as part of the
transaction that requests the shutdown, and therefore run under the authorization of
the user issuing the shutdown command.
The START command handles security for non-terminal transactions started by the
START command.
CICS can issue up to three surrogate user security checks on a single START
command, depending on the circumstances:
1. The userid of the transaction that issues the START command, if USERID is
specified
2. The userid of the CEDF transaction, if the transaction that issues the START
command is being run in CEDF dual-screen mode
3. The CICS region userid of the remote system, if the START command is
function shipped to another CICS system and link security is in effect.
A separate surrogate user security check is done for each of these userids, as
required, before the transaction is attached.
Program size
The early emphasis on small programs led CICS programmers to break up
programs into units that were as small as possible, and to transfer control using the
XCTL command, or link using the LINK command, between them. In current
systems, however, it is not always better to break up programs into such small
units, because there is CICS processing overhead for each transfer and, for LINK
commands, there is also storage overhead for the register save areas (RSAs).
For modestly-sized blocks of code that are processed sequentially, inline code is
most efficient. The exceptions to this rule are blocks of code that are:
v Fairly long and used independently at several different points in the application
v Subject to frequent change (in which case, you balance the overhead of LINK or
XCTL commands with ease of maintenance)
v Infrequently used, such as error recovery logic and code to handle uncommon
data combinations
If you have a block of code that for one of these reasons, has to be written as a
subroutine, the best way of dealing with this from a performance viewpoint is to use
a closed subroutine within the invoking program (for example, code that is dealt
with by a PERFORM command in COBOL). If it is needed by other programs, it
should be a separate program. A separate program can be called, with a CALL
statement (macro), or it can be kept separate and processed using an XCTL or a
LINK command. Execution overhead is least for a CALL, because no CICS services
are invoked; for example, the working storage of the program being called is not
copied. A called program, however, must be linked into the calling one and so
cannot be shared by other programs that need it unless you use special COBOL, C,
or PL/I facilities. A called subroutine is loaded as part of each program that CALLs it
and hence uses more storage. Thus, subsequent transactions using the program
may or may not have the changes in the working storage made to the called
program. This depends entirely on whether CICS has loaded a new copy of the
program into storage.
The load module resulting from any application program can occupy up to two
gigabytes of main storage. Clearly, there is an extra cost associated with loading
and initializing very large load modules, and CICS dynamic storage limits (EDSA)
would need to be set correspondingly high. You should, if possible, avoid the use of
large load modules. However large applications written in an object-oriented
language, such as C++, can easily exceed 16M in size. Experience with C++
classes bound into a single DLL is that performance of the classes is degraded if
the single DLL is reorganized into two or more DLLs. This is due to the processing
required to resolve function references between multiple DLLs.
You may get an abend code of APCG if your program occupies all the available
storage in the dynamic storage area (DSA).
Virtual storage
A truly conversational CICS task is one that converses with the terminal user for
several or many interactions, by issuing a terminal read request after each write (for
example, using either a SEND command followed by a RECEIVE command, or a
CONVERSE command). This means that the task spends most of its extended life
waiting for the next input from the terminal user.
Any CICS task requires some virtual storage throughout its life and, in a
conversational task, some of this virtual storage is carried over the periods when
the task is waiting for terminal I/O. The storage areas involved include the TCA and
associated task control blocks (including EIS or EIB) and the storage required for all
programs that are in use when any terminal read request is issued. Also included
are the work areas (such as copies of COBOL working storage) associated with this
task’s use of those programs.
With careful design, you can sometimes arrange for only one very small program to
be retained during the period of the conversation. The storage needed could be
shared by other users. You must multiply the rest of the virtual storage requirement
by the number of concurrent conversational sessions using that code.
The extra virtual storage you need for conversational applications usually means
that you need a correspondingly greater amount of real storage. The paging you
need to control storage involves additional overhead and virtual storage. The
Locality of reference
Keep the instructions processed and data used in a program within a relatively
small number of pages (4096-byte segments). This quality in a program is known
as “locality of reference”. You can do this by:
v Making the execution of the program as linear as possible.
v Keeping any subroutines you use in the normal execution sequence as close as
possible to the code that invokes them.
v Placing code inline, even if you have to repeat it, if you have a short subroutine
that is called from only a small number of places.
v Separating error-handling and other infrequently processed code from the main
flow of the program.
v Separating data used by such code from data used in normal execution.
v Defining data items (especially arrays and other large structures) in the order in
which they are referred to.
v Defining the elements within a data structure in the approximate order in which
they are referred to. For example, in PL/I, all the elements of one row are stored,
then the next row, and so on. You should define an array so that you can
process it by row rather than by column.
v Initializing data as close as possible to where it is first used.
v Avoiding COBOL variable MOVE operations because these expand into
subroutine calls.
Note: Some of the suggestions above may conflict with your installation’s
programming standards if these are aimed at the readability and
maintainability of the code, rather than speed of execution in a
virtual-storage environment. Some structured programming methods, in
particular modular programming techniques, make extensive use of the
PERFORM command in COBOL (and the equivalent programming
techniques in C, PL/I, and assembler language) to make the structure of the
program clear. This may also result in more exceptions to sequential
processing than are found in a nonstructured program. Nevertheless, the
much greater productivity associated with structured code may be worth the
possible loss of locality of reference.
Working set
The working set is the number and combination of pages of a program needed
during a given period. To minimize the size of the working set, the amount of
storage that a program refers to in a given period should be as small as possible.
You can do this by:
v Writing modular programs and structuring the modules according to frequency
and anticipated time of reference. Do not modularize merely for the sake of size;
consider duplicate code inline as opposed to subroutines or separate modules.
v Using separate subprograms whenever the flow of the program suggests that
execution is not be sequential.
v Not tying up main storage awaiting a reply from a terminal user.
v Using command-level file control locate-mode input/output rather than
move-mode.
v In COBOL programs, specifying constants as literals in the PROCEDURE
DIVISION, rather than as data variables in the WORKING STORAGE section.
v In C, C++, and PL/I programs, using static storage for constant data.
v Avoiding the use of LINK commands where possible, because they generate
requests for main storage.
Reference set
Try to keep the overall number of pages that a program uses during normal
operation as small as possible. These pages are termed the reference set, and
they give an indication of the real storage requirement of the program. You can
reduce the reference set by:
v Specifying constants in COBOL programs as literals in the PROCEDURE
DIVISION, rather than as data variables in the WORKING STORAGE SECTION.
The reason for this is that there is a separate copy of working storage for every
task executing the program, whereas literals are considered part of the program
itself, of which only one copy is used in CICS.
v Using static storage in C, C++, and PL/I for data that is genuinely constant, for
the same reason as in the previous point.
v Reusing data areas in the program as much as possible. You can do this with the
REDEFINES clause in COBOL, the union clause in C and C++, based storage in
If the program is dynamic, the entire program must be loaded across adjacent
pages before execution begins. Dynamic programs can be purged from storage if
they are not being used and an unsatisfied storage request exists. Allowing
sufficient dynamic area to prevent purging is more expensive than making them
resident, because a dynamic program does not share unused space on a page with
another program.
The primary resources that produce these locking delays are data sets, DL/I
databases, temporary storage, and transient data queues. The unit where protection
is based is the individual record (key) for data sets, the program specification block
(PSB) for DL/I databases, and the queue name for temporary storage. For transient
data, the “read” end of the queue is considered a separate resource from the “write”
end (that is, one transaction can read from a queue while another is writing to it).
To reduce transaction delays from contention for resource ownership, the length of
time between the claiming of the resource and its release (the end of the UOW)
should be minimized. In particular, conversational transactions should not own a
critical resource across a terminal read.
Note: Even for nonrecoverable data sets, VSAM prevents two transactions from
reading the same record for update at the same time. This enqueue ends as
soon as the update is complete, however, rather than at the end of the
UOW. Even this protection for a BDAM data set, can be relinquished by
defining them with “no exclusive control” (SERVREQ=NOEXCTL) in the file
control table.
It may be appropriate here to note the difference between CICS data sets on a
VSAM control interval, and VSAM internal locks on the data set. Because CICS has
no information about VSAM enqueue, a SHARE OPTION 4 control interval that is
updated simultaneously from batch and CICS can result in, at best, reduced
performance and, at worst, an undetectable deadlock situation between batch and
CICS. You should avoid such simultaneous updates between batch and CICS. In
any case, if a data set is updated by both batch and CICS, CICS is unable to
ensure data integrity.
Operational control
The following operational techniques can be used to influence the performance and
efficiency of the CICS system:
MXT
The CICS system initialization parameter MXT specifies the maximum number
of user tasks that can exist in a CICS system at the same time. MXT is
invaluable for avoiding short-on-storage (SOS) conditions and for controlling
contention for resources in CICS systems. It works by delaying the creation of
user tasks to process input messages, if there are already too many activities in
the CICS system. In particular, the virtual storage occupied by a message
awaiting processing is usually much less than that needed for the task to
process it, so you save virtual storage by delaying the processing of the
message until you can do so quickly.
Transaction classes are useful in limiting the number of tasks of a particular
user-defined type, or class, if these are heavy resource users.
Runaway tasks
CICS only resets a task’s runaway time (ICVR) when a task is suspended. An
EXEC CICS command cannot be guaranteed to cause a task to suspend during
processing because of the unique nature of each CICS implementation. The
runaway time may be exceeded causing a task to abend AICA. This abend can
be prevented by coding an EXEC CICS SUSPEND command in the application
This causes the dispatcher to suspend the task that issued the request and
allow any task of higher priority to run. If there is no task ready to run, the
program that issued the suspend is resumed. For further information about
abend AICA, see the CICS Problem Determination Guide.
Auxiliary trace
Use auxiliary trace to review your application programs. For example, it can
show up any obviously unnecessary code, such as a data set browse from the
beginning of a data set instead of after a SETL, too many or too large
On these commands, you can use the NOSUSPEND option (also known as the
NOQUEUE option in the case of the ALLOCATE command) to inhibit this waiting
and cause an immediate return to the instruction in the application program
following the command.
1. HANDLE CONDITION and IGNORE CONDITION commands are not supported for C and C++ programs.
Each request in progress against a VSAM data set requires at least one string.
Requests that hold position tie up a string until a command is issued to release
the hold position. Requests that do not hold position release the string as soon
as that request is complete.
If you are using BDAM data sets in update mode, you should be aware that
performance is affected dramatically by the means of data set integrity you choose.
If you specify exclusive control in file control table SERVREQ operands for a
BDAM data set, CICS requests the operating system to prevent concurrent updates.
However, this involves significant overhead.
You can use journals for input (in batch) as well as output (online) while CICS is
running. The supplied batch utility DFHJUP can be used for access to journal data,
for example, by printing or copying. Note that reading a journal in batch involves the
following restrictions:
v Access to MVS system logger log stream data is provided through a subsystem
interface, LOGR.
v Reading records from a journal is possible offline by means of a batch job only.
The MDT for a field is normally turned on by the 3270 hardware when the user
enters data into a field. However, you can also turn the tag on when you send a
map to the screen, either by specifying FSET in the map or by sending an override
attribute byte that has the tag on. You should never set the tag on in this way for a
field that is constant in the map, or for a field that has no label (and is not sent to
the program that receives the map).
Also, you do not normally need to specify FSET for an ordinary input field. This is
because, as already mentioned, the MDT is turned on automatically in any field in
which the user enters data. This is then included in the next RECEIVE command.
These tags remain on, no matter how many times the screen is sent, until explicitly
turned off by the program (by the FRSET, ERASEAUP, or ERASE option, or by an
override attribute with the tag off).
You can store information, between inputs, that the user did not enter on the
screen. This is an intended reason for turning the MDT on by a program. However,
this storage technique is appropriate only to small amounts of data, and is more
suitable for local than for remote terminals, because of the transmission overhead
involved. For example, this technique is particularly useful for storing default values
for input fields. In some applications, the user must complete a screen in which
some fields already contain default values. A user who does not want to change a
default just skips that field. The program processing the input has to be informed
what these defaults are. If they are always the same, they can be supplied as
constants in the program. If they are variable, however, and depend on earlier
inputs, you can simply save them on the screen by turning the MDT on with FSET
in the map that writes the screen. The program reading the screen then receives
the default value from a user who does not change the field and the new value from
a user who does.
Note: The saved values are not returned to the screen if the CLEAR, PA1, PA2, or
PA3 key is pressed.
This is because, when BMS builds the data stream representing your map, it
includes blanks (X'40') but omits nulls (X'00'). This makes the output data stream
shorter. BMS omits any field whose first data character is null, regardless of
subsequent characters in the field.
BMS requires you to initialize to nulls any area to be used to build a map. This is
done by moving nulls (X'00') to the mapnameO field in the symbolic map structure.
See “Initializing the output map” on page 474 for more information. BMS uses nulls
in attribute positions and in the first position of data to indicate that no change is to
be made to the value in the map. If you are reusing a map area in a program or in
a TIOA, you should take special care to clear it in this way.
The former is slightly easier to code (you do not need to have two map areas or
move any fields), but it may result in very much longer transmissions because the
output data stream contains the correct input fields as well as the error and
message fields. In fact, it may even be longer than the original input stream
because, if there were empty or short fields in the input, BMS may have replaced
the missing characters with blanks or zeros.
With the 3270 hardware, if the input stream for a terminal exceeds 256 bytes, the
terminal control unit automatically breaks it up into separate transmissions of 256
bytes maximum. This means that a long input stream may require several physical
I/O operations. Although this is transparent to the application program, it does
cause additional line and processor overhead. The output stream is generally sent
in a single transmission.
CICS provides an exit that is driven just before output is sent to a terminal (XTC
OUT). You may want to add SBA and RA substitutions to this exit to compress the
data stream using a general subroutine. This has the dual benefit of removing
compression logic from your application program and of applying to all output data
streams, whether they are produced by BMS or not.
If users really need to see all the pages, and need to scroll backward and forward
frequently, it may be more efficient to produce all the pages at the same time and
present them using “traditional” CICS paging services. However, if users need only
a few of the pages, or can easily specify how far back or forward in the message
they would like to scroll, there are two choices:
1. First, construct a pseudoconversational transaction to produce just one screen
of output. The first time this transaction is run, it produces the first page of the
many-page output. The output screen contains space for users to indicate the
page they want next. The transaction always sets the next transaction identifier
to point to itself, so that it can display the requested page when it is next run.
You will probably want to give users some of the options that CICS provides
(such as one page forward, one page back, and skip to a selected page) and
some relevant to the application, such as a data set key at which to begin the
next page of output.
2. The alternative is to page-build a multipage output message with the ACCUM
option, but to limit the number of pages in the message (say to five). Users
page through the subset pages with the usual CICS page commands. On the
last screen of the output, you add an indication that there is more output and a
place for them to indicate whether they want to see the next segment. As in the
However, if neither of the above conditions apply, you have a choice of two other
methods of delivering output to a terminal not associated with the transaction.
1. You can use a START command, with the TERMID option, to specify the
terminal to which you want to write and the FROM option to specify the data
you want to send. Your own transaction is the started transaction. It issues an
RETRIEVE command for the message and then sends it to its own terminal.
See the CICS Application Programming Reference manual for programming
information about the START command.
2. Similarly, you can put messages destined for a particular terminal on to an
intrapartition transient data queue. The definition for the transient data queue
must specify:
v The destination as a TERMINAL
v The terminal identifier
v A trigger level
v A transaction name
Your own transaction reads the transient data queue and sends the message to
its terminal. It repeats this sequence until the queue is empty, and then
terminates. The trigger level you specified means that it is invoked every time
the specified number of messages have been placed on the queue. The
CICS/ESA Sample Applications Guide describes the DFHœTDWT sample
program that performs this function.
Note: Because of the overhead associated with routing messages (by whatever
means), you should use facilities such as ROUTE=ALL with caution.
If a printer is available, and the request is from a remote device, CICS sends a very
short data stream to the control unit asking for a copy of the requesting device
buffer to be sent to the output device buffer.
The PROTECT option of the PROFILE definition implies message integrity and
causes the system to log all input and output messages, which adds to I/O and
processor overhead.
Data stored in the TCTUA and the CWA is available to any transaction in the
system. Subject to resource security and storage protection restrictions, any
transaction may write to them and any transaction may read them.
The use of some of these facilities may cause inter-transaction affinities. See
Chapter 15, “Affinity,” on page 219 for more information about transaction affinities.
If you want to restrict write access to the CWA, you can specify CWAKEY=CICS.
This means that CICS allocates the CWA from CICS-key storage, restricting
application programs defined with EXECKEY(USER) to read-only access to the
CWA. The only programs allowed to write to a CWA allocated from CICS-key
storage are those you define with EXECKEY(CICS).
Because any program that executes in CICS key can also write to CICS storage,
you should ensure that such programs are thoroughly tested to make sure that they
do not overwrite CICS storage.
If you want to give preference to protecting CICS rather than the CWA, specify
CWAKEY=USER for the CWA, and EXECKEY(USER) for all programs that write to
the CWA. This ensures that if a program exceeds the length of the CWA it does not
overwrite CICS storage. For more information about storage protection, see
Chapter 46, “Storage control,” on page 575.
Figure 37 illustrates a particular use of the CWA where the CWA itself is protected
from user-key application programs by CWAKEY=CICS.
CWA
(defined with
CWAKEY=CICS)
appl1_id Application
Storage Area
ptr_ref1 (for appl1)
(obtained from
appl2_id CICS-key storage)
ptr_ref2
Application
Storage Area
(for appl2)
(obtained from
user-key storage)
Figure 37. Example of use of CWA in CICS-key storage. This illustrates how the CWA can be
used to reference storage that is obtained in user-key or CICS-key storage for use by
application programs, while the CWA itself is protected by being in CICS-key storage.
In this illustration, the CWA is not used directly to store application data and
constants. The CWA contains pairs of application identifiers and associated
addresses, with the address fields containing the addresses of data areas that hold
the application-related data. For protection, the CWA is defined with
CWAKEY=CICS, therefore the program which in this illustration is a program
defined in the program list table post initialization (PLTPI) list, and that loads the
CWA with addresses and application identifiers must be defined with
EXECKEY(CICS). Any application programs requiring access to the CWA should be
In the sample code shown in Figure 38, the program list table post-initialization
(PLTPI) program is setting up the application data areas, with pointers to the data
stored in the CWA.
This example illustrates how to create global data for use by application programs,
with addresses of the data stored in the CWA—for example, by a PLTPI program.
The first data area is obtained from CICS-key storage, which is the default on a
GETMAIN command issued by a PLTPI program, the second from user-key storage
by specifying the USERDATAKEY option. The CWA itself is in CICS-key storage,
and PLTPROG is defined with EXECKEY(CICS).
ID DIVISION.
PROGRAM-ID. PLTPROG.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 APPLID PIC X(8) VALUE SPACES.
77 SYSID PIC X(4) VALUE SPACES.
01 COMM-DATA.
03 AREA-PTR USAGE IS POINTER.
03 AREA-LENGTH PIC S9(8) COMP.
LINKAGE SECTION.
01 COMMON-WORK-AREA.
03 APPL-1-ID PIC X(4).
03 APPL-1-PTR USAGE IS POINTER.
03 APPL-2-ID PIC X(4).
03 APPL-2-PTR USAGE IS POINTER.
PROCEDURE DIVISION.
MAIN-PROCESSING SECTION.
* Obtain APPLID and SYSID values
EXEC CICS ASSIGN APPLID(APPLID)
SYSID(SYSID)
END-EXEC.
* Set up addressability to the CWA
EXEC CICS ADDRESS
CWA(ADDRESS OF COMMON-WORK-AREA)
END-EXEC.
* Get 12KB of CICS-key storage for the first application (’APP1’)
MOVE 12288 TO AREA-LENGTH.
EXEC CICS GETMAIN SET(AREA-PTR)
FLENGTH(AREA-LENGTH)
SHARED
END-EXEC.
* Initialize CWA fields and link to load program
* for storage area 1.
MOVE ’APP1’ TO APPL-1-ID.
SET APPL-1-PTR TO AREA-PTR.
EXEC CICS LINK PROGRAM(’LOADTAB1’)
COMMAREA(COMM-DATA)
END-EXEC.
Using the TCTUA in this way does not require special discipline among using
transactions, because data is always read by the transaction following the one that
wrote it. However, if you use TCTUAs to store longer-term data (for example,
terminal or operator information needed by an entire application), they require the
The COMMAREA is allocated from the CICS shared subpool in main storage, and
is addressed by the TCTTE, between tasks of a pseudoconversational application.
The COMMAREA is freed unless it is passed to the next task.
The first program in the next task has automatic addressability to the passed
COMMAREA, as if the program had been invoked by either a LINK command or an
XCTL command (see “COMMAREA in LINK and XCTL commands” on page 157).
You can also use the COMMAREA option of the ADDRESS command to obtain the
address of the COMMAREA.
To summarize:
v Processor overhead is low (equivalent to using COMMAREA with an XCTL
command and approximately equal to using main temporary storage).
v It is not recoverable.
v There is no resource security.
v It is not suitable for very large amounts of data (because main storage is used,
and it is held until the terminal user responds).
v As with using COMMAREA to transfer data between programs, it is available only
to the first program in a transaction, unless that program explicitly passes the
data or its address to succeeding programs.
The transaction has two ways of using the valid data. It can save it (for example, in
COMMAREA), and pass it on for the next time it is run. In this case, the transaction
must merge the changed data on the screen with the data from previous entries.
Alternatively, it can save the data on the screen by not turning off the modified data
tags of the keyed fields.
Saving the data on the screen is very easy to code, but it is not very secure. You
are not recommended to save screens that contain large amounts of data as errors
may occur because of the additional network traffic needed to resend the
unchanged data. (This restriction does not apply to locally-attached terminals.)
Secondly, if the user presses the CLEAR key, the screen data is lost, and the
transaction must be able to recover from this. You can avoid this by defining the
CLEAR key to mean CANCEL or QUIT, if this is appropriate for the application
concerned.
Data other than keyed data may also be stored on the screen. This data can be
protected from changes (except those caused by CLEAR) and can be nondisplay, if
necessary.
To create named containers and assign them to a channel, a program uses EXEC
CICS PUT CONTAINER(container-name) CHANNEL(channel-name) commands. It
can then pass the channel (and its containers) to a second program using the
CHANNEL(channel-name) option of the EXEC CICS LINK, XCTL, START, or
RETURN commands.
The second program can read containers passed to it using the EXEC CICS GET
CONTAINER(container-name) command. This command reads the named container
belonging to the channel that the program was invoked with.
If the second program is invoked by a LINK command, it can also return containers
to the calling program. It can do this by creating new containers, or by reusing
existing containers.
Channels and containers are visible only to the program that creates them and the
programs they are passed to. When these programs terminate, CICS automatically
destroys the containers and their storage.
Basic examples
Figure 39 on page 191 shows a COBOL program, CLIENT1, that:
1. Uses PUT CONTAINER(container-name) CHANNEL(channel-name) commands
to create a channel called inqcustrec and add two containers, custno and
branchno, to it; these contain a customer number and a branch number,
respectively.
2. Uses a LINK PROGRAM(program-name) CHANNEL(channel-name) command
to link to program SERVER1, passing the inqcustrec channel.
3. Uses a GET CONTAINER(container-name) CHANNEL(channel-name) command
to retrieve the customer record returned by SERVER1. The customer record is in
the custrec container of the inqcustrec channel.
Note that the same COBOL copybook, INQINTC, is used by both the client and
server programs. Line 3 and lines 5 through 7 of the copybook represent the
INQUIRY-CHANNEL and its containers. These lines are not strictly necessary to the
working of the programs, because containers and channels are created simply by
being named (on, for example, PUT CONTAINER commands); they do not have to
be defined. However, the inclusion of these lines in the copybook used by both
programs makes for easier maintenance; they record the names of the containers
used.
Recommendation
Note: This example shows two COBOL programs. The same techniques can be
used in any of the other languages supported by CICS. However, for COBOL
programs only, if the server program uses the SET option (instead of INTO)
on the EXEC CICS GET CONTAINER command, the structure of the storage
pointed to by SET must be defined in the LINKAGE section of the program.
This means that you will require two copybooks rather than one. The first, in
the WORKING-STORAGE section of the program, names the channel and
containers used. The second, in the LINKAGE section, defines the storage
structure.
WORKING-STORAGE SECTION.
COPY INQINTC
* copybook INQINTC
* Channel name
* 01 INQUIRY-CHANNEL PIC X(16) VALUE ’inqcustrec’.
* Container names
* 01 CUSTOMER-NO PIC X(16) VALUE ’custno’.
* 01 BRANCH-NO PIC X(16) VALUE ’branchno’.
* 01 CUSTOMER-RECORD PIC X(16) VALUE ’custrec’.
* Define the data fields used by the program
* 01 CUSTNO PIC X(8).
* 01 BRANCHNO PIC X(5).
* 01 CREC.
* 02 CUSTNAME PIC X(80).
* 02 CUSTADDR1 PIC X(80).
* 02 CUSTADDR2 PIC X(80).
* 02 CUSTADDR3 PIC X(80).
PROCEDURE DIVISION.
MAIN-PROCESSING SECTION.
*
* INITIALISE CUSTOMER RECORD
*
... CREATE CUSTNO and BRANCHNO
*
* GET CUSTOMER RECORD
*
EXEC CICS PUT CONTAINER(CUSTOMER-NO) CHANNEL(INQUIRY-CHANNEL)
FROM(CUSTNO) FLENGTH(LENGTH OF CUSTNO)
END-EXEC
EXEC CICS PUT CONTAINER(BRANCH-NO) CHANNEL(INQUIRY-CHANNEL)
FROM(BRANCHNO) FLENGTH(LENGTH OF BRANCHNO)
END-EXEC
*
* PROCESS CUSTOMER RECORD
*
... FURTHER PROCESSING USING CUSTNAME and CUSTADDR1 etc...
EXIT.
Figure 39. A simple example of a program that creates a channel and passes it to a second
program
Figure 40 on page 192 shows the SERVER1 program linked to by CLIENT1. SERVER1
retrieves the data from the custno and branchno containers it has been passed, and
uses it to locate the full customer record in its database. It then creates a new
container, custrec, on the same channel, and returns the customer record in it.
Chapter 14. Enhanced inter-program data transfer: channels as modern-day COMMAREAs 191
Note that the programmer hasn’t specified the CHANNEL keyword on the GET and PUT
commands in SERVER1: if the channel isn’t specified explicitly, the current channel is
used—that is, the channel that the program was invoked with.
IDENTIFICATION DIVISION.
PROGRAM-ID. SERVER1.
WORKING-STORAGE SECTION.
COPY INQINTC
* copybook INQINTC
* Channel name
* 01 INQUIRY-CHANNEL PIC X(16) VALUE ’inqcustrec’.
* Container names
* 01 CUSTOMER-NO PIC X(16) VALUE ’custno’.
* 01 BRANCH-NO PIC X(16) VALUE ’branchno’.
* 01 CUSTOMER-RECORD PIC X(16) VALUE ’custrec’.
* Define the data fields used by the program
* 01 CUSTNO PIC X(8).
* 01 BRANCHNO PIC X(5).
* 01 CREC.
* 02 CUSTNAME PIC X(80).
* 02 CUSTADDR1 PIC X(80).
* 02 CUSTADDR2 PIC X(80).
* 02 CUSTADDR3 PIC X(80).
PROCEDURE DIVISION.
MAIN-PROCESSING SECTION.
EXIT.
Figure 40. A simple example of a linked to program that retrieves data from the channel it
has been passed. This program is linked-to by program CLIENT1 shown in Figure 39 on
page 191.
Inside the component, the programs can pass the channel between themselves.
Alternatively, a component program could, for example, pass a subset of the
original channel, by creating a new channel and adding one or more containers
from the original channel.
CH
EXEC CICS LINK PROGRAM('payr')
CHANNEL('payroll')
CH
CH
Figure 42. A “component”—a set of related programs invoked through a single external channel. “CH” indicates that
the programs within the component can pass channels between themselves.
Chapter 14. Enhanced inter-program data transfer: channels as modern-day COMMAREAs 193
The “loose coupling” between the client program and the component permits easy
evolution. That is, the client and the component can be upgraded at different times.
For example, first the component could be upgraded to handle a third channel,
consisting of a different set of containers from the first or second channels. Next,
the client program could be upgraded (or a new client written) to pass the third
channel.
:
CH
EXEC CICS LINK PROGRAM('payr') : CH
CHANNEL('payroll-2004')
Figure 43. Multiple external channels to the same component. “CH” indicates that the programs within the component
may pass channels between themselves.
Containers
Payroll component
Creating a channel
You create a channel by naming it on one of the following commands:
EXEC CICS LINK PROGRAM CHANNEL
EXEC CICS MOVE CONTAINER CHANNEL TOCHANNEL
EXEC CICS PUT CONTAINER CHANNEL
EXEC CICS RETURN TRANSID CHANNEL
EXEC CICS START TRANSID CHANNEL
EXEC CICS XCTL PROGRAM CHANNEL
If the channel doesn’t already exist, within the current program scope, it is created.
The most straightforward way to create a channel, and populate it with containers of
data, is to issue a succession of EXEC CICS PUT CONTAINER(container-name)
CHANNEL(channel-name) FROM(data_area) commands. The first PUT command
creates the channel (if it doesn’t already exist), and adds a container to it; the
subsequent commands add further containers to the channel. If the containers
already exist, their contents are overwritten by the new data.
Note:
Chapter 14. Enhanced inter-program data transfer: channels as modern-day COMMAREAs 195
1. If the CHANNEL or TOCHANNEL option isn’t specified, the current channel is
implied.
2. The source channel must be in program scope.
3. If the target channel doesn’t already exist, within the current program
scope, it is created.
4. If the source container doesn’t exist, an error occurs.
5. If the target container doesn’t already exist, it is created; if it already
exists, its contents are overwritten.
You can use MOVE CONTAINER, instead of GET CONTAINER and PUT
CONTAINER, as a more efficient way of transferring data between channels.
If the channel named on the following commands doesn’t already exist, within the
current program scope, an empty channel is created:
v EXEC CICS LINK PROGRAM CHANNEL(channel-name)
v EXEC CICS RETURN TRANSID CHANNEL(channel-name)
v EXEC CICS START TRANSID CHANNEL(channel-name)
v EXEC CICS XCTL PROGRAM CHANNEL(channel-name)
Program B’s current channel is X, passed by the CHANNEL option on the EXEC
CICS LINK command issued by program A. Program B modifies channel X by
adding one container and deleting another.
Program C’s current channel is also X, passed by the CHANNEL option on the
EXEC CICS LINK command issued by program B.
Program E’s current channel is Y, passed by the CHANNEL option on the EXEC
CICS LINK command issued by D.
PROG A
PUT CONTAINER(ONE) CHANNEL(X) FROM(area1)
PUT CONTAINER(TWO) CHANNEL(X) FROM(area2)
LINK PROGRAM(B) CHANNEL(X)
:
:
Current CH: X
PROG B
:
PUT CONTAINER(THREE) FROM(area-a)
DELETE CONTAINER(TWO)
LINK PROGRAM(C) CHANNEL(X)
:
:
RETURN
Current CH: X
PROG C
:
LINK PROGRAM(D)
:
:
RETURN
Current CH: Y
PROG E
:
:
RETURN
The following table lists the name of the current channel (if any) of each of the five
programs shown in the previous figure.
Chapter 14. Enhanced inter-program data transfer: channels as modern-day COMMAREAs 197
Table 10. The current channels of interactive programs—example with LINK commands
Prog. Current Issues commands Comments
CH
. Program A creates channel X and passes it to
EXEC CICS PUT CONTAINER(ONE) program B.
CHANNEL(X) FROM(area1)
EXEC CICS PUT CONTAINER(TWO) Note that, by the time control is returned to
A None CHANNEL(X) FROM(area2) program A by program B, the X channel has
EXEC CICS LINK PROGRAM(B) CHANNEL(X) been modified—it doesn’t contain the same set
. of containers as when it was created by
program A. (Container TWO has been deleted
and container THREE added by program B.)
. Program B modifies channel X (its current
EXEC CICS PUT CONTAINER(THREE) channel) by adding and deleting containers, and
FROM(area-a) passes the modified channel to program C.
EXEC CICS DELETE CONTAINER(TWO)
B X EXEC CICS LINK PROGRAM(C) CHANNEL(X) Program B doesn’t need to specify the
. CHANNEL option on the PUT CONTAINER and
. DELETE CONTAINER commands; its current
EXEC CICS RETURN
channel is implied.
. Program C links to program D, but does not
EXEC CICS LINK PROGRAM(D) pass it a channel.
C X .
.
EXEC CICS RETURN
. Program D creates a new channel, Y, which it
EXEC CICS PUT CONTAINER(first) passes to program E.
CHANNEL(Y) FROM(a1)
EXEC CICS PUT CONTAINER(second)
D None CHANNEL(Y) FROM(a2)
EXEC CICS LINK PROGRAM(E) CHANNEL(Y)
.
.
EXEC CICS RETURN
. Program E performs some processing on the
E Y RETURN data it’s been passed and returns.
.
B1’s current channel is X, passed by the CHANNEL option on the EXEC CICS LINK
command issued by A1.
B3’s current channel is Y, passed by the CHANNEL option on the EXEC CICS
XCTL command issued by B2.
PROG A1
XCTL PROGRAM(B3)
CHANNEL(Y)
Current CH: X Current CH: none Current CH: Y
The following table lists the name of the current channel (if any) of each of the four
programs shown in Figure 46.
Table 11. The current channels of interactive programs—example
Program Current Issues command
channel
.
A1 None EXEC CICS LINK PROGRAM(B1) CHANNEL(X)
.
.
B1 X EXEC CICS XCTL PROGRAM(B2)
.
.
B2 None EXEC CICS XCTL PROGRAM(B3) CHANNEL(Y)
.
.
B3 Y EXEC CICS RETURN
.
Chapter 14. Enhanced inter-program data transfer: channels as modern-day COMMAREAs 199
v On pseudoconversational RETURNs—that is, on RETURN commands that
specify, on the TRANSID option, the next transaction to be run at the user
terminal.
v If issued by a program at the highest logical level—that is, a program that
returns control to CICS.
The program that implements the next transaction is passed the channel, which
becomes its current channel.
The scope of the X channel—the code from which it can be accessed—is programs
A, B, and C.
Note that, by the time control is returned to program A by program B, the X channel
has been modified—it doesn’t contain the same set of containers as when it was
created by program A.
PROG A
Scope of Channel X
PUT CONTAINER(ONE) CHANNEL(X) FROM(area1)
PUT CONTAINER(TWO) CHANNEL(X) FROM(area2)
LINK PROGRAM(B) CHANNEL(X)
:
:
Current Channel: X
PROG B
:
PUT CONTAINER(THREE) FROM(area-a)
DELETE CONTAINER(TWO)
LINK PROGRAM(C) CHANNEL(X)
:
:
RETURN
Current Channel: X
PROG C
:
LINK PROGRAM(D)
:
:
RETURN
Current Channel: Y
PROG E
:
:
RETURN
The following table lists the name and scope of the current channel (if any) of each
of the five programs shown in the previous figure.
Chapter 14. Enhanced inter-program data transfer: channels as modern-day COMMAREAs 201
Table 12. The scope of a channel—example with LINK commands
Program Current channel Scope of channel
A None Not applicable
B X A, B, C
C X A, B, C
D None Not applicable
E Y D, E
Note that, by the time control is returned to program A1 by program B3, it’s possible
that the X channel may have been modified by program B1—it might not contain
the same set of containers as when it was created by A1.
X and Z scope =
XCTL PROGRAM(B3)
CHANNEL(Y)
Current CH: X
Current CH: none Current CH: Y
Current CH: Z
PROG C1
Figure 48. The scope of a channel—example showing LINK and XCTL commands
The following table lists the name and scope of the current channel (if any) of each
of the five programs shown in Figure 48.
Table 13. The scope of a channel—example with LINK and XCTL commands
Program Current channel Scope of channel
A1 None Not applicable
B1 X A1 and B1
B2 None Not applicable
B3 Y B2 and B3
C1 Z B1 and C1
Chapter 14. Enhanced inter-program data transfer: channels as modern-day COMMAREAs 203
Discovering which containers a program’s been passed
Typically, programs that exchange a channel are written to handle that channel.
That is, both client and server programs know the name of the channel, and the
names and number of the containers in the channel. However, if, for example, a
server program or component is written to handle more than one channel, on
invocation it must discover which of the possible channels it’s been passed.
A program can discover its current channel—that is, the channel with which it was
invoked—by issuing an EXEC CICS ASSIGN CHANNEL command. (If there is no
current channel, the command returns blanks.)
The program can also (should it need to) get the names of the containers in its
current channel by browsing. Typically, this is not necessary. A program written to
handle several channels is often coded to be aware of the names and number of
the containers in each possible channel.
To get the names of the containers in the current channel, use the browse
commands:
v EXEC CICS STARTBROWSE CONTAINER BROWSETOKEN(data-area) .
v EXEC CICS GETNEXT CONTAINER(data-area) BROWSETOKEN(token).
v EXEC CICS ENDBROWSE CONTAINER BROWSETOKEN(token).
Having retrieved the name of its current channel and, if necessary, the names of
the containers in the channel, a server program can adjust its processing to suit the
kind of data that it’s been passed.
On return, the first program knows the name of the channel which has been
returned, but not necessarily the names of the containers in the channel. (Does the
returned channel contain the same containers as the passed channel, or has the
second program deleted some or created others?) The first program can discover
the container-names by browsing. To do this, it uses the commands:
v EXEC CICS STARTBROWSE CONTAINER BROWSETOKEN(data-area)
CHANNEL(channel-name).
v EXEC CICS GETNEXT CONTAINER(data-area) BROWSETOKEN(token).
v EXEC CICS ENDBROWSE CONTAINER BROWSETOKEN(token).
You cannot overwrite, move, or delete a read only container. Thus, if you specify a
read only container on a PUT CONTAINER, MOVE CONTAINER, or DELETE
CONTAINER command an INVREQ condition occurs.
At the end of a DPL call, input containers that have not been changed by the
server program are not returned to the client. Input containers whose contents
have been changed by the server program, and containers created by the server
program, are returned. Therefore, for optimal DPL performance:
v Use separate containers for input and output data.
v The server program, not the client, should create the output containers.
v Use separate containers for read-only and read-write data.
v If a structure is optional, make it a separate container.
v Use dedicated containers for error information.
Here are some general tips on designing a channel. They include and expand on
the recommendations for achieving optimal DPL performance.
v Use separate containers for input and output data. This leads to:
– Better encapsulation of the data, making your programs easier to maintain.
– Greater efficiency when a channel is passed on a DPL call, because smaller
containers flow in each direction.
v The server program, not the client, should create the output containers. If the
client creates them, empty containers will be sent to the server region.
v Use separate containers for read-only and read-write data. This leads to:
– A simplification of your copybook structure, making your programs easier to
understand.
– Avoidance of the problems with REORDER overlays.
– Greater transmission efficiency between CICS regions, because read-only
containers sent to a server region will not be returned.
v Use separate containers for each structure. This leads to:
– Better encapsulation of the data, making your programs easier to understand
and maintain.
– Greater ease in changing one of the structures, because you don’t need to
recompile the entire component.
– The ability to pass a subset of the channel to sub-components, by using the
MOVE CONTAINER command to move containers between channels.
v If a structure is optional, make it a separate container. This leads to greater
efficiency, because the structure is passed only if the container is present.
v Use dedicated containers for error information. This leads to:
– Better documentation of what is error information.
– Greater efficiency, because:
1. The structure containing the error information is passed back only if an
error occurs.
2. It is more efficient to check for the presence of an error container by
issuing a GET CONTAINER(known-error-container-name) command (and
possibly receiving a NOTFOUND condition) than it is to initiate a browse
of the containers in the channel.
Chapter 14. Enhanced inter-program data transfer: channels as modern-day COMMAREAs 205
v When you need to pass data of different types—for example, binary data and
character data—use separate containers for each type, rather than one container
with a complicated structure. This improves your ability to move between different
code pages.
v When you need to pass a large amount of data, split it between multiple
containers, rather than put it all into one container.
When a channel is passed to a remote program or transaction, passing a large
amount of data may affect performance. This is particularly true if the local and
remote regions are connected by an ISC, rather than MRO, connection.
v Take care not to create so many large containers that you limit the amount of
storage available to other applications.
For information about migrating programs that use COMMAREAs to use channels
instead, see “Migration to the new function” on page 216.
Figure 49. How a client program can construct a channel, pass it to a server program, and
retrieve the server’s output
Figure 50 on page 207 shows part of the PAYR server program invoked by the client.
The server program:
1. Queries the channel with which it’s been invoked.
2. Issues EXEC CICS GET CONTAINER commands to retrieve the input from the
employee and wage containers of the payroll-2004 channel.
3. Processes the input data.
4. Issues an EXEC CICS PUT CONTAINER command to return its output in the
status container of the payroll-2004 channel.
Figure 50. How a server program can query the channel it’s been passed, retrieve data from
the channel’s containers, and return output to the caller
Chapter 14. Enhanced inter-program data transfer: channels as modern-day COMMAREAs 207
CICS Channel program CICS BTS program
DEFINE ACTIVITY('payroll')
PROGRAM('payact')
Program PAYACT
WHEN('....
EXEC CICS LINK PROGRAM('payr')
Program PAYR
* get the employee passed into this program
EXEC CICS GET CONTAINER('employee')
INTO(emp) Container-aware programs can
: be called from both Channel
:
* return the status to the caller
and BTS applications
EXEC CICS PUT CONTAINER('status')
FROM('OK')
Context
As shown in Figure 51, a program that issues container commands can be used,
without change, as part of a channel application or as part of a BTS activity.
For a program to be used in both a channel and a BTS context, the container
commands that it issues must not specify any options that identify them as either
channel or BTS commands. The options to be avoided on each of the container
commands are:
DELETE CONTAINER
ACQACTIVITY (BTS-specific)
When a container command is executed, CICS analyzes the context (channel, BTS,
or neither) in which it occurs, in order to determine how to process the command.
To determine the context, CICS uses the following sequence of tests:
1. Channel: does the program have a current channel?
2. BTS: is the program part of a BTS activity?
3. None: the program has no current channel and is not part of a BTS activity. It
therefore has no context in which to execute container commands. The
command is rejected with an INVREQ condition and a RESP2 value of 4.
The routing program is passed, in the DYRCHANL field of its communication area,
the name of the channel, if any, associated with the program-link or START
command. The DYRCHANL field applies only to the three types of request listed
above. For other types of request, or if there is no channel associated with the
request, it contains blanks.
Chapter 14. Enhanced inter-program data transfer: channels as modern-day COMMAREAs 209
Note: The routing program‘s communication area is mapped by the DFHDYPDS
DSECT.
Note that the routing program is given the name of the channel, not its address,
and so is unable to use the DYRCHANL field to inspect or change the contents of
the containers.
To give the routing program the same kind of functionality with channels, an
application that uses a channel can create, within the channel, a special container
named DFHROUTE. If the application issues a LINK or terminal-related START
request (but not a non-terminal-related START request) that is to be dynamically
routed, the dynamic routing program is given, in the DYRACMAA field of
DFHDYPDS, the address of the DFHROUTE container, and can inspect and
change its contents.
If you are migrating a program to pass a channel rather than a COMMAREA, you
could use its existing COMMAREA structure to map DFHROUTE.
For introductory information about dynamic and distributed routing, see the CICS
Intercommunication Guide. For information about writing a dynamic or distributed
routing program, see the CICS Customization Guide.
Data conversion
Appendix F of the z/OS Support for Unicode: Using Conversion Services manual
-SA22 -7649 records those conversions which are supported though these services.
These are not limited to Unicode, but include the ability to convert between a broad
range of character encodings, including EBCDIC, ASCII and Unicode.
Note:
CICS now supports any of these character conversions by making use of the z/OS
conversion services. However, those conversions that earlier releases of CICS
carried out using a set of tables, continue to be supported in that manner. It is only
if CICS TS 3.1 is asked to carry out a conversion between a pair of CCSIDs that
are unsupported via these tables, that it attempts the conversion using the z/OS
services.
Ensuring that required conversion images are available
Those CCSIDs used as part of CICS applications must be made known to
the System Programmers responsible for maintaining the z/OS Conversion
Image, so that specific conversions are available to the CICS regions where
these applications execute.
Handling CCSID 1200
CICS supports conversions involving UTF-16 data using any of the
following CCSID’s: 1200, 1201, and 1202. The z/OS conversion services
permit CCSID 1200, in its big-endian form, to be used, but does not contain
support for the little-endian form or for CCSIDs 1201 or 1202. CICS
transforms any source data that is identified in any of these unsupported
forms to the big-endian form of 1200 before passing the data to z/OS for
conversion. If the target data is one of the unsupported forms then CICS
receives the data as the big-endian form of 1200 and transforms it to the
required CCSID. If the target CCSID is 1200 then CICS assumes the
encoding to be in big-endian form. If the conversion is between any of
these CCSIDs then CICS will carry out the transformation without calling
the z/OS conversion services.
When setting up the z/OS conversion image for conversions involving any
of these forms of UTF-16 then CCSID 1200 must be specified. CCSIDs
1201 and 1202 will not be recognised by z/OS when attempting to create a
conversion image.
CICS respects the byte order marker for inbound conversions, but is not
able to retain that information when handling a related outbound
conversion. All outbound data for CCSID 1200 is UTF16-BE. Application
programmers need to know about this and perform their own BE to LE
conversions if they so require.
Sharing a conversion image
v Unless the PTF for APAR OA05744 is applied, do not specify a search
order for those conversions, installed into the z/OS image which are
intended for use by CICS.
v If the same conversions are needed for COBOL you must define the
conversion image with two separate statements:
– one with no search order, and
Chapter 14. Enhanced inter-program data transfer: channels as modern-day COMMAREAs 211
– the other explicitly specifying a search order of ’RECLM’.
for example:.
CONVERSION 850,037;
CONVERSION 850,037,RECLM;
With the APAR installed, CICS and COBOL can make use of those
supported conversions which specify the default search order implicitly or
explicitly, removing the need to provide two control statements in the image
generation file.
JAVA programs
Codepage conversion facilities exist within JAVA, So it is not neccessary to
duplicate these in CICS. The conversion facilities described here do not
extend to JAVA programs. For an example, see the putting data into a
container topic in the Java applications in CICS manual.
For detailed information about the PUT CONTAINER (CHANNEL) command, see
PUT CONTAINER (CHANNEL). For detailed information about the GET
CONTAINER (CHANNEL) command, see GET CONTAINER (CHANNEL).
There is no need to specify the FROMCCSID option unless the data is not in
the default CCSID of the client platform. (For CICS TS regions, the default
CCSID is specified on the LOCALCCSID system initialization parameter.) The
default CCSID is implied.
2. In the server program, issue a GET CONTAINER command to retrieve the
data from the program’s current channel:
EXEC CICS GET CONTAINER(cont_name) INTO(data_area1)
The data is returned in the default CCSID of the server platform. There is no
need to specify the INTOCCSID option unless you want the data to be
converted to a CCSID other than the default. If the client and server platforms
are different, data conversion takes place automatically.
3. In the server program, issue a PUT CONTAINER command to return a value
to the client:
EXEC CICS PUT CONTAINER(status) FROM(data_area2)
DATATYPE(DFHVALUE(CHAR))
The status is returned in the default CCSID of the client platform. There is no
need to specify the INTOCCSID option unless you want the data to be
Chapter 14. Enhanced inter-program data transfer: channels as modern-day COMMAREAs 213
converted to a CCSID other than the default. If the client and server platforms
are different, data conversion takes place automatically.
The following example converts data from the region’s default EBCDIC code page
to a specified UTF8 code page:
EXEC CICS PUT CONTAINER(temp) DATATYPE(DFHVALUE(CHAR))
FROM(ebcdic-data)
EXEC CICS GET CONTAINER(temp) INTOCCSID(utf8_ccsid)
SET(utf8-data-ptr) FLENGTH(utf8-data-len)
When using the container API in this way, bear the following in mind:
v On GET CONTAINER commands, use the SET option, rather than INTO, unless
the converted length is known. (You can retrieve the length of the converted data
by issuing a GET CONTAINER(cont_name) NODATA FLENGTH(len) command.)
v To avoid a storage overhead, after conversion copy the converted data and
delete the container.
v To avoid shipping the channel, use a temporary channel.
v All-to-all conversion is not possible. That is, a code page conversion error occurs
if a specified code page and the channel’s code page are an unsupported
combination.
A SOAP example
A CICS TS SOAP application:
1. Retrieves a UTF8 or UTF16 message from a socket or MQ message queue.
2. Puts the message into a container, in UTF8 format.
3. Puts EBCDIC data structures into other containers on the same channel.
4. Makes a distributed program link (DPL) call to a handler program on a back-end
AOR, passing the channel.
The back-end handler program, also running on CICS TS, can use EXEC CICS
GET CONTAINER commands to retrieve the EBCDIC data structures or the
messages. It can get the messages in UTF8 or UTF16, or in its own or the region’s
EBCDIC code page. Similarly, it can use EXEC CICS PUT CONTAINER commands
to place data into the containers, in UTF8, UTF16, or EBCDIC.
To retrieve one of the messages in the region’s EBCDIC code page, the handler
can issue the command:
EXEC CICS GET CONTAINER(input_msg) INTO(msg)
Because the INTOCCSID option is not specified, the message data is automatically
converted to the region’s EBCDIC code page. (This assumes that the PUT
CONTAINER command used to store the message data in the channel specified a
DATATYPE of CHAR; if it specified a DATATYPE of BIT, the default, no conversion
is possible.)
Because CHAR is not specified, no data conversion will be permitted. Because the
FROMCCSID option is not specified, the message data is taken to be in the
region’s EBCDIC code page.
To retrieve one of the messages in UTF8, the handler can issue the command:
EXEC CICS GET CONTAINER(input_msg) INTO(msg) INTOCCSID(utf8)
To return some output in UTF8, the server program can issue the command:
EXEC CICS PUT CONTAINER(output) FROM(output_msg) FROMCCSID(utf8)
The FROMCCSID option specifies that the message data is currently in UTF8
format. Because CHAR is not specified, no data conversion will be permitted.
Benefits of channels
The channel/container model has several advantages over the communication
areas (COMMAREAs) traditionally used by CICS programs to exchange data. For
example:
v Unlike COMMAREAs, channels are not limited in size to 32KB. There is no limit
to the number of containers that can be added to a channel, and the size of
individual containers is limited only by the amount of storage that you have
available.
CAUTION:
Take care not to create so many large containers that you limit the amount
of storage available to other applications.
v Because a channel can comprise multiple containers, it can be used to pass data
in a more structured way. In contrast, a COMMAREA is a monolithic block of
data.
v Unlike COMMAREAs, channels don’t require the programs that use them to
know the exact size of the data returned.
v A channel is a standard mechanism for exchanging data between CICS
programs. A channel can be passed on LINK, START, XCTL, and RETURN
commands. Distributed program link (DPL) is supported, and the transactions
started by START CHANNEL and RETURN TRANSID commands may be
remote.
Chapter 14. Enhanced inter-program data transfer: channels as modern-day COMMAREAs 215
2. Browse the containers in the channel
3. Vary its processing according to the channel it’s been passed
v You can build “components” from sets of related programs invoked through one
or more channels.
v The loose coupling between clients and components permits easy evolution.
Clients and components can be upgraded at different times. For example, first a
component could be upgraded to handle a new channel, then the client program
upgraded (or a new client written) to use the new channel.
v The programmer is relieved of storage management concerns. CICS
automatically destroys containers (and their storage) when they go out of scope.
v The data conversion model used by channel applications is much simpler than
that used by COMMAREA applications. Also, whereas in COMMAREA
applications data conversion is controlled by the system programmer, in channel
applications it is controlled by the application programmer, using simple API
commands.
v Programmers with experience of CICS business transaction services (BTS) will
find it easy to use containers in non-BTS applications.
v Programs that use containers can be called from both channel and BTS
applications.
v Non-BTS applications that use containers can be migrated into full BTS
applications. (They form a migration route to BTS.)
Note: In the COMMAREA example, PROG2, having put data in the COMMAREA,
has only to issue a RETURN command to return the data to PROG1. In the
channel example, to return data PROG2 must issue a PUT CONTAINER
command before the RETURN.
Chapter 14. Enhanced inter-program data transfer: channels as modern-day COMMAREAs 217
Migrating START data
To migrate two programs which use START data to exchange a structure, change
the instructions shown in Table 17.
Table 17. Migrating START data
Program Before After
PROG1 EXEC CICS START TRANSID(TRAN2) EXEC CICS PUT CONTAINER(structure-name)
FROM(structure) CHANNEL(channel-name) FROM(structure)
EXEC CICS START TRANSID(TRAN2)
CHANNEL(channel-name)
PROG2 EXEC CICS RETRIEVE INTO(structure) EXEC CICS GET CONTAINER(structure-name)
INTO(structure)
Note that the new version of PROG2 is the same as that in the
pseudoconversational example.
To give the routing program the same kind of functionality with channels, an
application that uses a channel can create, within the channel, a special container
named DFHROUTE. If the application issues a LINK or terminal-related START
request (but not a non-terminal-related START request) that is to be dynamically
routed, the dynamic routing program is given, in the DYRACMAA field of
DFHDYPDS, the address of the DFHROUTE container, and can inspect and
change its contents.
If you are migrating a program to pass a channel rather than a COMMAREA, you
could use its existing COMMAREA structure to map DFHROUTE.
For introductory information about dynamic and distributed routing, see the CICS
Intercommunication Guide. For information about writing a dynamic or distributed
routing program, see the CICS Customization Guide.
Java
This guidance on affinity between transactions describes applications written
using the EXEC CICS API. However, many of the comments are equally valid
for Java applications and enterprise beans executing in a CICSplex. For
guidance on developing Java applications and enterprise beans, see Java
Applications in CICS.
For detailed introductory information about dynamic and distributed routing, see the
CICS Intercommunication Guide.
Important
The following sections talk exclusively about affinities between transactions.
Keep in mind throughout the chapter that:
v Affinities can also exist between programs. (Although, strictly speaking, we
could say that it is the transactions associated with the programs that have
the affinity.) This may impose restrictions on the regions to which
program-link requests can be routed.
v The sections on safe, unsafe, and suspect programming techniques apply
to the routing of program-link and START requests, as well as to the routing
of transactions.
Types of affinity
There are two types of affinity that affect dynamic routing:
v Inter-transaction affinity
v Transaction-system affinity
Inter-transaction affinity
Transaction affinity among two or more CICS transactions is caused by the
transactions using techniques to pass information between one another, or to
synchronize activity between one another, in a way that requires the transactions to
execute in the same CICS region. This type of affinity is inter-transaction affinity,
where a set of transactions share a common resource and/or coordinate their
processing. Inter-transaction affinity, which imposes restrictions on the dynamic
routing of transactions, can occur in the following circumstances:
v One transaction terminates, leaving ‘state data’ in a place that a second
transaction can only access by running in the same CICS region as the first
transaction.
v One transaction creates data that a second transaction accesses while the first
transaction is still running. For this to work safely, the first transaction usually
waits on some event, which the second transaction posts when it has read the
data created by the first transaction. This technique requires that both
transactions are routed to the same CICS region.
v Two transactions synchronize, using an event control block (ECB) mechanism.
Because CICS has no function shipping support for this technique, this type of
affinity means the two transactions must be routed to the same CICS region.
Transaction-system affinity
There is another type of transaction affinity that is not an affinity among transactions
themselves. It is an affinity between a transaction and a particular CICS region,
where the transaction interrogates or changes the properties of that CICS
region—transaction-system affinity.
Transactions with affinity to a particular system, rather than another transaction, are
not eligible for dynamic routing. In general, they are transactions that use INQUIRE
and SET commands, or have some dependency on global user exit programs,
which also have an affinity with a particular CICS region.
Safe techniques
The programming techniques in the generally safe category are:
v The use of the communication area (COMMAREA), supported by the CICS API
on a number of CICS commands. However, it is the COMMAREA option on the
CICS RETURN command only that is of interest in a dynamic or distributed
routing environment with regard to transaction affinity, because it is the
COMMAREA on a RETURN command that is passed to the next transaction in a
pseudoconversational transaction.
v The use of a TCT user area (TCTUA) that is optionally available for each
terminal defined to CICS.
v Synchronization or serialization of tasks using CICS commands:
– ENQ / DEQ,provided that you have used appropriate ENQMODEL resource
definitions to give sysplex-wide scope to the ENQs. See “Using ENQ and
DEQ commands with ENQMODEL resource definitions” on page 226 and the
CICS Resource Definition Guide for a description of ENQMODELs.
v The use of containers to pass data between CICS Business Transaction Services
(BTS) activities. Container data is saved in an RLS-enabled BTS VSAM file.
For more information about the COMMAREA and the TCTUA, see “Safe
programming to avoid affinity” on page 222.
Unsafe techniques
The programming techniques in the unsafe category are:
v The use of long-life shared storage:
– The common work area (CWA)
– GETMAIN SHARED storage
– Storage obtained by a LOAD PROGRAM HOLD
v The use of task-lifetime local storage shared by synchronized tasks
It is possible for one task to pass the address of some task-lifetime storage to
another task.
It may be safe for the receiving task to use the passed address, provided the
owning task does not terminate. It is possible, but ill-advised, to use a CICS
task-synchronization technique to allow the receiving task to prevent the sending
task from terminating (or freeing the storage in some other way) before the
receiver has finished with the address. However, such designs are not robust
because there is a danger of the sending task being purged by some outside
agency.
Suspect techniques
Some programming techniques may, or may not, create affinity depending on
exactly how they are implemented. A good example is the use of temporary
storage. Application programs using techniques in this category must be checked to
determine whether they work without restrictions in a dynamic or distributed routing
environment. The programming techniques in the suspect category are:
v The use of temporary storage queues with restrictive naming conventions
v Transient data queues and the use of trigger levels
v Synchronization or serialization of tasks using CICS commands:
– RETRIEVE WAIT / START
– START / CANCEL REQID
– DELAY / CANCEL REQID
– POST / CANCEL REQID
v INQUIRE and SET commands and global user exits
Recommendations
The best way to deal with inter-transaction affinity is to avoid creating
inter-transaction affinity in the first place.
However, to remain free from affinity, COMMAREAs, TCTUAs, and BTS containers
must not contain addresses. Generally the storage referenced by such addresses
The COMMAREA
The use of the COMMAREA option on the RETURN command is the principal
example of a safe programming technique that you can use to pass data between
successive transactions in a CICS pseudoconversational transaction. CICS treats
the COMMAREA as a special form of user storage, even though it is CICS that
issues the GETMAIN and FREEMAIN requests for the storage, and not the
application program.
AOR1 AOR2
The TCTUA
The TCTUA is an optional extension to the terminal control table entry (TCTTE),
each entry specifying whether the extension is present, and its length. You specify
that you want a TCTUA associated with a terminal by defining its length on the
USERAREALEN parameter of a TYPETERM resource definition. This means that
the TCTUAs are of fixed length for all the terminals created using the same
TYPETERM definition.
A terminal control table user area (TCTUA) is safe to use in a dynamic transaction
routing environment as a means of passing data between successive transactions
in a pseudoconversational transaction. Like the COMMAREA, the TCTUA is always
accessible to transactions initiated at a user terminal, even when the transactions in
a pseudoconversation are routed to different target regions. This is illustrated in
Figure 53 on page 225. Some other general characteristics of TCTUAs are:
v Minimal processor overhead (only one CICS command is needed to obtain the
address).
v It is not recoverable.
v The length is fixed for the group of terminals associated with a given TYPETERM
definition. It is suitable only for small amounts of data, the maximum size allowed
being 255 bytes.
v If the terminal is autoinstalled, the TCTUA lasts as long as the TCTTE, the
retention of which is determined by the AILDELAY system initialization parameter.
The TCTTE, and therefore any associated TCTUA, is deleted when the
AILDELAY interval expires after a session between CICS and a terminal is
ended.
If the terminal is defined to CICS by an explicit terminal definition, the TCTTE
and its associated TCTUA are created when the terminal is installed and remain
until the next initial or cold start of CICS.
TOR1
(1) Using DTR,
routes TRN1
to AOR1.
AOR1 AOR2
It is also possible for a task to obtain the TCTUA of a principal facility other than its
own, by issuing an INQUIRE TERMINAL command that names the terminal
associated with another task (the INQUIRE TERMINAL command returns the
TCTUA address of the specified terminal). Using the TCTUA address of a terminal
other than a task’s own principal facility is another example an unsafe use of the
TCTUA facility. Depending on the circumstances, particularly in a dynamic routing
environment , the TCTUA of a terminal that is not the inquiring task’s principal
facility could be deleted after the address has been obtained. For example, in an
target region, an INQUIRE TERMINAL command could return the TCTUA address
associated with a surrogate terminal that is running a dynamically routed
transaction. If the next transaction from the terminal is routed to a different target
region, the TCTUA address ceases to be valid.
Local enqueues within a single CICS region are managed within the CICS address
space. Sysplex-wide enqueues that affect more than one CICS region are managed
by Global Resource Services (GRS). The main points of the changes to the CICS
enqueue/dequeue mechanism are as follows:
v Sysplex enqueue and dequeue expands the scope of an EXEC CICS ENQ|DEQ
command from region to sysplex, by introducing a new CICS resource definition
type, ENQMODEL, to define resource names that are to be sysplex-wide.
v ENQSCOPE, an attribute of the ENQMODEL resource definition, defines the set
of regions that share the same enqueue scope.
v When an EXEC CICS ENQ (or DEQ) command is issued for a resource whose
name matches that of an installed ENQMODEL resource definition, CICS checks
the value of the ENQSCOPE attribute to determine whether the scope is local or
sysplex-wide, as follows:
– If the ENQSCOPE attribute is left blank (the default value), CICS treats the
ENQ|DEQ as local to the issuing CICS region.
– If the ENQSCOPE is non-blank, CICS treats the ENQ|DEQ as sysplex-wide,
and passes a queue name and the resource name to GRS to manage the
enqueue. The resource name is as specified on the EXEC CICS ENQ|DEQ
command, and the queue name is made up by prefixing the 4-character
ENQSCOPE with the letters DFHE.
v The CICS regions that need to use sysplex-wide enqueue/dequeue function must
all have the required ENQMODELs defined and installed.
The recommended way to ensure this is for the CICS regions to share a CSD,
and for the initialization group lists to include the same ENQMODEL groups.
BTS containers
A container is owned by a BTS activity. Containers cannot be used outside of an
activity; for more information, see the CICS Business Transaction Services manual .
A container may be used to pass data between BTS activities or between different
activations of the same activity. An activity uses GET and PUT container to update
the container’s contents. CICS ensures that the appropriate containers are available
to an activity by saving all the information (including containers) associated with a
BTS activity in an RLS-enabled VSAM file. For this reason, note that a BTS
environment cannot extend outside a sysplex (see CICS Business Transaction
Services), but you can use dynamic routing within a sysplex passing data in
containers.
The programming techniques that are generally unsafe are described in the
following sections.
TOR
If the dynamic routing program
DTR routes TRN2 to AOR3 as shown,
program TRN2 will fail to access the
data stored for it by TRN1.
CWA
Figure 54. Illustration of inter-transaction affinity created by use of the CWA. The dynamic
routing program needs to be aware of this CWA affinity, and ensure it routes TRN2 to the
same target region as TRN1.
However, if the CWA contains read-only data, and this data is replicated in more
than one target region, it is possible to use the CWA and continue to have the full
benefits of dynamic routing. For example, you can run a program during the
post-initialization phase of CICS startup (a PLTPI program) that loads the CWA with
read-only data in each of a number of selected target regions. In this way, all
transactions routed to target regions loaded with the same CWA data have equal
access to the data, regardless of which of the target regions to which the
transactions are routed. With CICS subsystem storage protection, you can ensure
the read-only integrity of the CWA data by requesting the CWA from CICS-key
storage, and define all the programs that read the CWA to execute in user key.
AOR1 AOR2
Executes TRN1
which:
Terminates
Figure 55. Illustration of inter-transaction affinity created by use of shared storage. The
dynamic transaction routing program needs to be aware of this affinity, and ensure it routes
TRN2 to the same target region as TRN1.
Although you could use a temporary storage queue to make the address of the
loaded program’s storage available to other tasks, the more usual method would be
for other tasks to issue a LOAD PROGRAM command also, with the SET(ptr_ref)
option so that CICS can return the address of the held program.
The nature of the affinity caused by the use of the LOAD PROGRAM HOLD
command is virtually identical to that caused by the use of GETMAIN SHARED
storage (see Figure 55 and Figure 56 on page 230), and the same rule applies: to
preserve the application design, the dynamic or distributed routing program must
TOR
In this example, the TOR
DTR must route to AOR1 all other
program transactions that require
access to the program (table)
loaded by TRN1.
AOR1 AOR2
Executes TRN1
which:
(3) Terminate.
Figure 56. Illustration of inter-transaction affinity created by use of LOAD PROGRAM HOLD.
The dynamic routing program needs to be aware of this affinity, and ensure it routes TRN2 to
the same target region as TRN1.
Note: This rule applies also to programs defined with the RESIDENT option on the
resource definition for the loaded program (whether or not the HOLD option
is specified on the LOAD command). However, regardless of affinity
considerations, it is unsafe to use the RESIDENT option to enable
transactions to share data, because programs defined with RESIDENT are
subject to SET PROGRAM(program_name) NEWCOPY commands, and can
therefore be changed.
The rule also applies to a non-resident, non-held, loaded program where the
communicating tasks are synchronized.
TOR
DTR
program
AOR
TRN1
Figure 57. Illustration of inter-transaction affinity created by use of task-lifetime storage. TRN2
must execute in the same target region as TRN1. Also, TRN1 must not terminate until TRN2
has finished using its task-lifetime storage.
For two tasks to share task-lifetime storage belonging to one of them requires that
the tasks are synchronized in some way. See Table 18 for commands that provide
ways of suspending and resuming a task that passes the address of its local
storage.
Table 18. Methods for suspending and resuming (synchronizing) tasks
Suspending operation Resuming operation
WAIT EVENT, WAIT EXTERNAL, WAITCICS POST
RETRIEVE WAIT START
DELAY CANCEL
POST CANCEL
START CANCEL
ENQ DEQ
Some of these techniques themselves require that the transactions using them must
execute in the same target region, and these are discussed later in this chapter.
However, even in those cases where tasks running in different target regions can
be synchronized, it is not safe to pass the address of task-lifetime storage from one
to the other. Even without dynamic routing, designs that are based on the
synchronization techniques shown in Table 18 are fundamentally unsafe because it
is possible that the storage-owning task could be purged.
The completion of the event is signalled (posted) by the setting of a bit pattern into
the event control block (ECB). Both the waiting task and the posting task must have
direct addressability to the ECB, hence both tasks must execute in the same target
region. The use of a temporary storage queue is one way that the waiting task can
pass the address of the ECB to another task.
TOR
DTR
program
AOR
TRN1
If TRN2 shown in Figure 58 executed in a different target region from TRN1, the
value of ptr-ref would be invalid, the post operation would have unpredictable
results, and the waiting task would never be resumed. For this reason, a dynamic
Note that any ENQ that does not specify the LENGTH option is treated as an
enqueue on an address and therefore has only local scope.The use of ENQ and
DEQ for serialization (without ENQMODEL definitions to give sysplex-wide scope) is
illustrated in Figure 59.
TOR
DTR
program
AOR
TRN1
If TRN2 shown in Figure 59 executed in a different target region from TRN1, TRN2
would not be suspended while TRN1 accessed the shared resource. For this
reason, a dynamic or distributed routing program must ensure that all tasks that
enqueue on a given resource name must execute in the same target region to
preserve the application design. TRN2 would, of course, be serialized with other
CICS tasks that issue ENQ commands on the same resource name in its target
region.
The programming techniques that may be suspect are described in the following
sections.
Note: This latter statement is not strictly true in the case of a multi-program
transaction, where one of the programs is linked by a distributed program
link command and the linked-to program resides in a remote system. In this
case, the program linked by a DPL command runs under another CICS task
in the remote region. The recommended method for passing data to a DPL
program is by a COMMAREA, but if a TS queue is used for passing data in
a DPL application, the queue must be shared between the two regions.
The methods for specifying TS pool make it easy to migrate queues from a QOR to
a TS data-sharing pool. You can use the temporary storage global user exit,
XTSEREQ, to modify the SYSID on a TS request so that it references a TS
data-sharing pool. Figure 60 shows four AORs that are using the same TST
(TST=XX). The SYSIDNT option on the TST TYPE=SHARED macro maps
temporary storage requests to a pool of shared TS queues called DFHXQTS1. You
should define DFHXQTS1 in the poolname parameter of the JCL to start up the TS
TOR
DTR
program
DFHTSTXX
Prefix| Sysid
AAAA* CICQ
AOR1 AOR2 AOR3 AOR4 ABCD* CICQ
XXXX* CICQ
TST=XX TST=XX TST=XX TST=XX ZZZZ* CICQ
Sysid Pool
CICQ DFHXQTS1
DFHXQMN
TS Server
Coupling
Facility
Figure 60. Example of the use of the temporary storage data-sharing server
The usual convention is a 4-character prefix (for example, the transaction identifier)
followed by a 4-character terminal identifier as the suffix. This generates queue
names that are unique for a given terminal. Such generic queue names can be
defined easily as remote queues that are owned, for example, by:
v A QOR (thus avoiding transaction affinity problems)
v Shared queues residing in temporary storage data-sharing queue pools
v Remote queues that are owned by an target region, or in a temporary storage
data-sharing queue pool
TOR
DTR
program
DFHTSTXX
Prefix Sysid
AOR1 AOR2 AOR3 AOR4
AAAA* CICQ
TST=XX TST=XX TST=XX TST=XX ABCD* CICQ
XXXX* CICQ
ZZZZ* CICQ
ROR
Figure 61. Using remote queues to avoid inter-transaction affinity relating to temporary
storage. This example shows a combined file-owning and queue-owning region. Separate
regions can be used, but these require special care during recovery operations because of
‘in-doubt’ windows that can occur when recovering data managed independently by file
control and temporary storage control.
All transient data queues must be defined to CICS, and must be installed before the
resources become available to a CICS region. These definitions can be changed to
support a remote transient data queue-owning region (QOR).
However, there is a restriction for TD queues that use the trigger function. The
transaction to be invoked when the trigger level is reached must be defined as a
local transaction in the region where the queue resides (in the QOR). Thus the
trigger transaction must execute in the QOR. However, any terminal associated with
the queue need not be defined as a local terminal in the QOR. This does not create
an inter-transaction affinity.
TOR
DTR
program
TDQ defn.
Queue Syst.
AOR1 AOR2 AOR3 AOR4
AAAA CICQ
ABCD CICQ
XXXX CICQ
ZZZZ CICQ
TDQ definition
Figure 62. Using remote queues to avoid inter-transaction affinity relating to transient data.
The transient data queue definitions installed in the target regions are defined as owned by
the QOR (CICQ). All the transient data queue definitions installed in the QOR are local, some
with trigger levels.
TOR
DTR
program
AOR
TRN1
Figure 63. Illustration of task synchronization using RETRIEVE WAIT and START commands
An application design based on the remote TRANSID technique only works for two
target regions. An application design using the SYSID option on the START
command only works for multiple target regions if all target regions have
connections to all other target regions (which may not be desirable). In either case,
the application programs need to be modified: there is no acceptable way to use
this programming technique in a dynamic or distributed routing program except by
imposing restrictions on the routing program. In general, this means that the
dynamic or distributed routing program has to ensure that TRN2 has to execute in
the same region as TRN1 to preserve the application design.
A temporary storage queue is one way that the REQID can be passed from task to
task.
Note: To use this technique, the CANCEL command must specify the REQID
option, but the START command need not. This is because, provided the
NOCHECK option is not specified on the START command, CICS generates
a REQID for the request and stores it in the EXEC interface block (EIB) in
field EIBREQID.
DTR
program
AOR
TRN1
3. Terminates.
(suspended)
TRN2
Figure 64. Illustration of the use of the START and CANCEL REQID commands
Using this application programming technique, the CANCEL command that cancels
the START request must:
v Be issued in same target region that the START command was executed in, or
v Specify the SYSID of the target region where the START command was
executed, or
v Specify a TRANSID (TRNX in our example) that is defined as a remote
transaction residing on the target region where the START command was
executed.
Note: A START command is not necessarily executed in the same region as the
application program issuing the command. It can be function shipped (or, in
the case of a non-terminal-related START, routed) and executed in a different
CICS region. The above rules apply to the region where the START
command is finally executed.
An application design based on the remote TRANSID technique only works for two
target regions. An application design using the SYSID option on the cancel
command only works for multiple target regions if all target regions have
connections to all other target regions. In either case, the application programs
need to be modified: there is no acceptable way to use this programming technique
in a dynamic or distributed routing program except by imposing restrictions on the
routing program.
In general, this means that the dynamic or distributed routing program has to
ensure that TRN2 executes in the same region as TRN1 to preserve the application
design, and also that TRNX is defined as a local transaction in the same region.
The steps involved in this technique using a temporary storage queue to pass the
REQID are as follows:
1. A task (TRN1) writes a predefined DELAY REQID to a TS queue. For example:
EXEC CICS WRITEQ TS
QUEUE(’DELAYQUE’) FROM(reqid_value)
2. The task waits on another task by issuing a DELAY command, using the
reqid_value as the REQID. For example:
EXEC CICS DELAY
INTERVAL(1000) REQID(reqid_value)
3. Another task, TRN2, reads the REQID of the DELAY request from TS queue
called ‘DELAYQUE’.
4. TRN2 completes its processing, and resumes TRN1 by cancelling the DELAY
request.
TOR
DTR
program
AOR
TRN1
Figure 65. Illustration of the use of the DELAY and CANCEL REQID commands
Using this application programming technique, the CANCEL command that cancels
the DELAY request must:
v Be issued in same target region as the DELAY command was executed in, or
v Specify the SYSID of the target region where the DELAY command was
executed, or
v Specify a TRANSID (TRN1 in our example) that is defined as a remote
transaction residing on the target region where the DELAY command was
executed.
An application design based on the remote TRANSID technique only works for two
target regions. An application design using the SYSID option on the cancel
command only works for multiple target regions if all target regions have
connections to all other target regions. In either case, the application programs
need to be modified: there is no acceptable way to use this programming technique
in a dynamic or distributed routing environment except by imposing restrictions on
the routing program.
The time limit is signalled (posted) by CICS by setting a bit pattern in the event
control block (ECB). To determine whether notification has been received, the
requesting transaction (TRN1) has either to test the ECB periodically, or to issue a
WAIT command on the ECB.
A TS storage queue is one way that can be used to pass the REQID of the POST
request from task to task.
DTR
program
AOR
TRN1
If this technique is used, the dynamic or distributed routing program has to ensure
that TRN2 executes in the same CICS region as TRN1 to preserve the application
design.
The CANCEL command that notifies the task that issued the POST must:
v Be issued in same target region that the POST command was executed in, or
v Specify the SYSID of the target region where the POST command was executed,
or
v Specify a TRANSID (TRN1 in our example) that is defined as a remote
transaction residing on the target region where the POST command was
executed.
An application design based on the remote TRANSID technique only works for two
target regions. An application design using the SYSID option on the cancel
command only works for multiple target regions if all target regions have
connections to all other target regions. In either case, the application programs
need to be modified: there is no acceptable way to use this programming technique
in a dynamic or distributed routing program except by imposing restrictions on the
routing program.
In general, this means that the dynamic or distributed routing program has to
ensure that TRN2 executes in the same region as TRN1 to preserve the application
design.
Clearly, there is no problem if the CANCEL is issued by the same task that issued
the POST. If a different task cancels the POST command, it must specify REQID to
identify the particular instance of that command. Hence the CANCEL command with
Note: If you dynamically route program-link requests, you must discover which
programs (or their associated transactions) have affinities. You cannot use
| the CICS Interdependency Analyzer to do this.
If you do not use the utility, you can use one of the following methods to detect
affinities, although you are strongly recommended to use the utility.
v Review application design, paying particular attention to the techniques used for
inter-transaction communication.
v Search the source of application programs, looking for instances of the EXEC
CICS commands that can give rise to inter-transaction affinity.
v Run a trace analysis program that can analyze CICS auxiliary trace. For
example, if you run the CICS trace utility program, DFHTUP, with the ABBREV
option to format CICS auxiliary trace output, you can analyze the resulting
abbreviated trace data to find instances of suspect commands.
Clearly, the more inter-transaction affinity you have in a given CICS workload, the
less effective a dynamic routing program can be in balancing the workload across a
CICSplex. To minimize the impact of inter-transaction affinity, affinities within an
affinity group can characterized by their relation and lifetime. These relation and
lifetime attributes determine the scope and duration of an affinity.
There are four possible affinity relations that you can assign to your affinity groups:
1. Global
2. LUname
3. Userid
4. BAPPL
These are described in the following sections, together with the permitted lifetimes
for each relation.
Generally, transactions in this affinity category are not suitable candidates for
dynamic routing and you should consider making them statically routed
transactions.
Terminal
User TOR
enters
tranid Calls DTR DTR program Affinity group
GGGG program
1. Checks affinity Relation: GLOBAL
Routes GGGG groups for GGGG Lifetime: PERM
to AOR2 2. Start global
affinity for Transids: GGGG
transid GGGG
3. Select AOR from
candidate list
4. Records choice
of AOR (for
example, AOR2)
for this group. GGGG sent to AOR2
Figure 67. Managing inter-transaction affinity with global relation and permanent lifetime
A typical example of transactions that have an LUname relation are those that:
v Use a local TS queue to pass data between the transactions in a
pseudoconversation, and
v The TS queue name is derived, in part, from the terminal name (see “Naming
conventions for remote queues” on page 235 for information about TS queue
names).
This form of affinity is manageable and does not impose too severe a constraint on
dynamic transaction routing, and may occur commonly in many CICSplexes. It can
be managed easily by a dynamic routing program, and should not inhibit the use of
dynamic routing.
AAAA
Figure 68. Managing inter-transaction affinity with LUname relation and pseudoconversation
lifetime
A typical example of transactions that have a userid relation is where the userid is
used dynamically to identify a resource, such as a TS queue. The least restrictive of
the affinities in this category is one that lasts only for as long as the user remains
signed on.
An example of an affinity group with the userid relation and a signon lifetime is
shown in Figure 69.
Userid= TOR
ANOTHER
User Calls DTR DTR program Affinity group
enters program
tranid 1. Checks affinity Relation: USERID
WWWW Routes WWWW groups for WWWW Lifetime: SIGNON
to AOR4 2. Detects start
of pseudoconv. Transids: WWWW
3. Selects an AOR XXXX
from candidate .
list. .
4. Records choice YYYY
of AOR (for
example, AOR4)
for this group. WWWW sent to AOR4
for user=ANOTHER
WWWW
Figure 69. Managing inter-transaction affinity with userid relation and sign-on lifetime
An example of an affinity group with the BAPPL relation is shown in Figure 70.
AOR 1
BAPPL Calls
activity dynamic Dynamic routing Affinity group
started program
routing Relation: BAPPL
Transid 1. Checks affinity
program Lifetime: ACTIVITY
BAP1 groups for BAP1.
Routes BAP1 2. Start BAPPL
to AOR4 affinity for Transid : BAP1
transid BAP1
3. Select target
region from
candidate list
4. Record choice
of target Sent BAP1 to AOR4
region (for
example, AOR4)
for this group.
Figure 70. Managing inter-transaction affinity with BAPPL relation and activity lifetime
In this example, the first instance of BTS transaction BAP1 starts a BAPPL–activity
affinity. The first instance of BAP1 can be routed to any suitable target region
(AOR1 through AOR6), but all other instances of the activity must be routed to
whichever target region is selected for BAP1.
Although BTS itself does not introduce any affinities, and discourages programming
techniques that do, it does support existing code that may introduce affinities. You
must define such affinities to workload management. It is particularly important to
specify each affinity’s lifetime. Failure to do this may restrict unnecessarily the
workload management routing options.
It is important to note that a given activity can be run both synchronously and
asynchronously. Workload management is only able to honour invocations that are
made asynchronously. Furthermore, you are strongly encouraged not to create
these affinities, particularly activity and process affinities, because these affinities
are synchronized across the BTS-set. This could have serious performance impacts
on your systems.
You should also note that, with CICSPlex SM, the longest time that an affinity can
be maintained is while a CMAS involved in the workload is active; that is, an affinity
Journaling
CICS provides facilities for creating and managing journals during CICS
processing. Journals may contain any and all data the user needs to facilitate
subsequent reconstruction of events or data changes. For example, a journal might
act as an audit trail, a change-file of database updates and additions, or a record of
transactions passing through the system (often referred to as a log). Each journal
can be written from any task.
Journal control commands are provided to allow the application programmer to:
v Create a journal record (WRITE JOURNALNAME or WRITE JOURNALNUM
command)
v Synchronize with (wait for completion of) journal output (WAIT JOURNALNAME
or WAIT JOURNALNUM command)
Exception conditions that occur during execution of a journal control command are
handled as described in Chapter 17, “Dealing with exception conditions,” on page
257. (The earlier JFILEID option is supported for compatibility purposes only.)
Journal records
Each journal is identified by a name or number known as the journal identifier. This
number may range from 1 through 99. The name DFHLOG is reserved for the
journal known as the system log.
When a journal record is built, the data is moved to the journal buffer area. All
buffer space and other work areas needed for journal operations are acquired and
managed by CICS. The user task supplies only the data to be written to the journal.
Log manager is designed so that the application programmer requesting output
services does not have to be concerned with the detailed layout and precise
contents of journal records. The programmer has to know only which journal to use,
what user data to specify, and which user-identifier to supply.
The application programmer can also request asynchronous journal output. This
causes a journal record to be created in the journal buffer area but allows the
requesting task to retain control and thus to continue with other processing. The
task may check and wait for output completion (that is, synchronize) later by issuing
the WAIT JOURNALNAME or WAIT JOURNALNUM command.
Without WAIT, CICS does not write data to the log stream until it has a full buffer of
data, or until some other unrelated activity requests that the buffer be hardened,
thus reducing the number of I/O operations. Using WAIT makes it more difficult for
CICS to calculate accurately log structure buffer sizes. For CF log streams, this
could lead to inefficient use of storage in the coupling facility.
The basic process of building journal records in the CICS buffer space of a given
journal continues until one of the following events occurs:
v For system logs:
– Whenever the system requires it to ensure integrity and to permit a future
emergency restart
– The log stream buffer is filled
v For user journals:
– The log stream buffer is filled (or, if the journal resides on SMF, when the
journal buffer is filled)
– A request specifying the WAIT option is made (from any task) for output of a
journal record
– An EXEC CICS SET JOURNALNAME command is issued
– An EXEC CICS DISCARD JOURNALNAME command is issued
– Any of the above occurring for any other journal which maps onto the same
log stream
– On a normal shutdown
v For forward recovery logs:
– The log stream buffer is filled
– At syncpoint (first phase)
– On file closure
v For autojournals:
– The log stream buffer is filled
– A request specifying the WAIT option is made (from any task) for output of a
journal record
– On file closure
v For the log-of-logs (DFHLGLOG):
– On file OPEN and CLOSE requests
When any one of these occurs, all journal records present in the buffer, including
any deferred output resulting from asynchronous requests, are written to the log
stream as one block.
However, these advantages are achievable only at the cost of greater programming
complexity. It is necessary to plan and program to control synchronizing with journal
output. Additional decisions that depend on the data content of the journal record
and how it is to be used must be made in the application program. In any case, the
full benefit of deferring journal output is obtained only when the load on the journal
is high.
If the journal buffer space available at the time of the request is not sufficient to
contain the journal record, the NOJBUFSP condition occurs. If no HANDLE
CONDITION command is active for this condition, the requesting task loses control,
the contents of the current buffer are written, and the journal record is built in the
resulting freed buffer space before control returns to the requesting task.
If the requesting task is not willing to lose control (for example, if some
housekeeping must be performed before other tasks get control), a HANDLE
CONDITION command should be issued. If the NOJBUFSP condition occurs, no
journal record is built for the request, and control is returned directly to the
requesting program at the location provided in the HANDLE CONDITION command.
The requesting program can perform any housekeeping needed before reissuing
the journal output request.
Journal commands can cause immediate or deferred output to the journal. System
log records are distinguished from all other records by specifying
JOURNALNAME(DFHLOG) on the request. User journal records are created using
some other JOURNALNAME or a JOURNALNUM. All records must include a
journal type identifier, (JTYPEID). If the user journaling is to the system log, the
journal type identifier (according to the setting of the high-order bit) also serves to
control the presentation of these to the global user exit XRCINPT at a warm or
emergency restart. Records are presented during the backward scan of the log as
follows:
v For in-flight or in-doubt tasks only (high-order bit off)
v For all records encountered until the scan is terminated (high-order bit on)
See the CICS Customization Guide for information about the format and structure of
journal records. See the section on emergency restart in the CICS Recovery and
Restart Guide for background information and a description of the recovery process.
Syncpointing
To facilitate recovery in the event of abnormal termination of a CICS task or of
failure of the CICS system, the system programmer can, during CICS table
generation, define specific resources (for example, files) as recoverable. If a task is
terminated abnormally, these resources are restored to the condition they were in at
the start of the task, and can then be rerun. The process of restoring the resources
associated with a task is termed backout.
If failure occurs after a syncpoint but before the task has been completed, only
changes made after the syncpoint are backed out.
Alternatively, you can use the SAA Resource Recovery interface instead of the
SYNCPOINT command. This provides an alternative API to existing CICS resource
recovery services. You may wish to use the SAA Resource Recovery interface in
networks that include multiple SAA platforms, where the consistency of a common
API is seen to be of benefit. In a CICS system, the SAA Resource Recovery
interface provides the same function as the EXEC CICS API.2
For further information about the SAA Resource Recovery interface, see SAA
Common Programming Interface for Resource Recovery Reference manual.
UOWs should be entirely logically independent, not merely with regard to protected
resources, but also with regard to execution flow. Typically, an UOW comprises a
complete conversational operation bounded by SEND and RECEIVE commands. A
browse is another example of an UOW; an ENDBR command must therefore
precede the syncpoint.
A BMS logical message, started but not completed when a SYNCPOINT command
is processed, is forced to completion by an implied SEND PAGE command.
However, you should not rely on this because a logical message whose first page is
incomplete is lost. You should also code an explicit SEND PAGE command before
the SYNCPOINT command or before termination of the transaction.
2. Full SAA Resource Recovery provides some return codes that are not supported in its CICS implementation. (See the CICS
appendix in the SAA Common Programming Interface for Resource Recovery Reference manual.)
If something out of the ordinary happens, you get an exception condition, which
simply means a condition other than NORMAL. By testing this condition, you can
find out what has happened and, possibly, why.
Many exception conditions have an additional (RESP2) value associated with them,
which gives further information. You may obtain this RESP2 value either by using
the RESP2 option in your command in addition to the RESP option, or by reading it
from the EIB.
Not all conditions denote an error situation, even if they are not NORMAL. For
example, if you get an ENDFILE condition on a READNEXT command during a file
browse, it might be exactly what you expect. For information about all possible
conditions and the commands on which they can occur, see the CICS Application
Programming Reference manual.
The most common action by CICS is to cause an abend of some type to happen.
The particular behaviors for each condition and for each command are detailed in
the CICS Application Programming Reference and CICS System Programming
Reference manuals.
Sometimes you will be satisfied with the CICS default exception handling, in which
case you need do nothing. More often you will prefer some other course of action.
These are the different ways of turning off the default CICS handling of exception
conditions.
v Turn off the default CICS handling of exception conditions on a particular EXEC
CICS command call by specifying the NOHANDLE option.
v Alternatively, turn off the default CICS handling of exception conditions by
specifying the RESP option on the command. This, of itself, switches off the
default CICS exception handling in the same way as NOHANDLE does. It also
If the default CICS exception handling is turned off you should ensure that your
program copes with anything that may happen in the command call.
The traditional, but no longer recommended, way to specify some other course of
action is available only if you are programming in a language other than C or C++:
it is to use combinations of the HANDLE ABEND, HANDLE CONDITION, and
IGNORE CONDITION commands to modify the default CICS exception handling.
This is described in “Modifying default CICS exception handling” on page 261.
If your program is written in C or C++, in-line code is the only means you have of
handling exception conditions.
If you use the NOHANDLE or RESP option, you should ensure that your program
can cope with whatever condition may arise in the course of executing the
commands. The RESP value is available to enable your program to decide what to
do and more information which it may need to use is carried in the EXEC interface
block (EIB). In particular, the RESP2 value is contained in one of the fields of the
EIB. See the CICS Application Programming Reference manual for more
information on the EIB. Alternatively, if your program specifies RESP2 in the
command, the RESP2 value is returned by CICS directly.
The DFHRESP built-in translator function makes it very easy to test the RESP
value. It allows, you to examine RESP values symbolically. This is easier than
examining binary values that are less meaningful to someone reading the code.
The RESP value will be returned in response. The declaration of response sets up
the appropriate type of automatic variable.
In this example, any other condition is held to be an error. The example sets
ExitKey to DFHCLEAR—the same value that it would have set if the user had
cleared the screen—which it then returns to the calling program. By checking the
return code from ReadAccountMap, the calling program would know that the map
had not been updated and that some remedial action is required.
#
# Figure 72. An example of exception handling in COBOL
#
MAPNAME is the variable which contains the name of the map which is to be
received.
The condition handling is done by using IF ... statements. If the condition is neither
NORMAL nor MAPFAIL the program behaves as if the user had cleared the screen.
If the condition is either NORMAL or MAPFAIL the program saves the value of the
key which the user pressed to exit the screen in EXITKEY. In addition, if the
condition is NORMAL, the program branches to MODIFYMAP to perform some
additional function.
Note: These commands cannot be used in C, C++, or Java programs. The rest of
this chapter is not relevant for these languages.
HANDLE CONDITION
Specify the label to which control is to be passed if a condition occurs.
IGNORE CONDITION
Specify that no action is to be taken if a condition occurs.
HANDLE ABEND
Activate, cancel, or reactivate an exit for abnormal termination processing.
The HANDLE CONDITION command sets up some CICS code to name conditions
that interest you, and then uses this code to pass control to appropriate sections of
your application if those conditions arise. So with an active HANDLE CONDITION
command, control goes to whichever label you specified for that particular condition.
The same condition can arise, in some cases, on many different commands, and
for a variety of reasons. For example, you can get an IOERR condition during file
control operations, interval control operations, and others. One of your first tasks,
therefore, is to sort out which command has raised a particular condition; only
when you have discovered that, can you begin to investigate why it has happened.
This, for many programmers, is reason enough to start using the RESP option in
their new CICS applications. Although you need only one HANDLE CONDITION
command to set your error-handling for several conditions, it can sometimes be
awkward to pinpoint exactly which of several HANDLE CONDITION commands is
currently active when a CICS command fails somewhere in your code.
The need to deal with all conditions is a common source of errors when using the
HANDLE CONDITION command. When using an unfamiliar command, you should
refer to the description of the command in the CICS Application Programming
Reference manual to find out which exception conditions are possible. Even if you
then issue HANDLE commands for all of these, you may not finish all the
error-handling code adequately. The outcome is sometimes an error-handling
routine that, by issuing a RETURN command, allows incomplete or incorrect data
changes to be committed.
The best approach is to use the HANDLE CONDITION command, but to let the
system default action take over if you cannot see an obvious way round a particular
problem.
Bearing in mind the distinction between an error condition, a condition that merely
causes a wait (see page “How CICS keeps track of what to do” on page 264 for
examples of conditions that cause a wait), and the special case of the SEND MAP
command overflow processing, a HANDLE CONDITION command is active after a
HANDLE CONDITION condition(label), or HANDLE CONDITION ERROR(label)
command has been run in your application.
If no HANDLE CONDITION command is active for a condition, but one is active for
ERROR, control passes to the label for ERROR, if the condition is an error, not a
wait.
Take special care not to cause a loop on the ERROR condition itself. You can avoid
a loop by reverting temporarily to the system default action for the ERROR
condition. Do this by coding a HANDLE CONDITION ERROR command with no
label specified. At the end of your error processing routine, you can reinstate your
error action by including a HANDLE CONDITION ERROR command with the
appropriate label. If you know the previous HANDLE CONDITION state, you can do
this explicitly. In a general subroutine, which might be called from several different
points in your code, the PUSH HANDLE and POP HANDLE command may be
useful—see “Using PUSH HANDLE and POP HANDLE commands” on page 267.
You cannot include more than 16 conditions in the same command. You must
specify any additional conditions in further HANDLE CONDITION commands. You
can also use the ERROR condition within the same list to specify that all other
conditions are to cause control to be passed to the same label.
The HANDLE CONDITION command for a given condition applies only to the
program in which it is specified. The HANDLE CONDITION command:
v Remains active while the program is running, or until:
– An IGNORE CONDITION command for the same condition is met, in which
case the HANDLE CONDITION command is overridden
– Another HANDLE CONDITION command for the same condition is met, in
which case the new command overrides the previous one
v Is temporarily deactivated by the NOHANDLE or RESP option on a command
The following example shows you how to handle conditions, such as DUPREC,
LENGERR, and so on, that can occur when you use a WRITE command to add a
record to a data set. Suppose that you want DUPREC to be handled as a special
case; that you want standard system action (that is, to terminate the task
abnormally) to be taken for LENGERR; and that you want all other conditions to be
handled by the error routine ERRHANDL. You would code:
EXEC CICS HANDLE CONDITION
ERROR(ERRHANDL)
DUPREC(DUPRTN) LENGERR
END-EXEC.
CICS keeps a table of these conditions for each link level. Essentially, therefore,
each program level has its own HANDLE state table governing its own condition
handling.
PROCEDURE DIVISION.
*
* INITIALIZE.
* TRAP ANY UNEXPECTED ERRORS.
EXEC CICS HANDLE CONDITION
ERROR(OTHER-ERRORS)
END-EXEC.
*
Figure 73. Trapping the unexpected with the HANDLE CONDITION ERROR command
The HANDLE CONDITION ERROR command is the first command executed in the
procedure division of this COBOL program. This is because a HANDLE
CONDITION command must be processed before any CICS command is processed
that can raise the condition being handled. Note, however, that your program does
not see the effects when it processes the HANDLE CONDITION command; it only
sees them later, if and when it issues a CICS command that actually raises one of
the named conditions.
In this, and the other ACCT programs, you generally use the RESP option. All the
commands specifying the RESP option have been written with a “catch-all” test (IF
RESPONSE NOT = DFHRESP(NORMAL) GO TO OTHER-ERRORS) after any
explicit tests for specific conditions So any exceptions, other than those you might
particularly “expect”, take control to the paragraph at OTHER-ERRORS in each
program. Those relatively few commands that do not have RESP on them take
control to exactly the same place if they result in any condition other than NORMAL
because of this HANDLE CONDITION ERROR command.
While a single EXEC CICS command is being processed, it can raise several
conditions.3 CICS checks these and passes back to your application program the
first one that is not ignored (by your IGNORE CONDITION command). CICS
passes back only one exception condition at a time to your application program.
3. For example, you may have a file control command that is not only invalid but also applies to a file not defined in the file control
table.
You can choose an IGNORE CONDITION command if you have a program reading
records that are sometimes longer than the space you provided, but you do not
consider this an error and do not want anything done about it. You might, therefore,
code IGNORE CONDITION LENGERR before issuing READ commands.
You can also use an IGNORE CONDITION ERROR command to catch any
condition considered as an error for which there is no currently active HANDLE
CONDITION command that includes a label. When an error occurs, control is
passed to the next statement and it is up to the program to check for return codes
in the EIB. See page “How CICS keeps track of what to do” on page 264 for
examples of conditions that are not considered as errors.
You can also switch from ignoring a condition to handling it, or to using the system
default action. For example, you could code:
* MIXED ERROR PROCESSING
EXEC CICS IGNORE CONDITION LENGERR
. END-EXEC.
.
.
EXEC CICS HANDLE CONDITION DUPREC(DUPRTN)
LENGERR
ERROR(ERRHANDL)
END-EXEC.
Because this code initially ignores condition LENGERR, nothing happens if the
program raises a LENGERR condition; the application simply continues its
processing. Of course, if the fact that LENGERR has arisen means that the
application cannot sensibly continue, you have a problem.
Later in the code, you can explicitly set condition LENGERR to the system default
action by naming it in a HANDLE CONDITION command without a label. When this
command has been executed, the program no longer ignores condition LENGERR,
and if it subsequently occurs, it now causes the system default action. The point
about mixing methods is that you can, and that each condition is treated separately.
You cannot code more than 16 conditions in the same command. You must specify
additional conditions in further IGNORE CONDITION commands.
HANDLE ABEND lets you supply your own code to be executed when an abend is
processed. This means that your application can cope with the abnormal situation in
an orderly manner and carry on executing. You provide the user exit programs and
rely on CICS calling them when required.
The flow of control during abend processing is shown in Figure 74 on page 272.
CICS also keeps a table of conditions for each PUSH HANDLE command which
has not been countermanded by a matching POP HANDLE command.
When each condition occurs, CICS performs the following sequence of tests:
1. If the command has the RESP or NOHANDLE option, control returns to the next
instruction in your application program. Otherwise, CICS scans the condition
table to see what to do.
2. If an entry for the condition exists, this determines the action.
3. If no entry exists and the default action for this condition is to suspend
execution:
a. If the command has the NOSUSPEND or NOQUEUE option, control returns
to the next instruction.
b. If the command does not have one of these options, the task is suspended.
4. If no entry exists and the default action for this condition is to abend, a second
search is made, this time for the ERROR condition:
a. If found, this entry determines the action.
b. If ERROR cannot be found, the task is abended. You can choose to handle
abends. For information about the HANDLE ABEND command, see the
CICS Application Programming Reference.
Note: As using RESP implies NOHANDLE, be careful when using RESP with the
RECEIVE command, because it overrides the HANDLE AID command as
well as the HANDLE CONDITION command. This means that PF key
responses are ignored, and is the reason for testing them earlier in the
ACCT code. See “Using the HANDLE AID command” on page 495.
See the CICS Problem Determination Guide for full details about fixing problems,
and see the CICS Messages and Codes for information about the transaction
abend codes for abnormal terminations that are initiated by CICS, their meanings,
and your responses.
When activating an exit, you must use the PROGRAM option to specify the name of
a program to receive control, or (except for C, C++, and PL/I programs) the LABEL
option to specify a routine label to which control branches when an abnormal
termination condition occurs. Using an ON ERROR block in PL/I is the equivalent of
using the HANDLE ABEND LABEL command.
When a task terminates abnormally, CICS searches for an active abend exit,
starting at the logical level of the application program in which the abend occurred,
and proceeding to successively higher levels. The first active abend exit found, if
any, is given control. This procedure is shown in Figure 74 on page 272, which also
shows how subsequent abend processing is determined by the user-written abend
exit.
If CICS finds no abend exit, it passes control to the abnormal condition program to
terminate the task abnormally. This program invokes the user replaceable program
CICS deactivates the exit upon entry to the exit routine or program to prevent
recursive abends in an abend exit. If you wish to retry the operation, you can
branch to a point in the program that was in control at the time of the abend and
issue a HANDLE ABEND RESET command to reactivate the abend exit. You can
also use this command to reactivate an abend exit (at the logical level of the issuing
program) that was canceled previously by a HANDLE ABEND CANCEL command.
You can suspend the HANDLE ABEND command by means of the PUSH HANDLE
and POP HANDLE commands as described in “Using PUSH HANDLE and POP
HANDLE commands” on page 267.
Note that when an abend is handled, the dynamic transaction backout program is
not be invoked. If you need the dynamic transaction backout program, you take an
implicit or explicit syncpoint or issue SYNCPOINT ROLLBACK or issue an ABEND
command.
The HANDLE ABEND command cannot intercept ASPx or APSJ abend codes.
Abend exit programs can be coded in any supported language, but abend exit
routines must be coded in the same language as their program.
For abend exit routines, the addressing mode and execution key are set to the
addressing mode and execution key in which the HANDLE ABEND command has
been issued.
Upon entry to an abend exit program, no addressability can be assumed other than
that normally assumed for any application program coded in that language. There
are no register values for C, C++, or PL/I languages as these languages do not
support HANDLE ABEND label.
Retrying operations
If an abend occurs during the invocation of a CICS service, you should be aware
that issuing a further request for the same service may cause unpredictable
results, because the reinitialization of pointers and work areas, and the freeing of
storage areas in the exit routine, may not have been completed.
You should not try to recover from ATNI or ATND abends by attempting further I/O
operations. Either of these abends results in a TERMERR condition, requiring the
session to be terminated in all cases. You should not try to issue terminal control
commands while recovering from an AZCT abend, or an AZIG abend, as CICS has
not fully cleaned up from the RTIMOUT, and an indefinite wait can occur.
If an abend occurs as a result of a BMS command, control blocks are not tidied up
before control is returned to the BMS program, and results are unpredictable if the
command is retried.
No
Is
Yes Action taken in
application
Terminate the task exit program
program at highest
abnormally or routine ABEND
level?
No RETURN
Is
Look at the next application Yes
higher level program at highest Terminate the task
normally
level?
No
Exit to program
at the next higher
level
Trace
CICS trace is a debugging aid for application programmers, system programmers,
and IBM field engineers. It produces trace entries in response to trace commands.
The trace entries can be sent to any trace destination that is currently active. The
destinations are:
v Internal trace table
v Auxiliary trace data set
v Generalized trace facility (GTF) data set
For information about trace destinations, see the CICS Problem Determination
Guide.
You can:
v Specify user trace entry points (ENTER TRACENUM ). (The earlier ENTER
TRACEID command is supported for compatibility purposes. See the CICS for
MVS/ESA 4.1 Migration Guide for details.)
v Switch CICS internal trace on or off using the SET TRACEDEST, SET
TRACEFLAG, and SET TRACETYPE commands.
Two trace entries are made: the first when the command is issued, and the second
when CICS has performed the required function and is about to return control to
your application program. Between them, these two trace entries allow you to trace
the flow of control through an application, and to check which exception conditions,
if any, occurred during its execution. The ABEND, RETURN, TRACEFLAG, and
XCTL commands produce single entries only.
A trace entry is produced wherever the ENTER TRACENUM command is run. Each
trace entry request, which can be given a unique identifier, causes data to be
placed in the trace table.
Monitoring
CICS monitoring provides information about the performance of your application
transactions.
You should use the MONITOR command for user event monitoring points.
For example, you could use these user EMPs to count the number of times a
certain event occurs, or to time the interval between two events. For programming
information about monitoring, see the CICS Customization Guide; for background
information, see the CICS Performance Guide.
Dump
CICS dump allows you to specify areas of main storage to be dumped, by means of
the DUMP TRANSACTION , onto a sequential data set, which can be either on disk
or tape.
The PERFORM DUMP command allows you to request a system dump. See the
CICS System Programming Reference manual for programming information about
PERFORM DUMP.
You can format the contents of the dump data set and you can print them offline
using the CICS dump utility program (DFHDU640) for transaction dumps or the
interactive problem control system (IPCS) for system dumps. Instructions on using
these programs are given in the CICS Operations and Utilities Guide.
Only one dump control command is processed at a time. If you issue additional
dump control commands, while another task is taking a transaction dump, activity
within the tasks associated with those commands is suspended until the dump is
completed. Remaining dump commands are processed in the order in which they
are made. Using the DUMP TRANSACTION command causes some fields (for
example, EIBFN and EIBRCODE) in the EIB and the TCA to be overwritten.See the
CICS Application Programming Reference manual for programming information
about DUMP TRANSACTION.
Options on the DUMP TRANSACTION command allow you to dump the following
areas of main storage in various combinations:
v Task-related storage areas: selected main storage areas related to the requesting
task. You would normally use a dump of these areas to test and debug your
application program. (CICS automatically provides this service if the related task
is terminated abnormally.)
v CICS control tables:
– File control table (FCT)
– Program control table (PCT)
– Processing program table (PPT)
– System initialization table (SIT)
– Terminal control table (TCT)
A dump of these tables is typically the first dump taken in a test in which the
base of the test must be established; subsequent dumps are usually of the
task-related storage type.
v It is sometimes appropriate during execution of a task to have a dump of both
task-related storage areas and CICS control tables. Specifying one CICS control
tables dump and a number of task-related storage dumps is generally more
Program storage is not dumped for programs defined with the attribute
RELOAD(YES).
You also get a list of the CICS nucleus modules and active PPT programs, indexed
by address, at the end of the printed dump.
The terminal user in this context is the user invoking the transaction that contains
the QUERY SECURITY command.
You specify the type of resource that you are querying by the CICS resource type
name. For example, if you want to query a user’s authorization to access a file, you
can specify RESTYPE(‘FILE’). To identify a particular file within the type, you
specify the RESID parameter.
To query these classes and resources, the QUERY SECURITY command uses the
RESCLASS and RESID options (RESCLASS and RESTYPE are mutually exclusive
options). You can use the CVDA values returned by QUERY SECURITY to
determine whether to access the record or field.
Programming hints
v A transaction can use the QUERY SECURITY command to query a number of
resources in order to prepare a list of resources to which the terminal user has
access. The use of this technique could generate up to four resource violation
messages for each query on a resource that the transaction is not authorized to
access. These messages appear on the system console, the CSCS TD queue,
and the SMF log data set. If you want to suppress these messages, code
NOLOG in the QUERY SECURITY command.
v If a transaction accesses the same resource many times in one execution, you
can probably improve performance by defining the transaction with RESSEC(NO)
in the transaction resource definition. You can then code the transaction to issue
a single QUERY SECURITY command, and to permit access to the resource
according to the CVDA values returned. For detailed guidance, see the CICS
RACF Security Guide.
CICS file control lets you read, update, add, and browse data in VSAM and BDAM
data sets and delete data from VSAM data sets. You can also access CICS shared
data tables and coupling facility data tables using file control.
A CICS application program reads and writes its data in the form of individual
records. Each read or write request is made by a CICS command.
To access a record, the application program must identify both the record and the
data set that holds it. It must also specify the storage area into which the record is
to be read or from which it is to be written.
VSAM data sets are held on direct access storage devices (DASD) auxiliary
storage. VSAM divides its data set storage into control areas (CA), which are
further divided into control intervals (CI). Control intervals are the unit of data
transmission between virtual and auxiliary storage. Each one is of fixed size and, in
general, contains a number of records. A KSDS or ESDS can have records that
extend over more than one control interval. These are called spanned records.
When the data set is initially loaded with data, or when new records are added, the
logical order of the records depends on the collating sequence of the key field. This
also fixes the order in which you retrieve records when you browse through the
data set.
With releases of DFSMS/MVS® 1.4 and later, a data set can be greater than 4GB in
size if it is defined as extended format and extended addressability in the storage
class. CICS supports, in both RL and non-RLS mode, KSDS data sets that are
defined with these extended attributes.
Records are held in an ESDS in the order in which they were first loaded into the
data set. New records added to an ESDS always go after the last record in the data
set. You may not delete records or alter their lengths. After a record has been
stored in an ESDS, its RBA remains constant. When browsing, records are
retrieved in the order in which they were added to the data set.
With releases of DFSMS/MVS 1.5 and later, a data set can be greater than 4GB in
size if it is defined as extended format and extended addressability in the storage
class. However, CICS does not support ESDS data sets that are defined with these
extended attributes. Attempts to open data sets defined with the extended attribute
fail with error message DFHFC0966, codes 8504, 0008,0068.
Records in an RRDS can be fixed or variable length records, and the way in which
VSAM handles the data depends on whether the data set is a fixed or variable
RRDS. A fixed RRDS has fixed-length slots predefined to VSAM, into which records
are stored. The length of a record on a fixed RRDS is always equal to the size of
the slot. VSAM locates records in a fixed RRDS by multiplying the slot size by the
RRN (which you supply on the file control request), to calculate the byte offset from
the start of the data set.
A variable RRDS, on the other hand, can accept records of any length up to the
maximum for the data set. In a variable RRDS VSAM locates the records by means
of an index.
A fixed RRDS generally offers better performance. A variable RRDS offers greater
function.
With releases of DFSMS/MVS 1.5 and later, a data set can be greater than 4GB in
size if it is defined as extended format and extended addressability in the storage
class. However, CICS does not support RRDS or VRRDS data sets that are defined
with these extended attributes. Attempts to open data sets defined with the
extended attribute fail with error message DFHFC0966, codes 8504, 0008,0068.
If you were producing a telephone directory from the data set, you would want to
list people by name rather than by employee number. You can identify records in a
data set with a secondary (alternate) key instead of the primary key described
above. So the primary key is the employee number, and the employee name is the
alternate key. Alternate keys are just like the primary key in a KSDS—fields of
fixed length and fixed position within the record. You can have any number of
alternate keys per base file and, unlike the primary or base key, alternate keys need
not be unique.
VSAM allows KSDS and ESDS (but not RRDS) data sets to have alternate keys.
When the data set is created, one secondary or alternate index is built for each
alternate key in the record and is related to the primary or base key. To access
records using an alternate key, you must define a further VSAM object, an
alternate index path. The path then behaves as if it were a KSDS in which records
are accessed using the alternate key.
When you update a record by way of a path, the corresponding alternate index is
updated to reflect the change. However, if you update the record directly by way of
the base, or by a different path, the alternate index is only updated if it has been
defined to VSAM (when created) to belong to the upgrade set of the base data set.
For most applications, you probably want your alternate index to be in the upgrade
set.
It is also possible for a CICS application program to access a file that has been
directly defined as an alternate index rather than a path. This results in index data
being returned to the application program rather than file data. This operation is not
supported for files opened in record-level sharing (RLS) mode.
With RLS, CICS regions that share VSAM data sets can reside in one or more MVS
images within an MVS parallel sysplex. RLS also provides some benefits when data
sets are being shared between CICS regions and batch jobs.
CICS supports record-level sharing (RLS) access to the following types of VSAM
data set:
v Key sequenced data sets (KSDS). Note that if you are using KSDS, you cannot
use the relative byte address (RBA) to access files.
v Entry sequenced data sets (ESDS). Note that although RLS access mode is
permitted for entry sequenced data sets (ESDS), it is not recommended, as it
can have a negative effect on the performance and availability of the data set
when you are adding records. (See the CICS Performance Guide).
v Relative record data sets (RRDS), for both fixed and variable length records.
Note: If you issue the SET FILE EMPTY command for a file that specifies RLS
mode, the request is accepted but is ignored all the time the file is opened in
RLS mode. If you close and switch the file to non-RLS mode, the data set is
then reset to empty (provided it is defined as reusable on its IDCAMS
definition).
Physical
Count (recorded) Data
key
Physical record
Keyed BDAM files have a physical key identifying the BDAM record. The count area
contains the physical key length, the physical data length, and the record’s data
location.
CICS can define a further structure on top of BDAM data sets, introducing the
concept of blocked-data sets:
logrec 1 logrec 2
Physical record
The data portion of the physical record is viewed as a block containing logical
records. CICS supports the retrieval of logical records from the data part of the
physical record. CICS also supports unblocked records (where the structure reverts
to the original BDAM concept of one logical record per physical record).
To retrieve data from a physical record in a BDAM file under CICS, a record
identification field (RIDFLD) has to be defined to specify how the physical record
should be retrieved. This may be done using the physical key, by relative address,
or by absolute address.
If the data set is defined to CICS as being blocked, individual records within the
block can be retrieved (deblocked) in two addressing modes: by key or by relative
record.
Deblocking by key uses the key of the logical record (that is, the key contained in
the logical record) to identify which record is required from the block. Deblocking by
relative record uses the record number in the block, relative to zero, of the record to
be retrieved.
You specify the key or relative record number used for deblocking in a subfield of
the RIDFLD option used when accessing CICS BDAM files. The addressing mode
for CICS BDAM files is set in the FCT using the RELTYPE keyword.
For more details about record identification and BDAM record access, see
Chapter 22, “File control—BDAM considerations,” on page 315.
A table is defined using the CEDA DEFINE FILE panel. When a table is opened,
CICS builds it by extracting data from the table’s corresponding source data set and
loading it into virtual storage above the 16MB line.
The full file control API appropriate to VSAM KSDS data sets is supported for
CICS-maintained data tables. Requests that cannot be satisfied by reference to the
data table result in calls to VSAM to access the source data set. Tables defined to
be recoverable are supported with full integrity.
A subset of the file control API is supported for user-maintained tables. For
programming information about the commands, you should see the CICS
Application Programming Reference manual where they are listed separately under
the file control command name, followed by UMT. For example, the information on
writing a record to a user-maintained table is given under WRITE(UMT). A table
defined as recoverable participates in dynamic transaction backout but is not
recovered at restart or XRF takeover.
Typical uses might include sharing scratchpad data between CICS regions across a
sysplex, or sharing of files for which changes do not have to be permanently saved.
There are many different ways in which applications use informal shared data, and
most of these could be implemented using coupling facility data tables. Coupling
facility data tables are particularly useful for grouping data into different tables,
where the items can be identified and retrieved by their keys. For example, you
could use a record in a coupling facility data table to maintain the next free order
number for use by an order processing application. Other examples are:
v Look-up tables of telephone numbers or the numbers of stolen credit cards
v Working data consisting of a few items, such as a subset of customers from a
customer list
v Information that is specific to the user of the application, or that relates to the
terminal from which the application is being run
v Data extracted from a larger file or database for further processing.
For many purposes, because it is global in scope, coupling facility data tables can
offer significant advantages over resources such as the CICS common work area
(CWA).
Note: A coupling facility data table pool is defined as a coupling facility list
structure, and can hold more than one data table (see the CICS System
Definition Guide for information about creating a list structure for coupling
facility data tables).
v The access rules for a UMT that is in the course of loading allow any direct read
request to be satisfied either from the table (if the record has already been
loaded) or from the source data set, but reject any update request, or imprecise
read or browse request, with the LOADING condition. For a CFDT, any request is
allowed during loading, but requests succeed only for records that are within the
key range already loaded.
You specify the update model you want for each table on its file resource definition,
enabling different tables to use different models.
In Table 19, different techniques are considered for passing scratchpad data
between phases of a transaction, where only one task is accessing the data at a
time, but the data may be passed from a task in one region to a task in another.
Note that ‘remote UMT’ means a shared user-maintained data table that is
accessed from AORs either by function shipping where necessary (that is, for
update accesses) or by SDT cross-memory sharing for non-update accesses. The
table shows that, within a Parallel Sysplex®, a coupling facility data table is the best
In Table 20, different techniques for sharing queues of data are shown, where
information is stored in a specific sequence, to be processed by another application
program or task in the same sequence. The CICS transient data and temporary
storage queue facilities are recommended in the majority of cases, with a few
instances where data tables provide a more appropriate solution for handling
sequenced data.
Table 21. Techniques for sharing control records
Constraints and factors Single Single MVS Sysplex
Region
Technique no longer
CWA MVS CSA —
recommended
Single updating region, Shared TS queue or
TS queue or Remote TS queue or
single record CFDT (contention
UMT UMT
model)
Multiple updating regions or
UMT Remote UMT CFDT
multiple records
In Table 21, different techniques for managing control records are shown. This
illustrates where a central control record is used to make information available to all
transactions. For example, this may contain the next unused order number, or
customer number, to make it easier for programs to create new records in a keyed
file or database. (For this type of application, you should also consider the named
counter function, which is also a sysplex-wide facility. See Chapter 25, “Named
counter servers,” on page 337 for details.)
The table shows that within an MVS image, if there is a single region that makes all
the updates to a single record, you can use a UMT without any function shipping
overheads.
Where there are multiple regions updating the control record, or there is more than
one control record to update, then a coupling facility data table is the only solution
within a Parallel Sysplex environment, and it could also be more effective than
function shipping the updates to a UMT within a single MVS.
In Table 22, different techniques for sharing keyed data are shown. This covers
applications that use data similar in structure to a conventional keyed file, but where
the information does not need to be stored permanently, and the performance
benefits are sufficient to justify the use of main storage or coupling facility resources
to store the relevant data.
This kind of data is most appropriately accessed using the file control API, which
means that within a Parallel Sysplex, the solution is to use:
v A replicated user-maintained data table where the highest performance is
required, and where access is either read-only, or updates are rare and you can
arrange to make these from a single region and refresh the replicated UMT in
other regions
v A coupling facility data table.
Note that recovery support for UMTs is limited to transaction backout after a failure.
For coupling facility data tables, recovery is also provided for CICS and CFDT
server failures, and also for in-doubt failures,
For direct reading and browsing, if the file contains fixed-length records, and if the
application program provides an area into which the record is to be read, that area
must be of the defined length. If the file contains variable-length records, the
command must also specify the length of the area provided to hold them (which
should normally be the maximum length of records in the file).
For fixed-length records and for records retrieved into storage provided by CICS
(when you use the SET option), you need not specify the LENGTH argument.
However, although the LENGTH argument is optional, you are recommended to
specify it when using the INTO option, because it causes CICS to check that the
CICS SET storage normally remains valid until the next syncpoint, or the end of the
task, or until next READ against the same file, whichever comes first.
The GENERIC option indicates that you require a match on only a part of the key;
when you specify the GENERIC option, you also must specify the KEYLENGTH
option, to say how many positions of the key, starting from the left, must match. For
the READ command, CICS uses only the first KEYLENGTH option characters.
The GTEQ option indicates that you want the first record whose key is “greater than
or equal to” the key you have specified. You can use GTEQ with either a full or a
generic key.
The opposite of the GTEQ option is the EQUAL option (the default), which means
that you want only a record whose key matches exactly that portion (full or generic)
of the key that you have specified.
Note: Specify read integrity only when an application cannot tolerate ‘stale’ data.
This is because RLS uses locks to support read integrity, and as a result
your applications could encounter deadlocks that do not occur in releases of
CICS that do not support read integrity. This is particularly important if you
define read integrity on file resource definitions. The application programs
that reference these files may have been written for releases of CICS that do
not support read integrity, and are not designed to deal with deadlock
conditions on read-only file accesses.
If you specify either CONSISTENT or REPEATABLE, you can also specify the
NOSUSPEND option on a READ command to ensure that the request does not
wait if the record is locked by VSAM with an active lock. See “Active and retained
states for locks” on page 311 for more information about active locks.
The READNEXT command reads records sequentially from this starting point. On
completion of each READNEXT command, CICS returns the full key of the record it
retrieved in the field specified in the RIDFLD option. (Be sure to provide a field as
long as the full key, even if you use a STARTBR command with a shorter generic
key.)
You can also browse backwards in the file, by using READPREV commands
instead of READNEXT commands, and you can switch from one direction to the
other at any time. The READPREV command is like the READPREV command,
except that the records are read sequentially backward from the current position.
As you switch from one direction to the other, you retrieve the same record twice,
unless you reposition.
When the browse has started, you can change the current browse position either by
using a RESETBR command, or a READNEXT command, or a READPREV
command. The RESETBR command can also be used for other purposes, however.
For VSAM, but not for BDAM, you can reposition simply by varying the value in
RIDFLD when you issue the next READNEXT or READPREV command. When you
change RIDFLD, the record identifier must be in the same form as on the previous
STARTBR or RESETBR command (key, RBA, or RRN). In addition, you can change
the length of a generic key by specifying a KEYLENGTH in your READPREV
command, which is different from the current generic key length and not equal to
the full length. If you change the length of a generic key in this way, you reposition
to the generic key specified by RIDFLD option.
RESETBR command must be used to change the browse position in a BDAM file. If
you wish to change the form of the key from key to RBA or vice versa, you must
use a RESETBR command. You must also use a RESETBR command to switch
between generic and full keys or between “equal to” and “greater than or equal to”
searches. You can also only use X'FF' characters to point to the last record in the
file if you are using a RESETBR or STARTBR command.
Under certain conditions, CICS uses VSAM skip-sequential processing when you
change the key in this way, as explained in “Skip-sequential processing” on page
296.
You can use the options “key equal to” and “key greater than or equal to” on the
STARTBR command and they have the same meaning as on the READ command.
However, the STARTBR command assumes that you want to position at the key
specified or the first key greater if that key does not exist. That is, option GTEQ is
the default for the STARTBR command, whereas EQUAL is the default for the
READ command.
You can start a forward browse through a KSDS at the start of the file by specifying
a key of hexadecimal zeros, or by specifying options GENERIC, GTEQ, and
KEYLENGTH(0) on the STARTBR, RESETBR, READNEXT, or READPREV
command. (In the latter case, you need the RIDFLD keyword although its value is
not used and, after the command completes, CICS is using a generic key length of
one.)
If the alternate key is not unique, the DUPKEY condition is raised for each retrieval
operation except the last occurrence of the duplicate key. For example, if there are
three records with the same alternate key, DUPKEY is raised on the first two, but
not the third. The order in which records with duplicate alternate keys are returned
is the order in which they were written to the data set. This is true whether you are
using a READNEXT or a READPREV command. For this reason, you cannot
retrieve records with the same alternate key in reverse order.
Skip-sequential processing
When possible, CICS uses VSAM “skip-sequential” processing to speed browsing.
Skip-sequential processing applies only to forward browsing of a file when RIDFLD
After modification by the application program, the record is written back to the data
set using the REWRITE command, which does not identify the record being
rewritten. Within a unit of work, each REWRITE command should be associated
with a previous READ UPDATE by a common keyword (TOKEN). You can have
one READ UPDATE without a TOKEN outstanding at any one time. Attempts to
perform multiple concurrent update requests within a unit of work, upon the same
data set without the use of TOKENS, are prevented by CICS. If you want to release
the string held by a READ UPDATE without rewriting or deleting the record, use the
UNLOCK command. The UNLOCK command releases any CICS storage acquired
for the READ command, and releases VSAM resources held by the READ
command. If TOKEN is specified with the UNLOCK command, CICS attempts to
match this with an outstanding READ UPDATE whose TOKEN has the same value.
(For more explanation about the TOKEN option, see “The TOKEN option” on page
302.)
For both update and non-update commands, you must identify the record to be
retrieved by the record identification field specified in the RIDFLD option.
Immediately on completion of a READ UPDATE command, the RIDFLD data area
is available for reuse by the application program.
A record retrieved as part of a browse operation can only be updated during the
browse if the file is opened in RLS mode (see “Updating and deleting records in a
browse (VSAM RLS only)” on page 298). For files opened in non-RLS mode, the
application program must end the browse, read the desired record with a READ
UPDATE command, and perform the update. Failure to end the browse before
issuing the READ UPDATE command may cause a deadlock.
The record to be updated may (as in the case of a direct read) be read into an area
of storage supplied by the application program or into storage set by CICS. For a
READ UPDATE command, CICS SET storage remains valid until the next
REWRITE, UNLOCK, DELETE without RIDFLD, or SYNCPOINT command,
whichever is encountered first.
For a KSDS, the base key in the record must not be altered when the record is
modified. Similarly, if the update is being made by way of a path, the alternate key
For a file defined to CICS as containing fixed-length records, the length of record
being rewritten must equal the original length. For variable-length records, you
must specify the LENGTH option with both the READ UPDATE and the REWRITE
commands. The length must not be greater than the maximum defined to VSAM.
If a full key is provided with the DELETE command, a single record with that key is
deleted. So, if the data set is being accessed by way of an alternate index path that
allows non-unique alternate keys, only the first record with that key is deleted. After
the deletion, you know whether further records exist with the same alternate key,
because you get the DUPKEY condition if they do.
Note: An UNLOCK command does not free an RLS exclusive lock held by VSAM
against a record acquired during a browse operation. An UNLOCK within a
browse simply invalidates the TOKEN returned by the last request. Another
READNEXT or READPREV in the browse also invalidates the TOKEN for
the record read by the previous READNEXT or READPREV UPDATE
command. Therefore, it’s not necessary to use UNLOCK in an application
program that decides not to update a particular record.
Read integrity
The NOSUSPEND option discussed in “Read integrity (in RLS mode)” on page 294,
also applies to the CICS browse commands when you are using them to update a
file.
Adding to a KSDS
When adding a record to a KSDS, the base key of the record identifies the position
in the data set where the record is to be inserted. Although the key is part of the
record, CICS also requires the application program to specify the key separately
using the RIDFLD option on the WRITE command.
Adding to an ESDS
A record added to an ESDS is always added to the end of the file. You cannot
insert a record in an ESDS between existing records. After the operation is
completed, the relative byte address in the file where the record was placed is
returned to the application program.
When adding a record to an ESDS by way of an alternate index path, the record is
also placed at the end of the data set. The command must include the alternate
index key in the same way as for a KSDS path.
Adding to an RRDS
To add a record to an RRDS, include the relative record number as a record
identifier on the WRITE command. The record is then stored in the file in the
position corresponding to the RRN.
A MASSINSERT is completed by the UNLOCK command. This ensures that all the
records are written to the file and the position is released. Always issue an
UNLOCK command before performing an update operation on the same data set
(read update, delete with RIDFLD, or write). If you do not, you may get
unpredictable results, possibly including a deadlock.
Note: A READ command does not necessarily retrieve a record that has been
added by an incomplete MASSINSERT operation.
See “VSAM data sets” on page 173 for more information about MASSINSERT.
Use of the LENGTH option varies, depending on how you use the other options.
The RIDFLD option identifies a field containing the record identification appropriate
to the access method and the type of file being accessed.
The RIDFLD option by itself is not always enough to identify a specific record in the
file. So, when retrieving records from a KSDS, or from a KSDS or ESDS by way of
an alternate index path, or when setting a starting position for a browse in this type
of data set, you can have one or both of the further options GTEQ and GENERIC
with your command.
The INTO option specifies the main storage area into which the record is to be put.
For fixed-length records, you need not include the LENGTH option. If you do, the
length specified must exactly match the defined length; otherwise, you get the
LENGERR condition.
For variable-length records, always specify (in the LENGTH option) the longest
record your application program accepts (which must correspond to the value
defined as the maximum record size when the data set was created); otherwise,
you get the LENGERR condition. LENGERR occurs if the record exceeds the
length specified, and the record is then truncated to that length. After the record
retrieval, if you include the LENGTH option, the data area specified in it is set to the
actual record length (before any truncation occurs).
The SET option specifies a pointer to the buffer in main storage acquired by CICS
to hold the record. When using the SET option, you need not include the LENGTH
option. If you do include it, the data area specified is set to the actual record length
after the record has been retrieved.
The FROM option specifies the main storage area that contains the record to be
written. In general, this area is part of the storage owned by your application
program. With the REWRITE command, the FROM area is usually (but not
necessarily) the same as the corresponding INTO area on the READ UPDATE
command. The length of the record can be changed when rewriting to a KSDS with
variable-length records.
Always include the LENGTH option when writing to a file with variable-length
records. If the value specified exceeds the maximum allowed in the cluster
definition, LENGERR is raised when the command is executed. LENGERR is also
raised if the LENGTH option is omitted when accessing a file with variable-length
records.
When writing to a file with fixed-length records, CICS uses the length specified in
the cluster definition as the length of the record to be written, so you need not have
the LENGTH option. If you do, its value is checked against the defined value and
you get a LENGERR condition if the values do not match.
You can perform multiple concurrent updates on the same data set using the same
task by including the TOKEN option with a read for update command, and
specifying the token on the associated REWRITE, DELETE, or the UNLOCK
command. Note that, for files accessed in non-RLS mode, a set of concurrent
updates fails if more than one record is being updated in the same CI, irrespective
of the TOKEN associated with the request. Also, only one token remains valid for a
given REQID on a browse, and that is the one returned on the last READNEXT or
READPREV command (see “Updating and deleting records in a browse (VSAM
RLS only)” on page 298).
You can function ship a read for update request containing the TOKEN option.
However, if you function ship a request specifying TOKEN to a member of the CICS
family of products that does not recognize this keyword, the request fails.
For remote files for which the SYSID option has been specified, the KEYLENGTH
option must be specified if the RIDFLD option is passing a key to file control. If the
remote file is being browsed, the KEYLENGTH option is not required for the
READNEXT or READPREV command.
Transaction deadlocks
Design your applications so as to avoid transaction deadlocks. A deadlock occurs if
each of two transactions (for example, A and B) needs exclusive use of some
resource (for example, a particular record in a data set) that the other already
holds. Transaction A waits for the resource to become available. However, if
transaction B is not in a position to release it because it, in turn, is waiting on some
resource held by A, both are deadlocked and the only way of breaking the deadlock
is to cancel one of the transactions, thus releasing its resources.
With VSAM files accessed in RLS mode, only the individual record is ever locked
during this process. With VSAM files accessed in non-RLS mode, when VSAM
receives a command that requires control of the record, it locks the complete
control interval containing the record. CICS then obtains an enqueue on the record
that it requires, and releases the control interval, leaving only the record locked.
The control interval lock is released after each command, and only the individual
record is locked for the whole of the modification process. (For more information
about how the control interval lock is released, see CICS Recovery and Restart
Guide.)
In releases prior to CICS Transaction Server for z/OS, Version 2 Release 2, the
access method would also hold its lock on the complete control interval between
the commands, from the time when the modification began, to the time when it
ended. This is no longer the case.
Here are examples of different types of deadlock found in recoverable data sets:
v Two transactions running concurrently are modifying records within a single
recoverable file, through the same FCT entry, as follows:
WRITE record 2
Transaction 2
DELETE record 2
Transaction 1 has acquired the record lock for record 1 (even though it has
completed the READ UPDATE command with an UNLOCK command).
Transaction 2 has similarly acquired the record lock for record 2. The
transactions are then deadlocked because each wants to acquire the CICS lock
held by the other. The CICS lock is not released until syncpoint.
v Two transactions running concurrently are modifying two recoverable files as
follows:
Transaction 1 Transaction 2
READ UPDATE file 1, record 1 READ UPDATE file 2, record 2
REWRITE file 1, record 1 REWRITE file 2, record 2
Here, the record locks have been acquired on different files as well as different
records; however, the deadlock is similar to the first example.
For VSAM files accessed in non-RLS mode, CICS detects deadlock situations, and
a transaction about to enter a deadlock is abended with the abend code AFCF if it
is deadlocked by another transaction, or with abend code AFCG if it has
deadlocked itself.
Key
Generally, if you use a key, you can specify either a complete key or a generic
(partial) key. The exceptions to this rule are when you write a record to a KSDS or
when you write a record by an alternate index path. In either of these cases you
must specify the complete key in the RIDFLD option of the command.
When you use a generic key, you must specify its length in the KEYLENGTH option
and you must specify the GENERIC option on the command. A generic key cannot
have a key length equal to the full key length. You must define it to be shorter than
the complete key.
You can also specify the GTEQ option on certain commands, for both complete and
generic keys. The command then positions at, or applies to, the record with the
next higher key if a matching key cannot be found. When accessing a data set by
way of an alternate index path, the record identified is the one with the next higher
alternate key when a matching record cannot be found.
Even when using generic keys, always use a storage area for the record
identification field that is equal in length to the length of the complete key. During a
browse operation, after retrieving a record, CICS copies into the record identification
area the actual identifier of the record retrieved. CICS returns a complete key to
your application, even when you specified a generic key on the command. For
example, a generic browse through a KSDS returns the complete key to your
application on each READNEXT and READPREV command.
RBA
RBA specifies that the record identification field contains the relative byte address of
the record to be accessed. A relative byte address is used to access an ESDS, and
it may also be used to access a KSDS that is not opened in RLS access mode. All
file control commands that refer to an ESDS base, and specify the RIDFLD option,
must also specify the RBA option.
RRN
RRN specifies that the record identification field contains the relative record number
of the record to be accessed. The first record in the data set is number one. All file
control commands that refer to an RRDS, and specify the RIDFLD option, must also
specify the RRN option.
The separate delete lock is needed because of the way file control does its write
operations. Before executing a WRITE MASSINSERT command to a KSDS or
RRDS, file control finds and locks the empty range into which the new record or
records are to go. The empty range is locked by identifying the next existing record
in the data set and acquiring its delete lock.
The empty range is locked to stop other requests simultaneously adding records
into it. Moreover, the record defining the end of the empty range cannot be removed
during the add operation. If another transaction issues a request to add records into
Unlike an update lock, a delete lock is held only for the duration of a delete or write
operation, or a sequence of WRITE MASSINSERT commands terminated by an
UNLOCK command. A WRITE MASSINSERT command that adds records to the file
into more than one empty range releases the previous delete lock as it moves into
a new empty range.
The CICS enqueuing mechanism is only for updates and deletes and does not
prevent a read request being satisfied before the next syncpoint. The integrity of a
READ command in these circumstances is not guaranteed.
Record locks within RLS are owned by a named UOW within a named CICS region.
The lock owner name is the APPLID of the CICS region, plus the UOW id. For
example, when CICS makes a request that may create a lock, CICS passes to
VSAM the UOW id. This enables VSAM to build the lock name using the UOW id,
the record key, and the name of the CICS region.
When more than one request requires an exclusive lock against the same resource,
VSAM queues the second and subsequent requests until the resource is freed and
the lock can be granted. However, VSAM does not queue requests for resources
locked by a retained lock (see “Active and retained states for locks” on page 311).
Note: For MASSINSERT operations on a file opened in RLS access mode, CICS
acquires a separate update lock at the time each individual WRITE
command is issued. Unlike the non-RLS mode operation (described under
“Locking of VSAM records in recoverable files” on page 308) CICS does not
acquire the separate delete lock in addition to the update lock. There is no
equivalent to range locking for the MASSINSERT function for files opened in
non-RLS mode.
Exclusive locks can be active or retained; shared locks can only be active (see
“Active and retained states for locks” on page 311). Note that there are no delete
locks in RLS mode.
Shared locks
Shared locks support read integrity (see “Read integrity (in RLS mode)” on page
294). They ensure that a record is not in the process of being updated during a
read-only request. Shared locks can also be used to prevent updates of a record
between the time that a record is read and the next syncpoint.
A shared lock on a resource can be owned by several tasks at the same time.
However, although several tasks can own shared locks, there are some
circumstances in which tasks can be forced to wait for a lock:
v A request for a shared lock must wait if another task currently owns an exclusive
lock on the resource.
v A request for an exclusive lock must wait if other tasks currently own shared
locks on this resource.
v A new request for a shared lock must wait if another task is waiting for an
exclusive lock on a resource that already has a shared lock.
Lock duration
Shared locks for repeatable read requests, for recoverable and non-recoverable
data sets, are held until the next syncpoint.
Exclusive locks against records in a non-recoverable data set remain held only for
the duration of the request—that is, they are acquired at the start of a request and
released on completion of it. For example, a lock acquired by a WRITE request is
released when the WRITE request is completed, and a lock acquired by a READ
UPDATE request is released as soon as the following REWRITE or DELETE
request is completed. Exceptionally, locks acquired by sequential requests may
persist beyond the completion of the immediate operation. Sequential requests are
WRITE commands that specify the MASSINSERT option and browse for update
requests. A lock acquired by a WRITE command with the MASSINSERT option is
always released by the time the corresponding UNLOCK command completes, but
may have been released by an earlier request in the WRITE MASSINSERT
sequence. The exact request in the sequence that causes the lock to be released is
not predictable. Similarly, a lock acquired by a READNEXT UPDATE command may
still exist after the following DELETE or REWRITE command completes. Although
this lock is guaranteed to be released by the time the subsequent ENDBR
command completes, it may be released by some intermediate request in the
browse sequence.
If a request is made to update a recoverable data set, the associated exclusive lock
must remain held until the next syncpoint. This ensures that the resource remains
protected until a decision is made to commit or back out the request. If CICS fails,
VSAM continues to hold the lock until CICS is restarted.
Figure 77. Illustration of lock contention between CICS tasks on a recoverable data set
The active state is applicable to both exclusive and shared locks. However, only
exclusive locks against recoverable resources can have their state changed from
active to retained. The important characteristic of these states is that they determine
whether or not a task must wait for a lock:
v A request for a lock is made to wait if there is already an active lock against the
requested resource, except in two cases:
1. A request for a shared lock does not have to wait if the current active lock is
also a shared lock, and there are no exclusive lock requests waiting.
2. An update request that specifies NOSUSPEND does not wait for a lock if an
active lock already exists. In this case, CICS returns an exception condition
indicating that the “record is busy”.
v A request for a lock is rejected immediately with the LOCKED condition if there is
a retained lock against the requested resource.
When a lock is first acquired, it is an active lock. It is then either released, the
duration of the lock depending on the type of lock, or if an event occurs which
causes a UOW to fail temporarily and which would therefore cause the lock to be
held for an abnormally long time, it is converted into a retained lock. The types of
event that can cause a lock to become retained are:
v Failure of the CICS system, the VSAM server or the whole MVS system
v A unit of work entering the backout failed state
v A distributed unit of work becoming indoubt owing to the failure of either the
coordinating system or of links to the coordinating system
If a UOW fails, VSAM continues to hold the exclusive record locks that were owned
by the failed UOW for recoverable data sets. To avoid new requests being made to
wait for locks owned by the failed UOW, VSAM converts the active locks owned by
the failed UOW into retained locks. Retaining locks ensures that data integrity for
the locked records is maintained until the UOW is completed.
Exclusive recoverable locks are also converted into retained locks in the event of a
CICS failure, to ensure data integrity is maintained until CICS is restarted and
performs recovery.
Any shared locks owned by a failed CICS region are discarded, and therefore an
active shared lock can never become retained. Similarly, active exclusive
non-recoverable locks are discarded. Only locks that are both exclusive and apply
to recoverable resources are eligible to become retained.
Note: Requests that specify NOSUSPEND wait for at least 1 second before
CICS returns the RECORDBUSY response.
If you do not specify NOSUSPEND on your request, CICS causes it to wait for a
lock if the record is already locked by an active lock. If you specify NOSUSPEND,
your request receives a RECORDBUSY response if the record is locked by an
active lock.
If you issue a request (with or without the NOSUSPEND option) against a record
locked by a retained lock, CICS returns a LOCKED response.
Using RLS mode access for an ESDS can also cause availability problems. If a
CICS region fails while writing to an ESDS, the data set might be locked until the
CICS region is restarted. It is recommended that you do not use RLS mode access
for ESDS.
Note: When a blocked record is read for update, CICS maintains exclusive control
of the containing block. An attempt to read a second record from the block
before the first is updated (by a REWRITE command), or before exclusive
control is released (by an UNLOCK command), causes a deadlock.
Note: When using EDF, only the first of the above three fields (the block reference
subfield) is displayed.
The system programmer must specify the type of block reference you are using in
the RELTYPE operand of the DFHFCT TYPE=FILE system macro that defines the
data set.
Byte Number
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
If the data set contains blocked records, processing begins at the first record of the
first block and continues with each subsequent record, regardless of the contents of
the record identification field.
After the READNEXT command, CICS updates the RIDFLD with the complete
identification of the record retrieved. For example, assume a browse is to be started
with the first record of a blocked, keyed data set, and deblocking by logical key is to
be performed. Before issuing the STARTBR command, put the TTR (assuming that
is the addressing method) of the first block in the record identification field. After the
first READNEXT command, the record identification field might contain
X'0000010504', where X'000001' represents the TTR value, X'05' represents the
block key, (of length 1), and X'04' represents the logical record key.
Now assume that a blocked, nonkeyed data set is being browsed using relative
record deblocking and the second record from the second physical block on the
third relative track is read by a READNEXT command. Upon return to the
application program, the record identification field contains X'00020201', where
X'0002' represents the track, X'02' represents the block, and X'01' represents the
number of the record in the block relative to zero.
Note: Specify the options DEBREC and DEBKEY on the STARTBR command
when browsing blocked-data sets. This enables CICS to return the correct
contents in the RIDFLD. Specifying DEBREC on the STARTBR command
causes the relative record number to be returned. Specifying DEBKEY on
the STARTBR command causes the logical record key to be returned.
Do not omit DEBREC or DEBKEY when browsing a blocked file. If you do,
the logical record is retrieved from the block, the length parameter is set
equal to the logical record length, but the RIDFLD is not updated with the
full identification of the record. Do not use this method.
Compare this with what happens if you omit the DEBREC or DEBKEY option
when reading from a blocked BDAM data set. In this case, you retrieve the
whole block, and the length parameter is set equal to the length of the
block.
DL/I databases
You get a logical view of the database in terms of a hierarchy of segments. DL/I lets
you manipulate these segments without needing to know how they are organized.
DL/I databases are processed by the IBM licensed program Information
Management System/Enterprise Systems Architecture (IMS/ESA®).
CICS has two programming interfaces to DL/I. We recommend that you use the
higher-level EXEC DLI interface. It is straightforward, works with EDF, and can fully
exploit a 31-bit environment. The lower-level DL/I programming interface is the DL/I
CALL interface.
DB2 databases
DB2 databases also provide data independence, offering a logical view of the
database as a series of tables that you can interrelate more or less as you wish.
DB2 lets you manipulate these tables without needing to know how they are
organized. DB2 databases are processed by the IBM licensed program DB2
Universal Database™ for z/OS and OS/390.
CICS has one interface to DB2—the EXEC SQL interface, which offers powerful
statements for manipulating sets of tables—thus relieving the application program of
record-by-record (segment-by-segment, in the case of DL/I) processing.
CICS applications that process DB2 tables can also access DL/I databases. Any
CICS resources (files, transient data, and so on), DL/I, and DB2 can be accessed
from within one transaction. See the CICS IMS Database Control Guide for
information about what databases and resources you can access.
For information about SQL commands, which are not discussed in this book, see
the DB2 Universal Database for OS/390 and z/OS Application Programming and
SQL Guide.
Requests to DB2
Requests from CICS applications to DB2 are made using EXEC SQL commands.
DB2 runs in its own address space, like DBCTL. The CICS-DB2 and the
CICS-DBCTL interfaces are similar in that they both use the task-related user exit
interface (also known as the resource manager interface (RMI)) and have a
two-phase commit process. However, they differ in a number of respects. For
example, the CICS-DB2 interface uses the task-related user exit interface (also
known as the resource manager interface, RMI) and has a two-phase commit
process. CICS supports DBCTL and remote DL/I, and has to determine at PSB
schedule time which of them is being used.
Application
Invoke RMI
First
N request for Y
DB2 from this
task?
RMI
Invoke DB2
task-related user exit
Service request
Application
Creating a document
You can create an empty document using the DOCUMENT CREATE command,
and then build the contents with subsequent DOCUMENT INSERT commands, or
use DOCUMENT CREATE to create and build the document in one step.
DOCUMENT CREATE has a mandatory DOCTOKEN parameter requiring a
16–byte data-area. The document handler domain uses the DOCTOKEN operand to
return a token, which is used to identify the document on subsequent calls. The
following example creates an empty document, and returns the token in the variable
MYDOC:
EXEC CICS DOCUMENT CREATE
DOCTOKEN(MYDOC)
To create a document with data, use the DOCUMENT CREATE command in any of
the following ways:
v Using the BINARY option
v Using the TEXT option
v Using the FROMDOC option to copy an existing document
v Using the TEMPLATE option. “Setting up document templates” on page 322
describes this option.
where MYDOC2 and MYDOC3 are 16–character variables. MYDOC2 must contain
the token returned by a previous DOCUMENT CREATE command.
This results in two identical documents, each containing the text This is an example
of text to be added to a document.
Templates can contain static data, and symbols whose values are inserted into the
template when you issue the DOCUMENT CREATE or DOCUMENT INSERT
command. The values to be subsituted are specified in the application program;
they are associated with a particular document and cannot be used in a different
document.
Templates can be retrieved from several different sources, to suit the way they are
used in the application program; the DOCTEMPLATE definition specifies the source
of the template:
v from a partitioned data set
v from a CICS program
v from a CICS file
| v from a z/OS UNIX® System Services HFS file
v from a temporary storage queue
v from a transient data queue
v from an exit program
If you attempt to use a template for which there is no installed DOCTEMPLATE
definition, CICS attempts to retrieve the template from the partitioned data set with
a DDNAME of DFHHTML.
CICS loads a copy of the template from the partitioned data set when you install the
corresponding DOCTEMPLATE definition. Therefore you can modify the template in
the partitioned data set while CICS is running, and reinstall the definition in order to
activate the changes.
If your exit program sets a return code of 8, you can return an explanatory
message, which is written to the CSDH transient data destination. Return the
address and length of the message in dhtx_message_ptr and dhtx_message_len
respectively. The storage which contains the message must be accessible to the
caller of the exit program. For example, your exit program can issue a GETMAIN
command to acquire storage for the message. CICS will release the storage when
the task ends, unless you specify the SHARED option on the command.
When you are planning your use of symbols and templates, note that:
1. When a template containing symbols has been inserted into a document, you
cannot change the substituted values of those symbols in the document that is
being composed. If you set different values for the symbols, the new values will
be used the next time that the template is inserted into a document. Your
changes will not affect the values that have already been inserted into the
document.
2. If you insert a template before the symbols contained in it are set, the symbols
will never be substituted. This can occur if you create a document from a
template without specifying a symbol list.
3. Symbol substitution does not occur in html comments.
The support for symbols and symbol lists in the DOCUMENT application
programming interface is designed to interpret data with a content type of
application/x-www-form-urlencoded, as described in the HTML specification (at
http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4). This is the format in
which data is returned when it has been entered into a form on a web page.
This example defines three symbols. The first symbol called mytitle has the value
’New Authors’. The second symbol called auth1 has the value ’Halliwell Sutcliffe’
and the last symbol called auth2 has the value ’Stanley Weyman’. To adhere to the
specification for the content type application/x-www-form-urlencoded, plus signs
326 CICS TS for z/OS: CICS Application Programming Guide
have been used to indicate spaces within the symbol values; they will be converted
to spaces when the symbol values are put into the symbol table.
Here the symbol COMPANY has a value of ’BLOGGS & SON’, and the symbol
ORDER has a value of ’NUTS+BOLTS’. The symbol separator used in this example
is ’!’, but it is best to use a non-printable character that does not appear in the
symbol value. The use of a character other than the ampersand as the symbol
separator means that an ampersand can be used in ’BLOGGS & SON’. The use of
the UNESCAPED option ensures that the plus sign in ’NUTS+BOLTS’ does not get
converted to a space. Because the UNESCAPED option has been used, you must
use a space character, rather than a plus sign, to indicate where a space is
required in the symbol value, and the data no longer conforms to the specification
for the content type application/x-www-form-urlencoded.
Depending on your application, you might find that instead of specifying the exact
list length for your symbol list each time you define values for the symbols, it is
more convenient to choose a permanent value for the LISTLENGTH option, which
will provide a fixed list length for your symbol list. The fixed list length that you
choose should be long enough to include the maximum length of symbol list that
you expect to supply. However, on those occasions when the fixed list length that
you have specified for your symbol list is greater than the actual length of the
symbols that you supply, you might find that there are trailing spaces or
unpredictable characters in the value of the last symbol in the list. You can avoid
this issue by including an extra dummy symbol at the end of your symbol list, such
as ’&END=’. Do not include this symbol in any templates or documents. Any trailing
spaces or unpredictable characters will be assigned to the dummy symbol and will
not appear in your documents, so you can continue to specify a list length that is
greater than the actual length of the symbols.
As an alternative to using a symbol list, the DOCUMENT SET command allows you
to set individual symbol values with the SYMBOL and VALUE options. The
SYMBOL option specifies the name of the symbol, and the VALUE option specifies
the value for that symbol. The rules for including spaces in a symbol value in a
symbol list also apply to the VALUE option: you can use a simple space character
or a plus sign, unless the UNESCAPED option of the DOCUMENT SET command
has been specified, in which case you must use a space character. Also, the
special coding that is required to include a plus sign or percent sign in symbol lists
is similarly required in the VALUE option, unless the UNESCAPED option of the
DOCUMENT SET command has been specified. However, ampersands, or any
other character that you have specified as a symbol separator for the symbol list,
have no special significance when used in the VALUE option.
The characters used to start and end the Server Side Include must be in codepage
037, otherwise the command will be ignored. The hexadecimal equivalents for these
character sequences are X’4C5A60607B’ and X’60606E’.
The three commands that are supported are #set, #echo and #include.
#set
The #set command is used to set the values of symbols and is useful for setting
up default values for symbols. The #set command in the template will be
ignored if the symbol has already been given a value using the DOCUMENT
SET command. If a previous #set command has been used to assign a value to
the symbol, the value will be overridden. A symbol which has been assigned a
value using the DOCUMENT SET command can only be changed by issuing
another DOCUMENT SET command.
#echo
The #echo command identifies a symbol that must be substituted when the
template is inserted into the document. The string containing the #echo
command will be completely replaced by the value associated with the symbol.
If no symbol has been defined with that name, the #echo command will remain
in the output data.
An alternative method to using the #echo command is to specify the symbol
name, preceding it with an ampersand and terminating it with a semicolon. If we
set a symbol called ASYM and give it a value of ’sample’, the following two
templates will give the same result after substitution.
Template 1:
This is an example template.
<!--#set var=ASYM value=’sample’-->
This is a <!--#echo var=ASYM--> symbol.
Template 2:
This is an example template.
<!--#set var=ASYM value=’sample’-->
This is a &ASYM; symbol.
Result of substitution:
This is an example template.
This is a sample symbol.
#include
The #include command allows a template to be embedded within another
template. Up to 32 levels of embedding are allowed.
For example:
<!--#include template=templatename-->
This will result in a document being created with the content “ This is a sample
document which has been created by user DFLTUSER.”.
To change the symbol to another value, you can issue the DOCUMENT CREATE
command with the SYMBOLLIST option:
EXEC CICS DOCUMENT CREATE
DOCTOKEN(ATOKEN)
TEMPLATE(TEMPLATENAME)
SYMBOLLIST(’ASYM=Joe Soap’)
LISTLENGTH(13)
This will result in a document being created with the content “This is a sample
document which has been created by user Joe Soap.”.
When the document is retrieved, the data that is delivered to the application buffer
is stored in a form which contains control information necessary to reconstruct an
exact replica of the document. The document that is created from the retrieved copy
is therefore identical to the original document. To help the application calculate the
size of the buffer needed to hold a retrieved document, each document command
which alters the size of the document has a DOCSIZE option. This is a fullword
value which gives the maximum size that the buffer must be to contain the
document when it is retrieved. This size is calculated to include all the control
information and data. The size should not be taken as an accurate size of the
document as the actual length delivered to the application can often be slightly
smaller than this size. The length delivered will however never exceed the length in
the DOCSIZE option.
The above example introduced the use of the FROM option on the DOCUMENT
CREATE command. The data passed on the FROM option was the buffer returned
to the application when the DOCUMENT RETRIEVE command was issued. It is
possible for the application to supply data on the FROM option that did not originate
from the DOCUMENT RETRIEVE command. When this happens, the document
handler treats the data as a template and parses the data for template commands
and symbols.
When the commands have executed, the buffer DOCBUF will contain the string “A
sample document.”.
You can use the DOCUMENT RETRIEVE and DOCUMENT INSERT commands to
insert a whole document into an existing document. The following variables must
first be defined and initialized in the application program:
v A 16-byte field RTOKEN which contains the document token of the document to
be retrieved
v A buffer DOCBUF of sufficient length to hold the retrieved document
v A fullword binary field called RETRIEVLEN to hold the length of the data
retrieved
v A fullword binary field called MAXLEN to hold the maximum amount of data the
buffer can receive, i.e. the length of DOCBUF
v A 16-byte field ITOKEN which contains the document token of the document that
is being inserted into
The retrieved document is inserted at the end of the document specified in the
DOCUMENT INSERT command, and all the control information of the retrieved
document will be present in the second document. The LENGTH parameter of the
DOCUMENT INSERT command must be equal to the value returned from the
DOCUMENT RETRIEVE command into the field RETRIEVLEN.
Note that when a value associated with a symbol has been inserted into a
document, you cannot change that value in the document that is being composed. If
you set a different value for the symbol, the new value will be used the next time
Using Bookmarks
The sequence in which an application inserts data into a document might not reflect
the desired sequence that the data should appear in the document. Bookmarks
allow the application to insert blocks of data in any order yet still control the
sequence of the data in the document. A bookmark is a label that the application
inserts between blocks of data. Note: a bookmark cannot be inserted in the middle
of a block of data.
The following example creates a document with two blocks of text and a bookmark:
EXEC CICS DOCUMENT CREATE
DOCTOKEN(ATOKEN)
TEXT(’Pre-bookmark text. ’)
LENGTH(19)
EXEC CICS DOCUMENT INSERT
DOCTOKEN(ATOKEN)
BOOKMARK(’ABookmark ’)
EXEC CICS DOCUMENT INSERT
DOCTOKEN(ATOKEN)
TEXT(’Post-bookmark text. ’)
LENGTH(20)
Note that the text <ABookmark> does not appear in the document content but
serves merely as a pointer to that position in the document. To add data to this
document, you can insert text at the bookmark as follows:
EXEC CICS DOCUMENT INSERT
DOCTOKEN(ATOKEN)
TEXT(’Inserted at a bookmark. ’)
LENGTH(25)
AT(’ABookmark ’)
Logically, the data of the document will contain the following (Note that in this
instance, only the data is being shown and not the position of the bookmark).
Pre-bookmark text. Inserted at a bookmark. Post-bookmark text.
If the AT option is omitted, the data is always appended to the end of the document.
A special bookmark of ’TOP’ can be used to insert data at the top of the document,
making it unnecessary to define a bookmark which will mark the top of the
document.
You can now issue the command to replace the text between the two bookmarks,
BMark1 and BMark2:
EXEC CICS DOCUMENT INSERT
DOCTOKEN(ATOKEN)
TEXT(’Replacement Text. ’)
LENGTH(18)
AT(’BMark1 ’)
TO(’BMark2 ’)
You can make CICS documents include information about the code pages in which
they have been created. When you create a document using the EXEC CICS
DOCUMENT CREATE and EXEC CICS DOCUMENT INSERT commands, you can
use the HOSTCODEPAGE option together with any of the TEXT, FROM,
TEMPLATE and SYMBOL options, to indicate the code page for that block of data.
Each block can be specified in a different code page.
| For CICS Web support, when a CICS document is specified for sending by a
| Web-aware application program using the EXEC CICS WEB API commands, the
| EXEC CICS DOCUMENT RETRIEVE command is not used by the application
| program. Instead, the document token of the CICS document is specified, and CICS
| manages retrieval of the document. Conversion to a client code page is handled by
| CICS, according to options that the application program specifies on the EXEC
| CICS WEB API commands.
| Also for CICS Web support, when a CICS document template is specified in a
| URIMAP definition to provide a static response to a Web client, conversion to a
| client code page is handled by CICS. The host code page in which the template
| exists, and the client code page to which it should be converted, are specified in the
| URIMAP definition. When the static response is required, CICS creates a document
| using the template, retrieves the document, and carries out appropriate code page
| conversion.
CICS provides a facility for generating unique sequence numbers for use by
application programs in a Parallel Sysplex environment. This facility is controlled by
a named counter server, which maintains each sequence of numbers as a named
counter. Each time a sequence number is assigned, the corresponding named
counter is incremented automatically. By default, the increment is 1, ensuring that
the next request gets the next number in sequence. You can vary the increment
when using the EXEC CICS GET command to request the next number.
There are various uses for this facility, such as obtaining a unique number for
documents (for example, customer orders, invoices, and despatch notes), or for
obtaining a block of numbers for allocating customer record numbers in a customer
file.
In a single CICS region, there are various methods you can use to control the
allocation of a unique number. For example, you could use the CICS common work
area (CWA) to store a number that is updated by each application program that
uses the number. The problem with the CWA method is that the CWA is unique to
the CICS address space, and cannot be shared by other regions that are running
the same application. A CICS shared data table could be used to provide such a
service, but the CICS regions would all have to reside in the same MVS image. The
named counter facility overcomes all the sharing difficulties presented by other
methods by maintaining its named counters in the coupling facility, and providing
access through a named counter server running in each MVS image in the sysplex.
This ensures that all CICS regions throughout the Parallel Sysplex have access to
the same named counters.
When you use a named counter server, each normal request (to assign the next
counter value) only requires a single coupling facility access. This provides a
significant improvement in performance compared to the use of files for this
purpose. The named counter server also performs better than coupling facility data
tables in this respect, because at least two coupling facility accesses are required to
update a coupling facility data table. Depending on your hardware configuration,
you should easily be able to make many thousands of named counter server
requests each second.
All values are stored internally as 8-byte (doubleword) binary numbers. The EXEC
CICS interface allows you to use them as either fullword signed binary numbers or
doubleword unsigned binary numbers. This can give rise to overflow conditions if
you define a named counter using the doubleword command (see “Using the
named counter EXEC interface” on page 339) and request numbers from the server
using the signed fullword version of the command.
You create a named counter pool by defining the coupling facility list structure for
the pool, and then starting the first named counter server for the pool. Pool names
are of 1 to 8 bytes from the same character set for counter names. Although pool
names can be made up from any of the allowed characters, names of the form
DFHNCxxx are recommended.
You can create different pools to suit your needs. You could create a pool for use
by production CICS regions (for example, called DFHNCPRD), and others for test
and development regions (for example, using names like DFHNCTST and
DFHNCDEV). See “Named counter options table” for information about how you
can use logical pool names in your application programs, and how these are
resolved to actual pool names at runtime.
Defining a list structure for a named counter server, and starting a named counter
server, is explained in the CICS System Definition Guide.
The named counter options table, DFHNCOPT, provides several methods for
determining the actual pool name referenced by a named counter API command, all
of which are described in the CICS System Definition Guide. This also describes
the DFHNCO macro that you can use to create your own options table.
You can see from the above that you do not need to create you own options table,
and named counter API commands do not need to specify the POOL option, if:
v You use pool names of the form DFHNCxxx, or
v Your CICS region uses only one pool that can be defined by the NCPLDFT
system initialization parameter.
Notes:
1. DFHNCOPT named counter options tables are not suffixed. A CICS region loads
the first table found in the MVS link list.
2. There must be a named counter server running, in the same MVS image as
your CICS region, for each named counter pool used by your application
programs.
Using the REDUCE option: To ensure that a request does not fail because the
remaining range of numbers is too small to satisfy your INCREMENT value (the
current number is too near the maximum value), specify the REDUCE option.
With the reduce option, the server automatically adjusts the increment to allow it
to assign all the remaining numbers, leaving the counter in the counter-at-limit
condition.
Using both the WRAP and REDUCE options: If you specify both options, only
one is effective depending on the state of the counter:
v If the counter is already at its limit when the server receives the GET
request, the REDUCE option has no effect and the WRAP option is obeyed.
v If the counter is not quite at its limit when the server receives the GET
request, but the remaining range is too small for increment, the REDUCE
option is obeyed and the WRAP option has no effect.
Using the COMPAREMIN and COMPAREMAX options: You can use these
options to make the named counter GET (and UPDATE) operation conditional
upon the current number being within a specified range, or being greater than,
or less than, one of the specified comparison values.
QUERY
Queries the named counter to obtain the current, minimum, and maximum
values. Note that you cannot use more than one named counter command in a
way that is atomic, and you cannot rely on the information returned on a
The named counter call interface does not use CICS command-level API, therefore
the system initialization parameter CMDPROT=YES has no effect. If the interface is
called from a CICS application program that is excuting in user key, it switches to
CICS key while processing the request but CICS does not attempt to verify that the
program has write access to the output parameter fields.
Note: The named counter server interface uses MVS name/token services
internally. A consequence of this is that jobs using the named counter
interface cannot use MVS checkpoint/restart services (as described in APAR
OW06685).
The syntax of the assembler version of the call to the named counter interface
is as follows:
CALL DFHNCTR,(function,return_code,pool_selector,counter_name, X
value_length,current_value,minimum_value,maximum_value, X
counter_options,update_value,compare_min,compare_max),VL
The CALL macro must specify the VL option to set the end of list indication, as
shown in the following example:
CALL DFHNCTR,(NC_ASSIGN,RC,POOL,NAME,CTRLEN,CTR),VL
C/C++
The named counter interface definitions for C/C++ are provided in header file
DFHNCC. The symbolic constant names are in upper case. The function name
is dfhnctr, in lower case.
COBOL
The named counter interface definitions for COBOL are provided in copybook
DFHNCCOB.
COBOL does not allow underscores within names, therefore the symbolic
names provided in copy book DFHNCCOB use a hyphen instead of an
underscore (for example NC-ASSIGN and NC-COUNTER-AT-LIMIT).
Note that the RETURN-CODE special register is set by each call, which affects
the program overall return code if it is not explicitly set again before the
program terminates.
PL/I
The named counter interface definitions for PL/I are provided in include file
DFHNCPLI.
CALL DFHNCTR(function,return_code,pool_selector,counter_name,
value_length,current_value,minimum_value,maximum_value,
counter_options,update_value,compare_min,compare_max);
Notes:
1. All functions that refer to a named counter require at least the first four
parameters, but the remaining parameters are optional, and trailing unused
parameters can be omitted.
If you do not want to use an imbedded optional parameter, either specify the
default value or ensure that the parameter list contains a null address for the
omitted parameter. For an example of a call that omits an optional parameter,
see “Example of DFHNCTR calls with null parameters” on page 349.
2. The NC_FINISH function requires the first three parameters only.
function
specifies the function to be performed, as a 32-bit integer, using one of the
following symbolic constants.
NC_CREATE Create a new named counter, using the initial value, range
limits, and default options specified on the current_value,
minimum_value, maximum_value, update_value and
counter_options parameters.
If you omit an optional value parameter, the new named counter
is created using the default for the omitted value. For example,
if you omit all the optional parameters, the counter is created
with an initial value of 0, a minimum value of 0, and a maximum
value of high values (the double word field is filled with X'FF').
NC_ASSIGN Assign the current value of the named counter, then increment
it ready for the next request. When the number assigned equals
the maximum number specified for the counter, it is
incremented finally to a value 1 greater than the maximum. This
ensures that any subsequent NC_ASSIGN requests for the
named counter fail (with NC_COUNTER_AT_LIMIT) until the
counter is reset using the NC_REWIND function, or
automatically rewound by the NC_WRAP counter option (see
the counter_options parameter).
This operation can include a conditional test on the current
value of the named counter, using the compare_min and
compare_max parameters.
The server returns the minimum and maximum values if you
specify these fields on the call parameter list and the request is
successful.
You can use the counter_options parameter on the
NC_ASSIGN request to override the counter options set by the
NC_CREATE request.
You can use the update_value parameter to specify the
increment to be used on this request only for the named
counter (the default increment is 1). This enables you to obtain
the named counter server returns 109 and sets the current
value to 134 ready for the next NC_ASSIGN request, effectively
assigning numbers in the range 109 through 133. The
increment can be any value between zero and the limit is
determined by the minimum and maximum values set for the
named counter. Thus the increment limit is ((maximum_value
plus 1) minus minimum value). An increment of zero causes
NC_ASSIGN to operate the same as NC_INQUIRE, except for
any comparison options.
Note: The default pool name for the call interface is DFHNC001. The default
pool nam