CICS Application Programming Guide
CICS Application Programming Guide
SC34-5702-00
SC34-5702-00
Note! Before using this information and the product it supports, be sure to read the general information under Notices on page 631.
First edition (March 2001) This edition applies to Version 2 Release 1 of CICS Transaction Server for z/OS, program number 5697-E93, and to all subsequent versions, releases, and modifications until otherwise indicated in new editions. Make sure you are using the correct edition for the level of the product. Order publications through your IBM representative or the IBM branch office serving your locality. Publications are not stocked at the address given below. At the back of this publication is a page entitled Sending your comments to IBM. If you want to make comments, but the methods described are not available to you, please address them to: IBM United Kingdom Laboratories, Information Development, Mail Point 095, Hursley Park, Winchester, Hampshire, England, SO21 2JN. When you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information in any way it believes appropriate without incurring any obligation to you. Copyright International Business Machines Corporation 1989, 2001. All rights reserved. US Government Users Restricted Rights Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . xix What this book is about . . . . . . . . . . . . . . . . . . . . . xix Who should read this book . . . . . . . . . . . . . . . . . . . xix Summary of changes . . . . . . Changes for CICS Transaction Server Changes for CICS Transaction Server Changes for CICS Transaction Server . . . . . . . . . . . . . for z/OS Version 2 Release 1 . . for OS/390 Version 1 Release 3 . for OS/390 Version 1 Release 2 . . . . . . . . . . . . . xxi xxi xxi xxii
| | | | | |
Chapter 3. Programming in COBOL . . . . . Using based addressing with COBOL . . . . . Using WITH DEBUGGING MODE . . . . . COBOL programming restrictions . . . . . . Restrictions for 31-bit addressing . . . . . Using the DL/I CALL interface . . . . . . Mixing languages . . . . . . . . . . . . Calling subprograms from COBOL. . . . . . Using COBOL with the ANSI 85 standard . . . Literals intervening in blank lines . . . . . Sequence numbers containing any character . REPLACE statement. . . . . . . . . . Batch compilation . . . . . . . . . . . Nested programs . . . . . . . . . . . Reference modification . . . . . . . . . Global variables . . . . . . . . . . . Comma and semicolon as delimiters . . . . Symbolic character definition . . . . . . . Summary of ANS185 restrictions . . . . . Using the COBOL2 translator option . . . . . Translator action . . . . . . . . . . . Using the COBOL3 translator option . . . . . Translator action . . . . . . . . . . . Using the OO COBOL translator option . . . . Translator action . . . . . . . . . . . Nesting programs . . . . . . . . . . . Chapter 4. Programming in C and C++ C and C++ programming restrictions . . Passing arguments in C or C++. . . . Accessing the EIB. . . . . . . . .
Copyright IBM Corp. 1989, 2001
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . 9 . . . 9 . . . 10 . . . 10 . . . 12 . . . 12 . . . 13 . . . 14 . . . 18 . . . 19 . . . 19 . . . 20 . . . 20 . . . 22 . . . 27 . . . 27 . . . 27 . . . 27 . . . 28 . . . 28 . . . 28 . . . 29 . . . 29 . . . 29 . . . 30 . . . 30 . . . . . . . . . . . . 31 32 34 36
. . . .
. . . .
. . . .
iii
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
36 37 37 37
Chapter 5. Programming in PL/I . . . . . . . . . . . . . . . . . . 39 PL/I programming restrictions . . . . . . . . . . . . . . . . . . . 39 Using PL/I and dynamic storage . . . . . . . . . . . . . . . . . . 40 Chapter 6. Programming in Assembler . . . . . . . . . . . . . . . 43 Calling Assembler programs . . . . . . . . . . . . . . . . . . . . 44 Chapter 7. Language Environment . . . . . . . . . . Levels of support in Language Environment . . . . . . . Language Environment services . . . . . . . . . . . Using Language Environment Abend-handling . . . . . . User-written LE condition handlers. . . . . . . . . . Managing Language Environment storage . . . . . . . . Using C/C++ applications with Language Environment . . . Using COBOL applications with Language Environment . . . Using PL/I applications with Language Environment . . . . Using Assembler applications with Language Environment . . Mixing languages in Language Environment . . . . . . . Using Dynamic Link Libraries and Language Environment . . Defining run-time options for Language Environment . . . . Run-time options in child enclaves. . . . . . . . . . CEEBXITA coding . . . . . . . . . . . . . . . . Determining which options were used . . . . . . . . Writing a CEEBINT initialization exit for Language Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 47 48 49 50 50 51 52 54 55 57 59 60 61 61 62 62
iv
| | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Preparing for program installation . . . . . . . . . . . . Defining MVS residence and addressing modes. . . . . . . . Establishing a programs addressing mode . . . . . . . . CICS address space considerations . . . . . . . . . . . Making programs permanently resident . . . . . . . . . . Running applications in the link pack area . . . . . . . . . . Running application programs in the RDSAs . . . . . . . . . Assembler . . . . . . . . . . . . . . . . . . . . C and C/++ . . . . . . . . . . . . . . . . . . . . COBOL . . . . . . . . . . . . . . . . . . . . . PL/I . . . . . . . . . . . . . . . . . . . . . . . Using BMS map sets in application programs . . . . . . . . Using the CICS-supplied procedures to install application programs Installing programs in load library secondary extents . . . . . Including the CICS-supplied interface modules . . . . . . . . Installing assembler language application programs . . . . . . Sample JCL to install assembler application programs . . . . Installing COBOL application programs . . . . . . . . . . Sample JCL to install COBOL application programs . . . . . Installing PL/I application programs . . . . . . . . . . . . Sample JCL to install PL/I application programs . . . . . . Installing C application programs . . . . . . . . . . . . . Sample JCL to install C application programs . . . . . . . Using your own job streams . . . . . . . . . . . . . . Translator requirements . . . . . . . . . . . . . . . Online programs that use EXEC CICS or EXEC DLI commands Online programs that use the CALL DLI interface . . . . . . Batch or BMP programs that use EXEC DLI commands . . . Batch or BMP programs that use DL/I CALL commands . . . Chapter 10. Installing map sets and partition sets . . . Installing map sets . . . . . . . . . . . . . . . . Types of map sets . . . . . . . . . . . . . . . Installing physical map sets . . . . . . . . . . . . Installing symbolic description map sets . . . . . . . Installing physical and symbolic description maps together Installing partition sets . . . . . . . . . . . . . . . Defining programs, map sets, and partition sets to CICS . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. 90 . 91 . 91 . 91 . 92 . 92 . 93 . 93 . 94 . 94 . 95 . 96 . 96 . 97 . 97 . 98 . 99 . 100 . 101 . 104 . 104 . 106 . 107 . 108 . 109 . 109 . 112 . 112 . 112 . . . . . . . . 113 114 114 116 118 119 121 123
| | | | | | |
Contents
Temporary storage . . . . . . . . . Intrapartition transient data . . . . . . GETMAIN SHARED command . . . . Your own data sets . . . . . . . . . Lengths of areas passed to CICS commands LENGTH options. . . . . . . . . . Journal records . . . . . . . . . . Data set definitions . . . . . . . . . Recommendation . . . . . . . . . Minimizing errors. . . . . . . . . . . Protecting CICS from application errors . Testing applications . . . . . . . . . Non-terminal transaction security . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
141 142 143 143 143 144 144 144 144 144 145 145 146 147 147 148 149 151 152 153 153 154 154 154 156 156 156 157 157 157 160 162 163 165 165 165 168 169 169
Chapter 12. Design for performance . . . . . Program size . . . . . . . . . . . . . . Virtual storage. . . . . . . . . . . . . . Reducing paging effects . . . . . . . . . Exclusive control of resources . . . . . . . . Operational control . . . . . . . . . . . . Operating system waits . . . . . . . . . . The NOSUSPEND option . . . . . . . . . Efficient data operations . . . . . . . . . . Efficient database operations . . . . . . . Efficient data set operations. . . . . . . . Efficient browsing (in non-RLS mode) . . . . Efficient logging . . . . . . . . . . . . Efficient sequential data set access . . . . . Efficient terminal operations. . . . . . . . . Length of the data stream sent to the terminal . Basic mapping support considerations . . . . Page-building and routing operations . . . . Requests for printed output . . . . . . . . Additional terminal control considerations . . . Chapter 13. Sharing data across transactions Using the common work area (CWA) . . . . Protecting the CWA. . . . . . . . . . Using the TCTTE user area (TCTUA) . . . . Using the COMMAREA in RETURN commands Using the display screen to share data . . . Chapter 14. Affinity . . . . . . . Types of affinity . . . . . . . . . Inter-transaction affinity . . . . . Transaction-system affinity . . . . Programming techniques and affinity . Safe techniques . . . . . . . . Unsafe techniques . . . . . . . Suspect techniques . . . . . . . Recommendations . . . . . . . Safe programming to avoid affinity . . The COMMAREA . . . . . . . The TCTUA . . . . . . . . . Using ENQ and DEQ commands with BTS containers . . . . . . . . . . . . . .
171 172 172 172 173 173 173 174 174 174 175 176 177 . . 179
vi
Unsafe programming for affinity . . . . . . . . . . . . . Using the common work area . . . . . . . . . . . . . Using GETMAIN SHARED storage . . . . . . . . . . . Using the LOAD PROGRAM HOLD command . . . . . . . Sharing task-lifetime storage . . . . . . . . . . . . . Using the WAIT EVENT command . . . . . . . . . . . Using ENQ and DEQ commands without ENQMODEL resource Suspect programming for affinity . . . . . . . . . . . . . Using temporary storage . . . . . . . . . . . . . . . Using transient data . . . . . . . . . . . . . . . . Using the RETRIEVE WAIT and START commands . . . . . Using the START and CANCEL REQID commands . . . . . Using the DELAY and CANCEL REQID commands . . . . . Using the POST and CANCEL REQID commands . . . . . Detecting inter-transaction affinities . . . . . . . . . . . . Inter-transaction affinities caused by application generators . . Duration and scope of inter-transaction affinities . . . . . . . Affinity transaction groups . . . . . . . . . . . . . . Relations and lifetimes . . . . . . . . . . . . . . . Chapter 15. Recovery design . Journaling . . . . . . . . . Journal records . . . . . . Journal output synchronization. Syncpointing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
179 179 180 181 182 184 185 186 186 188 189 191 193 194 196 196 197 197 197 205 205 205 205 207 209 209 210 210 211 212 213 214 215 215 216 217 218 218 221 222 223 224 225 225 226 229 229 229 230 230 230
Chapter 16. Dealing with exception conditions . Default CICS exception handling . . . . . . . . Handling exception conditions by in-line code . . . How to use the RESP and RESP2 options . . . An example of exception handling in C . . . . An example of exception handling in COBOL . . Modifying default CICS exception handling . . . . Using the HANDLE CONDITION command . . . . RESP and NOHANDLE options . . . . . . . How CICS keeps track of what to do . . . . . Using the HANDLE CONDITION ERROR command. Using the IGNORE CONDITION command . . . . Using the HANDLE ABEND command . . . . . . Using PUSH HANDLE and POP HANDLE commands Chapter 17. Abnormal termination recovery . Creating a program-level abend exit . . . . Retrying operations . . . . . . . . . . . Trace . . . . . . . . . . . . . . . . Trace entry points . . . . . . . . . . Monitoring . . . . . . . . . . . . . . Dump . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Chapter 18. The QUERY SECURITY command . Using the QUERY SECURITY command . . . . Security protection at the record or field level . CICS-defined resource identifiers. . . . . . SEC system initialization parameter . . . . . Programming hints . . . . . . . . . . .
Contents
vii
Chapter 20. File controlVSAM considerations . . . . . . VSAM record identification . . . . . . . . . . . . . . . Key . . . . . . . . . . . . . . . . . . . . . . Relative byte address (RBA) and relative record number (RRN) Locking of VSAM records in recoverable files . . . . . . . . Update locks and delete locks (non-RLS mode only) . . . . Record locking of VSAM records for files accessed in RLS mode . Exclusive locks and shared locks. . . . . . . . . . . . Conditional VSAM file update requests . . . . . . . . . . File control implementation of NOSUSPEND . . . . . . . CICS locking for writing to ESDS . . . . . . . . . . . . .
Chapter 21. File controlBDAM considerations . . . . . . . . . . . 267 Identifying BDAM records . . . . . . . . . . . . . . . . . . . . 267 Block reference subfield . . . . . . . . . . . . . . . . . . . . 267
viii
Physical key subfield . . . . . . . Deblocking argument subfield . . . . Browsing records from BDAM data sets . Adding records to BDAM data sets . . . Updating records from BDAM data sets Chapter 22. Database control DL/I databases . . . . . . DATABASE 2 (DB2) databases Requests to DB2. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
267 267 268 269 270 271 271 271 271 273 273 273 274 274 275 276 277 279 280 281 283 283 284 284 285 287 287 289 296
Chapter 23. CICS documents . . . . . . Using the DOCUMENT programming interface . Creating a document . . . . . . . . . Programming with documents . . . . . . . Setting symbol values . . . . . . . . . Embedded template commands . . . . . Using templates in your application . . . . The lifespan of a document . . . . . . . Constructing a document. . . . . . . . Using Bookmarks . . . . . . . . . . Codepages and codepage conversion . . . Chapter 24. Named counter servers . . The named counter fields . . . . . . Named counter pools . . . . . . . . Named counter options table . . . . Using the named counter EXEC interface Using the named counter CALL interface . Application programming considerations Syntax . . . . . . . . . . . . Return codes . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents
ix
Coding considerations for sequential terminals . Using TCAM . . . . . . . . . . . . . . Coding for the DCB interface . . . . . . . Coding for the ACB interface . . . . . . . Using batch data interchange . . . . . . . . Destination selection and identification . . . . Definite response . . . . . . . . . . . Waiting for function completion . . . . . . Chapter 26. The 3270 family of terminals History of the 3270 . . . . . . . . . Screen fields . . . . . . . . . . Personal computers . . . . . . . The 3270 buffer . . . . . . . . . . The output datastream . . . . . . . 3270 write commands . . . . . . . Write control character . . . . . . 3270 display fields . . . . . . . . . Display characteristics . . . . . . . 3270 field attributes. . . . . . . . . Protection . . . . . . . . . . . Modification . . . . . . . . . . Intensity . . . . . . . . . . . . Base color . . . . . . . . . . . Extended attributes . . . . . . . . Orders in the data stream . . . . . . The start field order. . . . . . . . The modify field order . . . . . . . The set buffer address order . . . . The set attribute order . . . . . . . Outbound data stream sample. . . . . Input from a 3270 terminal . . . . . . Data keys . . . . . . . . . . . Keyboard control keys. . . . . . . Attention keys . . . . . . . . . . Reading from a 3270 terminal . . . . . Inbound field format . . . . . . . . Input data stream example . . . . . . Unformatted mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
320 321 321 322 322 323 324 324 325 325 326 326 328 328 328 329 329 330 330 330 331 331 332 332 333 333 334 335 335 336 338 338 338 338 339 340 341 341 343 343 344 345 345 346 346 346 347 348 348 349 349 349 350 350
Chapter 27. CICS support for printing . . . . . Formatting for CICS printers . . . . . . . . . CICS 3270 printers . . . . . . . . . . . . . CICS 3270 printer options . . . . . . . . . . PRINT option and print control bit . . . . . . ERASE option. . . . . . . . . . . . . . Line width options: L40, L64, L80, and HONEOM. NLEOM option . . . . . . . . . . . . . FORMFEED . . . . . . . . . . . . . . PRINTERCOMP option . . . . . . . . . . Non-3270 CICS printers . . . . . . . . . . . SCS input . . . . . . . . . . . . . . . Determining the characteristics of a CICS printer . . BMS page size, 3270 printers . . . . . . . . Supporting multiple printer types . . . . . . . Using CICS printers . . . . . . . . . . . .
Printing with a START command . . . Printing with transient data . . . . . Printing with BMS routing . . . . . Using Non-CICS printers . . . . . . . Formatting for non-CICS printers . . . Non-CICS printers: Delivering the data. Programming for non-CICS printers . . Notifying the print application . . . . Printing display screens . . . . . . . CICS print key . . . . . . . . . ISSUE PRINT and ISSUE COPY. . . Hardware print key . . . . . . . . BMS screen copy . . . . . . . . Chapter 28. CICS interface to JES Using the CICS interface to JES . . Spool interface restrictions . . . Creating output spool files . . . . Using the MVS internal reader. . Reading input spool files . . . . . JES exits . . . . . . . . . Identifying spool files . . . . . . Examples of SPOOL commands . . COBOL . . . . . . . . . . PL/I . . . . . . . . . . . C . . . . . . . . . . . . ASSEMBLER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
350 351 352 353 353 353 353 355 355 355 356 356 357 359 361 361 361 362 362 363 363 367 367 368 368 369
Chapter 29. CICS intercommunication . . . . . . . . . . . . . Design considerations . . . . . . . . . . . . . . . . . . . . Programming language . . . . . . . . . . . . . . . . . . Transaction routing . . . . . . . . . . . . . . . . . . . . . Function shipping . . . . . . . . . . . . . . . . . . . . . Distributed program link (DPL). . . . . . . . . . . . . . . . . Using the distributed program link function . . . . . . . . . . . Examples of distributed program link . . . . . . . . . . . . . Programming considerations for distributed program link . . . . . . Asynchronous processing . . . . . . . . . . . . . . . . . . Distributed transaction processing (DTP) . . . . . . . . . . . . . Common Programming Interface Communications (CPI Communications) External CICS interface (EXCI) . . . . . . . . . . . . . . . .
371 371 372 372 372 373 374 376 381 385 385 385 . . 386
Chapter 31. Creating the map Defining map fields: DFHMDF . Defining the map: DFHMDI . . Defining the map set: DFHMSD Writing BMS macros . . . .
Contents
xi
Assembling the map . . . . . . . . . . Physical and symbolic map sets . . . . . The SDF II alternative . . . . . . . . . Grouping maps into map sets . . . . . . The Application Data Structure (ADS) . . . Using complex fields . . . . . . . . . . Composite fields: the GRPNAME option . . Repeated fields: the OCCURS option . . . Block data . . . . . . . . . . . . . . Support for non-3270 terminals . . . . . . Output considerations for non-3270 devices . Differences on input . . . . . . . . . Special options for non-3270 terminals. . . Device-dependent maps . . . . . . . . . Device dependent support: DDS . . . . . Finding out about your terminal . . . . . Chapter 32. Sending BMS mapped output Acquiring and defining storage for the maps. BASE and STORAGE options . . . . . Initializing the output map . . . . . . . Moving the variable data to the map . . . Setting the display characteristics . . . . Changing the attributes . . . . . . . Attribute value definitions: DFHBMSCA . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
405 405 406 406 406 407 407 408 409 410 410 411 411 412 413 416 417 417 418 418 419 419 420 421 423 423 424 424 424 425 425 425 426 426 426 427 428 428 429 429 430 433 433 435 436 436 437 438 438 439 439 439 440
Chapter 33. Using the SEND MAP command . . . . SEND MAP control options . . . . . . . . . . . . Other BMS SEND options: WAIT and LAST . . . . . Merging the symbolic and physical maps . . . . . . . MAPONLY option . . . . . . . . . . . . . . DATAONLY option . . . . . . . . . . . . . . The SEND CONTROL command . . . . . . . . . Building the output screen . . . . . . . . . . . . What you start with . . . . . . . . . . . . . . What is sent . . . . . . . . . . . . . . . . Where the values come from . . . . . . . . . . Outside the map . . . . . . . . . . . . . . . Using GDDM and BMS . . . . . . . . . . . . Positioning the cursor . . . . . . . . . . . . . . Sending invalid data and other errors . . . . . . . . Output disposition options: TERMINAL, SET, and PAGING Using SET . . . . . . . . . . . . . . . . . Chapter 34. Receiving mapped data . An input-output example . . . . . . The symbolic input map . . . . . Programming mapped input. . . . . Using the RECEIVE MAP command . Getting storage for mapped input. . . Formatted screen input . . . . . . Modified data . . . . . . . . . Upper case translation . . . . . Using the attention identifier . . . . Using the HANDLE AID command . Finding the cursor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
xii
Processing the mapped input . . . . . . Handling input errors . . . . . . . . . Flagging errors . . . . . . . . . . Saving the good input . . . . . . . . Rechecking. . . . . . . . . . . . Sending mapped output after mapped input . MAPFAIL and other exceptional conditions . EOC condition. . . . . . . . . . . Formatting other input . . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
440 441 441 442 443 443 444 445 445 447 447 448 448 449 450 451 453 453 454 455 457 457 457 457 458 461 461 461 462 463 463 465 467 467 468 468 469 469 470 471 472 472 473 473 473 474 474 475 475 476 477
Chapter 35. BMS logical messages . . . . Building logical messages . . . . . . . . The SEND PAGE command . . . . . . . RETAIN and RELEASE . . . . . . . . . The AUTOPAGE option . . . . . . . . . Terminal operator paging: the CSPG transaction Logical message recovery . . . . . . . .
Chapter 36. Cumulative output the ACCUM option Floating maps: how BMS places maps using ACCUM . Page breaks: BMS overflow processing . . . . . . Map placement rules . . . . . . . . . . . . . ASSIGN options for cumulative processing . . . . Input from a composite screen. . . . . . . . . . Performance considerations. . . . . . . . . . . Minimizing path length. . . . . . . . . . . . Reducing message lengths . . . . . . . . . . Chapter 37. Text output. . . . The SEND TEXT command. . . Text logical messages . . . . Text pages . . . . . . . . . Text lines . . . . . . . . . Header and trailer format. . . . SEND TEXT MAPPED and SEND . . . . . . . . . . . . TEXT . . . . . . . . . . . . . . . . . . . . . . . . NOEDIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Chapter 38. Message routing . . . . . . . . Message destinations . . . . . . . . . . . . Eligible terminals. . . . . . . . . . . . . Destinations specified with OPCLASS only . . . OPCLASS and LIST omitted . . . . . . . . Route list provided . . . . . . . . . . . . Route list format . . . . . . . . . . . . . . Message delivery . . . . . . . . . . . . . Undeliverable messages . . . . . . . . . . Recoverable messages . . . . . . . . . . . Message identification . . . . . . . . . . . Programming considerations with routing . . . . . Routing and page overflow . . . . . . . . . Routing with SET . . . . . . . . . . . . Interleaving a conversation with message routing . Chapter 39. The MAPPINGDEV facility . . . SEND MAP with the MAPPINGDEV option . . RECEIVE MAP with the MAPPINGDEV option . Sample assembler MAPPINGDEV application . . . . . . . . .
Contents
xiii
Chapter 40. Partition support . . . . . . Uses for partitioned screens . . . . . . . Scrolling . . . . . . . . . . . . . . Data entry . . . . . . . . . . . . . Lookaside . . . . . . . . . . . . . Data comparison. . . . . . . . . . . Error messages . . . . . . . . . . . Partition definition . . . . . . . . . . . 3290 character size. . . . . . . . . . Establishing partitioning . . . . . . . . . Partition options for BMS SEND commands . . Determining the active partition . . . . . Partition options for BMS RECEIVE commands ASSIGN options for partitions . . . . . . Partitions and logical messages . . . . . . Partitions and routing . . . . . . . . . Attention identifiers and exception conditions . Terminal sharing . . . . . . . . . . . . Chapter 41. Support for special hardware . Logical device components . . . . . . . . Defining logical device components . . . . Sending data to a logical device component. LDCs and logical messages . . . . . . LDCs and routing . . . . . . . . . . 10/63 magnetic slot reader . . . . . . . . Field selection features . . . . . . . . . Trigger field support . . . . . . . . . Cursor and pen-detectable fields . . . . . . Selection fields . . . . . . . . . . . Attention fields . . . . . . . . . . . BMS input from detectable fields . . . . . Outboard formatting . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
479 480 480 480 480 481 481 481 482 482 483 483 484 484 484 485 485 486 487 487 487 488 488 488 489 489 489 490 491 491 491 492
Chapter 45. Storage control . . . . . . . . . . . . . . . . . . . 517 Overview of CICS storage protection and transaction isolation . . . . . . . 518
xiv
Storage protection . . . . . . . . . . . . . Transaction isolation . . . . . . . . . . . . Defining the storage key for applications . . . . . . System-wide storage areas . . . . . . . . . . Task lifetime storage . . . . . . . . . . . . Program working storage specifically for exit and PLT Passing data by a COMMAREA . . . . . . . . The GETMAIN command . . . . . . . . . . Selecting the execution and storage key . . . . . . User-key applications . . . . . . . . . . . . CICS-key applications . . . . . . . . . . . . Using transaction isolation . . . . . . . . . . . MVS subspaces . . . . . . . . . . . . . . . Subspaces and basespaces for transactions . . . The common subspace and shared storage . . . . Chapter 46. Transient data control Intrapartition transient data queues . Extrapartition queues . . . . . . Indirect queues . . . . . . . . Automatic transaction initiation (ATI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
518 519 520 521 521 521 521 522 523 524 524 527 529 529 530 533 533 534 534 535
Chapter 47. Temporary storage control . . . . . . . . . . . . . . 537 Temporary storage queues . . . . . . . . . . . . . . . . . . . . 537 Typical uses of temporary storage control . . . . . . . . . . . . . . 538
Chapter 50. Temporary storage browse (CEBR) Using the CEBR transaction . . . . . . . . What does the CEBR transaction display? . . . The header . . . . . . . . . . . . . . The command area . . . . . . . . . . .
Contents
xv
The body . . . . . . . . . . . The message line . . . . . . . . Using the CEBR function keys. . . . . Using the CEBR commands . . . . . Using the CEBR transaction with transient
. . . . . . . . data
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
573 573 573 574 576 579 579 579 580 582 583 583 584 585 586 586 586 588 588 589 590 590 590 590 591 591
Chapter 51. Command-level interpreter (CECI) . What does CECI display? . . . . . . . . . The command line . . . . . . . . . . . The status line . . . . . . . . . . . . The body . . . . . . . . . . . . . . The message line . . . . . . . . . . . CECI options on function keys. . . . . . . Using CECI. . . . . . . . . . . . . . . Making changes . . . . . . . . . . . . Using the CECI function keys . . . . . . . . Expanded area . . . . . . . . . . . . Variables. . . . . . . . . . . . . . . The EXEC interface block (EIB) . . . . . . Error messages display . . . . . . . . . Saving commands . . . . . . . . . . . . How CECI runs . . . . . . . . . . . . . CECI sessions . . . . . . . . . . . . Abends . . . . . . . . . . . . . . . Exception conditions . . . . . . . . . . Program control commands . . . . . . . . Terminal sharing . . . . . . . . . . . .
Bibliography . . . . . . . . . . . . . . . . CICS Transaction Server for z/OS . . . . . . . . CICS books for CICS Transaction Server for z/OS . CICSPlex SM books for CICS Transaction Server for Other CICS books . . . . . . . . . . . . . Books from related libraries . . . . . . . . . . . DL/I . . . . . . . . . . . . . . . . . . MVS . . . . . . . . . . . . . . . . . . DB2 . . . . . . . . . . . . . . . . . .
. . . . . . z/OS . . . . . . . . . .
xvi
Screen definition facility II (SDF II) . . . . . . . . Common programming interface . . . . . . . . . Common user access . . . . . . . . . . . . . Programming languages . . . . . . . . . . . . Teleprocessing Network Simulator (TPNS) . . . . . Distributed Processing Programming Executive (DPPX): Language Environment: . . . . . . . . . . . . Miscellaneous books . . . . . . . . . . . . . Determining if a publication is current . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613 Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . 631 Trademarks. . . . . . . . . . . . . . . . . . . . . . . . . . 632 Sending your comments to IBM . . . . . . . . . . . . . . . . . 633
Contents
xvii
xviii
Preface
What this book is about
This book gives guidance about the development of procedural application programs that use the CICS EXEC application programming interface to access CICS services and resources; it complements the reference information in the CICS Application Programming Reference manual. For guidance information on debugging such CICS applications, see the CICS Problem Determination Guide. 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.
Notes on terminology
API ASM MVS refers to the CICS command-level application programming interface unless otherwise stated. is sometimes used as the abbreviation for assembler language. 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). 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 X5B. 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.
VTAM
xix
Guidance for usage of the EXEC CICS WEB commands is not discussed in this book. See the CICS Internet Guide for this information. 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.
xx
Summary of changes
Changes for CICS Transaction Server for z/OS Version 2 Release 1
The following new function has been added: v Support for an integrated translator. Some compilers can now interpret CICS commands and translate them without the need for a separate translation step, see The integrated CICS translator on page 67. 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 6. 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 Java Applications in CICS, 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 129, from application design for performance, see Chapter 12. Design for performance on page 147. 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.
xxi
xxii
| | | | | |
Chapter 3. Programming in COBOL . . . . . Using based addressing with COBOL . . . . . Using WITH DEBUGGING MODE . . . . . COBOL programming restrictions . . . . . . Restrictions for 31-bit addressing . . . . . Using the DL/I CALL interface . . . . . . Mixing languages . . . . . . . . . . . . Calling subprograms from COBOL. . . . . . Using COBOL with the ANSI 85 standard . . . Literals intervening in blank lines . . . . . Separate Translator action. . . . . . . Integrated translator action . . . . . . Sequence numbers containing any character . Separate Translator action. . . . . . . Integrated translator action . . . . . . REPLACE statement. . . . . . . . . . Separate translator action . . . . . . . Integrated Translator action . . . . . . Batch compilation . . . . . . . . . . . Translator action . . . . . . . . . . Compiler and linkage editor . . . . . . Nested programs . . . . . . . . . . . Integrated CICS translator . . . . . . . Translator action . . . . . . . . . . Reference modification . . . . . . . . . Translator action . . . . . . . . . . Global variables . . . . . . . . . . . Translator action . . . . . . . . . . Comma and semicolon as delimiters . . . . Translator action . . . . . . . . . . Symbolic character definition . . . . . . . Translator action . . . . . . . . . . Summary of ANS185 restrictions . . . . . Using the COBOL2 translator option . . . . . Translator action . . . . . . . . . . . Using the COBOL3 translator option . . . . . Translator action . . . . . . . . . . . Using the OO COBOL translator option . . . . Translator action . . . . . . . . . . . Nesting programs . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . 9 . . . 9 . . . 10 . . . 10 . . . 12 . . . 12 . . . 13 . . . 14 . . . 18 . . . 19 . . . 19 . . . 19 . . . 19 . . . 19 . . . 20 . . . 20 . . . 20 . . . 20 . . . 20 . . . 20 . . . 20 . . . 22 . . . 23 . . . 23 . . . 27 . . . 27 . . . 27 . . . 27 . . . 27 . . . 27 . . . 27 . . . 28 . . . 28 . . . 28 . . . 28 . . . 29 . . . 29 . . . 29 . . . 30 . . . 30
C and C++ programming restrictions Passing arguments in C or C++. . Accessing the EIB. . . . . . . Naming EIB fields . . . . . . Data types in EIB fields . . . Using Locale support . . . . . Programming in C++ . . . . . . Restrictions . . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
32 34 36 36 36 37 37 37
Chapter 5. Programming in PL/I . . . . . . . . . . . . . . . . . . 39 PL/I programming restrictions . . . . . . . . . . . . . . . . . . . 39 Using PL/I and dynamic storage . . . . . . . . . . . . . . . . . . 40 Chapter 6. Programming in Assembler . . . . . . . . . . . . . . . 43 Calling Assembler programs . . . . . . . . . . . . . . . . . . . . 44 Chapter 7. Language Environment . . . . . . . . . . Levels of support in Language Environment . . . . . . . Language Environment services . . . . . . . . . . . Using Language Environment Abend-handling . . . . . . User-written LE condition handlers. . . . . . . . . . Managing Language Environment storage . . . . . . . . Using C/C++ applications with Language Environment . . . Using COBOL applications with Language Environment . . . Using PL/I applications with Language Environment . . . . Using Assembler applications with Language Environment . . Mixing languages in Language Environment . . . . . . . Using Dynamic Link Libraries and Language Environment . . Defining run-time options for Language Environment . . . . Run-time options in child enclaves. . . . . . . . . . CEEBXITA coding . . . . . . . . . . . . . . . . Determining which options were used . . . . . . . . Writing a CEEBINT initialization exit for Language Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 47 48 49 50 50 51 52 54 55 57 59 60 61 61 62 62
| | | | | | | | | | | | | | | | | | Task
You run a transaction by submitting its TRANSID to CICS. CICS uses the information recorded in the TRANSACTION definition to establish the correct execution environment, and starts the first program. 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 non-CICS documentation. You will also see the word task used extensively in CICS documentation. This word also has a specific meaning in CICS. When CICS receives a request to run a transaction, it starts a new task that is associated with this one instance of the execution of the transaction. type. That is, one execution of a transaction, with a particular set of data, usually on behalf of a particular user at a particular terminal. You can also consider it as analogous to a thread.. When the transaction completes, the task is terminated.
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
any of the CICS fields as arguments in CICS commands, because these fields may be altered by the EXEC interface modules.
Translation
Most the 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 separate translator on page 73 explains how to specify options, and Defining translator options on page 74 defines the options available.
| | | | | | | | | | | | | | | | | | | |
2. Write your program in the language of your choice, including EXEC CICS commands to request CICS services. See the CICS Application Programming Reference for a list of CICS commands. 3. If you are using a compiler that incorporates The integrated CICS translator on page 67, you will only need to compile your program, and then install it in CICS, using the process described in Program installation roadmap on page 89. Otherwise, you will need to define translator options for your program, using the process described in Using a separate translator on page 73, and then translate and compile your program, and install it in CICS, using the process described in Program installation roadmap on page 89. 4. Define your program and related transaction to CICS with PROGRAM and TRANSACTION resource definition statements and the CEDA transaction described in the CICS Resource Definition Guide . 5. Define any CICS resources that your program uses, such as files, queues or terminals. 6. Make the resources known to CICS using the CEDA INSTALL command described in the CICS Resource Definition Guide. 7. Run your program, by entering the transaction identifier at a CICS terminal, or by using any of the methods described in the CICS External Interfaces Guide and the CICS Internet Guide.
COBOL provides a simple method of obtaining addressability to the data areas defined in the LINKAGE SECTION using pointer variables and the ADDRESS special register. Figure 1 gives an example of this. 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 option of any command in ADDRESS mode. These commands include GETMAIN, LOAD, READ, and READQ. For programming information, including a complete list of these commands, see the CICS Application Programming Reference manual. Figure 1 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.
10
restrictions. How to use and create installation-specific COBOL reserved word tables is documented in the VS COBOL II Installation and Customization for MVS, and COBOL for OS/390 & VM Customization under OS/390 manuals. The following restrictions apply to a COBOL program that is to be used as a CICS application program. (See the appropriate COBOL programming guide for more information about these functions.) v If no IDENTIFICATION DIVISION is present, only the CICS commands are expanded. If the IDENTIFICATION DIVISION only is present, only DFHEIVAR, DFHEIBLK, and DFHCOMMAREA are produced. v Statements that produce variable-length areas, such as OCCURS DEPENDING ON, should be used with caution within the WORKING-STORAGE SECTION. v If you have any CICS applications written in COBOL, you may need to review the COBOL run-time options in use at your installation. In particular, if your applications are not coded to ensure that working storage is properly initialized (for example, cleared with binary zeros before sending maps), you should use the WSCLEAR run-time option. The default, as supplied in the COBOL module IGZEOPD (alias of IGZ9OPD) is NOWSCLEAR. The WSCLEAR function is included in VS COBOL II Version 1 Release 3 as supplied. For information about customizing run-time options, see the VS COBOL II Installation and Customization for MVS manual. v You cannot use entry points in COBOL in CICS. v When a debugging line is to be used as a comment, it must not contain any unmatched quotation marks. v Do not use COBOL statements that invoke operating system functions. Instead, use CICS commands. v Do not use EXEC CICS commands in a Declaratives Section. v You must use CICS commands for most input and output processing. Therefore, do not describe files or code any OPEN, CLOSE, READ, START, REWRITE, WRITE, or DELETE statements. Instead, use CICS commands to retrieve, update, insert, and delete data. v Do not use a format-1 ACCEPT statement in a CICS program. Some format-2 ACCEPT statements are supported by Language Environment enabled compilers. See Using COBOL applications with Language Environment on page 52 for more information about Language Environment. v Do not use DISPLAY . . . UPON CONSOLE and DISPLAY . . . UPON SYSPUNCH. DISPLAY to the system logical output device (SYSOUT, SYSLIST, SYSLST) is supported under CICS only by Language Environment enabled compilers. v Do not use STOP literal, where literal does not identify a contained subprogram. v There are restrictions on the use of the SORT statement. See the VS COBOL II Application Programming Guide or the COBOL for OS/390 & VM Programming Guide for information. Do not use MERGE. v Do not use: USE declaratives (except USE FOR DEBUGGING). You may specify USE FOR DEBUGGING, but it has no effect because the DEBUG LE option is ignored in CICS. ENVIRONMENT DIVISION and FILE SECTION entries associated with data management, because CICS handles data management
| | | | | | | | | | | | | |
11
| | | |
| | |
User-specified parameters to the main program v Do not use the following compiler options: DYNAM NOLIB (if program is to be translated) NORENT NORES TRUNC v The use of the FDUMP compiler option results in a very large increase in program size. Therefore, short-of-storage problems may occur when using this option. For more information about the FDUMP option, see the VS COBOL II Application Programming Guide or the COBOL3 Application Programming Guide. v Use TRUNC(OPT) for handling binary data items if they conform to the PICTURE definitions, otherwise use TRUNC(BIN). (TRUNC(STD) is the default and TRUNC(BIN) is slower.) v The length of working storage, plus 80 bytes for storage accounting and save areas, must not exceed 64KB when the COBOL compiler option DATA(24) is used. If, however, the compiler option DATA(31) is used, up to 128MB are available. v If the DLI option is specified and an ENTRY statement immediately follows the PROCEDURE DIVISION header, it is recommended that the ENTRY statement be terminated with a period (.). v VS COBOL II and PL/I application programs cannot be link-edited together. For further information about using COBOL with other languages, see the VS COBOL II Application Programming Guide. v The following compiler options have no effect in a CICS environment: ADV FASTSRT OUTDD v If you use HANDLE CONDITION or HANDLE AID, you can avoid addressing problems by using SET(ADDRESS OF A-DATA) or SET(A-POINTER) where A-DATA is a structure in the LINKAGE SECTION and A-POINTER is defined with the USAGE IS POINTER clause.
v Obtain the address of the required PCB from the address list in the UIB.
12
Figure 2 illustrates the whole of the above process. The example in the figure assumes that you have three PCBs defined in the PSB and want to use the second PCB in the database CALL. Therefore, when setting up the ADDRESS special register of the LINKAGE SECTION group item PCB, the program uses 2 to index the working-storage table, PCB-ADDRESS-LIST. To use the nth PCB, you use the number n to index PCB-ADDRESS-LIST.
WORKING-STORAGE SECTION. 77 PCB-CALL PIC X(4) VALUE 'PCB '. 77 GET-HOLD-UNIQUE PIC X(4) VALUE 'GHU '. 77 PSB-NAME PIC X(8) VALUE 'CBLPSB'. 77 SSA1 PIC X(40) VALUE SPACES. 01 DLI-IO-AREA. 02 DLI-IO-AREA1 PIC X(99). * LINKAGE SECTION. COPY DLIUIB. 01 OVERLAY-DLIUIB REDEFINES DLIUIB. 02 PCBADDR USAGE IS POINTER. 02 FILLER PIC XX. 01 PCB-ADDR-LIST. 02 PCB-ADDRESS-LIST USAGE IS POINTER OCCURS 10 TIMES. 01 PCB. 02 PCB-DBD-NAME PIC X(8). 02 PCB-SEG-LEVEL PIC XX. 02 PCB-STATUS-CODE PIC XX. * PROCEDURE DIVISION. *SCHEDULE THE PSB AND ADDRESS THE UIB CALL 'CBLTDLI' USING PCB-CALL PSB-NAME ADDRESS OF DLIUIB. * *MOVE VALUE OF UIBPCBAL, ADDRESS OF PCB ADDRESS LIST (HELD IN UIB) *(REDEFINED AS PCBADDR, A POINTER VARIABLE), TO *ADDRESS SPECIAL REGISTER OF PCB-ADDR-LIST TO PCBADDR. SET ADDRESS OF PCB-ADDR-LIST TO PCBADDR. *MOVE VALUE OF SECOND ITEM IN PCB-ADDRESS-LIST TO ADDRESS SPECIAL *REGISTER OF PCB, DEFINED IN LINKAGE SECTION. SET ADDRESS OF PCB TO PCB-ADDRESS-LIST(2). *PERFORM DATABASE CALLS ...... ........ MOVE ........ TO SSA1. CALL 'CBLTDLI' USING GET-HOLD-UNIQUE PCB DLI-IO-AREA SSA1. *CHECK SUCCESS OF CALLS ....... IF UIBFCTR IS NOT EQUAL LOW-VALUES THEN ...... error diagnostic code ........ IF PCB-STATUS-CODE IS NOT EQUAL SPACES THEN ...... error diagnostic code ........
Mixing languages
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.
13
An LE (Language Environment) run-unit can support a mixture of language levels, but if you are not using LE, a COBOL run unit can contain only: v COBOL programs compiled with the same compiler v Assembler language routines A CICS transaction can consist of many run units, each of which can be at a different language level. This means that a single transaction can consist of programs compiled by different compilers (including non-COBOL compilers). | | | | | | VS COBOL II programs can call VS COBOL II or assembler programs dynamically or statically, but programs compiled by different compilers can communicate with each other only using LINK or XCTL commands. COBOL for MVS & VM and later compilers can call any language programs statically or dynamically; LINK or XCTL are not required for inter-language communication.
In the first form, the called subprogram is explicitly named as a nonnumeric literal within quotation marks. In the second form, name refers to the COBOL data area with length equal to that required for the name of the subprogram. Static COBOL call The calling program contains a COBOL statement of the form:
CALL 'subpgname'
The called subprogram is explicitly named as a literal string. Dynamic COBOL call The calling program contains a COBOL statement of the form:
CALL identifier
The identifier is the name of a COBOL data area that must contain the name of the called subprogram. Table 1 on page 15 gives the rules governing the use of the three ways to call a subprogram. This table 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 18 shows logical levels and the effect of RETURN commands and CALL statements in linked and called programs. The term run unit, used in Figure 3 on page 18, is defined under the heading Mixing languages on page 13. When control is passed by a XCTL command, the
14
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 Table 1 refer to the separate translator. This step is not required if a compiler with an integrated translator is used.
Table 1. Rules governing methods of calling subprograms LINK Translation The linked subprogram must be translated if it, or any subprogram invoked from it, contains CICS function. The linked subprogram must be compiled and link-edited as a separate program. Static COBOL CALL 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). 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. 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.
Link-editing (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.)
CICS system definition data set (CSD) entries without program autoinstall (If you use program autoinstall, you do not need an entry in the CSD.)
The linked subprogram must be defined using RDO. If the linked subprogram is unknown or unavailable, even though autoinstall is active, the LINK fails with the PGMIDERR condition.
The calling program must be defined in the CSD. If program A calls program B and then program B attempts to call program A, COBOL issues a message and an abend (1015). The subprogram is part of the calling program so no CSD entry is required. The called subprogram must be defined in the CSD. If the called subprogram cannot be loaded or is unavailable even though autoinstall is active, COBOL issues a message and abends (1029).
The linked subprogram must return using either RETURN or the COBOL statement GOBACK. Any language supported by CICS.
The called subprogram must return using the COBOL statement GOBACK or EXIT PROGRAM. The use of RETURN in the called subprogram terminates the calling program. COBOL or assembler language.
15
Table 1. Rules governing methods of calling subprograms (continued) LINK Contents of called or linked subprogram Static COBOL CALL Dynamic COBOL CALL
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.
Passing parameters Data can be passed by any of the standard CICS methods to the subprogram (COMMAREA, TWA, TCTUA, TS queues) if the called or linked subprogram is processed by the CICS translator. If the COMMAREA is used, its address must be passed in the LINK command. If the linked subprogram uses 24-bit addressing, and the COMMAREA is above the 16MB line, CICS copies it to below the 16MB line, and recopies it on return. The CALL statement may pass DFHEIBLK and DFHCOMMAREA as the first two parameters, if the called program is to issue EXEC CICS requests, or the called program can issue EXEC CICS ADDRESS commands. The COMMAREA is optional but if other parameters are passed, a dummy commarea must also be passed. The rules for nested programs can be different. See Nestingwhat the application programmer must do on page 24. If the called subprogram uses 24-bit addressing and any parameter is above the 16MB line, COBOL issues a message and abends (1033). See the VS COBOL II Application Programming Debugging manual for information about this abend code.
Storage
On each entry to the linked subprogram, a new initialized copy of its working storage is provided, and the run unit is reinitialized (in some circumstances, this can cause a performance degradation).
On the first entry to the called subprogram within a CICS logical level, a new initialized copy of its working storage is provided. On subsequent entries to the called subprogram at the same logical level, the same WORKING STORAGE is provided in its last-used state, that is, no storage is freed, acquired, or initialized. If performance is unsatisfactory with LINK commands, COBOL calls may give improved results.
16
Table 1. Rules governing methods of calling subprograms (continued) LINK CICS condition/AID On entry to the called and abend handling subprogram, no abend or condition handling is active. Within the subprogram, the normal CICS rules apply. In order to establish an abend or condition handling environment, that exists for the duration of the subprogram, a new HANDLE command should be issued on entry to the subprogram. The environment so created remains in effect until either a further HANDLE command is issued, or the subprogram returns control to the caller. Static COBOL CALL Dynamic COBOL CALL If the dynamic COBOL CALL fails, CICS abend handling is not invoked, and you may get a COBOL abend code (1013). For COBOL calls without Language Environment/370 and COBOL calls with Language Environment/370 and CBLPSHPOP ON: On entry to the called subprogram, no abend or condition handling is active. Within the subprogram, the normal CICS rules apply. On entry to the called subprogram, COBOL issues a PUSH HANDLE to stack the calling programs condition or abend handlers. In order to establish an abend or condition handling environment that exists for the duration of the subprogram, a new HANDLE command should be issued on entry to the subprogram. The environment that this creates remains in effect until either a further HANDLE command is issued or the subprogram returns control to the caller. When control is returned to the calling program from the subprogram, COBOL unstacks the condition and abend handlers using a POP HANDLE. For COBOL calls with Language Environment/370 and CBLPSHPOP OFF: The condition/AID and abend handling for the calling program remain in effect. Location of called or linked program Can be remote. Must be local. Must be local.
17
CICS
Level 0
Run Unit A
Program U GOBACK ... STOP RUN ... EXEC CICS RETURN ... CALL ... ... ... EXEC CICS LINK ...
Level 1
Run Unit B
Program W GOBACK ... STOP RUN ... EXEC CICS RETURN ... CALL ... ... ... EXEC CICS XCTL ...
Run Unit C
Program Y CALL ... ... GOBACK ... STOP RUN ... EXEC CICS RETURN
Figure 3. Flow of control between COBOL programs, run units, and CICS
18
The 1985 COBOL rules that affect the separate translator are: v Literals intervening in blank lines v Sequence numbers containing any character v Lower-case characters supported in all COBOL words v REPLACE statement v Batch compilation v Nested programs v Reference modification v Global variables v Interchangeability of comma, semicolon, and space v Symbolic character definition If a standard is not fully supported by the translator, a programming restriction applies. The 1985 COBOL rules are described under their appropriate headings, and each description is followed by a Separate Translator action. Summary of ANS185 restrictions on page 28 summarizes this information. The translator actions assume that you have specified the ANSI85 translator option. The term unit of compilation means a section of source input from which the compiler produces a single object program. A unit of compilation can contain a program and other programs nested within it.
19
| | | | |
REPLACE statement
COBOL programs can include the REPLACE statement, which allows the replacement of identified text by defined substitution text. The text to be replaced and inserted is specified as in the REPLACING option of the COPY statement, and can be pseudo-text, an identifier, a literal, or a COBOL word. REPLACE statements are processed after COPY statements.
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 according to the ANSI85 standard. 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 specified in the CBL or PROCESS card that initiates the unit 2. Options specified when the translator is invoked 3. Default options For more information about compilation, see the Chapter 9. Installing application programs on page 89.
20
to include the stub at the start of each load module. These statements can be anywhere in the module, though by convention they are at the start. You may find it convenient to place them at the end of the module, immediately before each NAME statement. Figure 5 on page 22 shows the output from Figure 4 after editing in this way. For batch compilation you must vary the procedure described in the Chapter 9. Installing application programs on page 89. The following is a suggested method: 1. Split the supplied cataloged procedure DFHEITCL into two procedures; PROC1 containing the translate and compilation steps (TRN and COB), and PROC2 containing the linkage editor step LKED. 2. In PROC1, add the NAME option to the parameters in the EXEC statement for the compiler, which then looks like this:
//COB // // EXEC PGM=IGYCRCTL, PARM='....,NAME,....', REGION=1024K
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 22. 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. Note: For Language Environment/370 applications, a different COBOL stub should be used and the order statement in Figure 5 on page 22 should be changed. The new sequence of statements reads as follows:
INCLUDE SDFHCOB(DFHELII) ORDER DFHELII NAME PROGA(R)
To use the new stub, the procedure DFHEITCL (DFHEITVL for COBOL users) should be changed. The line that reads STUB=DFHEILIC should be changed to STUB=DFHEILID and the line LIB=SDFHCOB should be changed to LIB=SDFHC370. An alternative method would be to specify
Chapter 3. Programming in COBOL
21
STUB=DFHEILID when invoking the procedure to include DFHELII. This can be done by passing the stub value as a parameter when invoking the procedure as follows:
// EXEC PROC=DFHEITCL
or
// EXEC PROC=DFHEITCL,STUB=DFHEILID,LIB=SDFHC370
6. In PROC2, add a DD statement for the library that includes the CICS stub. The standard name of this library is CICSTS21.CICS.SDFHCOB. The INCLUDE statement for the stub refers to this library by the DD name. In Figure 5, it is assumed you have used the DD name SDFHCOB. The suggested statement is:
//SDFHCOB DD DSN=CICSTS21.CICS.SDFHCOB, // DISP=SHR
In this statement it is assumed that you have renamed the compiler output data set LOADSET. 8. Run PROC2.
....program a.... ................. INCLUDE SDFHCOB(DFHECI) ORDER DFHECI NAME PROGA(R) ................. ................. ....program b.... ................. ................. INCLUDE SDFHCOB(DFHECI) ORDER DFHECI NAME PROGB(R) ................. ....program c.... ................. INCLUDE SDFHCOB(DFHECI) ORDER DFHECI NAME PROGC(R)
Nested programs
Under the ANSI85 standard: 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.
22
For an explanation of valid calls to nested programs and of the COMMON attribute of a nested program, see the VS COBOL II Application Programming Guide. | | | | | | | | | |
Translator action
The translator treats top-level and nested programs differently. The translator translates a top-level program (a program that is not contained by any other program) in the normal way, with one addition. The translator uses the GLOBAL storage class for all translator-generated variables in the WORKING-STORAGE SECTION. The translator translates nested or contained programs in a special way as follows: v A DATA DIVISION and LINKAGE SECTION are added if they do not already exist. v Declarations for DFHEIBLK (EXEC interface block) and DFHCOMMAREA (communication area) are inserted into the LINKAGE SECTION. v EXEC CICS commands and CICS built-in functions are translated. v The PROCEDURE DIVISION statement is not modified. v No translator-generated temporary variables, used for pre-call assignments, are inserted in the WORKING-STORAGE SECTION. Recognition of nested programs: If the ANSI85 option is specified, the translator interprets that the input source starts with a top-level program if the first noncomment 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. Positioning of comments: The translator treats comments that follow an END PROGRAM statement as belonging to the next program in the input source. Comments that precede an IDENTIFICATION DIVISION statement appear in the listing after the IDENTIFICATION DIVISION statement.
Chapter 3. Programming in COBOL
23
To avoid confusion always place comments: v After the IDENTIFICATION DIVISION statement that initiates the program to which they refer and v Before the END PROGRAM statement that terminates the program to which they refer. Nestingwhat the application programmer must do: 1. Submit a top-level containing program and all its directly and indirectly contained programs as a single unit of compilation. 2. In each nested program that contains EXEC CICS commands, CICS built-in functions, or references to the EIB or COMMAREA, code DFHEIBLK and DFHCOMMAREA as the first two parameters of the PROCEDURE DIVISION statement as follows:
PROCEDURE DIVISION USING DFHEIBLK DFHCOMMAREA PARM1 PARM2 ...
3. In every call to a nested program that contains EXEC CICS commands, CICS built-in functions, or references to the EIB or COMMAREA, code DFHEIBLK and DFHCOMMAREA as the first two parameters of the CALL statement as follows:
CALL 'PROGA' USING DFHEIBLK DFHCOMMAREA PARM1 PARM2 ...
4. For every call that forms part of the control hierarchy between the top-level program and a nested program that contains EXEC CICS commands, CICS built-in functions, or references to the EIB or COMMAREA, code DFHEIBLK and COMMAREA as the first two parameters of the CALL For a PROCEDURE DIVISION statements in the calling and called programs respectively code DFHEIBLK and DFHCOMMAREA. This is necessary to allow addressability to the EIB and COMMAREA to be passed to programs not directly contained by the top-level program. 5. If it is not necessary to insert DFHEIBLK and DFHCOMMAREA in the PROCEDURE DIVISION of a nested program for any of the reasons given above (2, 3, and 4), calls to that program should not include DFHEIBLK and COMMAREA in the parameter list of the CALL statement. An example of a nested program: A unit of compilation (see Figure 6 on page 25) consists of a top-level program W and three nested programs, X, Y, and Z, all directly contained by W. Program W During initialization and termination, calls Y and Z to do initial CICS processing and non-CICS file access. Calls X to do main processing. Program X Calls Z for non-CICS file access and Y for CICS processing. Program Y Issues CICS commands. Calls Z for non-CICS file access. Program Z Accesses files in batch mode.
24
PROGRAM W
PROGRAM X
PROGRAM Y
PROGRAM Z
Applying the rules: v Y must be COMMON to enable a call from X. v Z must be COMMON to enable calls from X and Y. v Y issues CICS commands, therefore: All calls to Y must have DFHEIBLK and a COMMAREA as the first two parameters. Ys PROCEDURE DIVISION statement must have DFHEIBLK and DFHCOMMAREA as the first two parameters. v Though X does not access the EIB or the communication area, it calls Y, which issues CICS commands. Therefore the call to X must have DFHEIBLK and a COMMAREA as the first two parameters and Xs PROCEDURE DIVISION statement must have DFHEIBLK and DFHCOMMAREA as its first two parameters. Figure 7 on page 26 illustrates the points in Nestingwhat the application programmer must do on page 24.
25
. . .
. . .
. . .
. . . . . .
CALL Z.
. . .
. . .
. . . . . . . . .
CALL Z.
. . .
26
. . .
Reference modification
Reference modification supports a method of referencing a substring of a character data item by specifying the starting (leftmost) position of the substring in the data item and, optionally the length of the substring. The acceptable formats are:
data-name (starting-position:) data-name (starting-position: length)
Data-name can be subscripted or qualified or both. Both starting-position and length can be arithmetic expressions.
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. Note: If a CICS command uses reference modification in defining a data value, it must include a LENGTH option to specify the data length. Otherwise the translator generates a COBOL call with a LENGTH register reference in the form:
LENGTH OF (reference modification)
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 23) 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.
27
Translator action
The translator accepts the use of symbolic characters as specified in the standard. 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
The translator listing and output preserve the case of COBOL text as entered. In addition, the translator accepts mixed case in: v Translator options v EXEC CICS commands, both for keywords and for arguments to keywords
28
(If the ANSI85 option is not specified, the translator expects COBOL words to consist entirely of upper-case characters.) Notes: 1. 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 should always be entered in the same case as the external definition. 2. CBL and PROCESS statements must be in upper case.
Translator action
The translator listing and output preserve the case of COBOL text as entered. In v v v v addition, the translator accepts mixed case in: Translator options EXEC CICS commands, both for keywords and for arguments to keywords CBL and PROCESS statements Compiler directives such as EJECT and SKIP1
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. | | If you specify the LINKAGE translator option, or allow it to default, a mixed-case version of the EIB structure (DFHEIBLC) is inserted into the LINKAGE SECTION.
29
Translator action
The translator listing and output preserve the case of COBOL text as entered. In v v v v addition, the translator accepts mixed case in: Translator options EXEC CICS commands, both for keywords and for arguments to keywords CBL and PROCESS statements Compiler directives such as EJECT and SKIP1
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 should always be entered in the same case as the external definition. | | If you specify the LINKAGE translator option, or allow it to default, a mixed-case version of the EIB structure (DFHEIBLC) is inserted into the LINKAGE SECTION. The translator considers each class to be a separate unit of compilation. The translator does not monitor correct use of syntax. It makes the following assumptions about a user program: v Classes and methods are correctly terminated. v A class encapsulates only methods. v Methods do not encapsulate anything else. v A unit of compilation contains either a class or a program. The translator rejects any EXEC statements that appear in the PROCEDURE DIVISION of a class. The translator checks that a DATA DIVISION statement and a WORKING STORAGE SECTION both exist in a class definition.
Nesting programs
For OO COBOL, use the DFHEIBLC copybook, which is a lower-case version of DFHEIBLK. Apart from case, DFHEIBLC is the same as DFHEIBLK in all other respects except that the top-level name is 01 dfheiblk. instead of 01 EIBLK.
30
31
Return codes On return from a C or C++ language application, any value passed by C or C++ by the exit function or the return statement is saved in EIBRESP2. Sample programs A set of sample application programs is provided in Table 2 to show how EXEC CICS commands can be used in a program written in the C or C++ language.
Table 2. Sample programs Sample program DFH$DMNU Operator instruction (3270) DFH$DALL Update (3270) DFH$DBRW Browse (3270) DFH$DREN Order entry (3270) DFH$DCOM Order entry queue print (3270) DFH$DREP Report (3270) Map set DFH$DGA DFH$DGB DFH$DGC DFH$DGK DFH$DGL DFH$DGD Map source DFH$DMA DFH$DMB DFH$DMC DFH$DMK DFH$DML DFH$DMD Transaction ID DMNU DINQ, DADD, DUPD DBRW DORD DORQ DREP
The transaction and program definitions are provided in group DFH$DFLA in the CSD and should be installed using the command:
CEDA INSTALL GROUP(DFH$DFLA)
The following record description files are provided as C or C++ language header files: DFH$DFILFILEA record descriptor DFH$DL86L860 record descriptor Data declarations The following data declarations are provided by CICS for C and C++: v Execution interface block definitions (EIB) v BMS screen attributes definitionsC and C++ versions of the DFHBMSCA, DFHMSRCA, and DFHAID files are supplied by CICS, and may be included by the application programmer when using BMS. v DL/I supporta C language version of DFHDIB is included by the DLI translator if the translator option has been specified. (You have to include DLIUIB if the CALL DLI interface is used.) 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++.
32
v C and C++ languages do not support packed decimal data. The application has access to packed decimal data using the character string data type. No C or C++ standard library functions are available to perform arithmetic on this data, but you may write your own. v You can easily use HOURS, MINUTES, and SECONDS options. You may define expiration times using TIME or INTERVAL options if you provide functions to handle them in your application. v You can enter all CICS keywords in mixed case, except for CICS keywords on #pragma directives, which must be in upper case only. v You must specify the LENGTH option from commands that support the LENGTH option (for example, READ, READNEXT, READPREV, and WRITE commands). v All native C and C++ functions are allowed in the source program, but the following functions are not recommended. Some are not executable and result in return codes or pointers indicating that the function has failed. Some may work but impact the performance or execution of CICS. CDUMP CSNAP CTEST CTRACE CLOCK CTDLI SVC99 SYSTEM SETLOCALE The following commands are supported only if you use a Language Environment (LE) conforming compiler: FETCH RELEASE For further information see the Users Guide. Native C or C++ functions are implemented in the C or C++ run-time library. Native C or C++ file operations operate only on files opened with type=memory specified. I/O to CICS-supported access methods must use the CICS API. The string handling functions in the C or C++ standard library use a null character as an end-of-string marker. Because CICS does not recognize a null as an end-of-string marker, you must take care when using C or C++ functions, for example strcmp, to operate on CICS data areas. Two arguments, argc and argv, are normally passed to a C or C++ main function. argc denotes how many variables have been passed; argv is an array of zero-terminated variable strings. In CICS, the value of argc is 1, argv[0] is the transaction ID, and argv[1] is NULL. Where CICS expects a fixed-length character string such as a program name, map name, or queue name, you must pad the literal with blanks up to the required length if it is shorter than expected. For EXEC DLI commands, the SEGMENT name is padded by the translator if a literal is passed. Take care not to use field names, which, though acceptable to the assembler compiler, cause the C or C++ compiler to abend. These include $, #, and @. See the relevant users guide for more information.
v v
33
v In C and C++ there is a STACK option with a 4KB default and suboptions of ANY and below. Additionally there are ANYHEAP (for heap storage above the 16MB line) and BELOWHEAP to control heap allocations. There is a heap manager that optimizes allocations.
Chapter 4. Programming in C and C++ on page 31 Passing arguments in C or C++ Accessing the EIB on page 36 Using Locale support on page 37 Programming in C++ on page 37
34
Table 3. Rules for passing values as arguments in EXEC CICS commands Data type Character literal Usage Data-value (S) Coding the argument The user must specify the character literal directly. The translator takes care of any required indirection. The user must specify a pointer to the variable, possibly by prefixing the variable name with &. The user must specify the character variable directly. The translator takes care of any required indirection. 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. Whether receiving or sending, the argument should be the name of the character array containing the stringthe address of the first element of the array. The user must specify a pointer to the variable, possibly by prefixing the variable name with &. The user must specify the name of the variable. The translator looks after any indirection that is required. The user must specify the integer constant directly. The translator takes care of any required indirection. The user must code the address of the start of the structure or union, possibly by prefixing its name with &.
Data-area (R)
Data-value (S)
Name (S)
Data-value (S)
Data-value (S)
Structure or union
35
Table 3. Rules for passing values as arguments in EXEC CICS commands (continued) Data type Array (of anything) Usage Data-area (R) Data-value (S) Coding the argument The translator does nothing. You must code the address of the first member of the array. This is normally done simply by coding the name of the array, which the compiler interprets as the address of the first member. Whether receiving or sending, the argument should be the name of the variable that denotes the address of interest. The translator takes care of the extra level of indirection that is necessary to allow CICS to update the pointer.
Note: (R) indicates Receiver, where data is being received from CICS; (S) indicates Sender, where data is being passed to CICS.
or by passing the EIB address or particular fields therein as arguments to the CALL statement that invokes the external procedure. If access to the EIB is required, an ADDRESS EIB command is required at the beginning of each application. This applies to any commands that include RESP or RESP2 options.
36
v Single-character fields are defined as unsigned char v Character strings are defined as unsigned char arrays
The presence of the pragma filetag implies that the program is compiled with the IBM C for MVS/ESA compiler. A comparison of some of the code-points and characters is shown below:
Table 4. C language codesets Character \ backslash } right brace { left brace # hash IBM-1047 E0 D0 C0 7B IBM-273 EC DC 43 7B
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 as Language Environment/370. See Chapter 7. Language Environment on page 47 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);
37
EXEC CICS SEND TEXT FROM(errmsg) LENGTH(msglen) /* Send error message to screen */ RESP(rcode) RESP2(rcode2);
38
39
The following commands are supported only if you use a Language Environment (LE) conforming compiler:
FETCH RELEASE
You are provided with EXEC CICS commands for the storage and retrieval of data, and for communication with terminals. (However, you can use CLOSE, PUT, and OPEN, for SYSPRINT.) Refer to the PL/I Optimizing Compiler Programmers Guide for more guidance information about when the use of these PL/I statements is necessary and the consequences of using them. v You cannot use PL/I Sort/Merge. v You cannot use static storage (except for read-only data). v If you declare a variable with the STATIC attribute and EXTERNAL attribute you should also include the INITIAL attribute. If you do not, such a declaration generates a common CSECT that cannot be handled by CICS. v You cannot use the PL/I 48-character set option in EXEC CICS statements. v Do not define variables or structures with variable names that are the same as variable names generated by the translator. These begin with DFH. Care must be taken with the LIKE keyword to avoid implicitly generating such variable names. v All PROCEDURE statements must be in upper case, with the exception of the PROCEDURE name, which may be in lower case. v The suboptions of the XOPTS option of the *PROCESS statement must be in upper case. v If a CICS command uses the SUBSTR built-in function in defining a data value, it must include a LENGTH option to specify the data length. If it does not, the translator generates a PL/I call including an invocation of the CSTG built-in function in the form:
CSTG(SUBSTR(..,..,..))
40
estimate this size, activate the REPORT option during the test phase. This option tells you if the ISA size is sufficient or if you need to perform GETMAIN operations during program processing. You can avoid this problem happening in an ESA AMODE(31) environment by coding your program as follows. Instead of making your biggest PL/I structures and arrays AUTOMATIC, define them as BASED on a POINTER variable, which you initialize using GETMAIN SET (pointer) FLENGTH(length). (Note that you must use FLENGTH instead of LENGTH.) For example, suppose you have a PL/I program with these arrays declared:
DCL A(10,10) FLOAT
and
DCL B(100,10) CHAR(100)
These arrays need 400 (that is, 10 x 10 x 4) and 100000 (that is, 100 x 10 x 100), respectively. You code your PL/I program as illustrated in Figure 8.
DCL (APOINTER, BPOINTER) DCL A(10,10) B(100,10) CSTG EXEC CICS GETMAIN SET(APOINTER) FLENGTH(CSTG(A)); EXEC CICS GETMAIN SET(BPOINTER) FLENGTH(CSTG(B)); POINTER; FLOAT BASED(APOINTER), CHAR(100) BASED(BPOINTER), BUILTIN;
This prevents a PL/I abend (APLG) occurring, and means that your program can use storage above the line that would otherwise have been needed below the line.
41
42
43
The assembler language program performs an EXEC CICS SEND TEXT command, which displays the message string passed from the PL/I program.
44
DSECT DS CL14 DS F CSECT L 5,8(1) L 5,0(5) MVC MSG,0(5) EXEC CICS SEND TEXT FROM(MSG) LENGTH(14) RESP(MYRESP) END
For this to work, first link edit the assembler language program, as follows: and then link the PL/I and assembler language programs together:
INCLUDE SYSLIB(DFHEAI) INCLUDE OBJECT NAME ASMTEST(R)
An assembler language application program that is called by another begins with the DFHEIENT macro and ends with the DFHEIRET macro. The CICS translator inserts these for you, so if the program contains EXEC CICS commands and is to be passed to the translator, as in the example just given, you do not need to code these macros.
45
46
47
Language Environment also provides macros that enable assembler programs to be fully-conforming and so take advantage of the facilities provided under Language Environment. For details of these macros, see the OS/390 Language Environment for OS/390 & VM Programming Guide. Compatibility support Language Environment also supports the execution of programs that are not compiled with Language Environment-conforming compilers and assembler programs that do not use the macros provided. Such programs are known as non-Language Environment-conforming. They do not have to be recompiled or re-link-edited to run correctly in what Language Environment defines as compatibility mode. However, few of the advantages of Language Environment are available to such programs. The language in the PROGRAM definition for non-conforming programs does not have to be Language Environment for the program to execute correctly. Specify either the actual language or no language. 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. The following are the non-Language Environment-conforming compilers supported: v C/370 V1 & V2 v AD/Cycle C/370 V1R1 v OS/VS COBOL v VS COBOL II v OS PL/I Version 1 Release 3.0 onwards v OS PL/I Version 2
48
National language support These allow you to customize Language Environment output (such as messages, RPTOPTS reports, RPTSTG reports, and dumps) for a given country. Locale These allow you to customize culturally-sensitive output for a given national language, country, and codeset by specifying a locale name. General These are a set of callable services that are not directly related to a specific Language Environment function, for example, dump. Mathematical These allow you to perform standard mathematical computations. With the exception of date and time services which may be dynamically called by VS COBOL II programs, these services are only available to Language Environment-conforming programs. For further information about the details of these services, see the OS/390 Language Environment for OS/390 & VM Programming Guide. For information about the syntax required to call any of the services, see the OS/390 Language Environment for OS/390 & VM 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-handlingfor details. Storage Language Environment uses storage obtained from CICS for each run-unit. See Managing Language Environment storage on page 50 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 run-time option for messages and the ddname given in the fname argument of the CEE3DMP service for dumps. CICS ignores both of these ddnames.
49
When a CICS HANDLE ABEND is not active, Language Environment condition handling does gain control for abends and program interrupts if the run-time option TRAP(ON) is specified. Normal Language Environment condition handling is then performed. If TRAP(OFF) is specified, no error handling takes place; the abend proceeds. For details of the actions taken during normal Language Environment condition handling, see the OS/390 Language Environment for OS/390 & VM Programming Guide.
50
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 issued. If more storage is required for RUWAs because of different or extra CICS links, CICS issues a GETMAIN and updates the history, so that next time the single GETMAIN (and FREEMAIN) is for the larger amount. For transactions that issue a large number of CICS LINK commands, the performance improvement can be considerable. If a program specifies a run-time option of ALL31(OFF) and Language Environment needs to use storage below the 16MB line, two areas of storage are allocated, one below 16MB and one above the 16MB line. If necessary, any application can obtain CICSDATAKEY or USERDATAKEY storage by using a CICS GETMAIN command. However, a program with an EXECKEY of USER cannot use CICSDATAKEY storage.
51
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. Return value If you terminate a C or C++ program with an exit() function or return statement instead of a CICS RETURN command, the value passed through the exit() function is saved in the EIBRESP2 field of the EIB on return from the program. Invoking CSP programs All C/C++ programs running under CICS must run with AMODE(31), RMODE(ANY). Consequently, when passing parameters to a program produced by the Cross-System Product (CSP) interactive application generator, you must either: v Pass parameters below 16MB, or v Re-link the CSP load library with AMODE(31).
52
environment that is established for a run unit by the compatibility library routines supports only OS/VS COBOL. This compatibility library does not contain many of the services normally offered under Language Environment. In particular: v Language Environment run-time options and callable services are not supported. v Only static calls are permitted, and only to other OS/VS COBOL-compiled programs and assembler programs. v The called program cannot contain CICS commands. Utilities for re-linking If object modules are not available for re-linking existing COBOL programs to run under Language Environment, three sample jobs are provided in the SCEESAMP sample library that can be used to replace all OS/VS COBOL and VS COBOL II library routines in load modules containing OS/VS COBOL and VS COBOL II programs. These sample jobs are: v IGZWRLKA to re-link-edit a VS COBOL II load module with Language Environment v IGZWRLKB to re-link-edit an OS/VS COBOL load module with Language Environment v IGZWRLKC to re-link-edit a load module that contains both OS/VS COBOL programs and VS COBOL II programs with Language Environment. CICS stub Although COBOL programs linked with the old CICS stub, DFHECI, run under Language Environment, use of the DFHELII stub is recommended and could be essential in a mixed language environment. CBLPSHPOP option The CBLPSHPOP run-time 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 for OS/390 & VM, COBOL for MVS & VM, COBOL/370 or a VS COBOL II subroutine is called. If your application makes many COBOL subroutine CALLs under CICS, performance is better with CBLPSHPOP(OFF) than with CBLPSHPOP(ON). You can set CBLPSHPOP on an individual transaction basis by using CEEUOPT, as explained in Defining run-time options for Language Environment on page 60. However, because condition handling has not been stacked, be aware that: v If your called routine raises a condition that causes CICS to attempt to pass control to a condition handler in the calling routine, this is an error and your transaction will be abnormally terminated. v If you use any of the PUSHable CICS commands, HANDLE ABEND, HANDLE AID, HANDLE CONDITION, or IGNORE CONDITION, within the called routine, you will be changing the settings of your caller and this could lead to later errors. Using CEEWUCHA If you are adapting VS COBOL II programs to run under Language Environment, the sample user condition handler, CEEWUCHA, supplied by Language Environment in the SCEESAMP library, can be used to advantage. It does the following: v It provides compatibility with existing VS COBOL II applications running under CICS by allowing EXEC CICS HANDLE ABEND LABEL statements to get control when a run-time detected error occurs.
53
v It converts all unhandled run-time detected errors to the corresponding user 1xxx abend issued by VS COBOL II. v It suppresses all IGZ0014W messages, which are generated when IGZETUN or IGZEOPT is link-edited with a VS COBOL II application. (Performance is better if the programs are not link-edited with IGZETUN or IGZEOPT.) For further information on migrating existing COBOL programs to run under Language Environment, see the COBOL for OS/390 & VM Compiler and Run-Time Migration Guide.
54
non-Language Environment-conforming compilers for running under Language Environment by using the following linkage-editor statements:
INCLUDE SYSLIB(CEESTART) INCLUDE SYSLIB(CEESG010) INCLUDE SYSLIB(DFHELII) REPLACE PLISTART CHANGE PLIMAIN(CEEMAIN) INCLUDE mainprog INCLUDE subprog1 ....... ....... ORDER CEESTART ENTRY CEESTART NAME progname(R)
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.) 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 PL/I for MVS & VM Compiler and Run-Time 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 run-time option to register it to do this. For details of this option see the OS/390 Language Environment for OS/390 & VM Programming Guide.
55
v Use the macros provided by Language Environment. For a list of these macros, see the OS/390 Language Environment for OS/390 & VM Programming Guide. v Ensure that the CEEENTRY macro contains the option MAIN=NO. ( Language Environment-conforming assembler main routines are not supported under CICS and MAIN=YES is the default). v Translate your assembler routine with *ASM XOPTS(NOPROLOG NOEPILOG) if it contains CICS commands. v Ensure that the CEEENTRY macro contains the option NAB=NO if your routine is invoked by a static call from OS/VS COBOL or VS COBOL II. (NAB is Next Available Byte (of storage). NAB=NO means that this field may not be available, so the CEEENTRY macro generates code to find the available storage.) To communicate properly with assembler routines, observe certain register conventions on entry to the assembler routine, while it is running, and on exit from the assembler routine. Entry On entry into a Language Environment-conforming assembler subroutine, these registers must contain the following values when NAB=YES is specified on the CEEENTRY macro: R0 R1 R12 R13 R14 R15 Reserved Address of the parameter list, or zero Common anchor area (CAA) address Callers dynamic storage area (DSA) Return address Entry point address
Language Environment-conforming HLLs generate code that follows these register conventions, and the supplied macros do the same when you use them to write your Language Environment-conforming assembler routine. On entry to an assembler routine, CEEENTRY saves the callers registers (R14 through R12) in the DSA provided by the caller. It allocates a new DSA and sets the NAB field correctly in this new DSA. The first half word of the new DSA is set to binary zero and the back chain in the second word is set to point to the callers DSA. While the subroutine is running R13 must point to the routines DSA at all times while the Language Environment-conforming assembler routine is running. At any point in your code where you CALL another program, R12 must contain the common anchor area (CAA) address, except in the following cases: v When calling a COBOL program v When calling an assembler routine that is not Language Environment-conforming v When calling a Language Environment-conforming assembler routine that specifies NAB=NO on the CEEENTRY macro Exit
56
On exit from a Language Environment-conforming assembler routine, R0, R1, R14, and R15 are undefined. All the other registers must have the contents they had upon entry. The CEEENTRY macro automatically sets a module to AMODE (ANY) and RMODE (ANY). If you are converting an existing assembler routine to be Language Environment-conforming and the routine contains data management macros coded using 24-bit addressing mode, then you should change the macros to use 31-bit mode (see DFSMS/MVS Macro Instructions for Data Sets). If it is not possible to change all the modules making up a program to use 31-bit addressing mode, and if none of the modules explicitly sets RMODE (24), then you should set the program to be RMODE (24) during the link-edit process. Non-conforming routines Observe the following conventions when running non-Language Environment-conforming subroutines under Language Environment: v R13 must contain the address of the executing routines register save area. v The first two bytes of the register save area must be binary zeros. v The register save area back chain must be set to a valid 31-bit address (the high-order byte must be zero if it is a 24-bit address). If your assembler routine relies on C/C++, COBOL, or PL/I control blocks (for example, a routine that tests flags or switches in these control blocks), check that these control blocks have not changed under Language Environment. For more information, see the appropriate Language Environment migration guide. Non-conforming routines cannot use Language Environment callable services. For more information or for explanations of the terms used in this section see the chapter on Assembler Considerations in the OS/390 Language Environment for OS/390 & VM Programming Guide.
57
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 the OS/390 Language Environment for OS/390 & VM Writing Interlanguage Communication Applicationsmanual; you should consult this book if your application mixes C/C++ and COBOL. C/C++ and PL/I Under CICS, if all the components of your C/C++ and PL/I application are reentrant, Language Environment supports ILC between routines compiled by OS/390 C/C++ and PL/I for MVS & VM or VisualAge PL/I for OS/390 as follows: v C/C++ routines can statically call PL/I routines and PL/I routines can statically call C/C++ routines. v C/C++ routines can fetch() PL/I routines that have OPTIONS(FETCHABLE) specified. If the called routine contains any CICS commands, then C/C++ must pass the EIB and the COMMAREA as the first two parameters on the call statement. v PL/I routines can FETCH only those OS/390 C/C++ routines that have not been processed by the CICS translator. This is because during the dynamic call certain static fields created by the translator cannot be correctly set. COBOL and PL/I Under CICS, Language Environment supports ILC between routines compiled with COBOL for OS/390 & VM, COBOL for MVS & VM or COBOL/370, and PL/I for MVS & VM or VisualAge PL/I for OS/390 as follows: v COBOL routines can statically call PL/I routines, and PL/I routines can statically call COBOL routines. v COBOL programs can dynamically call PL/I routines that have OPTIONS(FETCHABLE) specified and PL/I routines can FETCH COBOL programs. If the called routine contains any CICS commands then the calling routine must pass the EIB and the COMMAREA as the first two parameters on the CALL statement. Assembler The following rules apply: v You can make static or dynamic calls from any Language Environment-conforming HLL program to a Language Environmentconforming assembler subroutine. Conversely, a Language Environment-conforming assembler routine can make a static call to any Language Environment-conforming routine, and can dynamically load another
58
routine, either assembler or HLL, by using either of the Language Environment macros CEEFETCH or CEELOAD. v You cannot delete (release) an ILC module that has been loaded using CEELOAD. v You can use the CEERELES macro to release an ILC module which has been fetched using CEEFETCH. v Use the language that fetched it to delete an assembler routine. This can only be done from C/C++, COBOL, and PL/I, if there is no ILC with PL/I in the module being released. Additionally, you can make static calls from any Language Environmentconforming HLL program or assembler subroutine to a non-conforming assembler subroutine. However, a non-conforming assembler routine cannot make a static call to any Language Environment-conforming routine, nor can it fetch or load a conforming routine, since it cannot use the Language Environment macros. Notes: 1. For assembler to call C or C++, you must include the following statement: C #pragma linkage(,OS) C++ extern OS 2. If you want to call a Language Environment-conforming assembler routine from a VS COBOL II program, specify NAB=NO on the CEEENTRY macro. DL/I If you are using DL/I in your ILC application under CICS, calls to DL/I, either by an EXEC DLI statement or by a CALL xxxTDLI, can be made only in programs with the same language as the main program. Language Environment does not support CALL CEETDLI under CICS.
59
v In PL/I programs, through the PLIXOPT declaration statement within the program. For example:
DECLARE PLIXOPT CHARACTER(18) VARYING STATIC EXTERNAL INIT('RPTOPTS(ON) NOSTAE');
Note: There is no source code mechanism that allows the setting of run-time options within COBOL programs or within C++ programs. 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 Language Environment for OS/390 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:
ABPERC DEBUG MSGFILE RTEREUS VERSION AIXBLD EXECOPS NONIPTSTACK RTLS CBLOPTS INTERRUPT PLITASKCOUNT SIMVRD CBLQDA LIBRARY POSIX THREADHEAP
60
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. Language Environment supplies a sample source version of CEEBXITA in the SCEESAMP library (it simply returns to its caller for whatever reason it is called). You can use this as it is or modify it for use as the installation default version. However, you can link-edit a specifically tailored version of CEEBXITA with any application program and this version is then used instead of the installation default version. Take great care if you choose this method since CEEBXITA is invoked for up to five different reasons during the course of program execution, and an application-specific version of CEEBXITA must be capable of handling all these invocations. For more details on both CEEBXITA and CEECSTX see Language Environment for OS/390 Customization.
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
Chapter 7. Language Environment
61
v v v v
62
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
67 67 67 68 68 69 72 72 72 72 73 74 75 75 75 75 75 75 75 76 76 76 76 76 76 76 76 77 77 77 77 77 78 78 78 78 79 79 79 79 79 79 80 80 80 80 80 80 80 81 81 81 81
63
NOSPIE . . . . . . . . . . . . . NOVBREF . . . . . . . . . . . . NUM . . . . . . . . . . . . . . OOCOBOL . . . . . . . . . . . . OPMARGINS(m,n[,c]) . . . . . . . . OPSEQUENCE(m,n). . . . . . . . . OPTIONS . . . . . . . . . . . . . PROLOG . . . . . . . . . . . . . QUOTE . . . . . . . . . . . . . SEQ . . . . . . . . . . . . . . . SEQUENCE(m,n) . . . . . . . . . . SOURCE . . . . . . . . . . . . . SP . . . . . . . . . . . . . . . SPACE(1 or 2 or 3) . . . . . . . . . SPIE . . . . . . . . . . . . . . SYSEIB . . . . . . . . . . . . . VBREF . . . . . . . . . . . . . . Translator options table . . . . . . . . . Using COPY statements . . . . . . . . . The CICS-supplied interface modules . . . . The EXEC interface modules. . . . . . . The CPI Communications interface module . The SAA Resource Recovery interface module Using the EXEC interface modules . . . . . COBOL and PL/I . . . . . . . . . . . C and C++ . . . . . . . . . . . . . Assembler language . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
81 81 81 82 82 82 82 82 82 83 83 83 83 83 84 84 84 84 85 86 86 86 86 86 87 87 87
| | | | | | | | | | | | | | | | | | | | | | | | | | |
Chapter 9. Installing application programs. . . . . . . . . Program installation roadmap . . . . . . . . . . . . . . Preparing for program installation . . . . . . . . . . . . Defining MVS residence and addressing modes. . . . . . . . Establishing a programs addressing mode . . . . . . . . CICS address space considerations . . . . . . . . . . . Making programs permanently resident . . . . . . . . . . Running applications in the link pack area . . . . . . . . . . Running application programs in the RDSAs . . . . . . . . . Assembler . . . . . . . . . . . . . . . . . . . . C and C/++ . . . . . . . . . . . . . . . . . . . . COBOL . . . . . . . . . . . . . . . . . . . . . PL/I . . . . . . . . . . . . . . . . . . . . . . . Using BMS map sets in application programs . . . . . . . . Using the CICS-supplied procedures to install application programs Installing programs in load library secondary extents . . . . . Including the CICS-supplied interface modules . . . . . . . . Installing assembler language application programs . . . . . . Sample JCL to install assembler application programs . . . . Installing COBOL application programs . . . . . . . . . . Sample JCL to install COBOL application programs . . . . . Installing PL/I application programs . . . . . . . . . . . . Sample JCL to install PL/I application programs . . . . . . Installing C application programs . . . . . . . . . . . . . Sample JCL to install C application programs . . . . . . . Using your own job streams . . . . . . . . . . . . . . Translator requirements . . . . . . . . . . . . . . . Online programs that use EXEC CICS or EXEC DLI commands
64
| | |
Online programs that use the CALL DLI interface . . . . . . . . . . . 112 Batch or BMP programs that use EXEC DLI commands . . . . . . . . 112 Batch or BMP programs that use DL/I CALL commands . . . . . . . . 112 Chapter 10. Installing map sets and partition sets . . . Installing map sets . . . . . . . . . . . . . . . . Types of map sets . . . . . . . . . . . . . . . Defining the type of map set you require . . . . . . Using extended data stream terminals . . . . . . . Installing physical map sets . . . . . . . . . . . . Installing symbolic description map sets . . . . . . . Installing physical and symbolic description maps together JCL to install physical and symbolic description maps . Adding a CSECT to your map assembly . . . . . . Installing partition sets . . . . . . . . . . . . . . . Defining programs, map sets, and partition sets to CICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 114 114 115 116 116 118 119 120 121 121 123
| | | | | | | | | | |
65
66
Supported compilers
The CICS integrated translator is supported by the following releases of the COBOL and PL/I compilers: v IBM COBOL for OS/390 & VM, Version 2 Release 2, program number 5648-A25, with APAR PQ45462 applied. v IBM VisualAge PL/I for OS/390, Version 2 Release 2.1, program number 5655-B22, with APAR PQ45562 applied.
67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
If you use any other compiler, you will need to translate your program in the traditional way descibed in Chapter 8. Translation and compilation on page 67.
For more information on specifying PL/I compiler options see the VisualAge PL/I for 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 COBOL for OS/390 & VM Programming Guide. For more information on the CICS compiler option, see APAR PQ45462. 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: v APOST or QUOTE v CPSM or NOCPSM v CICS v DBCS
68
| | | | | | | | | | | |
v v v v v v v v v v v
DEBUG or NODEBUG DLI EDF or NOEDF FEPI or NOFEPI GRAPHIC LENGTH or NOLENGTH LINKAGE or NOLINKAGE NATLANG OOCOBOL SP SYSEIB
69
CICS Translation
Compilation (assembly)
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 and EXEC DLI commands have been turned into function call statements. v CICS DFHRESP and DFHVALUE built-in functions have been processed.
70
v A data interchange block (DIB) structure and initialization call have been inserted if the program contains EXEC DLI statements. The CICS commands that get translated still appear in the source, but as comments only. Generally the non-CICS statements are unchanged. The output from the translator always goes to an 80 byte fixed-record length data set. SYSPRINT (Translator listing) shows the number of messages produced by the translator, and the highest severity code associated with any message. The options used in translating your program also appear, unless these have been suppressed with the NOOPTIONS option. For COBOL, C, C++, and PL/I programs, SYSPRINT also contains the messages themselves. In addition, if you specify the SOURCE option of the translator, you also get an annotated listing of the source in SYSPRINT. This listing contains almost the same information as the subsequent compilation listing, and therefore many installations elect to omit it (the NOSOURCE option). One item you may need from this listing which is not present in the compile listing, however, is the line numbers, if the translator is assigning them. Line numbers are one way to indicate points in the code when you debug with the execution diagnostic facility (EDF). If you specify the VBREF option, you also get a list of the commands in your program, cross-referenced by line number, and you can use this as an alternative to the source listing for EDF purposes. For assembler language programs, SYSPRINT contains only the translator options, the message count and maximum severity code. The messages themselves are inserted into the SYSPUNCH file as comments after the related statement. This causes the assembler to copy them through to the assembler listing, where you can check them. You may also see MNOTEs that are generated by the assembler as the result of problems encountered by the translator. 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. The 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 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 Page-building and routing operations on page 160.
71
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.
72
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 translated with the ANSI85 option, 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))
73
If you use the PARM operand of the EXEC job control statement to specify options, the XOPTS keyword is unnecessary, because the only options permitted here are translator options. However, you may use XOPTS, with or without its associated parentheses. If you use XOPTS with parentheses, be sure to enclose all of the translator options. For example, the following forms are valid:
PARM=(op1 op2 .. opn) PARM=(XOPTS op1 op2 .. opn) PARM=XOPTS(op1 op2 .. opn)
(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.
74
Translator options
ANS185
(COBOL only) ANS185 specifies that the translator is to translate COBOL programs that implement the ANSI85 standards. Note: This option causes the COBOL2 and NOSEQ options to be used, even if you have specified SEQ. ANSI85 is implied by either OOCOBOL or COBOL3 options.
APOST
(COBOL only) APOST indicates that literals are delineated by the apostrophe (). This is the defaultQUOTE is the alternative. The same value must be specified for the translator step and the following compile step. | | APOST and QUOTE apply only to VS COBOL II and COBOL /370. Later compilers can use either option with both types of delimiters in the same program. The CICS-supplied COBOL copybooks use APOST.
CBLCARD
(COBOL only) CBLCARD specifies that the translator is to generate a CBL statement. This is the defaultthe 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)
To translate a batch program written in COBOL, containing EXEC API commands, specify:
CBL XOPTS(EXCI)
COBOL2
(COBOL only) COBOL2 specifies that the translator is to translate programs compiled by the VS COBOL II (or later) compilers.
COBOL3
(COBOL only) COBOL3 specifies that the translator is to translate programs compiled by a Language Environment conforming compiler. See Levels of support in Language Environment on page 47. This option implies the ANSI85 and COBOL2 options.
Chapter 8. Translation and compilation
75
CPP
(C++ only)CPP specifies that the translator is to translate C++ programs for compilation by a supported C++ compiler, such as IBM C/C++ for MVS.
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 the VS COBOL II Application Programming: Language Reference and the COBOL for OS/390 &VM Language Reference. If you specify this option, the COBOL2 option is assumed.
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 defaultNODEBUG 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 defaultthe 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. EPILOG is the defaultthe alternative, NOEPILOG, prevents the translator inserting the macro DFHEIRET. (See the CICS Application Programming Reference manual for programming information about the DFHEIRET macro.)
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.
76
The EXCI option is also mutually exclusive to the DLI option. EXEC API commands for the External CICS Interface cannot be coded in batch programs using EXEC DLI commands. An error message is produced if both EXCI and DLI translator commands are specified. The EXCI translator option is specified by XOPTS, that is, XOPTS(EXCI).
FE
(COBOL only) FE produces translator information messages that print (in hexadecimal notation) the bit pattern corresponding to the first argument of the translated call. This bit pattern has the encoded information that CICS uses to determine which function is required and which options are specified. All diagnostic messages are listed, whatever the FLAG option specifies. The alternative is NOFE, which is the default.
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 not discussed in this book, but are discussed in the CICS Front End Programming Interface Users 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 S All except warning and information messages. 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.
77
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 PL/I Programming: Language Reference manual.
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 LINECOUNT specifies the number of lines to be included in each page of translator listing, including heading and blank lines. The value of n must be an integer in the range 1 through 255; if n is less than 5, only the heading and one line of listing are included on each page. The default is 60.
LINKAGE
(COBOL only) LINKAGE requests the translator to modify the LINKAGE SECTION and PROCEDURE DIVISION statements in top-level programs according to the existing rules. 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. | | DFHEIBLK is defined in upper-case, but if OOCOBOL or COBOL3 are also specified, a mixed-case version of the EIB structure (DFHEIBLC) is inserted. LINKAGE is the defaultthe alternative is NOLINKAGE. 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 option can also specify the position of an American National Standard printer control character to format the listing produced when the SOURCE option is specified; otherwise, the input records are listed without any intervening blank lines. The margin parameters are: m n Column number of left-hand margin. Column number of right-hand margin. It must be greater than m.
78
Note: When used as a C or C++ compiler option, the asterisk (*) is allowable for the second argument on the MARGIN option. For the translator, however, a numeric value between 1 and 100 inclusive must be specified. When the input data set has fixed-length records, the maximum value allowable for the right hand margin is 80. When the input data set has variable-length records, the maximum value allowable is 100. c Column number of the American National Standard printer control character. It must be outside the values specified for m and n. A zero value for c means no printer control character. If c is nonzero, only the following printer control characters can appear in the source: (blank) Skip 1 line before printing. 0 Skip 2 lines before printing. Skip 3 lines before printing. + No skip before printing. 1 New page.
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 KA (Default) English. 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 parameters which the CICS translator normally inserts must be set using VS COBOL IIs IGYCOPT macro. These parameters are RENT, RES, NODYNAM, and LIB.
NOCPSM
NOCPSM specifies that the translator is not to process EXEC CPSM commands. This is the defaultthe 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).
NOEDF
NOEDF specifies that the execution diagnostic facility is not to apply to the program. There is no performance advantage in specifying NOEDF, but the option can be useful to prevent commands in well-debugged subprograms appearing on EDF displays.
NOEPILOG
(Assembler language only)
Chapter 8. Translation and compilation
79
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.)
NOFE
(COBOL only) NOFE does not produce translator information messages that print the bit pattern corresponding to the first argument of the translated call. NOFE is the defaultthe alternative is FE.
NOFEPI
NOFEPI disallows access to the FEPI API commands of the CICS Front End Programming Interface (FEPI). NOFEPI is the defaultthe 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. This means that you can provide COBOL copybooks to define a COMMAREA and use the EXEC CICS ADDRESS command. LINKAGE is the default.
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 defaultthe alternative is NUM.
NOOPSEQUENCE
(C, C++, and PL/I only) Abbreviation: NOS NOOPSEQUENCE specifies the position of the sequence field in the translator output records. 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.
NOOPTIONS
Abbreviation: NOP
80
NOOPTIONS instructs the translator not to include a list of the options used during this translation in its output listing.
NOPROLOG
(Assembler language only) NOPROLOG instructs the translator not 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 Reference manual for programming information about these prolog macros.)
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. If you specify the ANSI85 option for COBOL, the translator does no sequence checking and the SEQ or NOSEQ option is ignored.
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. The default for fixed-length records is SEQUENCE(73,80). For variable-length records in C and C++, the default is NOSEQUENCE and for variable-length records in PL/I the default is SEQUENCE(1,8).
NOSOURCE
(C, C++ and PL/I only) 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) NOVBREF instructs the translator not to include a cross-reference of commands with line numbers in the translator listing. (NOVBREF used to be called NOXREF; for compatibility, NOXREF is still accepted.) NOVBREF is the defaultthe alternative is VBREF.
NUM
(COBOL only) NUM instructs the translator 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. The alternative is NONUM, which is the default.
Chapter 8. Translation and compilation
81
OOCOBOL
(OO COBOL only) OOCOBOL instructs the translator to recognize the object-oriented COBOL (OO COBOL) syntax. The phrases: v CLASS-ID xxx...xxx v END CLASS xxx...xxx v METHOD-ID xxx...xxx v END METHOD xxx...xxx are recognized but their correct usage is not monitored. The translator considers each class as a separate unit of compilation. This option implies the ANSI85, COBOL2, and COBOL3 options.
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
Abbreviations: 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 Reference manual for programming information about these prolog macros.) PROLOG is the defaultthe alternative is NOPROLOG.
QUOTE
(COBOL only)
82
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 defaultthe alternative is NOSEQ. If a statement is not in sequence, it is flagged. If you specify the ANSI85 option for COBOL, the translator does no sequence checking and the SEQ option is ignored.
SEQUENCE(m,n)
(C, C++, and PL/I only) Abbreviation: SEQ SEQUENCE specifies that statements in the translator input are sequence numbered and the columns in each line or record that contain the sequence field. The translator uses this number as the line number in error messages and cross-reference listings. No attempt is made to sort the input lines or records into sequence. If no sequence field is specified, the translator assigns its own line numbers. The SEQUENCE parameters are: m n Leftmost sequence number column. Rightmost sequence number column.
The sequence number field must not exceed eight characters and must not overlap the source program (as specified in the MARGINS option). The default for fixed-length records is SEQUENCE(73,80). For variable-length records in C and C++ the default is NOSEQUENCE and for variable-length records in PL/I the default is SEQUENCE(1,8).
SOURCE
(C, C++, and PL/I only) SOURCE instructs the translator to include a listing of the translated source program in the translator listing. SOURCE is the defaultthe alternative is NOSOURCE.
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, INQUIRE, PERFORM, RESYNC, and SET. They are generally used by system programmers. For programming information about these commands, see the CICS System Programming Reference manual.
SPACE(1 or 2 or 3)
(COBOL only)
Chapter 8. Translation and compilation
83
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 defaultthe 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) VBREF specifies whether the translator is to include a cross-reference of commands with line numbers in the translator listing. (VBREF used to be called XREF, and is still accepted.)
84
Table 5. Translator options applicable to programming language (continued) Translator option FEPI or NOFEPI FLAG(I or W or E or S) GDS GRAPHIC LENGTH or NOLENGTH LINECOUNT(n) LINKAGE or NOLINKAGE MARGINS(m,n) NATLANG NUM or NONUM OOCOBOL OPMARGINS(m,n[,c ]) OPSEQUENCE(m,n) or NOOPSEQUENCE OPTIONS or NOOPTIONS PROLOG or NOPROLOG QUOTE or APOST SEQ or NOSEQ SEQUENCE(m,n) or NOSEQUENCE SOURCE or NOSOURCE SP SPACE(1 or 2 or 3) SPIE or NOSPIE SYSEIB VBREF or NOVBREF X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X COBOL X X C X X X C++ X X X X X X X X PL/I X X X Assembler X
85
86
Table 6. Interface modules (continued) Language C COBOL PL/I Language Environment enabled Interface module name DFHELII DFHECI DFHPL1OI supplied by PL/I ( and DFHEPI which is part of the PL/I DFHPLIO1 module). DFHELII
C and C++
These programs must include the EXEC interface stub called DFHELII. There is no library stub. The stub must be link-edited with your application program to provide communication between your code and the EXEC interface program (DFHEIP). For C and C++, each EXEC CICS command is translated by the command translator into a C or C++ function invocation. The external entry point is invoked by the function and is resolved by an entry in the stub.
Assembler language
Each EXEC command is translated into an invocation of the DFHECALL macro by the command translator and the external entry point invoked by DFHECALL is resolved to an entry in the stub.
87
88
89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
access IBM DATABASE 2 (DB2) services using the EXEC SQL interface need an additional precompilation step. For information about this step, see the IBM DATABASE 2 Application Programming and SQL Guide. 3. Pre-link any C and C++ programs. 4. Link-edit the object module to produce a load module, which you store in an application load library that is concatenated to the DFHRPL DD statement of the CICS startup job stream. Additional INCLUDE statements are required for applications that access DB2 services using the EXEC SQL interface. For information about these extra statements, see the IBM DATABASE 2 Application Programming and SQL Guide. 5. Create resource definition entries, in the CSD, for any transaction that calls the program, and install them.. 6. Do one of the following: v If you are using program autoinstall, ensure that the autoinstall user-replaceable module can correctly install a resource definition for the program. v If you are not using program autoinstall, create a resource definition entry in the CSD for the program, and install it. If you have macro-level programs from an earlier release of CICS, recode them as command-level programs. Furthermore, 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 a CICS macro or references the CSA or the TCA. CICS provides a utility program, DFHMSCAN, to identify the macro-level programs used by your CICS applications. For information about using the DFHMSCAN utility to identify macro-level programs, see the CICS Operations and Utilities Guide.
90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
RMODE(ANY)
Note: C/370 language programs must be link-edited with AMODE(31). 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.) 4. The link-edit modules DFHECI and DFHEPI assign AMODE(31) and RMODE(ANY) to COBOL and PL/I programs.
91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Table 7. Valid AMODE and RMODE specifications and their effects AMODE 24 31 ANY 31 RMODE 24 24 24 ANY Residence Below 16MB Below 16MB Below 16MB Above 16MB Addressing 24-bit mode 31-bit mode 31-bit mode 31-bit mode
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) /* //
COBOL Do not overwrite WORKING STORAGE. (The CICS translator generates a CBL statement with the required compiler RENT option (unless you specify the translator option NOCBLCARD). For the COBOL and COBOL2 translator options, the translator also generates the RES compiler option.)
92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
PL/I Version 1 Release 5.1 or later Do not overwrite STATIC storage. (The CICS translator inserts the required REENTRANT option into the PROCEDURE statement.) If you want CICS to use modules that you have written to these standards, and installed in the LPA, specify USELPACOPY(YES) on the program resource definitions in the CSD. For information about installing CICS modules in the LPA, see the CICS Transaction Server for z/OS Installation Guide.
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 wayfor 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. The CICS-supplied procedure, DFHEITAL, has a LNKPARM parameter that specifies the XREF and LIST options only. To link-edit an ERDSA-eligible program, override LNKPARM from the calling job, specifying the RENT and RMODE(ANY) options in addition to any others you require. For example:
//ASMPROG JOB 1,user_name,MSGCLASS=A,CLASS=A,NOTIFY=userid //EITAL EXEC DFHEITAL, .
Chapter 9. Installing application programs
93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
//
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). If you want your application program link-edited as AMODE(31) and RMODE(ANY), you are recommended to use appropriate statements in your assembler program. For example:
MYPROG MYPROG MYPROG CSECT AMODE 31 RMODE ANY
There are two ways of setting AMODE and RMODE: v You can set the required AMODE and RMODE specification by using link-edit (or binder) control information in the JCL PARM keyword. For example:
//EITAL EXEC DFHEITAL, LNKPARM='LIST,XREF,RENT,AMODE(31),RMODE(ANY)'
v Alternatively, you can use the MODE control statement in the SYSIN dataset in the link-edit, or the binder step in your JCL. When using the binder, you may see unexpected warning messages about conflicting AMODE and RMODE specifications.
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 CICS-supplied procedures DFHYITDL (for C) and DFHYITEL (for C++) have 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 the other options you require. You do not need to add the RMODE(ANY ) option, because the CICS EXEC interface module for C/370 (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. The following sample job statements show the LNKPARM parameter with the RENT option added:
//C370PROG JOB 1,user_name,MSGCLASS=A,CLASS=A,NOTIFY=userid //EYTDL EXEC DFHEYTDL, . (other parameters as necessary) . // LNKPARM='LIST,MAP,LET,XREF,RENT'
COBOL
If you use the integrated CICS translator then the compile requires the RENT compiler option, so no CBL card needs to be added during translation.
94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
LE-conforming COBOL and VS COBOL II programs that require a separate translation step, are automatically eligible for the ERDSA, because: v The translator option, CBLCARD (the default), causes the required compiler option, RENT, to be included automatically on the CBL statement generated by the CICS translator. If you use the translator option, NOCBLCARD, you can specify the RENT option either on the PARM statement of the compile job step, or by using the COBOL macro IGYCOPT to set installation-defined options. v The COBOL compiler automatically generates code that conforms to read-only and 31-bit addressing standards. v The CICS EXEC interface module for COBOL (DFHECI) 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 interface stub, see The CICS-supplied interface modules on page 86. You also need to specify the reentrant attribute to link-edit. The CICS-supplied procedure, DFHYITVL (and also DFHEITVL), 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:
//COB2PROG 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 (DFHEPI, which is part of the PL/I DFHPL1OI module) 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 (and DFHEITPL), 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
Chapter 9. Installing application programs
95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Problem Determination Guide for some possible causes of storage protection exceptions in programs resident in the ERDSA.
96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Table 8. Procedures for installing application programs Language LE-conforming compilers Online Assembler C C++ COBOL PL/I DFHYITDL DFHYITEL DFHYITVL DFHYITPL EXCI DFHYXTDL DFHYXTEL DFHYXTVL DFHYXTPL non-LE-conforming compilers Online DFHEITAL DFHEITDL DFHEITVL DFHEITPL EXCI DFHEXTAL DFHEXTDL DFHEXTVL DFHEXTPL
Note: DFHYITEL may also be used for C as long as you specify the correct name of the C compiler on the COMPILER parameter. All the sample job streams shown apply if your program source statements are imbedded in the text. If your program source is a member of a partitioned data set, replace the //TRN.SYSIN statement by a statement in one of the following forms:
//TRN.SYSIN DD DSN=partition.dataset.name(programname),DISP=SHR //SYSIN DD DSN=partition.dataset.name(programname),DISP=SHR
In this COBOL example, the symbolic parameter STUB defaults to DFHEILIC. The DFHEILIC member contains the statement INCLUDE SYSLIB(DFHECI).
97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
In the DFHEITPL procedure for installing PL/I application programs, the SYS1.PL1BASE library is included in the SYSLIB concatenation. This is needed because the INCLUDE statement in the DFHEILIP module specifies INCLUDE SYSLIB(DFHPL1OI), where DFHPL1OI is the name of the PL/I interface module supplied by PL/I. . In the DFHEILIP module, after the INCLUDE statement, there is the REPLACE PLISTART link-edit command. This command causes the CSECT PLISTART, which is inserted by the compiler, to be removed because equivalent function is in the stub DFHPL1OI. The REPLACE PLISTART command is needed for programs to run under Language Environment, but is optional for other PL/I programs that run under CICS. If your application program is to use CPI Communications or the SAA Resource Recovery facility, do one of the following: v Add appropriate INCLUDE statements to the LKED.SYSIN override in the job used to call the CICS-supplied procedure to install your application program. Add the following INCLUDE statements: INCLUDE SYSLIB(DFHCPLC) if your program uses CPI Communications INCLUDE SYSLIB(DFHCPLRR) if your program uses SAA Resource Recovery v Rely on the link-edit automatic library-call mechanism to include the necessary modules. Warning messages may appear during the link-edit step, indicating DUPLICATE definitions for the DFHEI1 module. You may ignore these messages. For more information about link-edit requirements, see Using your own job streams on page 108.
98
|
Assembler-language source
Translator listing
CICS. SDFHMAC
CICS. SDFHLOAD
| | Figure 12. Installing assembler language programs using the DFHEITAL procedure | | | | | | | | |
99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
//jobname JOB accounting info,name,MSGLEVEL=1 // EXEC PROC=DFHExTAL //TRN.SYSIN DD * *ASM XOPTS(translator options . . .) . assembler-language source statements . /* //LKED.SYSIN DD * NAME anyname(R) /* //
1 2
Notes: 1 If you are installing a program into either of the read-only DSAs, see Running application programs in the RDSAs on page 93 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 92.) 2 For information about the translator options you can include on the XOPTS statement, see Defining translator options on page 74. .
100
|
High-level language source
CICS. SDFHLOAD
Translator listing
Intermediate storage DFHBMSCA DFHAID CICS. SDFHCOB or SDFHPL1 High-level language compiler Compiler listing
DFHEILIC DFHEILIP Intermediate storage DFHECI DFHEPI Linkage Editor Linkage Editor listing
CICS. SDFHLOAD
DFHPL1OI
SYS1.PLIBASE or COBLIB
CICS. SDFHLOAD
101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
//jobname JOB accounting info,name,MSGLEVEL=1 // EXEC PROC=DFHwxTVL //TRN.SYSIN DD * CBL XOPTS(Translator options . . .) . COBOL source statements . /* //LKED.SYSIN DD * NAME anyname(R) /* //
1 2 3
Notes for installing COBOL programs 1 Translator options: Specify the following translator options according to the version of the COBOL compiler called in the compile step. OOCOBOL for the IBM COBOL for MVS & VM, and COBOL for OS/390 & VM compilers. This option is only needed if the object-oriented syntax (such as class-id and method-id), is used in the application program. The OOCOBOL option implies the COBOL3, ANSI85 and COBOL2 translator options. COBOL3 for one of the LE-conforming COBOL compilers. COBOL3 implies the ANSI85 and COBOL2 translator options. ANSI85 for the VS COBOL II compiler. This option specifies that the translator is to translate VS COBOL II programs that implement the ANSI85 standards. ANSI85 implies the COBOL2 option. COBOL2 for the VS COBOL II compiler. Compiler options: To compile a VS COBOL II application program, you need the compiler options: RENT, RES, 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. To compile a COBOL program with one of the LE-conforming compilers, you need the compiler options: RENT, NODYNAM, and LIB. To compile a COBOL program with a compiler that has an integrated translator, you also need to use the CICS compiler option. The PARM statement of the COB step in DFHwxTVL specifies values for the compiler options. For example,
102
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
//COB //
It does 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=DFHwxTVL,PARM.COB='SIZE=512K,BUF=16K,.,.,.'
Ensure that the APOST|QUOTE option in effect for the VS COBOL II compiler matches that for the translator. There is no BATCH compiler option for VS COBOL II. For information about VS COBOL II compiler options, see Defining translator options on page 74. 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 DFHwxTCL procedure. 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 DFHwxTCL procedure. v The COBOL installation defaults macro, IGYCOPT. This is needed if you do not use a CBL statement; that is, have specified the translator option NOCBLCARD, and the compiler option ALOWCBL=NO. For information about the translator option CBLCARD|NOCBLCARD, see Defining translator options on page 74. If you choose to use the NOCBLCARD option, also specify the COBOL compiler option ALOWCBL=NO to prevent an error message of IGYOS4006-E being issued. The ALOWCBL=NO option can be overridden at compile time by the JCL PARM option or a TSO command. For more information about the ALOWCBL compiler option, see the relevant Installation and Customization manual for your version of COBOL. 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 The translator options on the XOPTS statement override similar options in the DFHwxTVL procedure. Any translator options you specify should include the type of COBOL translator option, COBOL2 or COBOL3. For information about the translator options you can include on the XOPTS statement, see Defining translator options on page 74. 4 You can ignore weak external references unresolved by the link-edit. The link-edit job step requires access to the libraries containing the environment-specific modules for CICS, the general VS COBOL II library subroutines, and the Language Environment link-edit modules, as appropriate. The
Chapter 9. Installing application programs
103
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
required libraries are included in the SYSLIB concatenation of procedures for VS COBOL II. Override or change the names of these libraries if the modules and library subroutines are installed in libraries with different names. If you are installing a program into either of the read-only DSAs, see Running application programs in the RDSAs on page 93 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 DFHEITVL procedure. (See Running applications in the link pack area on page 92.)
For more information about preparing PL/I programs, see the OS PL/I Version 2 Programming Guide, SC26-4307-02.
104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
//jobname JOB accounting info,name,MSGLEVEL=1 // EXEC PROC=DFHwxTPL 1 //TRN.SYSIN DD * 2 *PROCESS XOPTS(translator options...)PL/I compiler options...; 3 . PL/I source statements 4 . /* //LKED.SYSIN DD * 5 NAME anyname(R) /* //
Notes for installing a PL/I program: These notes apply to the DFHEITPL procedure only. 1 In the DFHEITPL procedure, the link-edit step includes module DFHPL1OI. This module is generated during the installation of PL/I and is normally placed either in the CICSTS21.CICS.SDFHLOAD library, the SYS1.PLIBASE library, or a user library. Find out which library contains this module, and either copy the module to the CICSTS21.CICS.SDFHLOAD library or concatenate the appropriate library in LKED.SYSLIB. If you include the PL/I REPORT and COUNT execution time options, output goes to the CPLI transient data destination. There is an example of this transient data queue coded in the sample destination control table in the CICSTS21.CICS.SDFHSAMP library. 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 and compiler options: For information about the translator options you can include on the XOPTS statement, see Defining translator options on page 74. . 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 CPLD transient data destination. The CICS supplied resource definition group, in the CSD, DFHDCTG, contains an entry for CPLD. 5 link-edit considerations:
105
| | | | | | | | | | | | | | | | | | | | | | | |
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 93 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 DFHEITPL procedure. (See Running applications in the link pack area on page 92 for more information.) To use the PL/I shared library facility, generate the module PLISHRE (see CICS Transaction Server for z/OS Installation Guide) before you compile and link-edit your application programs. When you have re-link-edited the PLISHRE module into the CICSTS21.CICS.SDFHLOAD library, put the INCLUDE SYSLIB(PLISHRE) control statement immediately after the INCLUDE SYSLIB(DFHPL1OI) statement in the DFHEILIP member in the CICSTS21.CICS.SDFHPL1 library. Also, code a LKED.SYSLIB DD statement to concatenate the library that contains the PLISHRE module in front of the SYS1.PLIBASE library. For example:
//LKED.SYSLIB // DD DSN=CICSTS21.CICS.SDFHLOAD,DISP=SHR DD DSN=SYS1.PLIBASE,DISP=SHR
106
|
High-level language source
CICS. SDFHLOAD
Translator listing
DFHBMSCA DFHAID
Intermediate storage
EDC.V1R2M0 SEDCBASE
EDC.V2R2M1 SIBMBASE
CICS. SDFHLOAD
107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
whether it is a CICS application program or an EXCI batch program. For the names of the CICS-supplied procedures, see Table 8 on page 97.
//jobname JOB accounting info,name,MSGLEVEL=1 // EXEC PROC=DFHwxTDL //TRN.SYSIN DD * #pragma XOPTS(Translator options . . .) . C source statements . /* //LKED.SYSIN DD * NAME anyname(R) /* // 1 2 3
Notes for installing a C program: 1 Compiler options: You can code compiler options by using the parameter override (PARM.C) in the EXEC statement that invokes the procedure, or by a C statement at the start of the source statements. If you use a C statement, you need a parameter override of BATCH on the EXEC PROC=DFHEITyL statement. You can compile your C/370 applications under Version 1 Release 2 of the C/370 compiler and run them under Version 1 Release 2 of the C/370 library. 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 93 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 DFHEITyL procedure. (See Running applications in the link pack area on page 92 for more information.) C language programs must be link-edited with AMODE(31), so the DFHwxTDL procedures specify AMODE(31) by default.
108
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
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 CICSTS21.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. 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.)
109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
3. Place the load module output from the link-edit (defined by the SYSLMOD DD statement) in CICSTS21.CICS.SDFHLOAD, or a user-defined application program library. Figure 19 shows sample JCL and an inline procedure, based on the CICS-supplied procedure DFHEITVL, that can be used to install VS COBOL II application programs. The procedure does not include the COPYLINK step and concatenation of the library member DFHEILIC that contains the INCLUDE statement for the required interface module (as included in the DFHEITVL procedure). Instead, the JCL provides the following INCLUDE statement:
INCLUDE SYSLIB(DFHECI)
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.
//COB2APPL JOB accounting info,name,MSGCLASS=A,MSGLEVEL=(1,1), // CLASS=A //* //********************************************************************* //* THIS JOB CAN BE USED TO INSTALL A VS COBOL II PROGRAM. //* //* THE JOB ILLUSTRATES THE USE OF: //* //* 1) AN INLINE PROCEDURE BASED ON THE CICS=SUPPLIED PROCEDURE, DFHEITVL //* //* 2) INCLUDE AND ORDER STATEMENTS FOR INTERFACE MODULE DFHECI //* //********************************************************************* //* //MYEITVL PROC SUFFIX=1$, // INDEX='CICSTS21.CICS', // INDEX2='CICSTS21.CICS', // OUTC=A, // REG=5M, // LNKPARM='XREF,RENT,REFR', // WORK=SYSDA //* //* THIS PROCEDURE CONTAINS 3 STEPS //* 1. EXEC THE COBOL TRANSLATOR (USING SUFFIX 1$) //* 2. EXEC THE VS COBOL II COMPILER //* 3. LINKEDIT THE OUTPUT TO SDFHLOAD LIBRARY //*
110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
//TRN EXEC PGM=DFHECP&SUFFIX, // PARM='COBOL2', // REGION=® //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=PP.COB2.COB2COMP,DISP=SHR //SYSLIB DD DSN=&INDEX..SDFHCOB,DISP=SHR // DD DSN=&INDEX..SDFHSAMP,DISP=SHR //* DD DSN=&INDEX2..SAMPLIB,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)) //SYSUT7 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=SYS2.COB2.COB2CICS,DISP=SHR // DD DSN=SYS2.COB2.COB2LIB,DISP=SHR //* SYSLMOD DD DSN=&INDEX2..LOADLIB,DISP=SHR //SYSLMOD DD DSN=&INDEX2..SDFHLOAD,DISP=SHR //SYSUT1 DD UNIT=&WORK,DCB=BLKSIZE=1024, // SPACE=(1024,(200,20)) //SYSPRINT DD SYSOUT=&OUTC //SYSLIN DD DSN=&&LOADSET,DISP=(OLD,DELETE) // DD DDNAME=SYSIN // PEND //* //COB2TEST EXEC MYEITVL, // INDEX='CICSTS21.CICS', QUALIFIER FOR CICS LIBRARIES // INDEX2='user.qualif', QUALIFIER FOR USER LIBRARIES // OUTC='*', // REG='2048K', SYSOUT CLASS // WORK='SYSDA', UNIT FOR TEMPORARY DATA SETS // LNKPARM='XREF,LIST,RENT' //TRN.SYSIN DD * ... VS COBOL II source statements ... /* //LKED.SYSIN DD * INCLUDE SYSLIB(DFHECI) NAME name(R) /* //
111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
112
Ty p e = DSECT
Assembler
Copy library
Ty p e = MAP
Assembler listing
Assembler
Assembler listing
Link Editor
| | | | |
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
Copyright IBM Corp. 1989, 2001
113
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
usually need to recompile (reassemble) all programs that use it. Some changes affect only the physical map and are not reflected in the corresponding symbolic map used by the program. One of these is a change in field position that does not alter the order of the fields. However, changes in data type, field length, field sequence, and others do affect the symbolic map, and it is always safest to recompile (reassemble). 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 30. Basic mapping support on page 393. 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. CICS also provides the DFHASMVS procedure (installed in the CICSTS21.CICS.SDFHPROC library) that you can use to assemble and link-edit map sets. Note: The DFHASMVS procedure refers to the MVS library SYS1.MODGEN. If you have not yet restructured MVS (moving members from SYS1.AMODGEN to SYS1.MODGEN), change the SYS1.MODGEN reference to SYS1.AMODGEN in the DFHASMVS procedure, until you have restructured MVS. When you have restructured MVS, you must return the SYS1.AMODGEN reference to SYS1.MODGEN. This chapter includes: v Installing map sets v Installing partition sets on page 121 v Defining programs, map sets, and partition sets to CICS on page 123
114
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
v A symbolic description map set, used in the application program to define the standard device-independent form of the user data. This is a DSECT in assembler language, a data definition in COBOL, a BASED or AUTOMATIC structure in PL/I, and a struct in C/370. 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.
115
| | | | | | | | | | | | | | |
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.
Assembly listing
Linkage Editor
CICS. SDFHLOAD
| | | | | |
Figure 22 on page 117 gives an example job stream for the assembly and link-editing of physical map sets.
116
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
/* //STEP2 //SYSLIN // /* //
2 3 4
Notes: 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 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 123.
117
| | | | | |
CICS. SDFHMAC
Assembler
Assembly listing
SYSPUNCH
| | | | | | | | | | | | | | | | | | | | | | | | | |
Figure 23. Installing symbolic description map sets using the DFHASMVS procedure
To use a symbolic description map set in a program, you must assemble the source statements for the map set and obtain a punched copy of the storage definition through SYSPUNCH. The first time this is done, you can direct the SYSPUNCH output to SYSOUT=A to get a listing of the symbolic description map set. If many map sets are to be used at your installation, or there are multiple users of common map sets, establish a private user copy library for each language that you use. 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 24 on page 119 to obtain a listing of a symbolic description map set. It applies to all the programming languages supported by CICS.
118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
JOB EXEC DD DD
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 24 to the following:
//ASSEM EXEC PROC=DFHASMVS,PARM.ASSEM='SYSPARM(ADSECT)'
To obtain a punched copy of a symbolic description map set, code the //SYSPUNCH statement in the above example to direct output to the punch data stream. For example:
//SYSPUNCH DD SYSOUT=B
To store a symbolic description map set in a private copy library, use job control statements similar to the following:
//SYSPUNCH DD //SYSPUNCH DD //SYSPUNCH DD DSN=USER.MAPLIB.ASM(map set name),DISP=OLD DSN=USER.MAPLIB.COB(map set name),DISP=OLD DSN=USER.MAPLIB.PLI(map set name),DISP=OLD
119
1
Macro statements defining the map set
2
CICS. SDFHMAC Assembler
Assembly listing
3
CICS. SDFHLOAD Linkage Editor Linkage Editor listing
4
Macro statements defining the map set Assembler CICS. SDFHMAC
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Figure 25. Installing a physical map set and a symbolic description map set together
The DFHMAPT procedure is similar to DFHMAPS, with an additional step that installs HTML templates generated from the BMS maps. In this step, TEMPLATE is coded in the SYSPARM global variable in the EXEC statement (PARM='SYSPARM(TEMPLATE)'). In the DFHMAPT procedure, the output is directed to CICSTS21.CICS.SDFHHTML.
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.
120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
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 26 on page 120, 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 CICSTS21.CICS.SDFHMAC library. Override this by specifying DSCTLIB=name on the EXEC statement, where name is the name of the chosen user copy library.
C C
| | Figure 27. Adding a CSECT to the map assembly | | | Installing partition sets | | Partition sets are installed in the same way as physical map sets (as illustrated in Figure 21 on page 116). There is no concept of a symbolic description partition set.
Chapter 10. Installing map sets and partition sets
121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
The job stream in Figure 28 is an example of the assembly and link-edit of partition sets.
//PREP //STEP1 //SYSPUNCH // //SYSIN . . . . . . JOB 'accounting information',CLASS=A,MSGLEVEL=1 EXEC PROC=DFHASMVS DD DSN=&&TEMP,DCB=(RECFM=FB,BLKSIZE=2960), SPACE=(2960,(10,10)),UNIT=SYSDA,DISP=(NEW,PASS) DD *
/* //STEP2 //SYSLIN // /* //
1 2 3
Notes: 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 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 Reference manual. 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.
122
| | | | | | | | | | | | | | | | | | |
123
124
Chapter 12. Design for performance . . . . . . . . . . Program size . . . . . . . . . . . . . . . . . . . Virtual storage. . . . . . . . . . . . . . . . . . . Reducing paging effects . . . . . . . . . . . . . . Locality of reference . . . . . . . . . . . . . . Working set . . . . . . . . . . . . . . . . . Reference set . . . . . . . . . . . . . . . . . Exclusive control of resources . . . . . . . . . . . . . Operational control . . . . . . . . . . . . . . . . . Operating system waits . . . . . . . . . . . . . . . The NOSUSPEND option . . . . . . . . . . . . . . Efficient data operations . . . . . . . . . . . . . . . Efficient database operations . . . . . . . . . . . . Efficient data set operations. . . . . . . . . . . . . VSAM data sets . . . . . . . . . . . . . . . . BDAM data sets . . . . . . . . . . . . . . . . Efficient browsing (in non-RLS mode) . . . . . . . . . Efficient logging . . . . . . . . . . . . . . . . . Efficient sequential data set access . . . . . . . . . . Efficient terminal operations. . . . . . . . . . . . . . Length of the data stream sent to the terminal . . . . . . Basic mapping support considerations . . . . . . . . . Avoid turning on modified data tags (MDTs) unnecessarily Use FRSET to reduce inbound traffic . . . . . . . .
Copyright IBM Corp. 1989, 2001
125
Do not send blank fields to the screen . . . . . . . . . . Address CICS areas correctly . . . . . . . . . . . . . Use the MAPONLY option when possible. . . . . . . . . Send only changed fields to an existing screen . . . . . . Design data entry operations to reduce line traffic . . . . . Compress data sent to the screen . . . . . . . . . . . Use nulls instead of blanks . . . . . . . . . . . . . . Use methods that avoid the need for nulls or blanks. . . . . Page-building and routing operations . . . . . . . . . . . Sending multipage output . . . . . . . . . . . . . . Sending messages to destinations other than the input terminal Sending pages built from multiple maps . . . . . . . . . Using the BMS page-copy facility. . . . . . . . . . . . Requests for printed output . . . . . . . . . . . . . . . Additional terminal control considerations . . . . . . . . . . Use only one physical SEND command per screen . . . . . On BTAM, avoid the WAIT option on a SEND command . . . Use the CONVERSE command . . . . . . . . . . . . Limit the use of message integrity options . . . . . . . . Avoid using the DEFRESP option on SEND commands . . . Avoid using unnecessary transactions . . . . . . . . . . Send unformatted data without maps . . . . . . . . . . Chapter 13. Sharing data across transactions Using the common work area (CWA) . . . . Protecting the CWA. . . . . . . . . . Using the TCTTE user area (TCTUA) . . . . Using the COMMAREA in RETURN commands Using the display screen to share data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
158 159 159 159 159 160 160 160 160 160 161 162 162 162 163 163 163 163 163 163 163 163 165 165 165 168 169 169 171 172 172 172 172 173 173 173 174 174 174 175 176 177 177 178 178 179 179 179 180 181 182 184 185 186
Chapter 14. Affinity . . . . . . . . . . . . . . . . . . . . . Types of affinity . . . . . . . . . . . . . . . . . . . . . . . Inter-transaction affinity . . . . . . . . . . . . . . . . . . . Transaction-system affinity . . . . . . . . . . . . . . . . . . Using INQUIRE and SET commands and global user exits . . . . . Programming techniques and affinity . . . . . . . . . . . . . . . Safe techniques . . . . . . . . . . . . . . . . . . . . . . Unsafe techniques . . . . . . . . . . . . . . . . . . . . . Suspect techniques . . . . . . . . . . . . . . . . . . . . . Recommendations . . . . . . . . . . . . . . . . . . . . . Safe programming to avoid affinity . . . . . . . . . . . . . . . . The COMMAREA . . . . . . . . . . . . . . . . . . . . . The TCTUA . . . . . . . . . . . . . . . . . . . . . . . Using the TCTUA in an unsafe way . . . . . . . . . . . . . . Using ENQ and DEQ commands with ENQMODEL resource definitions Overview of sysplex enqueue and dequeue . . . . . . . . . . . Benefits . . . . . . . . . . . . . . . . . . . . . . . . BTS containers . . . . . . . . . . . . . . . . . . . . . . Unsafe programming for affinity . . . . . . . . . . . . . . . . . Using the common work area . . . . . . . . . . . . . . . . . Using GETMAIN SHARED storage . . . . . . . . . . . . . . . Using the LOAD PROGRAM HOLD command . . . . . . . . . . . Sharing task-lifetime storage . . . . . . . . . . . . . . . . . Using the WAIT EVENT command . . . . . . . . . . . . . . . Using ENQ and DEQ commands without ENQMODEL resource definitions Suspect programming for affinity . . . . . . . . . . . . . . . . .
126
Using temporary storage . . . . . . . . . . . . . Naming conventions for remote queues . . . . . . Exception conditions for globally accessible queues . . Using transient data . . . . . . . . . . . . . . Exception conditions for globally accessible queues . . Using the RETRIEVE WAIT and START commands . . . Using the START and CANCEL REQID commands . . . Using the DELAY and CANCEL REQID commands . . . Using the POST and CANCEL REQID commands . . . Detecting inter-transaction affinities . . . . . . . . . . Inter-transaction affinities caused by application generators Duration and scope of inter-transaction affinities . . . . . Affinity transaction groups . . . . . . . . . . . . Relations and lifetimes . . . . . . . . . . . . . The global relation . . . . . . . . . . . . . . The LUname (terminal) relation . . . . . . . . . The userid relation . . . . . . . . . . . . . . The BAPPL relation. . . . . . . . . . . . . . Chapter 15. Recovery design . Journaling . . . . . . . . . Journal records . . . . . . Journal output synchronization. Syncpointing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
186 187 188 188 189 189 191 193 194 196 196 197 197 197 197 199 200 201 205 205 205 205 207 209 209 210 210 210 211 211 211 212 213 214 215 215 216 217 218 218 221 222 223 224 225 225 225 225 225 225 226
Chapter 16. Dealing with exception conditions . . Default CICS exception handling . . . . . . . . . Handling exception conditions by in-line code . . . . How to use the RESP and RESP2 options . . . . Use of RESP and DFHRESP in COBOL and PL/I. Use of RESP and DFHRESP in C and C++ . . . Use of DFHRESP in assembler . . . . . . . An example of exception handling in C . . . . . An example of exception handling in COBOL . . . Modifying default CICS exception handling . . . . . Using the HANDLE CONDITION command . . . . . RESP and NOHANDLE options . . . . . . . . How CICS keeps track of what to do . . . . . . Using the HANDLE CONDITION ERROR command. . Using the IGNORE CONDITION command . . . . . Using the HANDLE ABEND command . . . . . . . Using PUSH HANDLE and POP HANDLE commands . Chapter 17. Abnormal termination recovery . Creating a program-level abend exit . . . . Retrying operations . . . . . . . . . . . Trace . . . . . . . . . . . . . . . . Trace entry points . . . . . . . . . . System trace entry points . . . . . . User trace entry points . . . . . . . Exception trace entry points. . . . . . User exception trace entry points. . . . Monitoring . . . . . . . . . . . . . . Dump . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
127
Using the QUERY SECURITY command . Security protection at the record or field CICS-defined resource identifiers. . . SEC system initialization parameter . . Programming hints . . . . . . . .
. . level . . . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
128
129
the other facilities that CICS provides for this purpose. (See Chapter 13. Sharing data across transactions on page 165 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 view, pseudoconversational transactions are better for quick responses, but recovery and integrity implications may mean that you prefer to use conversational transactions. To summarize, although conversational tasks may be easier to write, they have serious disadvantagesboth in performance (especially the need for virtual storage) and in their effect on the overall operability of the CICS systems containing them. Processors are now larger, with more real storage and more power than in the past, and this makes conversational tasks less painful in small amounts; but if you use conversational applications, you may rapidly run into virtual storage constraint. If you run application programs above the line, you will probably encounter ENQ problems before running into virtual storage constraints. 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. When a transaction makes a change to a recoverable resource, CICS makes that resource unavailable to any other transaction that wants to change it until the original transaction has completed. In the case of a conversational transaction, the resources in question may be unavailable to other terminals for relatively long periods. 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 users 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 users 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,
130
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 previous example poses a further problem for pseudoconversational transactions. Although you could confine all updating to the final transaction of the sequence, there is nothing to prevent a second user from beginning an update transaction against the same record while the first user is still entering changes. This means that you need additional application logic to ensure integrity. You can use some form of enqueuing, or you can have the transaction compare the original version of the record with the current version before actually applying the update.
Terminal interruptibility
When a conversational task is running, CICS allows nothing else to send messages to that tasks terminal. This has advantages and disadvantages. The advantage is that unexpected messages (for example, broadcasts) cannot interrupt the user-machine dialogue and, worse, corrupt the formatted screen. The disadvantage is that the end user cannot then be informed of important information, such as the intention of the control operator to shut down CICS after 10 minutes. More importantly, the unwitting failure of the end user to terminate the conversation may in fact prevent or delay a normal CICS shutdown. Pseudoconversational applications can allow messages to come through between message pairs of a conversation. This means that notices like shutdown warnings can be delivered. This might disturb the display screen contents, and can sometimes interfere with transaction sequences controlled by the RETURN command with the TRANSID option. However, this can be prevented by using the IMMEDIATE option, or by forcing the terminal into NOATI status during the middle of a linked sequence of interactions.
131
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 350.1 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 29 on page 133, a diagram of this logic.
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 exception to this rule. This is possible because communications with TCAM terminals are always queued. Thus your task does not write directly to the destination terminal, but instead writes to a queue that will be delivered to it subsequently by TCAM (see Using TCAM on page 321). BMS routing, described in Chapter 38. Message routing on page 467, is another form of indirect access to other terminals by queues.
132
0
Terminal defined as to be queried? No Yes Has query been run to this terminal? Yes Yes Initiate printing No Initiate CQRY
1
3270 print request key? No Terminal supported by paging? No Yes Paging command entered? Yes Initiate CSPG
3
Transaction specified by TCT TRANSID? No Yes
4
Transaction specified by TRANSID of RETURN? No Yes Initiate specified transaction
5
Attach FMH present? Yes
No
6
Yes 3270? PA, PF, LPA, or OPID? Yes TASKREQ= specified? Yes
No
No
No
7
Terminal input begins with tranid? Yes
No
0.
On the very first input from a terminal, CICS sometimes schedules a preliminary task before creating one to process the input. This task executes the CICS-supplied query transaction, CQRY, which causes the
133
terminal to transmit an encoded description of some of its hardware characteristicsextended attributes, character sets, and so on. CQRY allows the system programmer to simplify maintenance of the terminal network by omitting these particulars from the terminal definitions. It occurs only if the terminal definition so specifies, and has no effect on the subsequent determination of what transaction to use to process the input, which goes as follows. 1. If the terminal is a 3270 and the input is the print request key, the CICS-supplied transaction that prints the contents of the screen, CSPP, is initiated. See CICS print key on page 355 for more information about this feature. For this purpose, a 3270 logical unit or any other device that accepts the 3270 data stream counts as a 3270. If full BMS support is present, the terminal is of a type supported by BMS terminal paging, and the input is a paging command, the CICS-supplied transaction CSPG is initiated to process the request. BMS support levels are explained in BMS support levels on page 393, and the same section contains a list of the terminals that BMS supports. The PGRET, SKRxxxx, PGCHAIN, PGCOPY, and PGPURGE options in the system initialization table define the paging commands. As paging requires full BMS, this step is skipped if the CICS system contains less than that level. If the terminal definition indicates that a specific transaction should be used to process all unsolicited inputs from that terminal, the indicated transaction is executed. (If present, this information appears in the TRANSACTION attribute of the TERMINAL definition.) If the previous task at the terminal specified the TRANSID option of the RETURN command that ended it, the transaction named is executed. If an attach function management header is present in the input, the attach names in the header are converted to a 4-character CICS transaction identifier, and that transaction is executed. If the terminal is a 3270, and the attention identifier is defined as a transaction, that transaction is executed. Attention keys on page 338 explains attention identifiers. You define one as a transaction identifier with the TASKREQ attribute of the corresponding TRANSACTION definition. If all of the preceding tests fail, the initial characters of the input are used to identify the transaction to be executed. The characters used are the first ones (up to four) after any control information in the data stream and before the first field separator character. Field separators are defined in the FLDSEP option of the system initialization table (the default is a blank). If there are no such characters in the input, as occurs when you use the CLEAR key, for example, or if there is no transaction definition that matches the input, CICS cannot determine what transaction to execute and sends an invalid transaction identification message to the terminal. 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.
2.
3.
4. 5.
6.
7.
134
| | | | | | | | | | | |
CICS RECEIVE MAP CICS READ UPDATE CICS REWRITE CICS SEND MAP
| | | | |
A sound principle of modular programming in CICS application design is to separate the presentation logic from the business logic, and to use a communication area and the EXEC CICS LINK command to make them into a single transaction. Figure 31 and Figure 32illustrate this approach to application design.
.. EXEC CICS RECEIVE MAP .. EXEC CICS LINK.. .. EXEC CICS SEND MAP ..
Figure 31. Presentation logic .. EXEC .. EXEC .. EXEC .. EXEC CICS ADDRESS COMMAREA CICS READ UPDATE CICS REWRITE CICS RETURN..
| | | | |
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.
Chapter 11. Application design
135
Multithreading
Multithreading is a technique that allows a single copy of an application program to be processed by several transactions concurrently. For example, one transaction may begin to execute an application program. When an EXEC CICS command is reached, causing a CICS WAIT and call to the dispatcher, another transaction may then execute the same copy of the application program. (Compare this with single-threading, which is the execution of a program to completion: processing of the program by one transaction is completed before another transaction can use it.) 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 DFHEPTR 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.
136
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). Quasi-reentrancy allows programs to access globally shared resourcesfor example, the CICS common work area (CWA)without the need to protect those resources from concurrent access by other programs. Such resources are effectively locked exclusively to the running program, until it issues its next CICS request. Thus, for example, an application can update a field in the CWA without using compare and swap (CS) instructions or locking (enqueuing on) the resource. 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. Take care if a program involves lengthy calculations: because an application program retains control from one EXEC CICS command to the next, the processing of other transactions on the QR TCB is completely excluded. However, you can use the task-control SUSPEND command to allow other transaction processing to proceed; see Chapter 43. Task control on page 499 for details. Note that runaway task time interval is controlled by the transaction definition and the system initialization parameter ICVR. CICS purges a task that does not return control before expiry of the IVCR-specified interval.
Threadsafe programs
In the CICS open transaction environment, threadsafe application programs and open task-related user exits, global user exit programs, and user-replaceable modules cannot rely on quasi-reentrancy, because they can run concurrently on an open TCB. Furthermore, even quasi-reentrant programs are at risk if they access resources that can also be accessed by a user task running concurrently under an open TCB. This means that the techniques used by user programs to access shared resources must take into account the possibility of simultaneous access by other programs. Programs that use appropriate serialization techniques when accessing shared resources are described as threadsafe. (The term fully reentrant is also used sometimes, but this can be misunderstood, hence threadsafe is the preferred term.) For most resources, such as files, transient data queues, temporary storage queues, and DB2 tables, CICS processing automatically ensures access in a threadsafe manner. However, for any other resources, such as shared storage, which are accessed directly by user programs, it is the responsibility of the user program to ensure threadsafe processing. Typical examples of shared storage are the CICS CWA, global user exit global work areas, and storage acquired by EXEC CICS GETMAIN SHARED commands. 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 considerd 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:
Chapter 11. Application design
137
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). v Perform accesses to shared resources only in a program that is defined as quasirent, by linking to the quasirent 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 136 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 application programs that access shared resources obey the rules. A program that is written correctly to threadsafe standards cannot safely update shared resources if another program that accesses the same resources does not obey the threadsafe rules.
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. To use non-reentrant application programs, or tables or control blocks that are modifiable by the execution of associated application programs, specify the RELOAD(YES) option on their resource definition. RELOAD(YES) results in a fresh copy of the program or module being loaded into storage for each request. This option ensures that multithreading tasks that access a non- reentrant program or table each work from their own copy of the program, and are unaffected by changes made to another version of the program by other concurrent tasks running in the CICS region. 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.)
138
If you want to execute a non-reentrant program or module, it must be loaded into a non-read-only DSA. The SDSA and ESDSA are user-key storage areas for non-reentrant user-key programs and modules. For more information about CICS DSAs, refer to the CICS System Definition Guide .
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
139
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 45. Storage control on page 517 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. The amount of processor overhead involved in a GETMAIN command means that you should not use it for a small amount of storage. You should use the TWA for the smaller amounts or group them together into a larger request. Although the storage acquired by a GETMAIN command may be held somewhat longer when using combined requests, the processor overhead and the reference set size are both reduced.
140
The overhead for using COMMAREA in an LINK command is minimal; it is slightly more with the XCTL and RETURN commands, when CICS creates the COMMAREA from a larger area of storage used by the program.
Program storage
CICS creates a separate copy of the variable area of a CICS program for each transaction using the program. This area is known as program storage. This area is called the WORKING-STORAGE SECTION in COBOL, automatic storage in C, C++, and PL/I, and the DFHEISTG section in assembler language. Like the TWA, this area is of fixed size and is allocated by CICS without you having to issue a GETMAIN command. The EXEC CICS interface sets up addressability automatically. Unlike the TWA, however, this storage lasts only while the program is being run, not for the duration of the transaction. This makes it useful for data areas that are not required outside the program and that are either small or, if large, are fixed in size and are required for all or most of the execution time of the program.
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. Temporary storage is implemented by the following methods: v By using a particular queue that is determined by what is specified on the command that creates the first item v By specifying the MAIN option so that the queue is kept in main storage, in space taken from the dynamic storage area v By using the AUXILIARY option so that the queue is written to an entry-sequenced VSAM data set Whichever method you use, CICS maintains an index of items in main storage. 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 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. These methods have characteristics that you should bear in mind: v Main temporary storage requires much more virtual storage than auxiliary. In general, you should use it only for small queues that have short lifetimes or are
Chapter 11. Application design
141
v v
accessed frequently. Auxiliary temporary storage is specifically designed for relatively large amounts of data that have a relatively long lifetime or are accessed infrequently. You may find it useful to establish a cutoff point of a lifetime of one second to decide which queues should be in main storage and which should be in auxiliary. You can make queues in auxiliary storage recoverable, but not queues in main storage: Shared temporary storage applies only to non-recoverable queues. Only one transaction at a time can update a recoverable temporary storage queue. So, if you choose to make queues recoverable, bear in mind the probability of enqueues. You should ensure that there are enough buffers and VSAM strings to eliminate as much contention as possible. If a task tries to write to temporary storage and there is no space available, CICS normally suspends it, although the task can regain control in this situation by using either a HANDLE CONDITION NOSPACE command, or the RESP or NOHANDLE option on the WRITEQ TS command. If suspended, the task is not resumed until some other task frees the necessary space in main storage or the VSAM data set. This can produce unexplained response delays, especially if the waiting task owns exclusive-use resources, in which case all other tasks needing those resources must also wait. It can be more efficient to use main temporary storage exclusively in very low-volume systems that have no need for recovery. You need to balance the needs for additional main storage requirement for the VSAM access method and a larger temporary storage program with the need for main storage for the temporary storage records.
The following points apply to temporary storage in general: v You must use an EXEC CICS command every time data is written to or read from a temporary storage queue, and CICS must find or insert the data using its internal index. This means that the overhead for using main temporary storage is greater than for the CWA or TCTUA. With auxiliary storage, (often the most frequently used), there is usually data set I/O as well, which increases overhead even more. v You need not allocate temporary storage until it is required; you need keep it only as long as it is required, and the item size is not fixed until you issue the command that creates it. This makes it a good choice for relatively high-volume data and data that varies in length or duration. v The fact that temporary storage queues can be named as they are created provides a very powerful form of direct access to saved data. You can access scratch-pad areas for terminals, data set records, and so on, simply by including the terminal name or record key in the queue name. v Resource protection is available for temporary storage.
142
v Transient data does not have the same dynamic characteristics as temporary storage. Unlike temporary storage queues, transient data queues cannot be created at the time data is written by an application program. However, transient data queues can be defined and installed using RDO while CICS is running. v Transient data queues must be read sequentially. Each item can be read only once. After a transaction reads an item, that item is removed from the queue and is not available to any other transaction. In contrast, items in temporary storage queues may be read either sequentially or directly (by item number). They can be read any number of times and are not removed from the queue until the entire queue is purged. These two characteristics make transient data inappropriate for scratch-pad data but suitable for queued data such as audit trails and output to be printed. In fact, for data that is read sequentially once, transient data is preferable to temporary storage. v Items in a temporary storage queue can be changed; items in transient data queues cannot. v Transient data queues are always written to a data set. (There is no form of transient data that corresponds to main temporary storage.) v You can define transient data queues so that writing items to the queue causes a specific transaction to be initiated (for example, to process the queue). Temporary storage has nothing that corresponds to this trigger mechanism, although you may be able to use a START command to perform a similar function. v Transient data has more recovery options than temporary storage. Transient data queues can be physically or logically recoverable. v Because the commands for intrapartition and extrapartition transient data are identical, you can switch between the two types of data set. To do this, change only the transient data queue definitions and not your application programs themselves. Temporary storage has no corresponding function of this kind.
143
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 of your CICS commands 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 205.)
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.
Minimizing errors
This section describes ways of making your applications error-free. Some of these suggestions apply not only to programming, but also to operations and systems. 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.
144
The key points in a well-designed application system are: v At all levels, each function is defined clearly with inputs and outputs well-stated v Resources that the system uses are adequately-defined v Interactions with other systems are known
Testing applications
The following general rules apply to testing applications: v Do not test on a production CICS systemuse 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 48. Testing applications on page 543 for more information about testing applications. v Use the CEDF transaction for initial testing. See Chapter 49. Execution diagnostic facility (EDF) on page 547 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. In particular, look for destroyed storage chains. 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.
Chapter 11. Application design
145
146
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/370, 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.
147
Overhead (but also flexibility) is highest with the XCTL and LINK commands. Both processor and storage requirements are much greater for a LINK command than for an XCTL command. Therefore, if the invoking program does not need to have control returned to it after the invoked program is processed, it should use an XCTL command. | | | | | | | | | 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, JCA, and LLAif used) 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 tasks 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. By contrast, a pseudoconversational sequence of tasks requires almost all of its virtual storage only for the period actually spent processing message pairs. Typically, this takes a period of 13 seconds in each minute (the rest being time waiting for operator input). The overall requirement for multiple concurrent users is thus perhaps five percent of that needed for conversational tasks. However, you should allow for data areas that are passed from each task to the next. This may be a COMMAREA of a few bytes or a large area of temporary storage. If it is the latter, you are normally recommended to use temporary storage on disk rather than in main storage, but that means adding extra temporary storage I/O overhead in a pseudoconversational setup, which you do not need with conversational processing. 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
148
adverse effects of paging increase as transaction rates go up, and so you should minimize its use as much as possible. See Reducing paging effects for information about doing so.
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.
149
v Issuing as few GETMAIN commands as possible. It is generally better for the program to add up its requirements and do one GETMAIN command than to do several smaller ones, unless the durations of these requirements vary greatly. v Avoiding use of the INITIMG option on a GETMAIN command, if possible. It causes an immediate page reference to the storage that is obtained, which might otherwise not occur until much later in the program, when there are other references to the same area. Note: Some of the suggestions above may conflict with your installations 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/370, 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 PL/I, and ORG or equivalents in assembler language. In particular, if you have a
150
map set that uses only one map at a time, code the DFHMSD map set definition without specifying either the STORAGE=AUTO or the BASE operand. This allows the maps in the map set to redefine one another. v Using the COBOL RES option. COBOL subroutines coded with this option are not link-edited into the calling program, but instead are loaded on their first use. They can then be shared by any other COBOL program requiring them. v Using the PL/I shared library (PLISHRE) for such subroutines. Refer to data directly by: v Avoiding long searches for data in tables v Using data structures that can be addressed directly, such as arrays, rather than structures that must be searched, such as chains v Avoiding methods that simulate indirect addressing No attempt should be made to use overlays (paging techniques) in an application program. System paging is provided automatically and has superior performance. The design of an application program for a virtual-storage environment is similar to that for a real environment. The system should have all modules resident so that code on pages not referred to need not be paged 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.
151
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. This protection scheme can also produce deadlocks as well as delays, unless specific conventions are observed. If two transactions update more than one recoverable resource, they should always update the resources in the same order. If they each update two data sets, for example, data set A should be updated before data set B in all transactions. Similarly, if transactions update several records in a single data set, they should always do so in some predictable order (low key to high, or conversely). You might also consider including the TOKEN keyword with each READ UPDATE command. See The TOKEN option on page 254 for information about the TOKEN keyword. Transient data, temporary storage, and user journals must be included among such resources. The CICS Recovery and Restart Guide contains further information on the extent of resource protection. 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 tasks 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
152
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 GETMAIN commands, failure to release storage when it is no longer needed, unintentional logic loops, and failure to unlock records held for exclusive control that are no longer needed.
2. HANDLE CONDITION and IGNORE CONDITION commands are not supported for C and C++ programs. Chapter 12. Design for performance
153
1. If the command has the NOHANDLE or RESP option, control returns to the next instruction in the application program. Otherwise, the condition table is scanned 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: v If the command has the NOSUSPEND or NOQUEUE option, control returns to the next instruction. v 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 looking for the ERROR condition: v If found, this entry determines the action. v If ERROR is searched for and not found, the task is abended.
154
v Minimize the time that VSAM resources are reserved for exclusive use. The exclusive use enqueue is the way CICS and VSAM prevent concurrent updates. If you use VSAM record-level sharing, described in Accessing files in RLS mode on page 237, VSAM locks a record that has been requested for update, so that no other transaction can attempt to update the record at the same time. If the file is recoverable, VSAM releases the lock at the next syncpoint. If the file is not recoverable, VSAM releases the lock when the request is complete. The recoverability of a file, is defined in the integrated catalog facility (ICF) catalog. If you do not use VSAM record-level sharing, CICS serializes update requests by base cluster record key. VSAM serializes by enqueuing on the control interval (CI), so that no transaction can update a record in the same control interval as another record being updated. The VSAM hold for exclusive use ends when the request is complete in VSAM terms. For example, in an update operation, exclusive use that starts with the READ command with the UPDATE option and ends when VSAM has completed the REWRITE command. For nonrecoverable data sets, the CICS exclusive use ends at the same time. For recoverable data sets, however, it does not end until the task ends or issues a SYNCPOINT command. Recoverability is specified in the data set resource definition. See the CICS Resource Definition Guide for more information about the FILE resource definitions. Table 10 shows which requests require exclusive use and when that reservation terminates. This table applies only if you are not using record-level sharing.
Table 10. Requests that require exclusive use and when reservation terminates Command READ.. UPDATE WRITE.. MASSINSERT WRITE DELETE.. RIDFLD Released by VSAM at REWRITE/DELETE/UNLOCK UNLOCK Completion of WRITE Completion of DELETE
v Hold position in a VSAM data set for as short a time as possible. Table 11 shows which commands hold position and when the hold is released.
Table 11. Commands that hold position and when hold is released Command READ.. UPDATE WRITE.. MASSINSERT STARTBR Released by VSAM at REWRITE/DELETE/UNLOCK UNLOCK ENDBR
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. To minimize processor overhead when using VSAM data sets: v Use the MASSINSERT option if you are adding many records in sequence. This improves performance by minimizing processor overheads and therefore improves the response times. For ESDSs and KSDSs, adding records with MASSINSERT causes CICS to use sequential VSAM processing. This changes the way VSAM places records within control intervals when a split is required, resulting in fewer splits and less unused space within the affected CIs.
155
v Use skip sequential processing if you are reading many records in sequence whose keys are relatively close together but not necessarily adjacent. (Skip sequential processing begins with a start browse (STARTBR command).) Each record is retrieved with an READNEXT command, but the key feedback area pointed to by RIDFLD is supplied with the key of the next requested record before the READNEXT command is issued. v Use the GENERIC option on the DELETE command when deleting a group of records whose keys start with a common character string. CICS internally optimizes a generic DELETE.
Efficient logging
CICS provides options to log some or all types of activity against a data set. Logging updates enables you to reconstruct data sets from backup copies, if necessary. You may also want to log reads for security reasons. Again, you have to balance the need for data integrity and security against the performance effects of logging. These are the actual operations needed to do the logging and the possible delays caused because of the exclusive control that logging implies.
156
storage on page 141 and in Intrapartition transient data on page 142) are the most efficient to use, but they must be created and processed entirely within CICS. Extrapartition transient data is the CICS way of handling standard sequential (QSAM/BSAM) data sets. It is the least efficient of the three forms of sequential support listed, because CICS has to issue operating system waits to process the data sets, as it does when handling BDAM. Moreover, extrapartition transient data sets are not recoverable. VSAM ESDSs, on the other hand, are recoverable within limitations, and processing is more efficient. The recovery limitation is that records added to an ESDS during an uncompleted UOW cannot be removed physically during the backout process, because of VSAM restrictions. They can, however, be flagged as deleted by a user exit routine. CICS journals provide another good alternative to extrapartition transient data, although only for output data sets. Journals are managed by the MVS system logger, but flexible processing options permit very efficient processing. Each journal command specifies operation characteristics, for example, synchronous or asynchronous, whereas extrapartition operations are governed entirely by the parameters in the transient data queue definition. Transactions should journal asynchronously, if possible, to minimize task waits in connection with journaling. However, if integrity considerations require that the journal records be physically written before end of task, you must use a synchronous write. If there are several journal writes, the transaction should use asynchronous writes for all but the last logical record, so that the logical records for the task are written with a minimum number of physical I/Os and only one wait. 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.
157
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.
158
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 418 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.
159
respond with a SEND CONTROL ERASEAUP command (or a map that contains only a short confirmation message and specifies the ERASEAUP option). This causes all the unprotected fields on the screen (that is, all the input data from the last entry) to be erased and to have their MDTs reset. The labels and other text, which are in protected fields, are unchanged, the screen is ready for the next data-entry cycle, and only the necessary data has been sent.
160
data set I/O activity. The pages must then be saved in temporary storage. If the terminal user looks at every page in a message, a large number of transactions are run to process the paging requests, each of which needs line and processor overhead. Obviously some overhead is caused by the size and complexity of the transaction, and it may be unavoidable. Indeed, if several users are scrolling rapidly through paged output at the same time, the transactions needed can monopolize a system. 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 first example, the next transaction identifier is set to the original transaction so that, if CICS does not receive a paging command, it invokes that transaction.
161
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 DFHTDWT 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.
162
163
164
165
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 45. Storage control on page 517. Figure 33 illustrates a particular use of the CWA where the CWA itself is protected from user-key application programs by CWAKEY=CICS. 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 defined with EXECKEY(USER), thereby ensuring the CWA is protected from overwriting by application programs. In Figure 33, one of the data areas is obtained from CICS-key storage, while the other is obtained from user-key storage.
CWA (defined with CWAKEY=CICS) appl1_id ptr_ref1 appl2_id ptr_ref2 Application Storage Area (for appl2) (obtained from user-key storage) The CWA is initialized by an AMODE(31) PLTPI program, which obtains storage for application-related tables, and stores the addresses of the GETMAINed storage in the CWA.
Figure 33. 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 the sample code shown in Figure 34 on page 167, the program list table post-initialization (PLTPI) program is setting up the application data areas, with pointers to the data stored in the CWA.
166
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.
Figure 34. Sample code for loading the CWA (Part 1 of 2). This example illustrates how to create global data for use by application programs, with addresses of the data stored in the CWAfor 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).
167
* Get 2KB of user-key storage for the second application ('APP2') MOVE 2048 TO AREA-LENGTH. EXEC CICS GETMAIN SET(AREA-PTR) FLENGTH(AREA-LENGTH) SHARED USERDATAKEY END-EXEC. * Initialize CWA fields and link to load program * for storage area 2. MOVE 'APP2' TO APPL-2-ID. SET APPL-2-PTR TO AREA-PTR. EXEC CICS LINK PROGRAM('LOADTAB2') COMMAREA(COMM-DATA) END-EXEC. EXEC CICS RETURN END-EXEC. MAIN-PROCESSING-EXIT. GOBACK.
Figure 34. Sample code for loading the CWA (Part 2 of 2). This example illustrates how to create global data for use by application programs, with addresses of the data stored in the CWAfor 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).
168
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 same care as the CWA to ensure that data used in one transaction does not overlay data used in another. You should not exceed the length of the allocated TCTUA, because this produces a storage violation.
169
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.
170
| | | | |
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.
| | |
Transactions, program-link requests, EXEC CICS START requests, CICS business transaction services (BTS) activities, and enterprise bean method calls can all be dynamically routed. You can use a dynamic routing program to dynamically route: v Transactions started from terminals v Transactions started by eligible terminal-related EXEC CICS START commands v Eligible CICS-to-CICS DPL requests v Eligible program-link requests received from outside CICS. You can use a distributed routing program to dynamically route: v Eligible BTS processes and activities. (BTS is described in the CICS Business Transaction Services manual.) v Eligible non-terminal-related EXEC CICS START requests. 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.
This chapter describes: v Types of affinity on page 172 v Programming techniques and affinity on page 173 v Safe programming to avoid affinity on page 174 v Unsafe programming for affinity on page 179
Copyright IBM Corp. 1989, 2001
171
v Suspect programming for affinity on page 186 v Detecting inter-transaction affinities on page 196 v Duration and scope of inter-transaction affinities on page 197
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. Note: The same is true if two transactions synchronize, using an enqueue (ENQ) mechanism, unless you have used appropriate ENQMODEL resource definitions (see the CICS Resource Definition Guide for a description of ENQMODELs) to give sysplex-wide scope to the ENQs.
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 regiontransaction-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.
172
Global user exits running in different CICS regions cannot exchange data. It is unlikely that user transactions pass data or parameters by means of user exits, but if such transactions do exist, they must run in the same target region as the global user exits.
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 (see Using ENQ and DEQ commands with ENQMODEL resource definitions on page 177 and the CICS Resource Definition Guide for a description of ENQMODELs) to give sysplex-wide scope to the ENQs. 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 174.
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.
Chapter 14. Affinity
173
See Sharing task-lifetime storage on page 182 for more details. v Synchronization or serialization of tasks using CICS commands: WAIT EVENT / WAIT EXTERNAL / WAITCICS ENQ / DEQ,unless you have used appropriate ENQMODEL resource definitions (see Using ENQ and DEQ commands with ENQMODEL resource definitions on page 177 and the CICS Resource Definition Guide for a description of ENQMODELs) to give sysplex-wide scope to the ENQs. For more information about unsafe programming techniques, see Unsafe programming for affinity on page 179.
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 For more information about suspect programming techniques, see Suspect programming for affinity on page 186.
Recommendations
The best way to deal with inter-transaction affinity is to avoid creating inter-transaction affinity in the first place. Where it is not possible to avoid affinities, you should: v Make the inter-transaction affinity easily recognizable, by using appropriate naming conventions, and v Keep the lifetime of the affinities as short as possible. Even if you could avoid inter-transaction affinities by changing your application programs, this is not absolutely necessary provided you include logic in your dynamic and distributed routing programs to cope with the affinities. Finally, you can statically route the affected transactions.
174
would have to be long-life storage, the use of which is an unsafe programming technique in a dynamic transaction routing environment.
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. CICS ensures that the contents of the COMMAREA specified on a RETURN command are always made available to the first program in the next transaction. This is true even when the sending and receiving transactions execute in different target regions. In a pseudoconversation, regardless of the target region to which a dynamic routing program chooses to route the next transaction, CICS ensures the COMMAREA specified on the previous RETURN command is made available in the target region. This is illustrated in Figure 35 on page 176. Some general characteristics of a COMMAREA are: v Processor overhead is low. v It is not recoverable. v The length of a COMMAREA on a RETURN command can vary from transaction to transaction, up to a theoretical upper limit of 32 763 bytes. (However to be safe, you should not exceed 24KB (1KB = 1024 bytes), as recommended in the Application Programming Reference manual, because of a number of factors that can reduce the limit from the theoretical maximum.) v CICS holds a COMMAREA in CICS main storage until the terminal user responds with the next transaction. This may be an important consideration if you are using large COMMAREAs, because the number of COMMAREAs held by CICS relates to terminal usage, and not to the maximum number of tasks in a region at any one time. v A COMMAREA is available only to the first program in the next transaction, unless that program explicitly passes the data to another program or a succeeding transaction.
175
TOR1 (1) Using DTR, routes TRN1 to AOR1. (2) Using DTR, routes TRN2 to AOR2 AOR1 Executes TRN1 TRN1 terminates with EXEC CICS RETURN COMMAREA(DATA) TRANSID(TRN2) AOR2 Executes TRN2 TRN2 has access to the COMMAREA data passed by TRN1
Figure 35. The use of a COMMAREA by a pseudoconversation in a dynamic transaction routing environment
The COMMAREA used in a pseudoconversational transaction, as shown in Figure 35, can be passed from transaction to transaction across a CICSplex, and, provided the COMMAREA contains only data and not addresses of storage areas, no inter-transaction affinity is created.
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 36 on page 177. 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.
176
Note that the TCTUA is available to a dynamic routing environment in the routing region as well as application programs in the target region. It can be used store information relating to the dynamic routing of a transaction. For example, you can use the TCTUA to store the name of the selected target region to which a transaction is routed.
TOR1 (1) Using DTR, routes TRN1 to AOR1. (2) Using DTR, routes TRN2 to AOR2
AOR1 Executes TRN1 which: (1) Gets TCTUA address (2) Stores data in TCTUA for next transaction (3) Ends with EXEC CICS RETURN TRANSID(TRN2)
AOR2 Executes TRN2 which: (1) Gets address of the TCTUA (2) Accesses the data stored by TRN1.
177
resource shared by tasks in different regions. Now, provided that the ENQs and DEQs are supported by appropriate ENQMODEL resource definitions (see the CICS Resource Definition Guide for a description of ENQMODELs) they can have sysplex-wide scope. This is primarily of interest to the system programmer who will determine transaction routing decisions, but application programmers should be aware of the advantages now available.
Benefits
Sysplex enqueue provides the following benefits: v Eliminates one of the most common causes of inter-transaction affinity. v Enables better exploitation of a parallel sysplex providing better price/performance, capacity, and availability.
178
v Reduces the need for inter-transaction affinity rules in dynamic and distributed routing programs thereby lowering the systems management cost of exploiting parallel sysplex. v Enables serialization of concurrent updates to shared temporary storage queues, performed by multiple CICS tasks across the sysplex. v Makes it possible to prevent interleaving of records written by concurrent tasks in different CICS regions to a remote transient data queue. v Allows the single-threading and synchronization of tasks across the sysplex. It is not designed for the locking of recoverable resources.
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 containers 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. Some general characteristics of containers are: v An activity may own any number of containers; you are not limited to one. v There is no size restriction. v They are recoverable. v They exist in main storage only while the associated activity is executing. Otherwise they are held on disk. Therefore, you do not need to be overly concerned with their storage requirements, unlike terminal COMMAREAs.
179
TOR DTR program If the dynamic routing program routes TRN2 to AOR3 as shown, TRN2 will fail to access the data stored for it by TRN1.
AOR1 CWA
AOR2 CWA
AOR3 CWA
CWA
Figure 37. 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.
180
In this example, the TOR must route TRN2 to AOR1, because it needs access to shared storage obtained by TRN1 in that region.
AOR1 Executes TRN1 which: (1) GETMAINs some SHARED storage (2) Stores data in shared storage (3) WRITEs address to a TS queue Terminates (leaving shared storage still allocated) Executes TRN2 which: (1) READs address from TS queue (2) Reads data from shared storage (3) FREEMAINs the shared storage Terminates
AOR2
Figure 38. 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.
If the two transactions shown in Figure 38 are parts of a pseudoconversational transaction, the use of shared storage should be replaced by a COMMAREA (provided that the amount of storage fits within the COMMAREA size limits).
181
ensure that all transactions that use the address of the loaded program (or table) are routed to the same target region.
TOR DTR program In this example, the TOR must route to AOR1 all other transactions that require access to the program (table) loaded by TRN1.
AOR1 Executes TRN1 which: (1) Issues LOAD PROGRAM HOLD command. (2) Terminates. Executes other transactions that: (1) Issue LOAD PROGRAM with SET option. (2) Read data from the loaded program (table) (3) Terminate.
AOR2
Figure 39. Illustration of inter-transaction affinity created by use of shared storage. 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.
182
For example, it is possible to use a temporary storage queue to pass the address of a PL/I automatic variable, or the address of a COBOL working-storage structure (see Figure 40 for an example).
AOR TRN1 1. Stores the address of task-lifetime storage (in TS queue) for TRN2 2. Suspends until TRN2 completes . (waiting) . . 3. Continues. TRN2 1. Reads address from TS queue. 2. Accesses the storage. 3. Resumes TRN1.
Figure 40. 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 12 for commands that provide ways of suspending and resuming a task that passes the address of its local storage.
Table 12. Methods for suspending and resuming (synchronizing) tasks Suspending operation WAIT EVENT, WAIT EXTERNAL, WAITCICS RETRIEVE WAIT DELAY POST START ENQ Resuming operation POST START CANCEL CANCEL CANCEL 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 12 are fundamentally unsafe because it is possible that the storage-owning task could be purged.
183
Notes: 1. Using synchronization techniques, such as RETRIEVE WAIT/START, to allow sharing of task-lifetime storage is unsafe in CICS Version 2 because the task issuing, for example, the RETRIEVE WAIT could be purged by a CEMT SET TASK(...) PURGE command. In CICS/ESA Version 3 and later, the SPURGE parameter on the transaction definition could be used to protect the first task, but even so the design is not recommended. 2. No inter-transaction affinity is caused in those cases where the task sharing another tasks task-lifetime storage is started by an START command, except when the START command is function-shipped or routed to a remote system.
AOR TRN1 1. Stores the address of ECB in temporary storage queue for TRN2 2. Suspends with WAIT EVENT ECADDR(ptr-ref) . . (waiting) . . . . 3. Resumed by CICS
TRN2 1. At end of processing, (completion of event) reads address of ECB from TS queue. 2. Posts ECB (by MVS POST or 'hand-posted') 3. Returns control to CICS
Figure 41. Illustration of inter-transaction affinity created by use of WAIT EXTERNAL command. TRN2 must execute in the same target region as TRN1.
If TRN2 shown in Figure 41 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
184
or distributed routing program must ensure that a posting task executes in the same target region as the waiting task to preserve the application design. The same considerations apply to the use of WAIT EXTERNAL and WAITCICS commands for synchronizing tasks.
AOR TRN1 1. Issues ENQ command on resource name of shared resource 2. Modifies or uses shared resource . . 3. Issues DEQ command on shared resource. TRN2 1. Issues ENQ command on resource name of shared resource 2. Suspended by CICS while resource in use by TRN1 3. Resumed by CICS when resource free
Figure 42. Illustration of inter-transaction affinity created by use of ENQ/DEQ commands. TRN2 must execute in the same target region as TRN1.
If TRN2 shown in Figure 42 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
185
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.
186
data-sharing pool. See Figure 43 for an illustration of a temporary storage data-sharing server.
TOR DTR program DFHTSTXX Prefix| Sysid AOR1 TST=XX AOR2 TST=XX AOR3 TST=XX AOR4 TST=XX AAAA* ABCD* XXXX* ZZZZ* Sysid CICQ DFHXQMN TS Server CICQ CICQ CICQ CICQ Pool DFHXQTS1
Coupling Facility
Figure 43. Example of the use of the temporary storage data-sharing server
187
Remote queues and shared queues can be defined in the same way for application programs, but requests for specific SYSIDs are routed to a temporary storage data server by means of TST TYPE=SHARED. However, if the naming convention for dynamically named queues does not conform to this rule, the queue cannot be defined as remote, and all transactions that access the queue must be routed to the target region where the queue was created. Furthermore, a TS queue name cannot be changed from a local to a remote queue name using the global user exits for TS requests. See Figure 44 for an illustration of the use of a remote queue-owning region.
DFHTSTXX Prefix Sysid AOR1 TST=XX AOR2 TST=XX AOR3 TST=XX AOR4 TST=XX AAAA* ABCD* XXXX* ZZZZ* CICQ CICQ CICQ CICQ
ROR
Figure 44. 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.
188
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. Figure 45 illustrates the use of a remote transient data queue-owning region.
TDQ defn. Queue AOR1 AOR2 AOR3 AOR4 AAAA ABCD XXXX ZZZZ CICQ CICQ CICQ CICQ Syst.
TDQ definition Queue FOR QOR (CICQ) AAAA ABCD XXXX ZZZZ Trig. Tran. Term. nn nn BBBB CCCC Tnnn Pnnn
Figure 45. 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.
189
The steps are as follows: 1. TRN1 writes data to a TS queue, containing its TRANSID and TERMID. 2. To cause itself to suspend, TRN1 issues a RETRIEVE WAIT command, which causes CICS to suspend the task until the RETRIEVE can be satisfied, which is not until TRN2 issues a START command with data passed by the FROM parameter. 3. However, TRN2 can only issue a START command to resume TRN1 if it knows the TRANSID and TERMID of the suspended task (TRN1 in our example). Thus it reads the TS queue to obtain the information written by TRN1. Using a temporary storage queue is one way that this information can be passed by the suspending task. 4. Using the information from the TS queue, TRN2 issues the START command for TRN1, causing CICS to resume TRN1 by satisfying the outstanding RETRIEVE WAIT.
AOR TRN1 1. Stores its TRANSID and TERMID in a TS queue for TRN2 2. Suspends by issuing a RETRIEVE WAIT . . (suspended) . . 3. Resumes. TRN2 1. Reads TRANSID & of TRN1 from TS . (process) . 3. Resumes TRN1 by START with FROM TERMID queue
issuing option.
Figure 46. Illustration of task synchronization using RETRIEVE WAIT and START commands
In the example of task synchronization using RETRIEVE WAIT and START commands shown in Figure 46, the START command that satisfies the RETRIEVE WAIT must: v Be issued in same target region as the transaction (TRN1 in our example) issuing the RETRIEVE WAIT command, or v Specify the SYSID of the target region where the RETRIEVE WAIT command was executed, or v Specify a TRANSID (TRN1 in our example) that is defined as a remote transaction residing on the target region that executed the RETRIEVE WAIT command.
190
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.
191
AOR TRN1 1. Starts TRNX and obtains the REQID 2. Writes the REQID for the START request to a TS queue 3. Terminates. (suspended) TRN2 1. Reads REQID from TS 2. Cancels TRNX using REQID
Figure 47. 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.
192
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. The process using a TS queue is illustrated in Figure 48 on page 194. Another way to pass the REQID when employing this technique would be for TRN1 to start TRN2 using the START command with the FROM and TERMID options. TRN2 could then obtain the REQID with the RETRIEVE command, using the INTO option.
193
AOR TRN1 1. Writes DELAY command REQID to TS queue for use by TRN2 2. Issues DELAY to wait until TRN2 issues CANCEL command . . (suspended) . . . . 3. Resumes. TRN2 1. Reads REQID of DELAY from TS queue . (process) . 2. Completes processing 3. Resumes TRN1 by CANCELing the DELAY.
Figure 48. 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. If the CANCEL command is issued by a transaction that is initiated from a terminal, it is possible that the transaction could be dynamically routed to the wrong target region.
194
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. Figure 49 illustrates this technique.
AOR TRN1 1. Issues POST command 2. Stores REQID of POST in TS queue for use by TRN2 . (process) . . . 3. Periodically check if posted 4. Resumes when time expired, or when POST cancelled by TRN2.
TRN2 1. Reads REQID of POST request . (process) . 2. Completes processing 3. Resumes TRN1 by CANCELing the POST.
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
195
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 REQID is indicative of an inter-transaction affinity problem. However, REQID need not be specified on the POST command because CICS automatically generates a REQID and pass it to the application in EIBREQID.
196
197
START command, or by any CICS BTS process, must execute in the same target region for the lifetime of the affinity. The affinity lifetime for global relations can be as follows: System The affinity lasts for as long as the target region exists, and ends whenever the target region terminates (at a normal, immediate, or abnormal termination). Permanent The affinity extends across all CICS restarts. This is the most restrictive of all the inter-transaction affinities. If you are running CICSPlex SM, this affinity lasts for as long as any CMAS involved in managing the CICSplex using the workload is active. An example of a global inter-transaction affinity with a lifetime of permanent is where the transaction uses (reads and/or writes) a local, recoverable, temporary storage queue, and where the TS queue name is not derived from the terminal. (You can only specify that a TS queue is recoverable in the CICS region in which the queue is local.) Generally, transactions in this affinity category are not suitable candidates for dynamic routing and you should consider making them statically routed transactions. An example of a global relation is illustrated in Figure 50.
Terminal User enters tranid GGGG TOR Calls DTR program Routes GGGG to AOR2 DTR program Affinity group Relation: GLOBAL Lifetime: PERM Transids: GGGG
1. Checks affinity groups for GGGG 2. Start global affinity for transid GGGG 3. Select AOR from candidate list 4. Records choice of AOR (for example, AOR2) for this group.
AOR1
AOR2 GGGG
AOR3
AOR4
AOR5
AOR6
Figure 50. Managing inter-transaction affinity with global relation and permanent lifetime
In this example, the first instance of transid GGGG, from any terminal, starts a permanent-lifetime affinity. The first instance of GGGG can be routed to any suitable target region (AOR1 through AOR6), but all other instances, from any terminal, must be routed to whichever target region is selected for GGGG.
198
199
TOR Calls DTR program Routes AAAA to AOR4 DTR program Affinity group Relation: LUNAME Lifetime: PCONV Transids: AAAA BBBB . . ZZZZ AAAA on IGKS201 sent to AOR4
1. Checks affinity groups for AAAA 2. Detects start of pseudoconv. 3. Selects an AOR from candidate list. 4. Records choice of AOR (for example, AOR4) for this group.
AOR1
AOR2
AOR3
AOR4 AAAA
AOR5
AOR6
Figure 51. Managing inter-transaction affinity with LUname relation and pseudoconversation lifetime
In this example, each instance of transid AAAA from a terminal starts a pseudoconversational-lifetime affinity. AAAA can be routed to any suitable target region (AOR1 through AOR6), but other transactions in the group from the same terminal (IGKS201 in this example) must be routed to whichever target region is selected for AAAA.
200
Delimit The affinity continues until a transaction with a pseudoconversation mode of END is encountered. 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 52.
TOR Calls DTR program Routes WWWW to AOR4 DTR program Affinity group Relation: USERID Lifetime: SIGNON Transids: WWWW XXXX . . YYYY WWWW sent to AOR4 for user=ANOTHER
1. Checks affinity groups for WWWW 2. Detects start of pseudoconv. 3. Selects an AOR from candidate list. 4. Records choice of AOR (for example, AOR4) for this group.
AOR1
AOR2
AOR3
AOR4 WWWW
AOR5
AOR6
Figure 52. Managing inter-transaction affinity with userid relation and sign-on lifetime
In this example, any instance of a transaction from a terminal starts a sign-on lifetime affinity. It can be routed to any suitable target region (AOR1 through AOR6), but other transactions in the group for the same user (ANOTHER in this example) must be routed to whichever target region is selected for the first instance of a transaction in the group.
201
Permanent The affinity extends across all CICS restarts. If you are running CICSPlex SM, this affinity lasts for as long as any CMAS involved in managing the CICSplex using the workload is active. A typical example of transactions that have a BAPPL relation is where a local temporary storage queue is used to pass data between the transactions within a BTS activity or process. An example of an affinity group with the BAPPL relation is shown in Figure 53.
AOR 1 BAPPL activity started Transid BAP1 Calls dynamic routing program Routes BAP1 to AOR4 Dynamic routing program 1. Checks affinity groups for BAP1. 2. Start BAPPL affinity for transid BAP1 3. Select target region from candidate list 4. Record choice of target region (for example, AOR4) for this group. Affinity group Relation: BAPPL Lifetime: ACTIVITY Transid : BAP1
AOR2
AOR3
AOR4
AOR5
AOR6
Figure 53. Managing inter-transaction affinity with BAPPL relation and activity lifetime
In this example, the first instance of BTS transaction BAP1 starts a BAPPLactivity 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 affinitys 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.
202
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 of PERMANENT. If there is a total system failure, or a planned shutdown, affinities will be lost, but activities in CICS will be recovered from the BTS RLS data set.
203
204
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 16. Dealing with exception conditions on page 209. (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.
205
Note: In some cases, a SHUTDOWN IMMEDIATE can cause user journal records to be lost, if they have been written to a log manager buffer but not to external storage. This is also the case if the CICS shut-down assist transaction (CESD) forces SHUTDOWN IMMEDIATE during a normal shutdown, because normal shutdown is hanging. To avoid the risk of losing journal records, you are recommended to issue CICS WAIT JOURNALNUM requests periodically, and before ending your program. 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. The advantages that may be gained by deferring journal output are: v Transactions may get better response times by waiting less. v The load of physical I/O requests on the host system may be reduced.
206
v Log streams may contain fewer but larger blocks and so better utilize primary storage. 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 an individual task fails, backout is performed by the dynamic transaction backout program. If the CICS system fails, backout is performed as part of the emergency restart process. See the CICS Recovery and Restart Guide which describes these facilities, which in general have no effect on the coding of application programs. However, for long-running programs, it may be undesirable to have a large number of changes, accumulated over a period of time, exposed to the possibility of
Chapter 15. Recovery design
207
backout in the event of task or system failure. This possibility can be avoided by using the SYNCPOINT command to split the program into logically separate sections known as units of work (UOWs); the end of an UOW is referred to as a synchronization point (syncpoint). For more information about syncpoints, see the CICS Recovery and Restart Guide. 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.3 The SAA Resource Recovery interface is implemented as a call interface, having two call types: SRRCMIT CommitEquivalent to SYNCPOINT command. SRRBACK BackoutEquivalent to SYNCPOINT ROLLBACK command. 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. In addition to a DL/I termination call being considered to be a syncpoint, the execution of a SYNCPOINT command causes CICS to issue a DL/I termination call. If a DL/I PSB is required in a subsequent UOW, it must be rescheduled using a program control block (PCB) call or a SCHEDULE command. With distributed program link (DPL), it is possible to specify that a syncpoint is taken in the server program, to commit the server resources before returning control to the client. This is achieved by using the SYNCONRETURN option on the LINK command. For programming information about the SYNCONRETURN option, see The SYNCONRETURN option for the server program on page 5 on page 379 and the CICS Application Programming Reference manual. 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. Consult your system programmer if syncpoints are to be issued in a transaction that is eligible for transaction restart.
3. 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.)
208
209
causes the variable named by the argument of RESP to be updated with the value of the condition returned by the command. This is described in more detail in Handling exception conditions by in-line code. v Write your application program in C or C++. If the default CICS exception handling is turned off you should ensure that your program copes wit