COB64 Programming Guide
COB64 Programming Guide
6.4
Programming Guide
IBM
SC27-8714-03
Note
Before using this information and the product it supports, be sure to read the general information under
“Notices” on page 973.
Tables.................................................................................................................xxi
Preface............................................................................................................. xxix
About this information.............................................................................................................................xxix
How this information will help you.................................................................................................... xxix
Abbreviated terms..............................................................................................................................xxix
Comparison of commonly used terms................................................................................................xxx
How to read syntax diagrams............................................................................................................ xxxi
How examples are shown................................................................................................................. xxxii
Additional documentation and support................................................................................................ xxxiii
Summary of changes............................................................................................................................. xxxiii
Enterprise COBOL for z/OS 6.4 with PTFs installed........................................................................ xxxiii
Enterprise COBOL for z/OS 6.4........................................................................................................ xxxiv
How to send your comments..................................................................................................................xxxv
iii
Assigning input from a screen or file (ACCEPT)............................................................................. 35
Displaying values on a screen or in a file (DISPLAY)........................................................................... 35
Displaying data on the system logical output device.....................................................................36
Using WITH NO ADVANCING..........................................................................................................37
Using intrinsic functions (built-in functions)....................................................................................... 38
Using tables (arrays) and pointers....................................................................................................... 39
Storage and its addressability..............................................................................................................39
iv
Chapter 5. Selecting and repeating program actions............................................................................... 91
Selecting program actions................................................................................................................... 91
Coding a choice of actions.............................................................................................................. 91
Coding conditional expressions......................................................................................................95
Repeating program actions.................................................................................................................. 99
Choosing inline or out-of-line PERFORM....................................................................................... 99
Coding a loop................................................................................................................................ 100
Looping through a table................................................................................................................101
Executing multiple paragraphs or sections................................................................................. 101
v
Reference modifiers and UTF-8 data items.................................................................................148
UTF-8 groups................................................................................................................................ 149
Converting to or from UTF-8 (Unicode) representation.............................................................. 150
Comparing UTF-8 data................................................................................................................. 151
Processing UTF-8 data using UTF-16 (national) data types.............................................................153
Using intrinsic functions to process UTF-8 encoded data...........................................................153
Processing Chinese GB 18030 data.................................................................................................. 157
Coding for use of DBCS support.........................................................................................................158
Defining DBCS data.......................................................................................................................158
Using DBCS literals....................................................................................................................... 159
Testing for valid DBCS characters................................................................................................ 159
Processing alphanumeric data items that contain DBCS data....................................................160
vi
Handling errors in VSAM files............................................................................................................ 204
Protecting VSAM files with a password............................................................................................. 204
Example: password protection for a VSAM indexed file..............................................................205
Working with VSAM data sets under z/OS and z/OS UNIX............................................................... 205
Defining VSAM files.......................................................................................................................205
Creating alternate indexes........................................................................................................... 206
Allocating VSAM files....................................................................................................................208
Sharing VSAM files through RLS...................................................................................................209
Allocation of record areas for VSAM files.......................................................................................... 211
Improving VSAM performance...........................................................................................................211
Extended addressability support.......................................................................................................212
vii
Handling errors in joining and splitting strings..................................................................................242
Handling errors in arithmetic operations.......................................................................................... 242
Example: checking for division by zero........................................................................................ 243
Handling errors in input and output operations................................................................................ 243
Using the end-of-file condition (AT END).....................................................................................246
Coding ERROR declaratives..........................................................................................................246
Using file status keys.................................................................................................................... 247
Example: file status key................................................................................................................248
Using VSAM status codes (VSAM files only)................................................................................ 248
Example: checking VSAM status codes....................................................................................... 249
Coding INVALID KEY phrases.......................................................................................................250
Example: FILE STATUS and INVALID KEY................................................................................... 251
Handling errors when calling programs............................................................................................ 251
Writing routines for handling errors...................................................................................................252
viii
Creating a DLL under z/OS UNIX.................................................................................................. 286
Example: using cob2 to compile and link under z/OS UNIX....................................................... 286
cob2 syntax and options...............................................................................................................287
cob2 input and output files.......................................................................................................... 289
Compiling using scripts...................................................................................................................... 290
Chapter 17. Compiling, linking, and running non-OO COBOL applications that interoperate with
Java..................................................................................................................................................... 301
Building non-OO applications that interoperate with Java...............................................................301
Introducing the COBPROD application..............................................................................................302
Preparing to compile, bind, and run non-OO COBOL applications that interoperate with Java......303
Step 1: Compiling user COBOL programs..........................................................................................303
Step 2: Running the cjbuild utility to build a DLL of Java stub programs......................................... 304
Step 3: Linking COBOL programs.......................................................................................................307
Step 4: Building Java programs......................................................................................................... 308
Example: COBPROD application - building and running................................................................... 308
Sample JCL for building and running the COBPROD application......................................................314
Example: COBOL-calls-Java application - building and running...................................................... 321
Sample JCL for building and running the COBOL-calls-java application..........................................324
Troubleshooting................................................................................................................................. 329
AMODE considerations for running non-OO COBOL/Java interoperable applications.................... 330
cjbuild command reference .............................................................................................................. 330
Chapter 18. Compiling, binding, and running COBOL AMODE 64 applications..................................... 335
Compiling and binding AMODE 64 programs under z/OS................................................................. 335
DLL considerations.............................................................................................................................336
Compiling and binding AMODE 64 programs under z/OS UNIX....................................................... 336
Running COBOL AMODE 64 applications.......................................................................................... 337
Specifying COBOL only runtime options............................................................................................337
ix
COMPILE....................................................................................................................................... 355
CONDCOMP...................................................................................................................................356
COPYLOC.......................................................................................................................................356
COPYRIGHT.................................................................................................................................. 357
CURRENCY.................................................................................................................................... 358
DATA..............................................................................................................................................359
DBCS............................................................................................................................................. 360
DECK............................................................................................................................................. 360
DEFINE..........................................................................................................................................360
DIAGTRUNC.................................................................................................................................. 362
DISPSIGN......................................................................................................................................362
DLL................................................................................................................................................ 363
DUMP............................................................................................................................................ 365
DYNAM.......................................................................................................................................... 366
EXIT...............................................................................................................................................367
EXPORTALL................................................................................................................................... 369
FASTSRT........................................................................................................................................369
FLAG..............................................................................................................................................369
FLAGSTD....................................................................................................................................... 370
HGPR.............................................................................................................................................372
INITCHECK................................................................................................................................... 373
INITIAL......................................................................................................................................... 374
INLINE.......................................................................................................................................... 375
INTDATE........................................................................................................................................375
INVDATA........................................................................................................................................376
JAVAIOP........................................................................................................................................379
LANGUAGE....................................................................................................................................381
LINECOUNT...................................................................................................................................381
LIST............................................................................................................................................... 382
LP...................................................................................................................................................383
MAP............................................................................................................................................... 384
MAXPCF........................................................................................................................................ 385
MDECK.......................................................................................................................................... 386
NAME.............................................................................................................................................387
NSYMBOL...................................................................................................................................... 387
NUMBER........................................................................................................................................388
NUMCHECK................................................................................................................................... 388
NUMPROC..................................................................................................................................... 392
OBJECT......................................................................................................................................... 393
OFFSET..........................................................................................................................................393
OPTFILE........................................................................................................................................ 394
OPTIMIZE..................................................................................................................................... 395
OUTDD.......................................................................................................................................... 396
PARMCHECK................................................................................................................................. 397
PGMNAME.....................................................................................................................................398
QUALIFY........................................................................................................................................400
RENT............................................................................................................................................. 401
RMODE.......................................................................................................................................... 402
RULES............................................................................................................................................403
SEQUENCE.................................................................................................................................... 405
SERVICE........................................................................................................................................ 405
SMARTBIN.................................................................................................................................... 406
SOURCE.........................................................................................................................................407
SPACE............................................................................................................................................408
SQL................................................................................................................................................ 408
SQLCCSID......................................................................................................................................409
SQLIMS......................................................................................................................................... 410
SSRANGE...................................................................................................................................... 411
x
STGOPT......................................................................................................................................... 412
SUPPRESS.....................................................................................................................................413
TERMINAL.....................................................................................................................................413
TEST.............................................................................................................................................. 414
THREAD.........................................................................................................................................418
TRUNC...........................................................................................................................................419
TUNE............................................................................................................................................. 421
VBREF........................................................................................................................................... 422
VLR................................................................................................................................................ 422
VSAMOPENFS............................................................................................................................... 424
WORD............................................................................................................................................ 425
XMLPARSE.................................................................................................................................... 425
XREF..............................................................................................................................................426
ZONECHECK..................................................................................................................................427
ZONEDATA.................................................................................................................................... 428
ZWB...............................................................................................................................................431
COBOL runtime options..................................................................................................................... 431
Specifying COBOL runtime options.............................................................................................. 432
VSAM dynamic access read option VSAMDYNAMICDIR............................................................. 434
Disabling COBOL runtime options report option DISABLEUOPTREPORT...................................434
Building IGZUOPT and IGZQUOPT runtime option control block............................................... 435
JCL samples for COBOL IGZUOPT runtime options.................................................................... 435
COBOL runtime options report.....................................................................................................435
xi
Coding COBOL programs to run under CICS..................................................................................... 495
Getting the system date under CICS............................................................................................497
Calling to or from COBOL programs............................................................................................. 497
Determining the success of ECI calls...........................................................................................498
Compiling with the CICS option......................................................................................................... 499
Separating CICS suboptions.........................................................................................................500
Integrated CICS translator........................................................................................................... 500
Using the separate CICS translator................................................................................................... 501
CICS reserved-word table..................................................................................................................502
Handling errors by using CICS HANDLE............................................................................................ 503
Example: handling errors by using CICS HANDLE....................................................................... 504
xii
CALL statement with AMODE 64 support......................................................................................... 534
Using compiler options to compile AMODE 64 programs.................................................................534
Other AMODE 64 considerations....................................................................................................... 535
Chapter 27. Developing COBOL programs in the mixed AMODE Language Environment.....................537
COBOL programs in AMODE 31 interacting with Java programs in AMODE 64............................... 537
Application calls between COBOL programs in AMODE 31 and Java programs in AMODE 64..537
Building the mixed AMODE COBOL/Java interoperability application .......................................538
Running the mixed AMODE COBOL/Java interoperability program............................................538
Examples for mixed AMODE COBOL/Java interoperability application .....................................539
Other considerations and restrictions..........................................................................................540
COBOL applications with mixed AMODE 31 and AMODE 64 programs........................................... 540
Dynamic call between AMODE 31 and AMODE 64 programs..................................................... 540
COBOL runtime option AMODE3164........................................................................................... 541
Other considerations and restrictions..........................................................................................542
xiii
Dynamic link libraries (DLLs)............................................................................................................. 579
Compiling programs to create DLLs...................................................................................................580
Linking DLLs........................................................................................................................................581
Example: sample JCL for a procedural DLL application....................................................................581
Using CALL identifier with DLLs......................................................................................................... 583
Search order for DLLs in the z/OS UNIX file system.................................................................... 584
Using DLL linkage and dynamic calls together.................................................................................. 584
Using procedure or function pointers with DLLs..........................................................................585
Calling DLLs from non-DLLs......................................................................................................... 585
Example: calling DLLs from non-DLLs..........................................................................................586
Using COBOL DLLs with C/C++ programs..........................................................................................587
Using DLLs in OO COBOL applications...............................................................................................588
xiv
XML parser in COBOL......................................................................................................................... 624
Accessing XML documents................................................................................................................ 625
Parsing XML documents.....................................................................................................................625
Writing procedures to process XML............................................................................................. 627
XML events....................................................................................................................................629
Transforming XML text to COBOL data items.............................................................................. 634
Parsing XML documents with validation...................................................................................... 634
Parsing XML documents one segment at a time..........................................................................637
Handling splits using the XML-INFORMATION special register.................................................. 639
The encoding of XML documents.......................................................................................................640
XML input document encoding.....................................................................................................641
Parsing XML documents encoded in UTF-8.................................................................................644
Handling XML PARSE exceptions.......................................................................................................645
How the XML parser handles errors.............................................................................................647
Handling encoding conflicts......................................................................................................... 648
Terminating XML parsing................................................................................................................... 649
XML PARSE examples........................................................................................................................ 649
Example: parsing a simple document..........................................................................................649
Example: program for processing XML........................................................................................ 650
Example: parsing an XML document that uses namespaces...................................................... 654
Example: parsing an XML document one segment at a time...................................................... 658
Example: parsing XML documents with validation......................................................................660
xv
Defining a subclass............................................................................................................................ 704
CLASS-ID paragraph for defining a subclass............................................................................... 705
REPOSITORY paragraph for defining a subclass......................................................................... 705
WORKING-STORAGE SECTION for defining subclass instance data..........................................706
Defining a subclass instance method.......................................................................................... 706
Example: defining a subclass (with methods)............................................................................. 706
Defining a factory section.................................................................................................................. 707
WORKING-STORAGE SECTION for defining factory data........................................................... 708
Defining a factory method............................................................................................................ 709
Example: defining a factory (with methods)................................................................................ 711
Wrapping procedure-oriented COBOL programs.............................................................................. 715
Structuring OO applications...............................................................................................................715
Examples: COBOL applications that run using the java command............................................. 716
Chapter 44. Accessing COBOL WORKING-STORAGE data items from Java......................................... 749
xvi
Example: restarting a job at a specific checkpoint step.............................................................. 762
Example: requesting a step restart.............................................................................................. 762
Example: resubmitting a job for a step restart............................................................................ 763
Example: resubmitting a job for a checkpoint restart................................................................. 763
xvii
DBCS notation..........................................................................................................................................803
Alphanumeric to DBCS data conversion (IGZCA2D).............................................................................. 803
IGZCA2D syntax................................................................................................................................. 803
IGZCA2D return codes....................................................................................................................... 804
Example: IGZCA2D............................................................................................................................ 805
DBCS to alphanumeric data conversion (IGZCD2A)...............................................................................805
IGZCD2A syntax................................................................................................................................. 805
IGZCD2A return codes....................................................................................................................... 806
Example: IGZCD2A............................................................................................................................ 807
xviii
Parse tree record: X'0024'...................................................................................................................... 872
Token record: X'0030'............................................................................................................................. 899
Source error record: X'0032'...................................................................................................................927
Source record: X'0038'............................................................................................................................927
COPY REPLACING record: X'0039'......................................................................................................... 928
Symbol record: X'0042'........................................................................................................................... 929
Symbol cross-reference record: X'0044'................................................................................................ 941
Nested program record: X'0046'.............................................................................................................943
Library record: X'0060'............................................................................................................................943
Statistics record: X'0090'........................................................................................................................ 944
EVENTS record: X'0120'.......................................................................................................................... 944
Notices..............................................................................................................973
Trademarks.............................................................................................................................................. 975
Glossary............................................................................................................ 977
List of resources.............................................................................................. 1021
Enterprise COBOL for z/OS publications...............................................................................................1021
Related publications..............................................................................................................................1021
Index.............................................................................................................. 1025
xix
xx
Tables
1. FILE-CONTROL entries..................................................................................................................................6
12. INTDATE(LILIAN) and compatibility of date intrinsic functions and callable services...........................59
13. INTDATE(ANSI) and compatibility of date intrinsic functions and callable services..............................59
17. National group items that are processed with group semantics...........................................................138
18. Encoding and size of alphanumeric, DBCS, and national data.............................................................. 139
19. Summary of file organizations, access modes, and record formats of COBOL files............................. 163
xxi
24. VSAM file organization, access mode, and record format..................................................................... 191
28. I/O statements for VSAM relative and indexed files.............................................................................. 197
32. Methods for checking for sort errors with NOFASTSRT......................................................................... 234
43. .................................................................................................................................................................305
48. DISPLAY output with the DISPSIGN(COMPAT) option or the DISPSIGN(SEP) option specified:.........363
xxii
49. Setting INVDATA and NUMPROC options when migrating from earlier COBOL versions..................... 376
66. Compiler options required for the integrated CICS translator.............................................................. 499
68. TRUNC compiler options recommended for the separate CICS translator.......................................... 502
xxiii
74. Special registers used by the XML parser.............................................................................................. 627
80. Hexadecimal values of special characters for various EBCDIC CCSIDs............................................... 644
83. XML events and special registers from parsing XML document with an undeclared namespace
prefix.........................................................................................................................................................657
97. Services that convert between jstring references and national data....................................................728
98. Services that convert between jstring references and alphanumeric data...........................................729
xxiv
99. Performance-related compiler options..................................................................................................778
105. Reason codes for XML PARSE exceptions that are unique to Enterprise COBOL............................... 809
107. XML PARSE exceptions that do not allow continuation (for XMLPARSE(COMPAT))........................... 814
xxv
124. MSGEXIT parameters........................................................................................................................... 834
126. Actions possible in exit modules for CICS, SQL and SQLIMS statements.......................................... 844
xxvi
149. SYSADATA EVENTS ERROR record layout............................................................................................947
xxvii
xxviii
Preface
Abbreviated terms
Certain terms are used in a shortened form in this information. Abbreviations for the product names used
most frequently are listed alphabetically in the following table.
Note:
1. IBM z/OS Debugger is a common component that is provided in the following products:
• IBM Debug for z/OS, previously known as IBM Debug Tool for z/OS
• IBM Developer for z/OS, previously known as IBM Developer for z Systems® and Rational®
Developer for z Systems
• IBM Developer for z/OS (Enterprise Edition), which is also provided with the IBM Application
Delivery Foundation for z/OS bundle
• IBM Z® and Cloud Modernization Stack
The debug features provided in different products vary. For more information, see Overview of IBM
z/OS Debugger.
Depending on the level of Enterprise COBOL that you are using to create the COBOL application,
update your debugger to a certain version:
• z/OS Debugger 15.0.5 and later supports Enterprise COBOL 6.4 and earlier versions
• z/OS Debugger 14.2 and later supports Enterprise COBOL 6.3 and earlier versions
• z/OS Debugger 14.1 supports Enterprise COBOL 6.2 and earlier versions
• z/OS Debugger 14.0 supports Enterprise COBOL 6.1 and earlier versions
• Debug Tool 13.1 supports Enterprise COBOL 5.1 and earlier versions
In addition to these abbreviated terms, the term "85 COBOL Standard" is used to refer to the combination
of the following standards:
• ISO 1989:1985, Programming languages - COBOL
• ISO/IEC 1989/AMD1:1992, Programming languages - COBOL: Intrinsic function module
• ISO/IEC 1989/AMD2:1994, Programming languages - Correction and clarification amendment for
COBOL
• ANSI INCITS 23-1985, Programming Languages - COBOL
• ANSI INCITS 23a-1989, Programming Languages - Intrinsic Function Module for COBOL
• ANSI INCITS 23b-1993, Programming Language - Correction Amendment for COBOL
The term "2002 COBOL Standard" is used to refer to the following standard:
• INCITS/ISO/IEC 1989-2002, Information technology - Programming languages - COBOL
The term "2014 COBOL Standard" is used to refer to the following standard:
• INCITS/ISO/IEC 1989:2014, Information technology - Programming languages, their environments and
system software interfaces - Programming language COBOL
The ISO standards are identical to the American National standards.
Other terms, if not commonly understood, are shown in italics the first time that they appear, and are
listed in the glossary.
xxx Preface
Language Environment term Enterprise COBOL equivalent
Array A table created using the OCCURS clause
Array element Table element
Enclave Run unit
External data WORKING-STORAGE data defined using the EXTERNAL clause
Local data Any non-EXTERNAL data item
Pass parameters directly, by value BY VALUE
Pass parameters indirectly, by reference BY REFERENCE
Pass parameters indirectly, by value BY CONTENT
Routine Program
Scalar Elementary item
required_item
required_item
optional_item
• If you can choose from two or more items, they appear vertically, in a stack. If you must choose one of
the items, one item of the stack appears on the main path:
required_item required_choice1
required_choice2
If choosing one of the items is optional, the entire stack appears below the main path:
Preface xxxi
required_item
optional_choice1
optional_choice2
If one of the items is the default, it appears above the main path and the remaining choices are shown
below:
default_choice
required_item
optional_choice
optional_choice
• An arrow returning to the left, above the main line, indicates an item that can be repeated:
required_item repeatable_item
If the repeat arrow contains a comma, you must separate repeated items with a comma:
required_item repeatable_item
• Keywords appear in uppercase (for example, FROM). They must be spelled exactly as shown. Variables
appear in lowercase italics (for example, column-name). They represent user-supplied names or values.
• If punctuation marks, parentheses, arithmetic operators, or other such symbols are shown, you must
enter them as part of the syntax.
xxxii Preface
Additional documentation and support
IBM Enterprise COBOL for z/OS provides Portable Document Format (PDF) versions of the entire library
for this version and for previous versions on the library page at https://www.ibm.com/support/pages/
enterprise-cobol-zos-documentation-library. These documents are also available in Japanese.
Support information is also available at https://www.ibm.com/support/pages/node/6560933.
Summary of changes
This topic lists the major changes that have been made to this document since Enterprise COBOL for
z/OS 6.4. The changes that are described in this information have an associated cross-reference for your
convenience. The latest technical changes are marked within >| and |< in the HTML version, or marked by
vertical bars (|) in the left margin in the PDF version.
For a complete list of new and improved features in Enterprise COBOL for z/OS 6.4 and COBOL 6.4 with
PTFs installed, see What is new in Enterprise COBOL for z/OS 6.4 and COBOL 6.4 with PTFs installed in
the Enterprise COBOL for z/OS What's New.
Preface xxxiii
• PH57400: You can use dynamic-length and UTF-8 (PIC U) data items as the arguments to the JSON
GENERATE and JSON PARSE statements. (Chapter 35, “Processing JSON input ,” on page 609 and
Chapter 36, “Producing JSON output ,” on page 619)
Note: COBOL Runtime LE APAR PH57152 must also be applied on all systems where programs that
make use of this new feature are linked or run.
• PH59733: You can generate and parse JSON null values by using the JSON GENERATE and JSON
PARSE statements. (“Generating JSON null values” on page 621 and “Handling JSON null values” on
page 614)
• Runtime APAR PH61133 (V2R4 or later): You can use ddname IGZPROUT at the run step of your JCL
to generate a report of COBOL programs that are compiled with Enterprise COBOL 5 or later releases.
(“Generating a report of COBOL programs” on page 490)
• PH61700: The cjbuild utility is enhanced to allow users to specify the names of COBOL programs in the
command line and process all files in the COBOL artifact directory. (“cjbuild command reference ” on
page 330)
xxxiv Preface
Debugging enhancement
With COBOL 6.4 at the base level, you can use ddname IGZPROUT at the run step of your JCL to generate
a report of all dynamically called programs that are compiled with Enterprise COBOL 5 or later releases.
With the COBOL runtime PTF for APAR PH61133 installed, the report contains COBOL 5 or later programs
that are called dynamically, statically, and via DLL linkage. (“Generating a report of COBOL programs” on
page 490)
Preface xxxv
xxxvi Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Part 1. Coding your program
Related tasks
“Identifying a program” on page 3
“Describing the computing environment” on page 5
“Describing the data” on page 11
“Processing the data” on page 17
“Defining a class” on page 682
“Defining a class instance method” on page 686
“Structuring OO applications” on page 715
Identifying a program
Use the IDENTIFICATION DIVISION to name a program and optionally provide other identifying
information.
You can use the optional AUTHOR, INSTALLATION, DATE-WRITTEN, and DATE-COMPILED paragraphs
for descriptive information about a program. The data you enter in the DATE-COMPILED paragraph is
replaced with the latest compilation date.
IDENTIFICATION DIVISION.
Program-ID. Helloprog.
Author. A. Programmer.
Installation. Computing Laboratories.
Date-Written. 05/31/2022.
Date-Compiled. 05/31/2022.
Use the PROGRAM-ID paragraph to name your program. The program-name that you assign is used in
these ways:
• Other programs use that name to call your program.
• The name appears in the header on each page, except the first, of the program listing that is generated
when you compile the program.
• If you use the NAME compiler option, the name is placed on the NAME binder (linkage-editor) control
statement to identify the object module that the compilation creates.
Tip: Do not use program-names that start with prefixes used by IBM products. If you use program-
names that start with any of the following prefixes, your CALL statements might resolve to IBM library
or compiler routines rather than to your intended program:
– AFB
– AFH
– CBC
– CEE
– CEH
– CEL
– CEQ
– CEU
Related tasks
“Changing the header of a source listing” on page 5
“Identifying a program as recursive” on page 4
“Marking a program as callable by containing programs” on page 4
“Setting a program to an initial state” on page 4
Related references
Compiler limits (Enterprise COBOL for z/OS Language Reference)
Conventions for program-names (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Sharing data in recursive
or multithreaded programs” on page 16
“Making recursive calls” on page 557
Related concepts
“Nested programs” on page 555
4 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
• Changed GO TO statements and PERFORM statements are in their initial states.
• Non-EXTERNAL files are closed.
Related tasks
“Ending and reentering main programs or subprograms” on page 546
“Making static calls” on page 548
“Making dynamic calls” on page 548
Related references
“INITIAL” on page 374
PP 5655-EC6 IBM Enterprise COBOL for z/OS 6.4.0 PXXXXXX Date 05/31/2022 Time 15:05:19
Page 1
The header indicates the compilation platform. You can customize the header on succeeding pages of the
listing by using the compiler-directing TITLE statement.
Note: If you are using the IBM Enterprise COBOL Value Unit Edition for z/OS product, the header on the
first page of a source listing is the same as that for IBM Enterprise COBOL for z/OS. The product number
will show 5655-EC6 rather than 5697-V61. The 5697-V61 product number for the Value Unit Edition
product is only significant for product ordering purposes and product registration at installation time.
Related references
TITLE statement (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Specifying the collating sequence” on page 7
“Defining symbolic characters” on page 8
“Defining a user-defined class” on page 8
“Defining files to the operating system” on page 8
Related references
Sections and paragraphs (Enterprise COBOL for z/OS Language Reference)
1. The SELECT clause chooses a file in the COBOL program to be associated with an external data set.
2. The ASSIGN clause associates the program's name for the file with the external name for the actual data
file. You can define the external name with a DD statement or an environment variable.
3. The ORGANIZATION clause describes the file's organization. For QSAM files, the ORGANIZATION clause is
optional.
4. The ACCESS MODE clause defines the manner in which the records are made available for processing:
sequential, random, or dynamic. For QSAM and line-sequential files, the ACCESS MODE clause is optional.
These files always have sequential organization.
5. For VSAM files, you might have additional statements in the FILE-CONTROL paragraph depending on the
type of VSAM file you use.
Related tasks
Chapter 9, “Processing QSAM files,” on page 167
Chapter 10, “Processing VSAM files,” on page 189
Chapter 11, “Processing line-sequential files,” on page 215
“Describing the computing environment” on page 5
6 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Specifying the collating sequence
You can use the PROGRAM COLLATING SEQUENCE clause and the ALPHABET clause of the SPECIAL-
NAMES paragraph to establish the collating sequence that is used in several operations on alphanumeric
items.
These clauses specify the collating sequence for the following operations on alphanumeric items:
• Comparisons explicitly specified in relation conditions and condition-name conditions
• HIGH-VALUE and LOW-VALUE settings
• SEARCH ALL
• SORT and MERGE unless overridden by a COLLATING SEQUENCE phrase in the SORT or MERGE
statement
“Example: specifying the collating sequence” on page 7
The sequence that you use can be based on one of these alphabets:
• EBCDIC: references the collating sequence associated with the EBCDIC character set
• NATIVE: references the same collating sequence as EBCDIC
• STANDARD-1: references the collating sequence associated with the ASCII character set defined by
ANSI INCITS X3.4, Coded Character Sets - 7-bit American National Standard Code for Information
Interchange (7-bit ASCII)
• STANDARD-2: references the collating sequence associated with the character set defined by ISO/IEC
646 -- Information technology -- ISO 7-bit coded character set for information interchange, International
Reference Version
• An alteration of the EBCDIC sequence that you define in the SPECIAL-NAMES paragraph
The PROGRAM COLLATING SEQUENCE clause does not affect comparisons that involve national or DBCS
operands.
Related tasks
“Choosing alternate collating sequences” on page 231
“Comparing national (UTF-16) data” on page 140
IDENTIFICATION DIVISION.
. . .
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
Source-Computer. IBM-390. Object-Computer. IBM-390
Program Collating Sequence Special-Sequence.
Special-Names.
Alphabet Special-Sequence Is
"A" Also "a"
"B" Also "b"
"C" Also "c"
"D" Also "d"
"E" Also "e"
"F" Also "f"
"G" Also "g"
"H" Also "h"
"I" Also "i"
"J" Also "j"
"K" Also "k"
"L" Also "l"
Related tasks
“Specifying the collating sequence” on page 7
You can reference the class-name only in a class condition. (This user-defined class is not the same as an
object-oriented class.)
(1)
//OUTFILE DD DSNAME=MY.OUT171,UNIT=SYSDA,SPACE=(TRK,(50,5))
/*
8 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
• Environment variable (export command):
(1)
export OUTFILE=DSN(MY.OUT171),UNIT(SYSDA),SPACE(TRK,(50,5))
• COBOL code:
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT CARPOOL
ASSIGN TO OUTFILE (1)
ORGANIZATION IS SEQUENTIAL.
. . .
DATA DIVISION.
FILE SECTION.
FD CARPOOL (2)
LABEL RECORD STANDARD
BLOCK CONTAINS 0 CHARACTERS
RECORD CONTAINS 80 CHARACTERS
(1)
The assignment-name in the ASSIGN clause points to the ddname OUTFILE in the DD statement or
the environment variable OUTFILE in the export command:
• //OUTFILE DD DSNAME=OUT171 . . ., or
• export OUTFILE= . . .
(2)
When you specify a file file-name in a FILE-CONTROL entry, you must describe the file in an FD entry:
SELECT CARPOOL
. . .
FD CARPOOL
Related tasks
“Optimizing buffer and device space” on page 10
Related references
“FILE SECTION entries” on page 12
FILE SECTION (Enterprise COBOL for z/OS Language Reference)
Assume the three possible input files are MAIN1, MAIN2, and MAIN3. Before running the program, code
one of the following DD statements in the job step that calls for program execution, or issue one of the
following export commands from the same shell from which you run the program:
//MAINA DD DSNAME=MY.MAIN1,. . .
export MAINA=DSN(MY.MAIN1),. . .
//MAINA DD DSNAME=MY.MAIN2,. . .
export MAINA=DSN(MY.MAIN2),. . .
//MAINA DD DSNAME=MY.MAIN3,. . .
export MAINA=DSN(MY.MAIN3),. . .
Any reference in the program to MAIN will therefore be a reference to the file that is currently assigned to
the ddname or environment-variable name MAINA.
Notice that in this example, you cannot use the PATH(path) form of the export command to reference a
line-sequential file in the z/OS UNIX file system, because you cannot specify an organization field (S- or
AS-) with a line-sequential file.
10 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
record area, should be immediately moved to a data item in WORKING-STORAGE for use by the program.
For example:
FD MY-INPUT-FILE
LABEL RECORDS ARE STANDARD
RECORDING MODE IS V
BLOCK CONTAINS 0 RECORDS
DATA RECORD IS IN-RECORD-AREA.
01 IN-RECORD-AREA PIC X(100).
WORKING-STORAGE.
01 WS-IN-RECORD-AREA PIC X(100).
PROCEDURE DIVISION.
...
READ MY-INPUT-FILE INTO WS-IN-RECORD-AREA.
Related references
“AWO” on page 350
Related concepts
“Comparison of WORKING-STORAGE and LOCAL-STORAGE” on page 14
Related tasks
“Using data in input and output operations” on page 11
“Using data from another
program” on page 16
Related references
Compiler limits (Enterprise COBOL for z/OS Language Reference)
Programs in the same run unit can share, or have access to, common files. The method for doing this
depends on whether the programs are part of a nested (contained) structure or are separately compiled
(including programs compiled as part of a batch sequence).
You can use the EXTERNAL clause for separately compiled programs. A file that is defined as EXTERNAL
can be referenced by any program in the run unit that describes the file.
You can use the GLOBAL clause for programs in a nested, or contained, structure. If a program contains
another program (directly or indirectly), both programs can access a common file by referencing a GLOBAL
file-name.
Related concepts
“Nested programs” on page 555
Related tasks
“Sharing files between programs (external files)” on page 573
Related references
“FILE SECTION entries” on page 12
12 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 2. FILE SECTION entries (continued)
Clause To define Notes
BLOCK CONTAINS Size of physical records If the CHARACTERS phrase is specified, size
indicates the number of bytes in a record
regardless of the USAGE of the data items in the
record.
QSAM: If provided, must match information on JCL
or data-set label. If specified as BLOCK CONTAINS
0, or not provided, the system determines the
optimal block size for you.
Line sequential: Can be specified to control
buffering for WRITE statements.
VSAM: Syntax-checked, but has no effect on
execution.
RECORD Size of logical records (fixed Integer size indicates the number of bytes in a
CONTAINS n length) record regardless of the USAGE of the data items in
the record. If the clause is provided, it must match
information on JCL or data-set label. If n is equal to
0, LRECL must be coded on JCL or data-set label.
RECORD IS Size of logical records Integer size or sizes, if specified, indicate the
VARYING (variable length) number of bytes in a record regardless of the
USAGE of the data items in the record. If the
clause is provided, it must match information on
JCL or data-set label; compiler checks that record
descriptions match.
RECORD Size of logical records The integer sizes indicate the number of bytes
CONTAINS n TO m (variable length) in a record regardless of the USAGE of the data
items in the record. If the clause is provided, it
must match information on JCL or data-set label;
compiler checks that record descriptions match.
LABEL RECORDS Labels for QSAM files VSAM: Handled as comments
STANDARD Labels exist QSAM: Handled as comments
OMITTED Labels do not exist QSAM: Handled as comments
data-name Labels defined by the user QSAM: Allowed for (optional) tape or disk
VALUE OF An item in the label records Comments only
associated with file
DATA RECORDS Names of records associated Comments only
with file
LINAGE Depth of logical page QSAM only
CODE-SET ASCII or EBCDIC files QSAM only.
When an ASCII file is identified with the CODE-
SET clause, the corresponding DD statement
might need to have DCB=(OPTCD=Q. . .) or
DCB=(RECFM=D. . .) coded if the file was not
created using VS COBOL II, COBOL for OS/390® &
VM, or IBM Enterprise COBOL for z/OS.
Related references
FILE SECTION (Enterprise COBOL for z/OS Language Reference)
A separate copy of LOCAL-STORAGE data is allocated for each call of a program or invocation of a
method, and is freed on return from the program or method. If you specify a VALUE clause for a LOCAL-
STORAGE item, the item is initialized to that value on each call or invocation. If a VALUE clause is not
specified, the initial value of the item is undefined.
Threading: Each invocation of a program that runs simultaneously on multiple threads shares access to a
single copy of WORKING-STORAGE data. Each invocation has a separate copy of LOCAL-STORAGE data.
“Example: storage sections” on page 14
Related tasks
“Ending and reentering main programs or subprograms” on page 546
Chapter 31, “Preparing COBOL programs for multithreading,” on page 589
“WORKING-STORAGE SECTION for defining class instance data” on page 685
Related references
WORKING-STORAGE SECTION (Enterprise COBOL for z/OS Language Reference)
LOCAL-STORAGE SECTION (Enterprise COBOL for z/OS Language Reference)
CBL pgmn(lu)
*********************************
* Recursive Program - Factorials
*********************************
IDENTIFICATION DIVISION.
Program-Id. factorial recursive.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 numb pic 9(4) value 5.
01 fact pic 9(8) value 0.
LOCAL-STORAGE SECTION.
14 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
01 num pic 9(4).
PROCEDURE DIVISION.
move numb to num.
if numb = 0
move 1 to fact
else
subtract 1 from numb
call 'factorial'
multiply num by fact
end-if.
0000! = 00000001
0001! = 00000001
0002! = 00000002
0003! = 00000006
0004! = 00000024
0005! = 00000120
The following tables show the changing values of the data items in LOCAL-STORAGE and WORKING-
STORAGE in the successive recursive calls of the program, and in the ensuing gobacks. During the
gobacks, fact progressively accumulates the value of 5! (five factorial).
Recursive calls Value for num in Value for numb in Value for fact in
LOCAL-STORAGE WORKING-STORAGE WORKING-STORAGE
Main 5 5 0
1 4 4 0
2 3 3 0
3 2 2 0
4 1 1 0
5 0 0 0
Gobacks Value for num in Value for numb in Value for fact in
LOCAL-STORAGE WORKING-STORAGE WORKING-STORAGE
5 0 0 1
4 1 0 1
3 2 0 2
2 3 0 6
1 4 0 24
Main 5 0 120
Related concepts
“Comparison of WORKING-STORAGE and LOCAL-STORAGE” on page 14
Related tasks
“Sharing data in separately compiled programs” on page 16
“Sharing data in nested programs” on page 16
“Sharing data in recursive
or multithreaded programs” on page 16
“Passing data” on page 563
Related tasks
“Passing data” on page 563
“Coding the LINKAGE SECTION” on page 567
Related concepts
“Nested programs” on page 555
Related concepts
“Multithreading” on page 589
Related tasks
“Making recursive calls” on page 557
“Processing files with multithreading” on page 592
16 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Related references
“THREAD” on page 418
SET statement (Enterprise COBOL for z/OS Language Reference)
PROCEDURE DIVISION.
You can code the division header to receive parameters by using the USING phrase, or to return a value by
using the RETURNING phrase.
To receive an argument that was passed by reference (the default) or by content, code the division header
for a program in either of these ways:
You can also combine USING and RETURNING in a PROCEDURE DIVISION header:
Related concepts
“How logic is divided in the PROCEDURE DIVISION” on page 18
Related tasks
“Coding the LINKAGE SECTION” on page 567
“Coding the PROCEDURE DIVISION
for passing arguments” on page 568
“Using PROCEDURE DIVISION RETURNING . . .” on page 572
“Eliminating repetitive coding” on page 786
Related references
The procedure division header (Enterprise COBOL for z/OS Language Reference)
The USING phrase (Enterprise COBOL for z/OS Language Reference)
CALL statement (Enterprise COBOL for z/OS Language Reference)
Related concepts
“Compiler-directing statements” on page 19
“Scope terminators” on page 20
“Imperative statements” on page 18
“Conditional statements” on page 18
“Declaratives” on page 21
Related references
PROCEDURE DIVISION structure (Enterprise COBOL for z/OS Language Reference)
Imperative statements
An imperative statement (such as ADD, MOVE, INVOKE, or CLOSE) indicates an unconditional action to be
taken.
You can end an imperative statement with an implicit or explicit scope terminator.
A conditional statement that ends with an explicit scope terminator becomes an imperative statement
called a delimited scope statement. Only imperative statements (or delimited scope statements) can be
nested.
Related concepts
“Conditional statements” on page 18
“Scope terminators” on page 20
Conditional statements
A conditional statement is either a simple conditional statement (IF, EVALUATE, SEARCH) or a conditional
statement made up of an imperative statement that includes a conditional phrase or option.
You can end a conditional statement with an implicit or explicit scope terminator. If you end a conditional
statement explicitly, it becomes a delimited scope statement (which is an imperative statement).
18 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
You can use a delimited scope statement in these ways:
• To delimit the range of operation for a COBOL conditional statement and to explicitly show the levels of
nesting
For example, use an END-IF phrase instead of a period to end the scope of an IF statement within a
nested IF.
• To code a conditional statement where the COBOL syntax calls for an imperative statement
For example, code a conditional statement as the object of an inline PERFORM:
An explicit scope terminator is required for the inline PERFORM statement, but it is not valid for the
out-of-line PERFORM statement.
For additional program control, you can use the NOT phrase with conditional statements. For example, you
can provide instructions to be performed when a particular exception does not occur, such as NOT ON
SIZE ERROR. The NOT phrase cannot be used with the ON OVERFLOW phrase of the CALL statement, but
it can be used with the ON EXCEPTION phrase.
Do not nest conditional statements. Nested statements must be imperative statements (or delimited
scope statements) and must follow the rules for imperative statements.
The following statements are examples of conditional statements if they are coded without scope
terminators:
• Arithmetic statement with ON SIZE ERROR
• Data-manipulation statements with ON OVERFLOW
• CALL statements with ON OVERFLOW
• I/O statements with INVALID KEY, AT END, or AT END-OF-PAGE
• RETURN with AT END
Related concepts
“Imperative statements” on page 18
“Scope terminators” on page 20
Related tasks
“Selecting program actions” on page 91
Related references
Conditional statements (Enterprise COBOL for z/OS Language Reference)
Compiler-directing statements
A compiler-directing statement causes the compiler to take specific action about the program structure,
COPY processing, listing control, or control flow.
A compiler-directing statement is not part of the program logic.
Related references
Chapter 20, “Compiler-directing statements,” on page 439
Compiler-directing statements (Enterprise COBOL for z/OS Language Reference)
IF ITEM = "A"
DISPLAY "THE VALUE OF ITEM IS " ITEM
ADD 1 TO TOTAL
MOVE "C" TO ITEM
DISPLAY "THE VALUE OF ITEM IS NOW " ITEM.
IF ITEM = "B"
ADD 2 TO TOTAL.
IF ITEM = "A"
DISPLAY "THE VALUE OF ITEM IS " ITEM
ADD 1 TO TOTAL
MOVE "C" TO ITEM
DISPLAY "THE VALUE OF ITEM IS NOW " ITEM
END-IF
IF ITEM = "B"
ADD 2 TO TOTAL
END-IF
If you use implicit terminators, the end of statements can be unclear. As a result, you might end
statements unintentionally, changing your program's logic. Explicit scope terminators make a program
easier to understand and prevent unintentional ending of statements. For example, in the program
fragment below, changing the location of the first period in the first implicit scope example changes
the meaning of the code:
IF ITEM = "A"
DISPLAY "VALUE OF ITEM IS " ITEM
ADD 1 TO TOTAL.
MOVE "C" TO ITEM
DISPLAY " VALUE OF ITEM IS NOW " ITEM
IF ITEM = "B"
ADD 2 TO TOTAL.
The MOVE statement and the DISPLAY statement after it are performed regardless of the value of ITEM,
despite what the indentation indicates, because the first period terminates the IF statement.
For improved program clarity and to avoid unintentional ending of statements, use explicit scope
terminators, especially within paragraphs. Use implicit scope terminators only at the end of a paragraph
or the end of a program.
Be careful when coding an explicit scope terminator for an imperative statement that is nested within
a conditional statement. Ensure that the scope terminator is paired with the statement for which it was
intended. In the following example, the scope terminator will be paired with the second READ statement,
though the programmer intended it to be paired with the first.
READ FILE1
AT END
MOVE A TO B
READ FILE2
END-READ
20 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
To ensure that the explicit scope terminator is paired with the intended statement, the preceding example
can be recoded in this way:
READ FILE1
AT END
MOVE A TO B
READ FILE2
END-READ
END-READ
Related concepts
“Conditional statements” on page 18
“Imperative statements” on page 18
Declaratives
Declaratives provide one or more special-purpose sections that are executed when an exception
condition occurs.
Start each declarative section with a USE statement that identifies the function of the section. In the
procedures, specify the actions to be taken when the condition occurs.
Related tasks
“Finding and handling input-output errors” on page 445
Related references
Declaratives (Enterprise COBOL for z/OS Language Reference)
This information is intended to help non-COBOL programmers relate terms for data used in other
programming languages to COBOL terms. It introduces COBOL fundamentals for variables, structures,
literals, and constants; assigning and displaying values; intrinsic (built-in) functions, and tables (arrays)
and pointers.
Related concepts
“Storage and its addressability” on page 39
Related tasks
“Using variables, structures, literals, and constants” on page 23
“Assigning values to data items” on page 26
“Displaying values on a screen or in a file (DISPLAY)” on page 35
“Using intrinsic functions (built-in functions)” on page 38
“Using tables (arrays) and pointers” on page 39
Chapter 7, “Processing data in an international environment,” on page 123
Related tasks
“Using variables” on page 23
“Using data items and group items” on page 24
“Using literals” on page 25
“Using constants” on page 26
“Using figurative constants” on page 26
Related references
Classes and categories of data (Enterprise COBOL for z/OS Language Reference)
Using variables
A variable is a data item whose value can change during a program. The value is restricted, however, to
the data type that you define when you specify a name and a length for the data item.
For example, if a customer name is an alphanumeric data item in your program, you could define and use
the customer name as shown below:
Data Division.
01 Customer-Name Pic X(20).
01 Original-Customer-Name Pic X(20).
. . .
Procedure Division.
Move Customer-Name to Original-Customer-Name
. . .
You could instead define the customer names above as national or UTF-8 data items by specifying
their PICTURE and USAGE clauses as Pic N(20) USAGE NATIONAL or Pic U(20) USAGE UTF-8,
respectively. National data items are represented in Unicode UTF-16, in which most characters are
Related concepts
“Unicode and the encoding of language characters” on page 124
Related tasks
“Using national data (Unicode) in COBOL” on page 125
“Using UTF-8 data (Unicode) in COBOL” on page 142
Related references
“NSYMBOL” on page 387
“Storage of character data” on page 139
PICTURE clause (Enterprise COBOL for z/OS Language Reference)
Data Division.
File Section.
FD Customer-File
Record Contains 45 Characters.
01 Customer-Record.
05 Customer-Name.
10 Last-Name Pic x(17).
10 Filler Pic x.
10 Initials Pic xx.
05 Part-Order.
10 Part-Name Pic x(15).
10 Part-Color Pic x(10).
Working-Storage Section.
01 Orig-Customer-Name.
05 Surname Pic x(17).
05 Initials Pic x(3).
01 Inventory-Part-Name Pic x(15).
. . .
Procedure Division.
Move Customer-Name to Orig-Customer-Name
Move Part-Name to Inventory-Part-Name
. . .
You could instead define Customer-Record as a national group item that is composed of two
subordinate national group items by changing the declarations in the DATA DIVISION as shown below.
National group items behave in the same way as elementary category national data items in most
operations. The GROUP-USAGE NATIONAL clause indicates that a group item and any group items
subordinate to it are national groups. Subordinate elementary items in a national group must be explicitly
or implicitly described as USAGE NATIONAL.
Data Division.
File Section.
FD Customer-File
Record Contains 90 Characters.
01 Customer-Record Group-Usage National.
05 Customer-Name.
10 Last-Name Pic n(17).
10 Filler Pic n.
24 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
10 Initials Pic nn.
05 Part-Order.
10 Part-Name Pic n(15).
10 Part-Color Pic n(10).
Working-Storage Section.
01 Orig-Customer-Name Group-Usage National.
05 Surname Pic n(17).
05 Initials Pic n(3).
01 Inventory-Part-Name Pic n(15) Usage National.
. . .
Procedure Division.
Move Customer-Name to Orig-Customer-Name
Move Part-Name to Inventory-Part-Name
. . .
In the example above, the group items could instead specify the USAGE NATIONAL clause at the group
level. A USAGE clause at the group level applies to each elementary data item in a group (and thus serves
as a convenient shorthand notation). However, a group that specifies the USAGE NATIONAL clause is not
a national group despite the representation of the elementary items within the group. Groups that specify
the USAGE clause are alphanumeric groups and behave in many operations, such as moves and compares,
like elementary data items of USAGE DISPLAY (except that no editing or conversion of data occurs).
Related concepts
“Unicode and the encoding of language characters” on page 124
“National groups” on page 133
Related tasks
“Using national data (Unicode) in COBOL” on page 125
“Using national groups” on page 137
Related references
“FILE SECTION entries” on page 12
“Storage of character data” on page 139
Classes and categories of group items (Enterprise COBOL for z/OS Language Reference)
PICTURE clause (Enterprise COBOL for z/OS Language Reference)
MOVE statement (Enterprise COBOL for z/OS Language Reference)
USAGE clause (Enterprise COBOL for z/OS Language Reference)
Using literals
A literal is a character string whose value is given by the characters themselves. If you know the value
you want a data item to have, you can use a literal representation of the data value in the PROCEDURE
DIVISION.
You do not need to define a data item for the value nor refer to it by using a data-name. For example, you
can prepare an error message for an output file by moving an alphanumeric literal:
You can compare a data item to a specific integer value by using a numeric literal. In the example below,
"Name is not valid" is an alphanumeric literal, and 03519 is a numeric literal:
You can use the opening delimiter N" or N' to designate a national literal if the NSYMBOL(NATIONAL)
compiler option is in effect, or to designate a DBCS literal if the NSYMBOL(DBCS) compiler option is in
effect.
You can use the opening delimiter NX" or NX' to designate national literals in hexadecimal notation
(regardless of the setting of the NSYMBOL compiler option). Each group of four hexadecimal digits
designates a single national character.
Related tasks
“Using national literals” on page 126
“Using DBCS literals” on page 159
Related references
“NSYMBOL” on page 387
Literals (Enterprise COBOL for z/OS Language Reference)
Using constants
A constant is a data item that has only one value. COBOL does not define a construct for constants.
However, you can define a data item with an initial value by coding a VALUE clause in the data description
(instead of coding an INITIALIZE statement).
Data Division.
01 Report-Header pic x(50) value "Company Sales Report".
. . .
01 Interest pic 9v9999 value 1.0265.
The example above initializes an alphanumeric and a numeric data item. You can likewise use a VALUE
clause in defining a national or DBCS constant.
Related tasks
“Using national data (Unicode) in COBOL” on page 125
“Coding for use of DBCS
support” on page 158
Related tasks
“Using national-character figurative constants” on page 132
“Coding for use of DBCS
support” on page 158
“Using UTF-8-character figurative constants” on page 147
Related references
Figurative constants (Enterprise COBOL for z/OS Language Reference)
26 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 3. Assignment to data items in a program
What you want to do How to do it
Assign values to a data item or large data area. Use one of these ways:
• INITIALIZE statement
• MOVE statement
• STRING or UNSTRING statement
• VALUE clause (to set data items to the values
you want them to have when the program is in
initial state)
Related tasks
“Initializing a structure (INITIALIZE)” on page 31
“Assigning values to elementary
data items (MOVE)” on page 32
“Assigning values to group data items (MOVE)” on page 33
“Assigning input from a screen or file (ACCEPT)” on page 35
“Joining data items (STRING)” on page 103
“Splitting data items (UNSTRING)” on page 105
“Assigning arithmetic results (MOVE or COMPUTE)” on page 34
“Tallying and replacing data items (INSPECT)” on page 112
Chapter 7, “Processing data in an international environment,” on page 123
An INITIALIZE statement is functionally equivalent to one or more MOVE statements. The related tasks
about initializing show how you can use an INITIALIZE statement on a group item to conveniently
initialize all the subordinate data items that are in a given data category.
Initializing a data item to blanks or zeros:
INITIALIZE identifier-1
28 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
ALPHABETIC-1 ANJUST before ANJUST after
ABCD bbbbbbbb1 bbbbABCD1
Related tasks
“Initializing a structure (INITIALIZE)” on page 31
“Initializing a table (INITIALIZE)” on page 73
“Defining numeric data” on page 43
Related references
“NSYMBOL” on page 387
30 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Initializing a structure (INITIALIZE)
You can reset the values of all subordinate data items in a group item by applying the INITIALIZE
statement to that group item. However, it is inefficient to initialize an entire group unless you really need
all the items in the group to be initialized.
The following example shows how you can reset fields to spaces and zeros in transaction records that
a program produces. The values of the fields are not identical in each record that is produced. (The
transaction record is defined as an alphanumeric group item, TRANSACTION-OUT.)
01 TRANSACTION-OUT.
05 TRANSACTION-CODE PIC X.
05 PART-NUMBER PIC 9(6).
05 TRANSACTION-QUANTITY PIC 9(5).
05 PRICE-FIELDS.
10 UNIT-PRICE PIC 9(5)V9(2).
10 DISCOUNT PIC V9(2).
10 SALES-PRICE PIC 9(5)V9(2).
. . .
INITIALIZE TRANSACTION-OUT
You can likewise reset the values of all the subordinate data items in a national group item by applying the
INITIALIZE statement to that group item. The following structure is similar to the preceding structure,
but instead uses Unicode UTF-16 data:
Regardless of the previous contents of the transaction record, after the INITIALIZE statement above is
executed:
• TRANSACTION-CODE contains NX"0020" (a national space).
• Each of the remaining 27 national character positions of TRANSACTION-OUT contains NX"0030" (a
national-decimal zero).
When you use an INITIALIZE statement to initialize an alphanumeric or national group data item,
the data item is processed as a group item, that is, with group semantics. The elementary data items
within the group are recognized and processed, as shown in the examples above. If you do not code the
REPLACING phrase of the INITIALIZE statement:
• SPACE is the implied sending item for alphabetic, alphanumeric, alphanumeric-edited, DBCS, category
national, and national-edited receiving items.
Related concepts
“National groups” on page 133
Related tasks
“Initializing a table (INITIALIZE)” on page 73
“Using national groups” on page 137
Related references
INITIALIZE statement (Enterprise COBOL for z/OS Language Reference)
You can move an alphabetic, alphanumeric, alphanumeric-edited, DBCS, integer, or numeric-edited data
item to a category national or national-edited data item; the sending item is converted. You can move
a national data item to a category national or national-edited data item. If the content of a category
national data item has a numeric value, you can move that item to a numeric, numeric-edited, external
floating-point, or internal floating-point data item. You can move a national-edited data item only to a
category national data item or another national-edited data item. Padding or truncation might occur.
For complete details about elementary moves, see the related reference below about the MOVE
statement.
The following example shows an alphanumeric data item in the Greek language that is moved to a
national data item:
CBL CODEPAGE(00875)
. . .
01 Data-in-Unicode Pic N(100) usage national.
01 Data-in-Greek Pic X(100).
. . .
Read Greek-file into Data-in-Greek
Move Data-in-Greek to Data-in-Unicode
Related concepts
“Unicode and the encoding of language characters” on page 124
Related tasks
“Assigning values to group data items (MOVE)” on page 33
“Converting to or from national (Unicode) representation” on page 134
32 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Related references
“CODEPAGE” on page 353
Classes and categories of data (Enterprise COBOL for z/OS Language Reference)
MOVE statement (Enterprise COBOL for z/OS Language Reference)
You can move a national group item (a data item that is described with the GROUP-USAGE NATIONAL
clause) to another national group item. The compiler processes the move as though each national group
item were an elementary item of category national, that is, as if each item were described as PIC N(m),
where m is the length of that item in national character positions.
You can move an alphanumeric group item to an alphanumeric group item or to a national group item.
You can also move a national group item to an alphanumeric group item. The compiler performs such
moves as group moves, that is, without consideration of the individual elementary items in the sending
or receiving group, and without conversion of the sending data item. Be sure that the subordinate
data descriptions in the sending and receiving group items are compatible. The moves occur even if a
destructive overlap could occur at run time.
You can code the CORRESPONDING phrase in a MOVE statement to move subordinate elementary items
from one group item to the identically named corresponding subordinate elementary items in another
group item:
01 Group-X.
02 T-Code Pic X Value "A".
02 Month Pic 99 Value 04.
02 State Pic XX Value "CA".
02 Filler PIC X.
01 Group-N Group-Usage National.
02 State Pic NN.
02 Month Pic 99.
02 Filler Pic N.
02 Total Pic 999.
. . .
MOVE CORR Group-X TO Group-N
In the example above, State and Month within Group-N receive the values in national representation
of State and Month, respectively, from Group-X. The other data items in Group-N are unchanged.
(Filler items in a receiving group item are unchanged by a MOVE CORRESPONDING statement.)
In a MOVE CORRESPONDING statement, sending and receiving group items are treated as group items,
not as elementary data items; group semantics apply. That is, the elementary data items within each
group are recognized, and the results are the same as if each pair of corresponding data items were
referenced in a separate MOVE statement. Data conversions are performed according to the rules for the
MOVE statement as specified in the related reference below. For details about which types of elementary
data items correspond, see the related reference about the CORRESPONDING phrase.
Related concepts
“Unicode and the encoding of language characters” on page 124
“National groups” on page 133
Related tasks
“Assigning values to elementary
data items (MOVE)” on page 32
“Using national groups” on page 137
“Converting to or from national (Unicode) representation” on page 134
Related references
Classes and categories of group items (Enterprise COBOL for z/OS Language Reference)
Move w to z
Compute z = w
In the example above, the two statements in most cases have the same effect. The MOVE statement
however carries out the assignment with truncation. You can use the DIAGTRUNC compiler option to
request that the compiler issue a warning for MOVE statements that might truncate numeric receivers.
When significant left-order digits would be lost in execution, the COMPUTE statement can detect the
condition and allow you to handle it. If you use the ON SIZE ERROR phrase of the COMPUTE statement,
the compiler generates code to detect a size-overflow condition. If the condition occurs, the code in the
ON SIZE ERROR phrase is performed, and the content of z remains unchanged. If you do not specify
the ON SIZE ERROR phrase, the assignment is carried out with truncation. There is no ON SIZE ERROR
support for the MOVE statement.
You can also use the COMPUTE statement to assign the result of an arithmetic expression or intrinsic
function to a data item. For example:
Compute z = y + (x ** 3)
Compute x = Function Max(x y z)
You can assign the results of date, time, mathematical, and other calculations to data items by using
Language Environment callable services. Language Environment services are available through a standard
COBOL CALL statement, and the values they return are passed in the parameters of the CALL statement.
For example, you can call the Language Environment service CEESIABS to find the absolute value of a
data item by coding the following statement:
As a result of this call, data item Result is assigned the absolute value of the value in data item
Arg; data item Feedback-code contains the return code that indicates whether the service completed
successfully. You have to define all the data items in the DATA DIVISION using the correct descriptions
according to the requirements of the particular callable service. For the example above, the data items
could be defined as follows:
Related references
“DIAGTRUNC” on page 362
Intrinsic functions (Enterprise COBOL for z/OS Language Reference)
Language Environment Programming Reference (Callable services)
34 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Assigning input from a screen or file (ACCEPT)
One way to assign a value to a data item is to read the value from a screen or a file.
To enter data from the screen, first associate the monitor with a mnemonic-name in the SPECIAL-NAMES
paragraph. Then use ACCEPT to assign the line of input entered at the screen to a data item. For example:
Environment Division.
Configuration Section.
Special-Names.
Console is Names-Input.
. . .
Accept Customer-Name From Names-Input
To read from a file instead of the screen, make the following change:
• Change Console to device, where device is any valid system device (for example, SYSIN). For example:
SYSIN is Names-Input
device can be a ddname that references a z/OS UNIX file system path. If this ddname is not defined and
your program is running in the z/OS UNIX environment, stdin is the input source. If this ddname is not
defined and your program is not running in the z/OS UNIX environment, the ACCEPT statement fails.
When you use the ACCEPT statement, you can assign a value to an alphanumeric or national group item,
or to an elementary data item that has USAGE DISPLAY, USAGE DISPLAY-1, or USAGE NATIONAL.
When you assign a value to a USAGE NATIONAL data item, input data from the console is converted
from the EBCDIC code page specified in the CODEPAGE compiler option to national (Unicode UTF-16)
representation. This is the only case where conversion of national data is done when you use the ACCEPT
statement. Conversion is done in this case because the input is known to be coming from a screen.
To have conversion done when the input data is from any other device, use the NATIONAL-OF intrinsic
function.
Related concepts
“Unicode and the encoding of language characters” on page 124
Related tasks
“Converting alphanumeric or DBCS to national (NATIONAL-OF)” on page 135
Related references
“CODEPAGE” on page 353
ACCEPT statement (Enterprise COBOL for z/OS Language Reference)
SPECIAL-NAMES paragraph (Enterprise COBOL for z/OS Language Reference)
Display "No entry for surname '" Customer-Name "' found in the file.".
In the example above, if the content of data item Customer-Name is JOHNSON, then the statement
displays the following message on the system logical output device:
You can specify a file in the z/OS UNIX file system by using the SYSPUNCH DD statement. For example,
the following definition causes DISPLAY output to be written to the file /u/userid/cobol/demo.lst:
//SYSPUNCH DD PATH='/u/userid/cobol/demo.lst',
// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),PATHMODE=SIRWXU,
// FILEDATA=TEXT
The following statement writes to the job log or console and to the TSO screen if you are running under
TSO:
When you display the value of a USAGE NATIONAL data item to the console, the data item is converted
from Unicode (UTF-16) representation to EBCDIC based on the value of the CODEPAGE option. This is the
only case in which conversion of national data is done when you use the DISPLAY statement. Conversion
is done in this case because the output is known to be directed to a screen.
To have a national data item be converted when you direct output to a different device, use the DISPLAY-
OF intrinsic function, as in the following example:
Related concepts
“Unicode and the encoding of language characters” on page 124
Related tasks
“Displaying data on the system logical output device” on page 36
“Using WITH NO ADVANCING” on page 37
“Converting national to alphanumeric (DISPLAY-OF)” on page 135
“Coding COBOL programs to run under CICS” on page 495
Related references
“CODEPAGE” on page 353
DISPLAY statement (Enterprise COBOL for z/OS Language Reference)
The output is directed to the ddname that you specify in the OUTDD compiler option. You can specify a file
in the z/OS UNIX file system with this ddname.
If the OUTDD ddname is not allocated and you are not running in the z/OS UNIX environment, a default
DD of SYSOUT=* is allocated. If the OUTDD ddname is not allocated and you are running in the z/OS UNIX
environment, the _IGZ_SYSOUT environment variable is used as follows:
Undefined or set to stdout
Output is routed to stdout (file descriptor 1).
36 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Set to stderr
Output is routed to stderr (file descriptor 2).
Otherwise (set to something other than stdout or stderr)
The DISPLAY statement fails; a severity-3 Language Environment condition is raised.
When DISPLAY output is routed to stdout or stderr, the output is not subdivided into records. The output
is written as a single stream of characters without line breaks.
If OUTDD and the Language Environment runtime option MSGFILE specify the same ddname, both
DISPLAY output and Language Environment runtime diagnostics are routed to the Language Environment
message file.
Related tasks
“Setting and accessing environment variables” on page 526
Related references
“OUTDD” on page 396
DISPLAY statement (Enterprise COBOL for z/OS Language Reference)
DISPLAY "ABC"
DISPLAY "CDEF" WITH NO ADVANCING
DISPLAY "GHIJK" WITH NO ADVANCING
DISPLAY "LMNOPQ"
DISPLAY "RSTUVWX"
If you code the statements above, the result sent to the output device is:
ABC
CDEF
+GHIJK
+LMNOPQ
RSTUVMX
The output that is printed depends on how the output device interprets printer control characters.
If you do not specify the WITH NO ADVANCING phrase and the output is going to stdout or stderr, a
newline character is appended to the end of the stream.
Related references
DISPLAY statement (Enterprise COBOL for z/OS Language Reference)
A function-identifier represents both the invocation of the function and the data value returned by the
function. Because it actually represents a data item, you can use a function-identifier in most places in the
PROCEDURE DIVISION where a data item that has the attributes of the returned value can be used. You
can also use a function-identifier in the ENVIRONMENT DIVISION within the REPOSITORY paragraph.
The COBOL word function is a reserved word, but the function-names are not reserved. You can use
them in other contexts, such as for the name of a data item. For example, you could use Sqrt to invoke an
intrinsic function and to name a data item in your program:
Working-Storage Section.
01 x Pic 99 value 2.
01 y Pic 99 value 4.
01 z Pic 99 value 0.
01 Sqrt Pic 99 value 0.
. . .
Compute Sqrt = 16 ** .5
Compute z = x + Function Sqrt(y)
. . .
A function-identifier represents a value that is of one of these types: alphanumeric, national, numeric,
or integer. You can include a substring specification (reference modifier) in a function-identifier for
alphanumeric or national functions. Numeric intrinsic functions are further classified according to the
type of numbers they return.
The functions MAX and MIN can return either type of value depending on the type of arguments you
supply.
Functions can reference other functions as arguments provided that the results of the nested functions
meet the requirements for the arguments of the outer function. For example, Function Sqrt(5)
returns a numeric value. Thus, the three arguments to the MAX function below are all numeric, which is an
allowable argument type for this function:
Related tasks
“Processing table items using intrinsic functions” on page 87
“Converting data items (intrinsic functions)” on page 113
“Evaluating data items (intrinsic functions)” on page 117
Related references
REPOSITORY paragraph (Enterprise COBOL for z/OS Language Reference)
38 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Using tables (arrays) and pointers
In COBOL, arrays are called tables. A table is a set of logically consecutive data items that you define in
the DATA DIVISION by using the OCCURS clause.
Pointers are data items that contain virtual storage addresses. You define them either explicitly with the
USAGE IS POINTER clause in the DATA DIVISION or implicitly as ADDRESS OF special registers.
You can perform the following operations with pointer data items:
• Pass them between programs by using the CALL . . . BY REFERENCE statement.
• Set a pointer to allocated storage or free storage by using the ALLOCATE and FREE statements.
• Move them to other pointers by using the SET statement.
• Compare them to other pointers for equality by using a relation condition.
• Initialize them to contain an invalid address by using VALUE IS NULL.
Use pointer data items to:
• Accomplish limited base addressing, particularly if you want to pass and receive addresses of a record
area that is defined with OCCURS DEPENDING ON and is therefore variably located.
• Handle a chained list.
Related tasks
“Defining a table (OCCURS)” on page 67
“Using procedure and function pointers” on page 557
40 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Note:
• To run COBOL programs with addressing mode 24, you must compile all COBOL programs with
Enterprise COBOL 5.1.1, or later versions; or Enterprise COBOL 4.2 or earlier versions. If any component
of a program object is compiled with Enterprise COBOL 5.1.0, the program object must run in
addressing mode 31. COBOL programs that run with addressing mode 24 must be linked with the
binder option RMODE(24).
• To run COBOL programs with addressing mode 64, you must compile all COBOL programs with
Enterprise COBOL 6.3, or later versions, and use the LP(64) compiler option.
Table 4. Effect of RMODE and RENT compiler options on the RMODE attribute
RMODE compiler option RENT compiler option RMODE attribute
RMODE(AUTO) RENT RMODE ANY
RMODE(AUTO) NORENT RMODE 24
RMODE(24) RENT or NORENT RMODE 24
RMODE(ANY) RENT RMODE ANY
RMODE(ANY) NORENT Compiler option conflict.
Link-edit considerations: When the object code that COBOL generates has an attribute of RMODE 24, you
must link-edit it with RMODE 24. When the object code that COBOL generates has an attribute of RMODE
ANY, you can link-edit it with RMODE ANY or RMODE 24.
Related concepts
“AMODE switching” on page 550
AMODE considerations for heap storage
(Language Environment Programming Guide)
Related tasks
Chapter 28, “Using subprograms,” on page 545
Chapter 29, “Sharing data,” on page 563
Related references
“Allocation of buffers for QSAM files” on page 186
“Allocation of record areas for VSAM files” on page 211
“DATA” on page 359
“RENT” on page 401
“RMODE” on page 402
“Performance-related compiler options” on page 778
ALLOCATE statement (Enterprise COBOL for z/OS Language Reference)
HEAP, STACK, ALL31 (Language Environment Programming Reference)
MVS Program Management: User's Guide and Reference
42 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Chapter 3. Working with numbers and arithmetic
In general, you can view COBOL numeric data as a series of decimal digit positions. However, numeric
items can also have special properties such as an arithmetic sign or a currency sign.
To define, display, and store numeric data so that you can perform arithmetic operations efficiently:
• Use the PICTURE clause and the characters 9, +, -, P, S, and V to define numeric data.
• Use the PICTURE clause and editing characters (such as Z, comma, and period) along with MOVE and
DISPLAY statements to display numeric data.
• Use the USAGE clause with various formats to control how numeric data is stored.
• Use the numeric class test to validate that data values are appropriate.
• Use ADD, SUBTRACT, MULTIPLY, DIVIDE, and COMPUTE statements to perform arithmetic.
• Use the CURRENCY SIGN clause and appropriate PICTURE characters to designate the currency you
want.
Related tasks
“Defining numeric data” on page 43
“Displaying numeric data” on page 45
“Controlling how numeric data is stored” on page 46
“Checking for incompatible data (numeric class test)” on page 53
“Performing arithmetic” on page 55
“Using currency signs” on page 64
You can similarly define numeric data items to hold national characters (UTF-16). For example, Count-n
below is an external decimal data item that has USAGE NATIONAL (a national decimal item):
You can code up to 18 digits in the PICTURE clause when you compile using the default compiler option
ARITH(COMPAT) (referred to as compatibility mode). When you compile using ARITH(EXTEND) (referred
to as extended mode), you can code up to 31 digits in the PICTURE clause.
Other characters of special significance that you can code are:
P
Indicates leading or trailing zeros
S
Indicates a sign, positive or negative
V
Implies a decimal point
The field can therefore hold a positive or a negative value. The v indicates the position of an implied
decimal point, but does not contribute to the size of the item because it does not require a storage
position. An s usually does not contribute to the size of a numeric item, because by default s does not
require a storage position.
However, if you plan to port your program or data to a different machine, you might want to code the sign
for a zoned decimal data item as a separate position in storage. In the following case, the sign takes 1
byte:
This coding ensures that the convention your machine uses for storing a nonseparate sign will not cause
unexpected results on a machine that uses a different convention.
Separate signs are also preferable for zoned decimal data items that will be printed or displayed.
Separate signs are required for national decimal data items that are signed. The sign takes 2 bytes of
storage, as in the following example:
You cannot use the PICTURE clause with internal floating-point data (COMP-1 or COMP-2). However, you
can use the VALUE clause to provide an initial value for an internal floating-point literal:
For information about external floating-point data, see the examples referenced below and the related
concept about formats for numeric data.
“Examples: numeric data and internal representation” on page 49
Related concepts
“Formats for numeric data” on page 47
Appendix A, “Intermediate results and arithmetic precision,” on page 793
Related tasks
“Displaying numeric data” on page 45
“Controlling how numeric data is stored” on page 46
“Performing arithmetic” on page 55
“Defining national numeric data items” on page 132
Related references
“Sign representation of zoned and packed-decimal data” on page 53
“Storage of character data” on page 139
“ARITH” on page 349
“NUMPROC” on page 392
SIGN clause (Enterprise COBOL for z/OS Language Reference)
44 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Displaying numeric data
You can define numeric items with certain editing symbols (such as decimal points, commas, dollar signs,
and debit or credit signs) to make the items easier to read and understand when you display or print
them.
For example, in the code below, Edited-price is a numeric-edited item that has USAGE DISPLAY. (You
can specify the clause USAGE IS DISPLAY for numeric-edited items; however, it is implied. It means
that the items are stored in character format.)
If the contents of Price are 0150099 (representing the value 1,500.99), $ 1,500.99 is displayed when
you run the code. The z in the PICTURE clause of Edited-price indicates the suppression of leading
zeros.
You can define numeric-edited data items to hold national (UTF-16) characters instead of alphanumeric
characters. To do so, define the numeric-edited items as USAGE NATIONAL. The effect of the editing
symbols is the same for numeric-edited items that have USAGE NATIONAL as it is for numeric-edited
items that have USAGE DISPLAY, except that the editing is done with national characters. For example,
if Edited-price is declared as USAGE NATIONAL in the code above, the item is edited and displayed
using national characters.
To display numeric or numeric-edited data items that have USAGE NATIONAL in EBCDIC, direct them
to CONSOLE. For example, if Edited-price in the code above has USAGE NATIONAL, $ 1,500.99 is
displayed when you run the program if the last statement above is:
You can cause an elementary numeric or numeric-edited item to be filled with spaces when a value of
zero is stored into it by coding the BLANK WHEN ZERO clause for the item. For example, each of the
DISPLAY statements below causes blanks to be displayed instead of zeros:
You cannot use numeric-edited items as sending operands in arithmetic expressions or in ADD,
SUBTRACT, MULTIPLY, DIVIDE, or COMPUTE statements. (Numeric editing takes place when a numeric-
edited item is the receiving field for one of these statements, or when a MOVE statement has a numeric-
edited receiving field and a numeric-edited or numeric sending field.) You use numeric-edited items
primarily for displaying or printing numeric data.
You can move numeric-edited items to numeric or numeric-edited items. In the following example, the
value of the numeric-edited item (whether it has USAGE DISPLAY or USAGE NATIONAL) is moved to the
numeric item:
Related tasks
“Displaying values on a screen or in a file (DISPLAY)” on page 35
“Controlling how numeric data is stored” on page 46
“Defining numeric data” on page 43
“Performing arithmetic” on page 55
“Defining national numeric data items” on page 132
“Converting to or from national (Unicode) representation” on page 134
Related references
MOVE statement (Enterprise COBOL for z/OS Language Reference)
BLANK WHEN ZERO clause (Enterprise COBOL for z/OS Language Reference)
The compiler converts displayable numbers to the internal representation of their numeric values before
using them in arithmetic operations. Therefore it is often more efficient if you define data items as
BINARY or PACKED-DECIMAL than as DISPLAY or NATIONAL. For example:
46 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Regardless of which USAGE clause you use to control the internal representation of a value, you use the
same PICTURE clause conventions and decimal value in the VALUE clause (except for internal floating-
point data, for which you cannot use a PICTURE clause).
“Examples: numeric data and internal representation” on page 49
Related concepts
“Formats for numeric data” on page 47
“Data format conversions” on page 51
Appendix A, “Intermediate results and arithmetic precision,” on page 793
Related tasks
“Defining numeric data” on page 43
“Displaying numeric data” on page 45
“Performing arithmetic” on page 55
Related references
“Conversions and precision” on page 52
“Sign representation of zoned and packed-decimal data” on page 53
The minus signs (-) do not mean that the mantissa and exponent must necessarily be negative numbers.
Instead, they mean that when the number is displayed, the sign appears as a blank for positive numbers
If Compute-Result-N is displayed, the signs appear as described above for Compute-Result, but
in national characters. To instead display Compute-Result-N in EBCDIC characters, direct it to the
console:
You cannot use the VALUE clause for external floating-point items.
As with external decimal numbers, external floating-point numbers have to be converted (by the
compiler) to an internal representation of their numeric value before they can be used in arithmetic
operations. If you compile with the default option ARITH (COMPAT), external floating-point numbers are
converted to long (64-bit) floating-point format. If you compile with ARITH (EXTEND), they are instead
converted to extended-precision (128-bit) floating-point format.
48 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 5. Ranges in value of COMP-5 data items
PICTURE Storage representation Numeric values
S9(1) through S9(4) Binary halfword (2 bytes) -32768 through +32767
S9(5) through S9(9) Binary fullword (4 bytes) -2,147,483,648 through +2,147,483,647
S9(10) through Binary doubleword (8 bytes) -9,223,372,036,854,775,808 through
S9(18) +9,223,372,036,854,775,807
9(1) through 9(4) Binary halfword (2 bytes) 0 through 65535
9(5) through 9(9) Binary fullword (4 bytes) 0 through 4,294,967,295
9(10) through 9(18) Binary doubleword (8 bytes) 0 through 18,446,744,073,709,551,615
You can specify scaling (that is, decimal positions or implied integer positions) in the PICTURE clause
of COMP-5 items. If you do so, you must appropriately scale the maximal capacities listed above. For
example, a data item you describe as PICTURE S99V99 COMP-5 is represented in storage as a binary
halfword, and supports a range of values from -327.68 through +327.67.
Large literals in VALUE clauses: Literals specified in VALUE clauses for COMP-5 items can, with a few
exceptions, contain values of magnitude up to the capacity of the native binary representation. See
Enterprise COBOL for z/OS Language Reference for the exceptions.
Regardless of the setting of the TRUNC compiler option, COMP-5 data items behave like binary data does
in programs compiled with TRUNC(BIN).
Related concepts
“Unicode and the encoding of language characters” on page 124
Appendix A, “Intermediate results and arithmetic precision,” on page 793
Related tasks
“Defining numeric data” on page 43
“Defining national numeric data items” on page 132
Related references
“Storage of character data” on page 139
“TRUNC” on page 419
Classes and categories of data (Enterprise COBOL for z/OS Language Reference)
SIGN clause (Enterprise COBOL for z/OS Language Reference)
VALUE clause (Enterprise COBOL for z/OS Language Reference)
+ 1234 4E F1 F2 F3 F4
PIC S9999 DISPLAY - 1234 60 F1 F2 F3 F4
SIGN LEADING SEPARATE
+ 1234 F1 F2 F3 F4 4E
PIC S9999 DISPLAY - 1234 F1 F2 F3 F4 60
SIGN TRAILING
SEPARATE
+ 1234 00 2B 00 31 00 32 00 33 00
34
PIC S9999 NATIONAL
SIGN LEADING - 1234 00 2D 00 31 00 32 00 33 00
SEPARATE 34
+ 1234 00 31 00 32 00 33 00 34 00
2B
PIC S9999 NATIONAL
SIGN TRAILING - 1234 00 31 00 32 00 33 00 34 00
SEPARATE 2D
Binary + 1234 04 D2
PIC S9999 BINARY - 1234 FB 2E
PIC S9999 COMP
PIC S9999 COMP-4
50 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 6. Internal representation of numeric items (continued)
Numeric type PICTURE and USAGE and Value Internal representation
optional SIGN clause
Internal + 1234 01 23 4C
decimal PIC S9999 PACKED- - 1234 01 23 4D
DECIMAL
PIC S9999 COMP-3
1234 01 23 4F
PIC 9999 PACKED-
DECIMAL
PIC 9999 COMP-3
- 12.34E+02
00 2D 00 31 00 32 00 2E 00
33
00 34 00 45 00 2B 00 30 00
32
1. The example demonstrates that COMP-5 data items can contain values of magnitude up to the capacity
of the native binary representation (2, 4, or 8 bytes), rather than being limited to the value implied by the
number of 9s in the PICTURE clause.
Conversions between fixed-point data formats (external decimal, packed decimal, or binary) are without
loss of precision provided that the target field can contain all the digits of the source operand.
A loss of precision is possible in conversions between fixed-point data formats and floating-point data
formats (short floating point, long floating point, or external floating point). These conversions happen
during arithmetic evaluations that have a mixture of both fixed-point and floating-point operands.
Related references
“Conversions and precision” on page 52
“Sign representation of zoned and packed-decimal data” on page 53
52 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Related concepts
Appendix A, “Intermediate results and arithmetic precision,” on page 793
The COBOL NUMPROC compiler option affects sign processing for zoned decimal and internal decimal
data. NUMPROC has no effect on binary data, national decimal data, or floating-point data.
NUMPROC(PFD)
Given X'sd', where s is the sign representation and d represents the digit, when you use
NUMPROC(PFD), the compiler assumes that the sign in your data is one of three preferred signs:
Signed positive or 0:
X'C'
Signed negative:
X'D'
Unsigned or alphanumeric:
X'F'
Based on this assumption, the compiler uses whatever sign it is given to process data. The preferred
sign is generated only where necessary (for example, when unsigned data is moved to signed data).
Using the NUMPROC(PFD) option can save processing time, but you must use preferred signs with
your data for correct processing.
NUMPROC(NOPFD)
When the NUMPROC(NOPFD) compiler option is in effect, the compiler accepts any valid sign
configuration. The preferred sign is always generated in the receiver. NUMPROC(NOPFD) is less
efficient than NUMPROC(PFD), but you should use it whenever data that does not use preferred signs
might exist.
If an unsigned, zoned-decimal sender is moved to an alphanumeric receiver, the sign is unchanged
(even with NUMPROC(NOPFD) in effect).
Related references
“NUMPROC” on page 392
“ZWB” on page 431
Linkage Section.
01 Count-x Pic 999.
. . .
Procedure Division Using Count-x.
If Count-x is numeric then display "Data is good"
The numeric class test checks the contents of a data item against a set of values that are valid for the
PICTURE and USAGE of the data item. For example, a packed decimal item is checked for hexadecimal
values X'0' through X'9' in the digit positions and for a valid sign value in the sign position (whether
separate or nonseparate). An external decimal data item that has USAGE DISPLAY is checked for
hexadecimal values X'0' through X'9' in the digit positions (the lower 4 bits of each byte), for a valid
zone code in the upper 4 bits of each byte and for a valid sign value in the sign position (whether separate
or nonseparate). The sign code is in the upper 4 bits of the sign byte or in a separate byte if SIGN IS
SEPARATE was specified. If the SIGN IS SEPARATE clause is used, the upper four bits of all bytes must
be x'F'.
Note: Although the INVDATA compiler option allows toleration of invalid zone codes in USAGE DISPLAY
numeric (zoned decimal) data items in numeric comparisons, invalid zone codes in zoned decimal data
items will be treated as nonnumeric by the numeric class test.
For zoned decimal and packed decimal items, the numeric class test is affected by the NUMPROC compiler
option and the NUMCLS option (which is set at installation time). To determine the NUMCLS setting used at
your installation, consult your system programmer.
If NUMCLS(PRIM) is in effect at your installation, use the following table to find the values that the
compiler considers valid for the sign.
If NUMCLS(ALT) is in effect at your installation, use the following table to find the values that the
compiler considers valid for the sign.
For more information about numeric class condition, see Class condition in the Enterprise COBOL for z/OS
Language Reference.
You can also use the NUMCHECK(ZON,PAC) option to have the compiler generate implicit numeric class
tests for zoned decimal (numeric USAGE DISPLAY) and packed decimal (COMP-3) data items that are
used as sending data items. This numeric class test validates data and also validates sign fields against
the NUMPROC compiler option to help you decide whether you can use NUMPROC(PFD) or not. For details,
see “NUMCHECK” on page 388.
For more information about other invalid data issues, in particular for COBOL migration purposes, see the
FAQ about invalid data in the Enterprise COBOL Migration Guide.
54 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Related references
“NUMCHECK” on page 388
“NUMPROC” on page 392
“INVDATA” on page 376
Performing arithmetic
You can use any of several COBOL language features (including COMPUTE, arithmetic expressions,
numeric intrinsic functions, and math and date callable services) to perform arithmetic. Your choice
depends on whether a feature meets your particular needs.
For most common arithmetic evaluations, the COMPUTE statement is appropriate. If you need to use
numeric literals, numeric data, or arithmetic operators, you might want to use arithmetic expressions. In
places where numeric expressions are allowed, you can save time by using numeric intrinsic functions.
Language Environment callable services for mathematical functions and for date and time operations also
provide a means of assigning arithmetic results to data items.
Related tasks
“Using COMPUTE and other arithmetic statements” on page 55
“Using arithmetic expressions” on page 56
“Using numeric intrinsic functions” on page 56
“Using math-oriented callable services” on page 58
“Using date callable services” on page 59
Compute z = a + b / c ** d - e
Compute x y z = a + b / c ** d - e
Some arithmetic calculations might be more intuitive using arithmetic statements other than COMPUTE.
For example:
You might also prefer to use the DIVIDE statement (with its REMAINDER phrase) for division in which you
want to process a remainder. The REM intrinsic function also provides the ability to process a remainder.
Related concepts
“Fixed-point contrasted with floating-point arithmetic” on page 62
Appendix A, “Intermediate results and arithmetic precision,” on page 793
Related tasks
“Defining numeric data” on page 43
If (a + b) > (c - d + 5) Then. . .
Arithmetic expressions can consist of a single numeric literal, a single numeric data item, or a single
intrinsic function reference. They can also consist of several of these items connected by arithmetic
operators.
Arithmetic operators are evaluated in the following order of precedence:
Operators at the same level of precedence are evaluated from left to right; however, you can use
parentheses to change the order of evaluation. Expressions in parentheses are evaluated before the
individual operators are evaluated. Parentheses, whether necessary or not, make your program easier to
read.
Related concepts
“Fixed-point contrasted with floating-point arithmetic” on page 62
Appendix A, “Intermediate results and arithmetic precision,” on page 793
Integer
Those that return an integer
56 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Floating point
Those that return a long (64-bit) or extended-precision (128-bit) floating-point value (depending on
whether you compile using the default option ARITH(COMPAT) or using ARITH(EXTEND))
Mixed
Those that return an integer, a floating-point value, or a fixed-point number with decimal places,
depending on the arguments
You can use intrinsic functions to perform several different arithmetic operations, as outlined in the
following table.
You can reference one function as the argument of another. A nested function is evaluated independently
of the outer function (except when the compiler determines whether a mixed function should be
evaluated using fixed-point or floating-point instructions).
You can also nest an arithmetic expression as an argument to a numeric function. For example, in the
statement below, there are three function arguments (a, b, and the arithmetic expression (c / d)):
You can reference all the elements of a table (or array) as function arguments by using the ALL subscript.
You can also use the integer special registers as arguments wherever integer arguments are allowed.
Many of the capabilities of numeric intrinsic functions are also provided by Language Environment callable
services.
Related concepts
“Fixed-point contrasted with floating-point arithmetic” on page 62
Appendix A, “Intermediate results and arithmetic precision,” on page 793
1. RANDOM returns a long (64-bit) floating-point result even if you pass it a 31-digit argument and compile with
ARITH(EXTEND).
Both the RANDOM intrinsic function and CEERAN0 service generate random numbers between zero and
one. However, because each uses its own algorithm, RANDOM and CEERAN0 produce different random
numbers from the same seed.
Even for functions that produce the same results, how you use intrinsic functions and Language
Environment callable services differs. The rules for the data types required for intrinsic function
arguments are less restrictive. For numeric intrinsic functions, you can use arguments that are of any
numeric data type. When you invoke a Language Environment callable service with a CALL statement,
58 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
however, you must ensure that the parameters match the numeric data types (generally COMP-1 or
COMP-2) required by that service.
The error handling of intrinsic functions and Language Environment callable services sometimes differs.
If you pass an explicit feedback token when calling the Language Environment math services, you must
check the feedback code after each call and take explicit action to deal with errors. However, if you call
with the feedback token explicitly OMITTED, you do not need to check the token; Language Environment
automatically signals any errors.
Related concepts
“Fixed-point contrasted with floating-point arithmetic” on page 62
Appendix A, “Intermediate results and arithmetic precision,” on page 793
Related tasks
“Using Language Environment callable
services” on page 787
Related references
“ARITH” on page 349
Table 12. INTDATE(LILIAN) and compatibility of date intrinsic functions and callable services
COBOL intrinsic function Language Environment callable service Results
DATE-OF-INTEGER CEEDATE with picture string YYYYMMDD Compatible
DAY-OF-INTEGER CEEDATE with picture string YYYYDDD Compatible
INTEGER-OF-DATE CEEDAYS Compatible
INTEGER-OF-DATE CEECBLDY Incompatible
When the default setting of INTDATE(ANSI) is in effect, COBOL uses January 1, 1601 as day 1. The
following table compares the results when INTDATE(ANSI) is in effect.
Table 13. INTDATE(ANSI) and compatibility of date intrinsic functions and callable services
COBOL intrinsic function Language Environment callable service Results
INTEGER-OF-DATE CEECBLDY Compatible
DATE-OF-INTEGER CEEDATE with picture string YYYYMMDD Incompatible
DAY-OF-INTEGER CEEDATE with picture string YYYYDDD Incompatible
INTEGER-OF-DATE CEEDAYS Incompatible
Related tasks
“Using Language Environment callable
services” on page 787
01 X Pic 9(2).
01 Price1 Pic x(8) Value "$8000".
01 Price2 Pic x(8) Value "$2000".
01 Output-Record.
05 Product-Name Pic x(20).
05 Product-Number Pic 9(9).
05 Product-Price Pic 9(6).
. . .
Procedure Division.
Compute Product-Price =
Function Max (Function Numval-C(Price1) Function Numval-C(Price2))
Compute X = Function Length(Output-Record)
Additionally, to ensure that the contents in Product-Name are in uppercase letters, you can use the
following statement:
Finance
Business investment decisions frequently require computing the present value of expected future cash
inflows to evaluate the profitability of a planned investment. The present value of an amount that you
expect to receive at a given time in the future is that amount, which, if invested today at a given interest
rate, would accumulate to that future amount.
60 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
For example, assume that a proposed investment of $1,000 produces a payment stream of $100, $200,
and $300 over the next three years, one payment per year respectively. The following COBOL statements
calculate the present value of those cash inflows at a 10% interest rate:
You can use the ANNUITY function in business problems that require you to determine the amount of
an installment payment (annuity) necessary to repay the principal and interest of a loan. The series of
payments is characterized by an equal amount each period, periods of equal length, and an equal interest
rate each period. The following example shows how you can calculate the monthly payment required to
repay a $15,000 loan in three years at a 12% annual interest rate (36 monthly payments, interest per
month = .12/12):
Mathematics
The following COBOL statement demonstrates that you can nest intrinsic functions, use arithmetic
expressions as arguments, and perform previously complex calculations simply:
Here in the addend the intrinsic function REM (instead of a DIVIDE statement with a REMAINDER clause)
returns the remainder of dividing X by 2.
Statistics
Intrinsic functions make calculating statistical information easier. Assume you are analyzing various city
taxes and want to calculate the mean, median, and range (the difference between the maximum and
minimum taxes):
Related tasks
“Converting to numbers (NUMVAL, NUMVAL-C, NUMVAL-F)” on page 115
• Arithmetic comparisons
Floating-point evaluations
In general, if your arithmetic coding has either of the characteristics listed below, it is evaluated in
floating-point arithmetic:
• An operand or result field is floating point.
An operand is floating point if you code it as a floating-point literal or if you code it as a data item that
is defined as USAGE COMP-1, USAGE COMP-2, or external floating point (USAGE DISPLAY or USAGE
NATIONAL with a floating-point PICTURE).
An operand that is a nested arithmetic expression or a reference to a numeric intrinsic function results
in floating-point arithmetic when any of the following conditions is true:
– An argument in an arithmetic expression results in floating point.
– The function is a floating-point function.
– The function is a mixed function with one or more floating-point arguments.
• An exponent contains decimal places.
An exponent contains decimal places if you use a literal that contains decimal places, give the item a
PICTURE that contains decimal places, or use an arithmetic expression or function whose result has
decimal places.
An arithmetic expression or numeric function yields a result that has decimal places if any operand or
argument (excluding divisors and exponents) has decimal places.
Fixed-point evaluations
In general, if an arithmetic operation contains neither of the characteristics listed above for floating point,
the compiler causes it to be evaluated in fixed-point arithmetic. In other words, arithmetic evaluations
are handled as fixed point only if all the operands are fixed point, the result field is defined to be fixed
point, and none of the exponents represent values with decimal places. Nested arithmetic expressions
and function references must also represent fixed-point values.
62 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Arithmetic comparisons (relation conditions)
When you compare numeric expressions using a relational operator, the numeric expressions (whether
they are data items, arithmetic expressions, function references, or some combination of these) are
comparands in the context of the entire evaluation. That is, the attributes of each can influence the
evaluation of the other: both expressions are evaluated in fixed point, or both are evaluated in floating
point. This is also true of abbreviated comparisons even though one comparand does not explicitly appear
in the comparison. For example:
if (a + d) = (b + e) and c
evaluate (a + d)
when (b + e) thru c
when (f / g) thru (h * i)
. . .
end-evaluate
01 employee-table.
05 emp-count pic 9(4).
05 employee-record occurs 1 to 1000 times
depending on emp-count.
10 hours pic +9(5)ve+99.
. . .
01 report-matrix-col pic 9(3).
01 report-matrix-min pic 9(3).
01 report-matrix-max pic 9(3).
01 report-matrix-tot pic 9(3).
01 average-hours pic 9(3)v9.
01 whole-hours pic 9(4).
To specify the symbols for displaying financial information, use the CURRENCY SIGN clause (in the
SPECIAL-NAMES paragraph in the CONFIGURATION SECTION) with the PICTURE characters that relate
to those symbols. In the following example, the PICTURE character $ indicates that the currency sign $US
is to be used:
In this example, if Invoice-Amount contained 1500.00, the display output would be:
By using more than one CURRENCY SIGN clause in your program, you can allow for multiple currency
signs to be displayed.
You can use a hexadecimal literal to indicate the currency sign value. Using a hexadecimal literal could
be useful if the data-entry method for the source program does not allow the entry of the intended
characters easily. The following example shows the hexadecimal value X'9F' used as the currency sign:
If there is no corresponding character for the euro sign on your keyboard, you need to specify it as a
hexadecimal value in the CURRENCY SIGN clause. The hexadecimal value for the euro sign is either
X'9F' or X'5A' depending on the code page in use, as shown in the following table.
64 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 14. Hexadecimal values of the euro sign
Code page Applicable countries Modified Euro sign
CCSID from
1140 USA, Canada, Netherlands, Portugal, Australia, New 037 X'9F'
Zealand
1141 Austria, Germany 273 X'9F'
1142 Denmark, Norway 277 X'5A'
1143 Finland, Sweden 278 X'5A'
1144 Italy 280 X'9F'
1145 Spain, Latin America - Spanish 284 X'9F'
1146 UK 285 X'9F'
1147 France 297 X'9F'
1148 Belgium, Canada, Switzerland 500 X'9F'
1149 Iceland 871 X'9F'
Related references
“CURRENCY” on page 358
CURRENCY SIGN clause (Enterprise COBOL for z/OS Language Reference)
IDENTIFICATION DIVISION.
PROGRAM-ID. EuroSamp.
Environment Division.
Configuration Section.
Special-Names.
Currency Sign is "CHF " with Picture Symbol "F"
Currency Sign is "EUR " with Picture Symbol "Y".
Data Division.
WORKING-STORAGE SECTION.
01 Deposit-in-Euro Pic S9999V99 Value 8000.00.
01 Deposit-in-CHF Pic S99999V99.
01 Deposit-Report.
02 Report-in-Franc Pic -FFFFF9.99.
02 Report-in-Euro Pic -YYYYY9.99.
01 EUR-to-CHF-Conv-Rate Pic 9V99999 Value 1.53893.
. . .
PROCEDURE DIVISION.
Report-Deposit-in-CHF-and-EUR.
Move Deposit-in-Euro to Report-in-Euro
Compute Deposit-in-CHF Rounded
= Deposit-in-Euro * EUR-to-CHF-Conv-Rate
On Size Error
Perform Conversion-Error
Not On Size Error
Move Deposit-in-CHF to Report-in-Franc
Display "Deposit in euro = " Report-in-Euro
Display "Deposit in franc = " Report-in-Franc
End-Compute
Goback.
Conversion-Error.
Display "Conversion error from EUR to CHF"
Display "Euro value: " Report-in-Euro.
The exchange rate used in this example is for illustrative purposes only.
66 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Chapter 4. Handling tables
A table is a collection of data items that have the same description, such as account totals or monthly
averages. A table consists of a table name and subordinate items called table elements. A table is the
COBOL equivalent of an array.
In the example above, SAMPLE-TABLE-ONE is the group item that contains the table. TABLE-COLUMN
names the table element of a one-dimensional table that occurs three times.
Rather than defining repetitious items as separate, consecutive entries in the DATA DIVISION, you use
the OCCURS clause in the DATA DIVISION entry to define a table. This practice has these advantages:
• The code clearly shows the unity of the items (the table elements).
• You can use subscripts and indexes to refer to the table elements.
• You can easily repeat data items.
Tables are important for increasing the speed of a program, especially a program that looks up records.
Related concepts
“Complex OCCURS DEPENDING
ON” on page 81
Related tasks
“Defining a table (OCCURS)” on page 67
“Nesting tables” on page 69
“Referring to an item in
a table” on page 70
“Putting values into a table” on page 73
“Creating variable-length tables (DEPENDING ON)” on page 78
“Searching a table” on page 84
“Sorting
a table” on page 87
“Processing table items using intrinsic functions” on page 87
“Working with unbounded tables and groups” on page 88
01 table-name.
05 element-name OCCURS n TIMES.
. . . (subordinate items of the table element)
In the example above, table-name is the name of an alphanumeric group item. The table element
definition (which includes the OCCURS clause) is subordinate to the group item that contains the table.
The OCCURS clause cannot be used in a level-01 description.
Any elementary item that is subordinate to a national group must be explicitly or implicitly described as
USAGE NATIONAL, and any subordinate numeric data item that is signed must be implicitly or explicitly
described with the SIGN IS SEPARATE clause.
To create tables of two to seven dimensions, use nested OCCURS clauses.
To create a variable-length table, code the DEPENDING ON phrase of the OCCURS clause.
To specify that table elements will be arranged in ascending or descending order based on the values in
one or more key fields of the table, code the ASCENDING or DESCENDING KEY phrases of the OCCURS
clause, or both. Specify the names of the keys in decreasing order of significance. Keys can be of class
alphabetic, alphanumeric, DBCS, national, or numeric. (If it has USAGE NATIONAL, a key can be of
category national, or can be a national-edited, numeric-edited, national decimal, or national floating-point
item.)
You must code the ASCENDING or DESCENDING KEY phrase of the OCCURS clause to do a binary search
(SEARCH ALL) of a table. You can use a format 2 SORT statement to order the table according to its
defined keys, thereby making the table searchable by the SEARCH ALL statement. Note that SEARCH
ALL will return unpredictable results if the table has not been ordered according to the keys.
“Example: binary search” on page 86
Related concepts
“National groups” on page 133
Related tasks
“Nesting tables” on page 69
“Referring to an item in
a table” on page 70
“Putting values into a table” on page 73
“Creating variable-length tables (DEPENDING ON)” on page 78
“Using national groups” on page 137
“Doing a binary search (SEARCH ALL)” on page 86
“Defining numeric data” on page 43
Related references
OCCURS clause (Enterprise COBOL for z/OS Language Reference)
SIGN clause (Enterprise COBOL for z/OS Language Reference)
ASCENDING KEY and DESCENDING KEY phrases
(Enterprise COBOL for z/OS Language Reference)
SORT statement (Enterprise COBOL for z/OS Language Reference)
68 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Nesting tables
To create a two-dimensional table, define a one-dimensional table in each occurrence of another one-
dimensional table.
In a two-dimensional table, the two subscripts correspond to the row and column numbers. In a three-
dimensional table, the three subscripts correspond to the depth, row, and column numbers.
Related tasks
“Defining a table (OCCURS)” on page 67
“Referring to an item in
a table” on page 70
“Putting values into a table” on page 73
“Creating variable-length tables (DEPENDING ON)” on page 78
“Searching a table” on page 84
“Processing table items using intrinsic functions” on page 87
“Handling tables efficiently” on page 774
Related references
OCCURS clause (Enterprise COBOL for z/OS Language Reference)
TABLE-COLUMN (2, 2, 1)
TABLE-COLUMN (2 2 1)
In either table reference, the first value (2) refers to the second occurrence within TABLE-DEPTH, the
second value (2) refers to the second occurrence within TABLE-ROW, and the third value (1) refers to the
first occurrence within TABLE-COLUMN.
The following reference to SAMPLE-TABLE-TWO uses variable subscripts. The reference is valid if SUB1
and SUB2 are data-names that contain positive integer values within the range of the table.
Related tasks
“Subscripting” on page 71
Example: indexing
The following example shows how displacements to elements that are referenced with indexes are
calculated.
01 SAMPLE-TABLE-FOUR
05 TABLE-DEPTH OCCURS 3 TIMES INDEXED BY INX-A.
10 TABLE-ROW OCCURS 4 TIMES INDEXED BY INX-B.
15 TABLE-COLUMN OCCURS 8 TIMES INDEXED BY INX-C PIC X(8).
This reference causes the following computation of the displacement to the TABLE-COLUMN element:
Related tasks
“Indexing” on page 72
70 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
• Use the data-name of the table element, along with its occurrence number (called a subscript) in
parentheses. This technique is called subscripting.
• Use the data-name of the table element, along with a value (called an index) that is added to the
address of the table to locate an item (as a displacement from the beginning of the table). This
technique is called indexing, or subscripting using index-names.
• Use both subscripts and indexes together.
Related tasks
“Subscripting” on page 71
“Indexing” on page 72
Subscripting
The lowest possible subscript value is 1, which references the first occurrence of a table element. In a
one-dimensional table, the subscript corresponds to the row number.
You can use a literal or a data-name as a subscript. If a data item that has a literal subscript is of fixed
length, the compiler resolves the location of the data item.
When you use a data-name as a variable subscript, you must describe the data-name as an elementary
numeric integer. The most efficient format is COMPUTATIONAL (COMP) with a PICTURE size that is smaller
than five digits. You cannot use a subscript with a data-name that is used as a subscript. The code
generated for the application resolves the location of a variable subscript at run time.
You can increment or decrement a literal or variable subscript by a specified integer amount. For example:
You can change part of a table element rather than the whole element. To do so, refer to the character
position and length of the substring to be changed. For example:
01 ANY-TABLE.
05 TABLE-ELEMENT PIC X(10)
OCCURS 3 TIMES VALUE "ABCDEFGHIJ".
. . .
MOVE "??" TO TABLE-ELEMENT (1) (3 : 2).
The MOVE statement in the example above moves the string '??' into table element number 1, beginning
at character position 3, for a length of 2 characters.
Related tasks
“Indexing” on page 72
“Putting values into a table” on page 73
“Searching a table” on page 84
“Handling tables efficiently” on page 774
The compiler calculates the value contained in the index as the occurrence number (subscript) minus
1, multiplied by the length of the table element. Therefore, for the fifth occurrence of TABLE-ITEM, the
binary value contained in INX-A is (5 - 1) * 8, or 32.
You can use an index-name to reference another table only if both table descriptions have the same
number of table elements, and the table elements are of the same length.
You can use the USAGE IS INDEX clause to create an index data item, and can use an index data item
with any table. For example, INX-B in the following code is an index data item:
The index-name INX-A is used to traverse table TABLE-ITEM above. The index data item INX-B is used
to hold the index of the last element of the table. The advantage of this type of coding is that calculation of
offsets of table elements is minimized, and no conversion is necessary for the UNTIL condition.
You can use the SET statement to assign to an index data item the value that you stored in an index-name,
as in the statement SET INX-B TO INX-A above. For example, when you load records into a variable-
length table, you can store the index value of the last record into a data item defined as USAGE IS
INDEX. Then you can test for the end of the table by comparing the current index value with the index
value of the last record. This technique is useful when you look through or process a table.
You can increment or decrement an index-name by an elementary integer data item or a nonzero integer
literal, for example:
The integer represents a number of occurrences. It is converted to an index value before being added to
or subtracted from the index.
Initialize the index-name by using a SET, PERFORM VARYING, or SEARCH ALL statement. You can then
use the index-name in SEARCH or relational condition statements. To change the value, use a PERFORM,
SEARCH, or SET statement.
Because you are comparing a physical displacement, you can directly use index data items only in
SEARCH and SET statements or in comparisons with indexes or other index data items. You cannot use
index data items as subscripts or indexes.
“Example: indexing” on page 70
Related tasks
“Subscripting” on page 71
“Putting values into a table” on page 73
“Searching a table” on page 84
“Processing table items using intrinsic functions” on page 87
“Handling tables efficiently” on page 774
72 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Related references
INDEXED BY phrase (Enterprise COBOL for z/OS Language Reference)
INDEX phrase (Enterprise COBOL for z/OS Language Reference)
SET statement (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Loading a table dynamically” on page 73
“Loading a variable-length table” on page 80
“Initializing a table (INITIALIZE)” on page 73
“Assigning values when you define a table (VALUE)” on page 74
“Assigning values to a variable-length table” on page 80
Related references
PERFORM statement (Enterprise COBOL for z/OS Language Reference)
To move the character 'X' into each of the elementary alphanumeric data items in TABLE-ONE, you can
code the following statement:
When you use the INITIALIZE statement to initialize a table, the table is processed as a group item
(that is, with group semantics); elementary data items within the group are recognized and processed. For
example, suppose that TABLE-ONE is an alphanumeric group that is defined like this:
01 TABLE-ONE.
02 Trans-out Occurs 20.
05 Trans-code Pic X Value "R".
05 Part-number Pic XX Value "13".
05 Trans-quan Pic 99 Value 10.
05 Price-fields.
10 Unit-price Pic 99V Value 50.
10 Discount Pic 99V Value 25.
The table below shows the content that each of the twenty 12-byte elements Trans-out(n) has before
execution and after execution of the INITIALIZE statement shown above:
You can similarly use an INITIALIZE statement to load a table that is defined as a national group. For
example, if TABLE-ONE shown above specified the GROUP-USAGE NATIONAL clause, and Trans-code
and Part-number had N instead of X in their PICTURE clauses, the following statement would have the
same effect as the INITIALIZE statement above, except that the data in TABLE-ONE would instead be
encoded in UTF-16:
Related tasks
“Initializing a structure (INITIALIZE)” on page 31
“Assigning values when you define a table (VALUE)” on page 74
“Assigning values to a variable-length table” on page 80
“Looping through a table” on page 101
“Using data items and group items” on page 24
“Using national groups” on page 137
Related references
INITIALIZE statement (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Initializing each table item individually” on page 75
“Initializing a table at the group level” on page 75
“Initializing all occurrences
74 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
of a given table element” on page 76
“Initializing a structure (INITIALIZE)” on page 31
***********************************************************
*** E R R O R F L A G T A B L E ***
***********************************************************
01 Error-Flag-Table Value Spaces.
88 No-Errors Value Spaces.
05 Type-Error Pic X.
05 Shift-Error Pic X.
05 Home-Code-Error Pic X.
05 Work-Code-Error Pic X.
05 Name-Error Pic X.
05 Initials-Error Pic X.
05 Duplicate-Error Pic X.
05 Not-Found-Error Pic X.
01 Filler Redefines Error-Flag-Table.
05 Error-Flag Occurs 8 Times
Indexed By Flag-Index Pic X.
In the example above, the VALUE clause at the 01 level initializes each of the table items to the same
value. Each table item could instead be described with its own VALUE clause to initialize that item to a
distinct value.
To initialize larger tables, use MOVE, PERFORM, or INITIALIZE statements.
Related tasks
“Initializing a structure (INITIALIZE)” on page 31
“Assigning values to a variable-length table” on page 80
Related references
REDEFINES clause (Enterprise COBOL for z/OS Language Reference)
OCCURS clause (Enterprise COBOL for z/OS Language Reference)
In the following example, the national group data item Table-OneN uses a VALUE clause that initializes
each of the three elements of the subordinate data item Table-TwoN (each of which is implicitly USAGE
NATIONAL). Note that you can initialize a national group data item with a VALUE clause that uses an
alphanumeric literal, as shown below, or a national literal.
Related references
OCCURS clause (Enterprise COBOL for z/OS Language Reference)
GROUP-USAGE clause (Enterprise COBOL for z/OS Language Reference)
01 T2.
05 T-OBJ PIC 9 VALUE 3.
05 T OCCURS 5 TIMES
DEPENDING ON T-OBJ.
10 X PIC XX VALUE "AA".
10 Y PIC 99 VALUE 19.
10 Z PIC XX VALUE "BB".
For example, the code above causes all the X elements (1 through 5) to be initialized to AA, all the Y
elements (1 through 5) to be initialized to 19, and all the Z elements (1 through 5) to be initialized to BB.
T-OBJ is then set to 3.
Related tasks
“Assigning values to a variable-length table” on page 80
Related references
OCCURS clause (Enterprise COBOL for z/OS Language Reference)
***********************************************************
*** E R R O R F L A G T A B L E ***
***********************************************************
01 Error-Flag-Table Value Spaces.
88 No-Errors Value Spaces.
05 Type-Error Pic X.
05 Shift-Error Pic X.
05 Home-Code-Error Pic X.
05 Work-Code-Error Pic X.
05 Name-Error Pic X.
05 Initials-Error Pic X.
05 Duplicate-Error Pic X.
05 Not-Found-Error Pic X.
01 Filler Redefines Error-Flag-Table.
05 Error-Flag Occurs 8 Times
Indexed By Flag-Index Pic X.
77 Error-on Pic X Value "E".
***********************************************************
*** E R R O R M E S S A G E T A B L E ***
***********************************************************
01 Error-Message-Table.
05 Filler Pic X(25) Value
"Transaction Type Invalid".
05 Filler Pic X(25) Value
"Shift Code Invalid".
05 Filler Pic X(25) Value
"Home Location Code Inval.".
05 Filler Pic X(25) Value
"Work Location Code Inval.".
76 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
05 Filler Pic X(25) Value
"Last Name - Blanks".
05 Filler Pic X(25) Value
"Initials - Blanks".
05 Filler Pic X(25) Value
"Duplicate Record Found".
05 Filler Pic X(25) Value
"Commuter Record Not Found".
01 Filler Redefines Error-Message-Table.
05 Error-Message Occurs 8 Times
Indexed By Message-Index Pic X(25).
. . .
PROCEDURE DIVISION.
. . .
Perform
Varying Sub From 1 By 1
Until No-Errors
If Error-Flag (Sub) = Error-On
Move Space To Error-Flag (Sub)
Move Error-Message (Sub) To Print-Message
Perform 260-Print-Report
End-If
End-Perform
. . .
***********************************************************
*** E R R O R F L A G T A B L E ***
***********************************************************
01 Error-Flag-Table Value Spaces.
88 No-Errors Value Spaces.
05 Type-Error Pic X.
05 Shift-Error Pic X.
05 Home-Code-Error Pic X.
05 Work-Code-Error Pic X.
05 Name-Error Pic X.
05 Initials-Error Pic X.
05 Duplicate-Error Pic X.
05 Not-Found-Error Pic X.
01 Filler Redefines Error-Flag-Table.
05 Error-Flag Occurs 8 Times
Indexed By Flag-Index Pic X.
77 Error-on Pic X Value "E".
***********************************************************
*** E R R O R M E S S A G E T A B L E ***
***********************************************************
01 Error-Message-Table.
05 Filler Pic X(25) Value
"Transaction Type Invalid".
05 Filler Pic X(25) Value
"Shift Code Invalid".
05 Filler Pic X(25) Value
"Home Location Code Inval.".
05 Filler Pic X(25) Value
"Work Location Code Inval.".
05 Filler Pic X(25) Value
"Last Name - Blanks".
05 Filler Pic X(25) Value
"Initials - Blanks".
05 Filler Pic X(25) Value
"Duplicate Record Found".
05 Filler Pic X(25) Value
"Commuter Record Not Found".
01 Filler Redefines Error-Message-Table.
05 Error-Message Occurs 8 Times
Indexed By Message-Index Pic X(25).
. . .
PROCEDURE DIVISION.
. . .
Set Flag-Index To 1
Perform Until No-Errors
Search Error-Flag
When Error-Flag (Flag-Index) = Error-On
Move Space To Error-Flag (Flag-Index)
In the example above, X is called the ODO subject, and Y is called the ODO object.
You can also specify unbounded tables and groups, see Variable-length tables in the Enterprise COBOL for
z/OS Language Reference for details.
Two factors affect the successful manipulation of variable-length records:
• Correct calculation of record lengths
The length of the variable portions of a group item is the product of the object of the DEPENDING ON
phrase and the length of the subject of the OCCURS clause.
• Conformance of the data in the object of the OCCURS DEPENDING ON clause to its PICTURE clause
If the content of the ODO object does not match its PICTURE clause, the program could terminate
abnormally. You must ensure that the ODO object correctly specifies the current number of occurrences
of table elements.
The following example shows a group item (REC-1) that contains both the subject and object of the
OCCURS DEPENDING ON clause. The way the length of the group item is determined depends on whether
it is sending or receiving data.
WORKING-STORAGE SECTION.
01 MAIN-AREA.
03 REC-1.
05 FIELD-1 PIC 9.
05 FIELD-2 OCCURS 1 TO 5 TIMES
DEPENDING ON FIELD-1 PIC X(05).
01 REC-2.
03 REC-2-DATA PIC X(50).
If you want to move REC-1 (the sending item in this case) to REC-2, the length of REC-1 is determined
immediately before the move, using the current value in FIELD-1. If the content of FIELD-1 conforms to
its PICTURE clause (that is, if FIELD-1 contains a zoned decimal item), the move can proceed based on
the actual length of REC-1. Otherwise, the result is unpredictable. You must ensure that the ODO object
has the correct value before you initiate the move.
When you do a move to REC-1 (the receiving item in this case), the length of REC-1 is determined using
the maximum number of occurrences. In this example, five occurrences of FIELD-2, plus FIELD-1,
yields a length of 26 bytes. In this case, you do not need to set the ODO object (FIELD-1) before
referencing REC-1 as a receiving item. However, the sending field's ODO object (not shown) must be set
to a valid numeric value between 1 and 5 for the ODO object of the receiving field to be validly set by the
move.
However, if you do a move to REC-1 (again the receiving item) where REC-1 is followed by a variably
located group (a type of complex ODO), the actual length of REC-1 is calculated immediately before the
78 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
move, using the current value of the ODO object (FIELD-1). In the following example, REC-1 and REC-2
are in the same record, but REC-2 is not subordinate to REC-1 and is therefore variably located:
01 MAIN-AREA
03 REC-1.
05 FIELD-1 PIC 9.
05 FIELD-3 PIC 9.
05 FIELD-2 OCCURS 1 TO 5 TIMES
DEPENDING ON FIELD-1 PIC X(05).
03 REC-2.
05 FIELD-4 OCCURS 1 TO 5 TIMES
DEPENDING ON FIELD-3 PIC X(05).
The compiler issues a message that lets you know that the actual length was used. This case requires that
you set the value of the ODO object before using the group item as a receiving field.
The following example shows how to define a variable-length table when the ODO object (LOCATION-
TABLE-LENGTH below) is outside the group:
DATA DIVISION.
FILE SECTION.
FD LOCATION-FILE
RECORDING MODE F
BLOCK 0 RECORDS
RECORD 80 CHARACTERS
LABEL RECORD STANDARD.
01 LOCATION-RECORD.
05 LOC-CODE PIC XX.
05 LOC-DESCRIPTION PIC X(20).
05 FILLER PIC X(58).
WORKING-STORAGE SECTION.
01 FLAGS.
05 LOCATION-EOF-FLAG PIC X(5) VALUE SPACE.
88 LOCATION-EOF VALUE "FALSE".
01 MISC-VALUES.
05 LOCATION-TABLE-LENGTH PIC 9(3) VALUE ZERO.
05 LOCATION-TABLE-MAX PIC 9(3) VALUE 100.
*****************************************************************
*** L O C A T I O N T A B L E ***
*** FILE CONTAINS LOCATION CODES. ***
*****************************************************************
01 LOCATION-TABLE.
05 LOCATION-CODE OCCURS 1 TO 100 TIMES
DEPENDING ON LOCATION-TABLE-LENGTH PIC X(80).
Related concepts
“Complex OCCURS DEPENDING
ON” on page 81
Related tasks
“Assigning values to a variable-length table” on page 80
“Loading a variable-length table” on page 80
“Preventing overlay when adding elements to a variable table” on page 83
“Finding the length of data items” on page 120
Related references
OCCURS DEPENDING ON clause
(Enterprise COBOL for z/OS Language Reference)
Variable-length tables (Enterprise COBOL for z/OS Language Reference)
DATA DIVISION.
FILE SECTION.
FD LOCATION-FILE
RECORDING MODE F
BLOCK 0 RECORDS
RECORD 80 CHARACTERS
LABEL RECORD STANDARD.
01 LOCATION-RECORD.
05 LOC-CODE PIC XX.
05 LOC-DESCRIPTION PIC X(20).
05 FILLER PIC X(58).
. . .
WORKING-STORAGE SECTION.
01 FLAGS.
05 LOCATION-EOF-FLAG PIC X(5) VALUE SPACE.
88 LOCATION-EOF VALUE "YES".
01 MISC-VALUES.
05 LOCATION-TABLE-LENGTH PIC 9(3) VALUE ZERO.
05 LOCATION-TABLE-MAX PIC 9(3) VALUE 100.
*****************************************************************
*** L O C A T I O N T A B L E ***
*** FILE CONTAINS LOCATION CODES. ***
*****************************************************************
01 LOCATION-TABLE.
05 LOCATION-CODE OCCURS 1 TO 100 TIMES
DEPENDING ON LOCATION-TABLE-LENGTH PIC X(80).
. . .
PROCEDURE DIVISION.
. . .
Perform Test After
Varying Location-Table-Length From 1 By 1
Until Location-EOF
Or Location-Table-Length = Location-Table-Max
Move Location-Record To
Location-Code (Location-Table-Length)
Read Location-File
At End Set Location-EOF To True
End-Read
End-Perform
If you define the entire table by using the DEPENDING ON phrase, all the elements are initialized using the
maximum defined value of the ODO (OCCURS DEPENDING ON) object.
If the ODO object is initialized by a VALUE clause, it is logically initialized after the ODO subject has been
initialized.
For example, in the code above, the ODO subject Y(1) is initialized to 'A', Y(2) to 'B', . . ., Y(5) to 'E',
and finally the ODO object X is initialized to 3. Any subsequent reference to TABLE-THREE (such as in a
DISPLAY statement) refers to X and the first three elements, Y(1) through Y(3), of the table.
Related tasks
“Assigning values when you define a table (VALUE)” on page 74
80 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Related references
OCCURS DEPENDING ON clause
(Enterprise COBOL for z/OS Language Reference)
Related tasks
“Preventing index errors when changing ODO object value” on page 82
“Preventing overlay when adding elements to a variable table” on page 83
Related references
“Effects of change
in ODO object value” on page 82
OCCURS DEPENDING ON clause
(Enterprise COBOL for z/OS Language Reference)
01 FIELD-A.
02 COUNTER-1 PIC S99.
02 COUNTER-2 PIC S99.
02 TABLE-1.
03 RECORD-1 OCCURS 1 TO 5 TIMES
DEPENDING ON COUNTER-1 PIC X(3).
02 EMPLOYEE-NUMBER PIC X(5). (1)
02 TABLE-2 OCCURS 5 TIMES (2)(3)
INDEXED BY INDX. (4)
03 TABLE-ITEM PIC 99. (5)
03 RECORD-2 OCCURS 1 TO 3 TIMES
DEPENDING ON COUNTER-2.
04 DATA-NUM PIC S99.
Definition: In the example, COUNTER-1 is an ODO object, that is, it is the object of the DEPENDING ON
clause of RECORD-1. RECORD-1 is said to be an ODO subject. Similarly, COUNTER-2 is the ODO object of
the corresponding ODO subject, RECORD-2.
The types of complex ODO occurrences shown in the example above are as follows:
(1)
A variably located item: EMPLOYEE-NUMBER is a data item that follows, but is not subordinate to, a
variable-length table in the same level-01 record.
Related tasks
“Preventing index errors when changing ODO object value” on page 82
“Preventing overlay when adding elements to a variable table” on page 83
82 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
When you change the value of an ODO object, the byte offset in an associated complex-ODO index is no
longer valid because the table length has changed. Unless you take precautions, you will have unexpected
results if you then code a reference to the index-name such as:
• A reference to an element of the table
• A SET statement of the form SET integer-data-item TO index-name (format 1)
• A SET statement of the form SET index-name UP|DOWN BY integer (format 2)
To avoid this type of error, do these steps:
1. Save the index in an integer data item. (Doing so causes an implicit conversion: the integer item
receives the table element occurrence number that corresponds to the offset in the index.)
2. Change the value of the ODO object.
3. Immediately restore the index from the integer data item. (Doing so causes an implicit conversion:
the index-name receives the offset that corresponds to the table element occurrence number in the
integer item. The offset is computed according to the table length then in effect.)
The following code shows how to save and restore the index-name (shown in “Example: complex ODO”
on page 81) when the ODO object COUNTER-2 changes.
Related references
SET statement (Enterprise COBOL for z/OS Language Reference)
WORKING-STORAGE SECTION.
01 VARIABLE-REC.
05 FIELD-1 PIC X(10).
05 CONTROL-1 PIC S99.
05 CONTROL-2 PIC S99.
05 VARY-FIELD-1 OCCURS 1 TO 10 TIMES
DEPENDING ON CONTROL-1 PIC X(5).
05 GROUP-ITEM-1.
10 VARY-FIELD-2
OCCURS 1 TO 10 TIMES
Each element of VARY-FIELD-1 has 5 bytes, and each element of VARY-FIELD-2 has 9 bytes. If
CONTROL-1 and CONTROL-2 both contain the value 3, you can picture storage for VARY-FIELD-1 and
VARY-FIELD-2 as follows:
To add a fourth element to VARY-FIELD-1, code as follows to prevent overlaying the first 5 bytes of
VARY-FIELD-2. (GROUP-ITEM-2 serves as temporary storage for the variably located GROUP-ITEM-1.)
You can picture the updated storage for VARY-FIELD-1 and VARY-FIELD-2 as follows:
Note that the fourth element of VARY-FIELD-1 did not overlay the first element of VARY-FIELD-2.
Searching a table
COBOL provides two search techniques for tables: serial and binary.
To do serial searches, use SEARCH and indexing. For variable-length tables, you can use PERFORM with
subscripting or indexing.
To do binary searches, use SEARCH ALL and indexing.
A binary search can be considerably more efficient than a serial search. For a serial search, the number
of comparisons is of the order of n, the number of entries in the table. For a binary search, the number of
comparisons is of the order of only the logarithm (base 2) of n. A binary search, however, requires that the
table items already be sorted.
Related tasks
“Doing a serial search (SEARCH)” on page 85
“Doing a binary search (SEARCH ALL)” on page 86
84 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Doing a serial search (SEARCH)
Use the SEARCH statement to do a serial (sequential) search beginning at the current index setting. To
modify the index setting, use the SET statement.
The conditions in the WHEN phrase are evaluated in the order in which they appear:
• If none of the conditions is satisfied, the index is increased to correspond to the next table element, and
the WHEN conditions are evaluated again.
• If one of the WHEN conditions is satisfied, the search ends. The index remains pointing to the table
element that satisfied the condition.
• If the entire table has been searched and no conditions were met, the AT END imperative statement
is executed if there is one. If you did not code AT END, control passes to the next statement in the
program.
You can reference only one level of a table (a table element) with each SEARCH statement. To search
multiple levels of a table, use nested SEARCH statements. Delimit each nested SEARCH statement with
END-SEARCH.
Performance: If the found condition comes after some intermediate point in the table, you can speed up
the search by using the SET statement to set the index to begin the search after that point. Arranging the
table so that the data used most often is at the beginning of the table also enables more efficient serial
searching. If the table is large and is presorted, a binary search is more efficient.
“Example: serial search” on page 85
Related references
SEARCH statement (Enterprise COBOL for z/OS Language Reference)
01 TABLE-ONE.
05 TABLE-ENTRY1 OCCURS 10 TIMES
INDEXED BY TE1-INDEX.
10 TABLE-ENTRY2 OCCURS 10 TIMES
INDEXED BY TE2-INDEX.
15 TABLE-ENTRY3 OCCURS 5 TIMES
ASCENDING KEY IS KEY1
INDEXED BY TE3-INDEX.
20 KEY1 PIC X(5).
20 KEY2 PIC X(10).
. . .
PROCEDURE DIVISION.
. . .
SET TE1-INDEX TO 1
SET TE2-INDEX TO 4
SET TE3-INDEX TO 1
MOVE "A1234" TO KEY1 (TE1-INDEX, TE2-INDEX, TE3-INDEX + 2)
MOVE "AAAAAAAA00" TO KEY2 (TE1-INDEX, TE2-INDEX, TE3-INDEX + 2)
. . .
SEARCH TABLE-ENTRY3
AT END
MOVE 4 TO RETURN-CODE
WHEN TABLE-ENTRY3(TE1-INDEX, TE2-INDEX, TE3-INDEX)
= "A1234AAAAAAAA00"
MOVE 0 TO RETURN-CODE
END-SEARCH
TE1-INDEX = 1
TE2-INDEX = 4
TE3-INDEX points to the TABLE-ENTRY3 item
that equals "A1234AAAAAAAA00"
RETURN-CODE = 0
Each key and its object of comparison must be compatible according to the rules for comparison of data
items. Note though that if a key is compared to a national literal or identifier, the key must be a national
data item.
“Example: binary search” on page 86
Related tasks
“Defining a table (OCCURS)” on page 67
Related references
SEARCH statement (Enterprise COBOL for z/OS Language Reference)
General relation conditions (Enterprise COBOL for z/OS Language Reference)
01 TABLE-A.
05 TABLE-ENTRY OCCURS 90 TIMES
ASCENDING KEY-1, KEY-2
DESCENDING KEY-3
INDEXED BY INDX-1.
10 PART-1 PIC 99.
10 KEY-1 PIC 9(5).
10 PART-2 PIC 9(6).
10 KEY-2 PIC 9(4).
10 PART-3 PIC 9(18).
10 KEY-3 PIC 9(5).
86 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
AT END
PERFORM NOENTRY
WHEN KEY-1 (INDX-1) = VALUE-1 AND
KEY-2 (INDX-1) = VALUE-2 AND
KEY-3 (INDX-1) = VALUE-3
MOVE PART-1 (INDX-1) TO OUTPUT-AREA
END-SEARCH
If an entry is found in which each of the three keys is equal to the value to which it is compared (VALUE-1,
VALUE-2, and VALUE-3, respectively), PART-1 of that entry is moved to OUTPUT-AREA. If no matching
key is found in the entries in TABLE-A, the NOENTRY routine is performed.
Sorting a table
You can sort a table by using the format 2 SORT statement. It is part of the 2002 COBOL Standard.
The format 2 SORT statement sorts table elements according to the specified table keys, and it is
especially useful for tables used with SEARCH ALL. You can specify the keys for sorting as part of the
table definition, which can also be used in the SEARCH ALL statement. Alternatively, you can also specify
the keys for sorting as part of the SORT statement, either if you want to sort the table using different keys
than those specified in the table definition, or if the table has no keys specified.
With the format 2 SORT statement, you don't need to use the input and output procedures as you do with
the format 1 SORT statement.
See the following example in which the table is sorted based on specified keys:
WORKING-STORAGE SECTION.
01 GROUP-ITEM.
05 TABL OCCURS 10 TIMES
10 ELEM-ITEM1 PIC X.
10 ELEM-ITEM2 PIC X.
10 ELEM-ITEM3 PIC X.
...
PROCEDURE DIVISION.
...
SORT TABL DESCENDING ELEM-ITEM2 ELEM-ITEM3.
IF TABL (1)...
Related references
SORT statement (Enterprise COBOL for z/OS Language Reference)
“Using the format 2 SORT statement to sort a table” on page 791
You might often need to iteratively process the data in tables. For intrinsic functions that accept multiple
arguments, you can use the subscript ALL to reference all the items in the table or in a single dimension of
the table. The iteration is handled automatically, which can make your code shorter and simpler.
You can mix scalars and array arguments for functions that accept multiple arguments:
Related tasks
“Using intrinsic functions (built-in functions)” on page 38
“Converting data items (intrinsic functions)” on page 113
“Evaluating data items (intrinsic functions)” on page 117
Related references
Intrinsic functions (Enterprise COBOL for z/OS Language Reference)
The following example computes various salary values for all the employees whose salaries are encoded
in Employee-Table:
01 Employee-Table.
05 Emp-Count Pic s9(4) usage binary.
05 Emp-Record Occurs 1 to 500 times
depending on Emp-Count.
10 Emp-Name Pic x(20).
10 Emp-Idme Pic 9(9).
10 Emp-Salary Pic 9(7)v99.
. . .
Procedure Division.
Compute Max-Salary = Function Max(Emp-Salary(ALL))
Compute I = Function Ord-Max(Emp-Salary(ALL))
Compute Avg-Salary = Function Mean(Emp-Salary(ALL))
Compute Salary-Range = Function Range(Emp-Salary(ALL))
Compute Total-Payroll = Function Sum(Emp-Salary(ALL))
88 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
4. Use the unbounded table and its containing unbounded group according to the following rules:
• You can reference unbounded tables in COBOL syntax anywhere a table can be referenced.
• You can reference unbounded groups in COBOL syntax anywhere an alphanumeric or national group
can be referenced, with the following exceptions:
– You cannot specify unbounded groups as a BY CONTENT argument in a CALL statement.
– You cannot specify unbounded groups as data-name-2 on the PROCEDURE DIVISION
RETURNING phrase.
– You cannot specify unbounded groups as arguments to intrinsic functions, except as an argument
to the LENGTH intrinsic function.
Related references
“Example:
Using unbounded tables for parsing XML documents” on page 89
Example: ALLOCATE and FREE storage for unbounded tables
(Enterprise COBOL for z/OS Language Reference)
Variable-length tables (Enterprise COBOL for z/OS Language Reference)
OCCURS DEPENDING ON clause
(Enterprise COBOL for z/OS Language Reference)
XML schema
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://example.org"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="G">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="A" type="xsd:string" maxOccurs="1" />
<xsd:element name="B" type="xsd:int" maxOccurs="unbounded" />
<xsd:element name="C" type="xsd:int" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Related tasks
“Working with unbounded tables and groups” on page 88
90 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Chapter 5. Selecting and repeating program actions
Use COBOL control language to choose program actions based on the outcome of logical tests, to iterate
over selected parts of your program and data, and to identify statements to be performed as a group.
These controls include the IF, EVALUATE, and PERFORM statements, and the use of switches and flags.
Related tasks
“Selecting program actions” on page 91
“Repeating program actions” on page 99
Related tasks
“Coding a choice of actions” on page 91
“Coding conditional expressions” on page 95
Related references
IF statement (Enterprise COBOL for z/OS Language Reference)
EVALUATE statement (Enterprise COBOL for z/OS Language Reference)
IF condition-p
statement-1
ELSE
statement-2
END-IF
When one of two processing choices is no action, code the IF statement with or without ELSE. Because
the ELSE clause is optional, you can code the IF statement as follows:
IF condition-q
statement-1
END-IF
Such coding is suitable for simple cases. For complex logic, you probably need to use the ELSE clause.
For example, suppose you have nested IF statements in which there is an action for only one of the
processing choices. You could use the ELSE clause and code the null branch of the IF statement with the
CONTINUE statement:
IF condition-q
statement-1
ELSE
CONTINUE
END-IF
IF condition-r
statement-1
ELSE
CONTINUE or NEXT SENTENCE
END-IF
*> CONTINUE goes to statement-2
statement-2
statement-3.
*> NEXT SENTENCE goes to statement-4
statement-4
For details about NEXT SENTENCE, see IF statement in the Enterprise COBOL for z/OS Language
Reference.
The EVALUATE statement is an expanded form of the IF statement that allows you to avoid nesting IF
statements, a common source of logic errors and debugging problems.
Related tasks
“Using nested IF statements” on page 92
“Using the EVALUATE statement” on page 93
“Coding conditional expressions” on page 95
IF condition-p
IF condition-q
statement-1
ELSE
statement-2
END-IF
statement-3
ELSE
statement-4
END-IF
In the pseudocode above, an IF statement and a sequential structure are nested in one branch of the
outer IF. In this structure, the END-IF that closes the nested IF is very important. Use END-IF instead
of a period, because a period would end the outer IF structure also.
The following figure shows the logic structure of the pseudocode above.
92 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Related tasks
“Coding a choice of actions” on page 91
Related references
Explicit scope terminators (Enterprise COBOL for z/OS Language Reference)
You can also use the EVALUATE statement to cause multiple conditions to lead to the same processing, as
shown in these examples:
In an EVALUATE statement, the operands before the WHEN phrase are referred to as selection subjects,
and the operands in the WHEN phrase are called the selection objects. Selection subjects can be identifiers,
literals, conditional expressions, or the word TRUE or FALSE. Selection objects can be identifiers, literals,
conditional or arithmetic expressions, or the word TRUE, FALSE, or ANY.
You can separate multiple selection subjects with the ALSO phrase. You can separate multiple selection
objects with the ALSO phrase. The number of selection objects within each set of selection objects must
be equal to the number of selection subjects, as shown in this example:
“Example: EVALUATE testing several conditions” on page 95
Identifiers, literals, or arithmetic expressions that appear within a selection object must be valid operands
for comparison to the corresponding operand in the set of selection subjects. Conditions or the word TRUE
or FALSE that appear in a selection object must correspond to a conditional expression or the word TRUE
or FALSE in the set of selection subjects. (You can use the word ANY as a selection object to correspond
to any type of selection subject.)
The execution of the EVALUATE statement ends when one of the following conditions occurs:
• The statements associated with the selected WHEN phrase are performed.
Related tasks
“Coding a choice of actions” on page 91
Related references
EVALUATE statement (Enterprise COBOL for z/OS Language Reference)
General relation conditions (Enterprise COBOL for z/OS Language Reference)
EVALUATE CARPOOL-SIZE
WHEN 1
MOVE "SINGLE" TO PRINT-CARPOOL-STATUS
WHEN 2
MOVE "COUPLE" TO PRINT-CARPOOL-STATUS
WHEN 3 THRU 6
MOVE "SMALL GROUP" TO PRINT-CARPOOL STATUS
WHEN OTHER
MOVE "BIG GROUP" TO PRINT-CARPOOL STATUS
END-EVALUATE
IF CARPOOL-SIZE = 1 THEN
MOVE "SINGLE" TO PRINT-CARPOOL-STATUS
ELSE
IF CARPOOL-SIZE = 2 THEN
MOVE "COUPLE" TO PRINT-CARPOOL-STATUS
ELSE
IF CARPOOL-SIZE >= 3 and CARPOOL-SIZE <= 6 THEN
MOVE "SMALL GROUP" TO PRINT-CARPOOL-STATUS
ELSE
MOVE "BIG GROUP" TO PRINT-CARPOOL-STATUS
END-IF
END-IF
END-IF
EVALUATE MARITAL-CODE
WHEN "M"
ADD 2 TO PEOPLE-COUNT
WHEN "S"
WHEN "D"
WHEN "W"
ADD 1 TO PEOPLE-COUNT
END-EVALUATE
94 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
ADD 2 TO PEOPLE-COUNT
ELSE
IF MARITAL-CODE = "S" OR
MARITAL-CODE = "D" OR
MARITAL-CODE = "W" THEN
ADD 1 TO PEOPLE-COUNT
END-IF
END-IF
Identification Division.
Program-ID. MiniEval.
Environment Division.
Configuration Section.
Source-Computer. IBM-390. Data Division.
Working-Storage Section.
01 Age Pic 999.
01 Sex Pic X.
01 Description Pic X(15).
01 A Pic 999.
01 B Pic 9999.
01 C Pic 9999.
01 D Pic 9999.
01 E Pic 99999.
01 F Pic 999999.
Procedure Division.
PN01.
Evaluate True Also True
When Age < 13 Also Sex = "M"
Move "Young Boy" To Description
When Age < 13 Also Sex = "F"
Move "Young Girl" To Description
When Age > 12 And Age < 20 Also Sex = "M"
Move "Teenage Boy" To Description
When Age > 12 And Age < 20 Also Sex = "F"
Move "Teenage Girl" To Description
When Age > 19 Also Sex = "M"
Move "Adult Man" To Description
When Age > 19 Also Sex = "F"
Move "Adult Woman" To Description
When Other
Move "Invalid Data" To Description
End-Evaluate
Evaluate True Also True
When A + B < 10 Also C = 10
Move "Case 1" To Description
When A + B > 50 Also C = ( D + E ) / F
Move "Case 2" To Description
When Other
Move "Case Other" To Description
End-Evaluate
Stop Run.
Related concepts
“Switches and flags” on page 96
Related tasks
“Defining switches and flags” on page 97
“Resetting switches and flags” on page 98
“Checking for incompatible data (numeric class test)” on page 53
“Comparing national (UTF-16) data” on page 140
“Testing for valid DBCS characters” on page 159
Related references
General relation conditions (Enterprise COBOL for z/OS Language Reference)
Class condition (Enterprise COBOL for z/OS Language Reference)
Rules for condition-name entries (Enterprise COBOL for z/OS Language Reference)
Sign condition (Enterprise COBOL for z/OS Language Reference)
Combined conditions (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Defining switches and flags” on page 97
“Resetting switches and flags” on page 98
96 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Defining switches and flags
In the DATA DIVISION, define level-88 items that will act as switches or flags, and give them meaningful
names.
To test for more than two values with flags, assign more than one condition-name to a field by using
multiple level-88 items.
The reader can easily follow your code if you choose meaningful condition-names and if the values
assigned to them have some association with logical values.
Example: switches
The following examples show how you can use level-88 items to test for various binary-valued (on-off)
conditions in your program.
For example, to test for the end-of-file condition for an input file named Transaction-File, you can use the
following data definitions:
WORKING-STORAGE SECTION.
01 Switches.
05 Transaction-EOF-Switch Pic X value space.
88 Transaction-EOF value "y".
The level-88 description says that a condition named Transaction-EOF is in effect when
Transaction-EOF-Switch has value 'y'. Referencing Transaction-EOF in the PROCEDURE
DIVISION expresses the same condition as testing Transaction-EOF-Switch = "y". For example,
the following statement causes a report to be printed only if Transaction-EOF-Switch has been set to
'y':
If Transaction-EOF Then
Perform Print-Report-Summary-Lines
End-if
Example: flags
The following examples show how you can use several level-88 items together with an EVALUATE
statement to determine which of several conditions in a program is true.
Consider for example a program that updates a main file. The updates are read from a transaction file.
The records in the file contain a field that indicates which of the three functions is to be performed: add,
change, or delete. In the record description of the input file, code a field for the function code using
level-88 items:
01 Transaction-Input Record
05 Transaction-Type Pic X.
88 Add-Transaction Value "A".
88 Change-Transaction Value "C".
88 Delete-Transaction Value "D".
The code in the PROCEDURE DIVISION for testing these condition-names to determine which function is
to be performed might look like this:
Evaluate True
When Add-Transaction
Perform Add-Main-Record-Paragraph
When Change-Transaction
Perform Update-Existing-Record-Paragraph
When Delete-Transaction
Using the SET statement and meaningful condition-names makes it easier for readers to follow your code.
01 Switches
05 Transaction-EOF-Switch Pic X Value space.
88 Transaction-EOF Value "y".
. . .
Procedure Division.
000-Do-Main-Logic.
Perform 100-Initialize-Paragraph
Read Update-Transaction-File
At End Set Transaction-EOF to True
End-Read
The following example shows how to assign a value to a field in an output record based on the transaction
code of an input record:
01 Input-Record.
05 Transaction-Type Pic X(9).
01 Data-Record-Out.
05 Data-Record-Type Pic X.
88 Record-Is-Active Value "A".
88 Record-Is-Suspended Value "S".
88 Record-Is-Deleted Value "D".
05 Key-Field Pic X(5).
. . .
Procedure Division.
Evaluate Transaction-Type of Input-Record
When "ACTIVE"
Set Record-Is-Active to TRUE
When "SUSPENDED"
Set Record-Is-Suspended to TRUE
When "DELETED"
Set Record-Is-Deleted to TRUE
End-Evaluate
98 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Example: set switch off
The following example shows how you can set a switch off by coding a MOVE statement that moves the
condition name value to the conditional variable.
For example, you can use a data item called SWITCH-OFF to set an on-off switch to off, as in the following
code, which resets a switch to indicate that end-of-file has not been reached:
01 Switches
05 Transaction-EOF-Switch Pic X Value space.
88 Transaction-EOF Value "y".
01 SWITCH-OFF Pic X Value "n".
. . .
Procedure Division.
. . .
Move SWITCH-OFF to Transaction-EOF-Switch
Related tasks
“Choosing inline or out-of-line PERFORM” on page 99
“Coding a loop” on page 100
“Looping through a table” on page 101
“Executing multiple paragraphs
or sections” on page 101
Related references
PERFORM statement (Enterprise COBOL for z/OS Language Reference)
Perform 100-Initialize-Paragraph
* The following statement is an inline PERFORM:
Perform Until Transaction-EOF
Read Update-Transaction-File Into WS-Transaction-Record
At End
Set Transaction-EOF To True
Not At End
Perform 200-Edit-Update-Transaction
If No-Errors
Perform 300-Update-Commuter-Record
Else
Perform 400-Print-Transaction-Errors
* End-If is a required scope terminator
End-If
Perform 410-Re-Initialize-Fields
* End-Read is a required scope terminator
End-Read
End-Perform
Coding a loop
Use the PERFORM . . . TIMES statement to execute a procedure a specified number of times.
In the example above, when control reaches the PERFORM statement, the code for the procedure 010-
PROCESS-ONE-MONTH is executed 12 times before control is transferred to the INSPECT statement.
Use the PERFORM . . . UNTIL statement to execute a procedure until a condition you choose is
satisfied. You can use either of the following forms:
Use the PERFORM . . . WITH TEST AFTER . . . UNTIL statement if you want to execute the
procedure at least once, and test before any subsequent execution. This statement is equivalent to a
do-until structure:
In the following example, the implicit WITH TEST BEFORE phrase provides a do-while structure:
PERFORM 010-PROCESS-ONE-MONTH
UNTIL MONTH GREATER THAN 12
INSPECT . . .
100 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
When control reaches the PERFORM statement, the condition MONTH GREATER THAN 12 is tested. If the
condition is satisfied, control is transferred to the INSPECT statement. If the condition is not satisfied,
010-PROCESS-ONE-MONTH is executed, and the condition is tested again. This cycle continues until the
condition tests as true. (To make your program easier to read, you might want to code the WITH TEST
BEFORE clause.)
The following section of code shows an example of looping through a table to check for invalid data:
When control reaches the PERFORM statement above, WS-DATA-IX is set equal to 1 and the PERFORM
statement is executed. Then the condition WS-DATA-IX = 12 is tested. If the condition is true, control
drops through to the INSPECT statement. If the condition is false, WS-DATA-IX is increased by 1, the
PERFORM statement is executed, and the condition is tested again. This cycle of execution and testing
continues until WS-DATA-IX is equal to 12.
The loop above controls input-checking for the 12 fields of item WS-DATA. Empty fields are not allowed in
the application, so the section of code loops and issues error messages as appropriate.
Related tasks
“Processing table items using intrinsic functions” on page 87
Related references
EXIT PERFORM or EXIT PERFORM CYCLE statement
(Enterprise COBOL for z/OS Language Reference)
EXIT PARAGRAPH or EXIT SECTION statement
(Enterprise COBOL for z/OS Language Reference)
COBOL provides language constructs for performing many different operations on string data items.
For example, you can:
• Join or split data items.
• Manipulate null-terminated strings, such as count or move characters.
• Refer to substrings by their ordinal position and, if needed, length.
• Tally and replace data items, such as count the number of times a specific character occurs in a data
item.
• Convert data items, such as change to uppercase or lowercase.
• Evaluate data items, such as determine the length of a data item.
Related tasks
“Joining data items (STRING)” on page 103
“Splitting data items (UNSTRING)” on page 105
“Manipulating null-terminated strings” on page 108
“Referring to substrings of data items” on page 109
“Tallying and replacing data items (INSPECT)” on page 112
“Converting data items (intrinsic functions)” on page 113
“Evaluating data items (intrinsic functions)” on page 117
Chapter 7, “Processing data in an international environment,” on page 123
Related references
STRING statement (Enterprise COBOL for z/OS Language Reference)
01 RCD-01.
05 CUST-INFO.
10 CUST-NAME PIC X(15).
10 CUST-ADDR PIC X(35).
05 BILL-INFO.
10 INV-NO PIC X(6).
10 INV-AMT PIC $$,$$$.99.
10 AMT-PAID PIC $$,$$$.99.
10 DATE-PAID PIC X(8).
10 BAL-DUE PIC $$,$$$.99.
10 DATE-DUE PIC X(8).
The record RCD-01 contains the following information (the symbol b indicates a blank space):
J.B.bSMITHbbbbb
444bSPRINGbST.,bCHICAGO,bILL.bbbbbb
A14275
$4,736.85
$2,400.00
09/22/76
$2,336.85
10/22/76
In the PROCEDURE DIVISION, these settings occur before the STRING statement:
• RPT-LINE is set to SPACES.
• LINE-POS, the data item to be used as the POINTER field, is set to 4.
Here is the STRING statement:
STRING
LINE-NO SPACE CUST-INFO INV-NO SPACE DATE-DUE SPACE
DELIMITED BY SIZE
BAL-DUE
DELIMITED BY DEC-POINT
INTO RPT-LINE
WITH POINTER LINE-POS.
Because the POINTER field LINE-POS has value 4 before the STRING statement is performed, data is
moved into the receiving field RPT-LINE beginning at character position 4. Characters in positions 1
through 3 are unchanged.
The sending items that specify DELIMITED BY SIZE are moved in their entirety to the receiving field.
Because BAL-DUE is delimited by DEC-POINT, the moving of BAL-DUE to the receiving field stops when a
decimal point (the value of DEC-POINT) is encountered.
104 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
STRING results
When the STRING statement is performed, items are moved into RPT-LINE as shown in the table below.
Item Positions
LINE-NO 4-8
Space 9
CUST-INFO 10 - 59
INV-NO 60 - 65
Space 66
DATE-DUE 67 - 74
Space 75
Portion of BAL-DUE that precedes the decimal point 76 - 81
After the STRING statement is performed, the value of LINE-POS is 82, and RPT-LINE has the values
shown below.
Related concepts
“Unicode and the encoding of language characters” on page 124
Related tasks
“Handling errors in joining and splitting strings” on page 242
Related references
UNSTRING statement (Enterprise COBOL for z/OS Language Reference)
Classes and categories of data (Enterprise COBOL for z/OS Language Reference)
In the PROCEDURE DIVISION, these settings occur before the UNSTRING statement:
• A period (.) is placed in DBY-1 for use as a delimiter.
• CHAR-CT (the POINTER field) is set to 3.
• The value zero (0) is placed in FLDS-FILLED (the TALLYING field).
• Data is read into record INV-RCD, whose format is as shown below.
106 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Here is the UNSTRING statement:
Because the POINTER field CHAR-CT has value 3 before the UNSTRING statement is performed, the two
character positions of the CONTROL-CHARS field in INV-RCD are ignored.
UNSTRING results
When the UNSTRING statement is performed, the following steps take place:
1. Positions 3 through 18 (FOUR-PENNY-NAILS) of INV-RCD are placed in ITEM-NAME, left justified in
the area, and the four unused character positions are padded with spaces. The value 16 is placed in
CTR-1.
2. Because ALL SPACES is coded as a delimiter, the five contiguous space characters in positions 19
through 23 are considered to be one occurrence of the delimiter.
3. Positions 24 through 29 (707890) are placed in INV-NO. The delimiter character slash (/) is placed in
DLTR-1, and the value 6 is placed in CTR-2.
4. Positions 31 through 33 (BBA) are placed in INV-CLASS. The delimiter is SPACE, but because no field
has been defined as a receiving area for delimiters, the space in position 34 is bypassed.
5. Positions 35 through 40 (475120) are placed in M-UNITS. The value 6 is placed in CTR-3. The
delimiter is SPACE, but because no field has been defined as a receiving area for delimiters, the space
in position 41 is bypassed.
6. Positions 42 through 46 (00122) are placed in FIELD-A and right justified in the area. The high-order
digit position is filled with a zero (0). The delimiter is SPACE, but because no field was defined as a
receiving area for delimiters, the space in position 47 is bypassed.
7. Positions 48 through 53 (000379) are placed in DISPLAY-DOLS. The period (.) delimiter in DBY-1 is
placed in DLTR-2, and the value 6 is placed in CTR-4.
8. Because all receiving fields have been acted on and two characters in INV-RCD have not been
examined, the ON OVERFLOW statement is executed. Execution of the UNSTRING statement is
completed.
After the UNSTRING statement is performed, the fields contain the values shown below.
Field Value
DISPLAY-REC 707890 FOUR-PENNY-NAILS 000379
WORK-REC 475120000122BBA
CHAR-CT (the POINTER field) 55
FLDS-FILLED (the TALLYING field) 6
MOVE 0 TO char-count
INSPECT source-field TALLYING char-count
FOR CHARACTERS
BEFORE X"00"
• Use an UNSTRING statement to move characters in a null-terminated string to a target field, and get the
character count:
WORKING-STORAGE SECTION.
01 source-field PIC X(1001).
01 char-count COMP-5 PIC 9(4).
01 target-area.
02 individual-char OCCURS 1 TO 1000 TIMES DEPENDING ON char-count
PIC X.
. . .
PROCEDURE DIVISION.
UNSTRING source-field DELIMITED BY X"00"
INTO target-area
COUNT IN char-count
ON OVERFLOW
DISPLAY "source not null terminated or target too short"
END-UNSTRING
• Use a SEARCH statement to locate trailing null or space characters. Define the string being examined as
a table of single characters.
• Check each character in a field in a loop (PERFORM). You can examine each character in a field by using a
reference modifier such as source-field (I:1).
“Example: null-terminated strings” on page 108
Related tasks
“Handling null-terminated
strings” on page 568
Related references
Alphanumeric literals (Enterprise COBOL for z/OS Language Reference)
108 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
into N.
. . .
* Concatenate two null-terminated strings to produce another:
String L delimited by x'00'
M delimited by x'00'
X'00' delimited by size
into N.
You code a reference modifier in parentheses immediately after the data item. As the example shows, a
reference modifier can contain two values that are separated by a colon, in this order:
1. Ordinal position (from the left) of the character that you want the substring to start with
2. (Optional) Length of the required substring in character positions
The reference-modifier position and length for an item that has USAGE DISPLAY are expressed in
terms of single-byte characters. The reference-modifier position and length for items that have USAGE
DISPLAY-1 or NATIONAL are expressed in terms of DBCS character positions and national character
positions, respectively.
If you omit the length in a reference modifier (coding only the ordinal position of the first character,
followed by a colon), the substring extends to the end of the item. Omit the length where possible as a
simpler and less error-prone coding technique.
You can refer to substrings of USAGE DISPLAY data items, including alphanumeric groups,
alphanumeric-edited data items, numeric-edited data items, display floating-point data items, and zoned
decimal data items, by using reference modifiers. When you reference-modify any of these data items, the
result is of category alphanumeric. When you reference-modify an alphabetic data item, the result is of
category alphabetic.
You can refer to substrings of USAGE NATIONAL data items, including national groups, national-edited
data items, numeric-edited data items, national floating-point data items, and national decimal data
items, by using reference modifiers. When you reference-modify any of these data items, the result is of
category national. For example, suppose that you define a national decimal data item as follows:
You can refer to substrings of table entries, including variable-length entries, by using reference
modifiers. To refer to a substring of a table entry, code the subscript expression before the reference
modifier. For example, assume that PRODUCT-TABLE is a properly coded table of character strings. To
move D to the fourth character in the second string in the table, you can code this statement:
Because numeric function identifiers can be used anywhere that arithmetic expressions can be used, you
can code a numeric function identifier in a reference modifier as the leftmost character position or as the
length, or both.
“Example: intrinsic functions as reference modifiers” on page 111
Each number in the reference modifier must have a value of at least 1. The sum of the two numbers
must not exceed the total length of the data item by more than 1 character position so that you do not
reference beyond the end of the substring.
If the leftmost character position or the length value is a fixed-point noninteger, truncation occurs to
create an integer. If either is a floating-point noninteger, rounding occurs to create an integer.
The SSRANGE compiler option detects out-of-range reference modifiers, and flags violations with a
runtime message.
Related concepts
“Reference modifiers” on page 110
“Unicode and the encoding of language characters” on page 124
Related tasks
“Referring to an item in
a table” on page 70
Related references
“SSRANGE” on page 411
Reference modification (Enterprise COBOL for z/OS Language Reference)
Function definitions (Enterprise COBOL for z/OS Language Reference)
Reference modifiers
Reference modifiers let you easily refer to a substring of a data item.
For example, assume that you want to retrieve the current time from the system and display its value in an
expanded format. You can retrieve the current time with the ACCEPT statement, which returns the hours,
minutes, seconds, and hundredths of seconds in this format:
HHMMSSss
However, you might prefer to view the current time in this format:
HH:MM:SS
Without reference modifiers, you would have to define data items for both formats. You would also have
to write code to convert from one format to the other.
With reference modifiers, you do not need to provide names for the subfields that describe the TIME
elements. The only data definition you need is for the time as returned by the system. For example:
110 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
* the number of hours:
REFMOD-TIME-ITEM (1:2)
":"
* Retrieve the portion of the time value that corresponds to
* the number of minutes:
REFMOD-TIME-ITEM (3:2)
":"
* Retrieve the portion of the time value that corresponds to
* the number of seconds:
REFMOD-TIME-ITEM (5:2)
Related tasks
“Assigning input from a screen or file (ACCEPT)” on page 35
“Referring to substrings of data items” on page 109
“Using national data (Unicode) in COBOL” on page 125
Related references
Reference modification (Enterprise COBOL for z/OS Language Reference)
The program counts the number of leading spaces and, using arithmetic expressions in a reference
modifier, moves the right-justified characters into another field, justified to the left:
The MOVE statement transfers characters from RIGHTY, beginning at the position computed as I + 1 for a
length that is computed as LENGTH OF RIGHTY - I, into the field LEFTY.
Related references
INTEGER (Enterprise COBOL for z/OS Language Reference)
INTEGER-PART (Enterprise COBOL for z/OS Language Reference)
Related concepts
“Unicode and the encoding of language characters” on page 124
Related references
INSPECT statement (Enterprise COBOL for z/OS Language Reference)
112 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
DATA-2 before COUNTR after DATA-2 after
00ACADEMY00 2 00AC2DEMY00
0000ALABAMA 4 0000ALABAMA
CHATHAM0000 0 CH2THAM0000
In the following example, the INSPECT statement examines and replaces characters in data item
DATA-3. Each character that precedes the first instance of a quotation mark (") is replaced by the
character 0.
The following example shows the use of INSPECT CONVERTING with AFTER and BEFORE phrases to
examine and replace characters in data item DATA-4. All characters that follow the first instance of the
character / but that precede the first instance of the character ? (if any) are translated from lowercase to
uppercase.
“Converting
to hexadecimal or bit data (HEX-OF, BIT-OF)” on page 116
“Converting from hexadecimal or bit data (HEX-TO-CHAR, BIT-TO-CHAR)” on page 117
The code above displays the following messages on the system logical output device:
Hello World!
HELLO WORLD!
hello world!
HELLO WORLD!
The DISPLAY statements do not change the actual contents of Item-1, but affect only how the letters
are displayed. However, the MOVE statement causes uppercase letters to replace the contents of Item-2.
Note: The UPPER-CASE and LOWER-CASE intrinsic functions do not support alphanumeric arguments
that contain UTF-8 encoded data.
Related tasks
“Assigning input from a screen or file (ACCEPT)” on page 35
“Displaying values on a screen or in a file (DISPLAY)” on page 35
For example, the statement above reverses the order of the characters in Orig-cust-name. If the
starting value is JOHNSONbbb, the value after the statement is performed is bbbNOSNHOJ, where b
represents a blank space.
Related concepts
“Unicode and the encoding of language characters” on page 124
114 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Converting to numbers (NUMVAL, NUMVAL-C, NUMVAL-F)
The NUMVAL, NUMVAL-C and NUMVAL-F functions convert character strings (alphanumeric or national
literals, or class alphanumeric or class national data items) to numbers. Use these functions to convert
free-format character-representation numbers to numeric form so that you can process them numerically.
Use NUMVAL-C when the argument includes a currency symbol or comma or both, as shown in the
example above. You can also place an algebraic sign before or after the character string, and the sign
will be processed. The arguments must not exceed 18 digits when you compile with the default option
ARITH(COMPAT) (compatibility mode) nor 31 digits when you compile with ARITH(EXTEND) (extended
mode), not including the editing symbols.
Use NUMVAL-F when the argument includes an exponent value, as shown in the example above. You can
also place an algebraic sign before the character string, and the sign will be processed. The arguments
must not exceed 18 digits when you compile with the default option ARITH(COMPAT) (compatibility
mode) nor 31 digits when you compile with ARITH(EXTEND) (extended mode), not including the editing
symbols.
NUMVAL, NUMVAL-C and NUMVAL-F return long (64-bit) floating-point values in compatibility mode, and
return extended-precision (128-bit) floating-point values in extended mode. A reference to either of these
functions represents a reference to a numeric data item.
At most 15 decimal digits can be converted accurately to long-precision floating point (as described in the
related reference below about conversions and precision). Internally NUMVAL uses long-precision floating
calculations to convert the given number to the output, so if the argument to NUMVAL, NUMVAL-C, or
NUMVAL-F has more than 15 digits, it is recommended that you specify the ARITH(EXTEND) compiler
option so that an extended-precision function result that can accurately represent the value of the
argument is returned. Otherwise, the result may lose precision in an unexpected manner.
When you use NUMVAL, NUMVAL-C, or NUMVAL-F, you do not need to statically define numeric data in a
fixed format nor input data in a precise manner. For example, suppose you define numbers to be entered
as follows:
The user of the application must enter the numbers exactly as defined by the PICTURE clause. For
example:
+001.23
-300.00
01 A Pic x(10).
01 B Pic S999V99.
. . .
Accept A from Console
Compute B = Function Numval(A)
1.23
-300
Related concepts
“Formats for numeric data” on page 47
“Data format conversions” on page 51
“Unicode and the encoding of language characters” on page 124
Related tasks
“Converting to or from national (Unicode) representation” on page 134
Related references
“Conversions and precision” on page 52
“ARITH” on page 349
Related concepts
“Unicode and the encoding of language characters” on page 124
Related tasks
“Converting to or from national (Unicode) representation” on page 134
116 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
For example, FUNCTION BIT-OF('Hello, world!') returns
'110010001000010110010011100100111001011001101011010000001010011010010110
10011001100100111000010001011010'.
Note: The first eight characters '11001000' of the output string correspond to the hexadecimal value
x'C8', which matches the output of the HEX-OF intrinsic function shown above and corresponds to the
EBCDIC encoding of the letter 'H'.
The argument to the BIT-OF intrinsic function can be a literal, a data item, or the result of an intrinsic
function.
Related references
BIT-OF (Enterprise COBOL for z/OS Language Reference)
HEX-OF (Enterprise COBOL for z/OS Language Reference)
Related references
BIT-TO-CHAR (Enterprise COBOL for z/OS Language Reference)
HEX-TO-CHAR (Enterprise COBOL for z/OS Language Reference)
Related concepts
“Unicode and the encoding of language characters” on page 124
Related tasks
“Evaluating single characters for collating sequence” on page 118
“Finding the largest or smallest data item” on page 118
“Finding the length of data items” on page 120
“Finding the date of compilation” on page 121
If you know the ordinal position in the collating sequence of a character, and want to find the character
that it corresponds to, use the CHAR function with the integer ordinal position as the argument. CHAR
returns the required character. For example:
The ordinal number associated with a character is not the same as the numeric value (in decimal) of
the hex value of the character. For example, if you are using the EBCDIC collating sequence, the ordinal
number of X'00' is one instead of zero. Similarly, the ordinal number of X'FF' is 256 instead of 255.
Therefore, the ordinal values returned from the ORD intrinsic function when using the EBCDIC collating
sequence range from 1 - 256, not 0 - 255 that are the decimal values of the hex values of the valid
EBCDIC characters.
Related references
CHAR (Enterprise COBOL for z/OS Language Reference)
ORD (Enterprise COBOL for z/OS Language Reference)
118 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
The following statement assigns VALLEJObbb to the first 10 character positions of Customer-record,
where b represents a blank space:
The statement above assigns the integer 3 to x if the same arguments are used as in the previous
example. If you used ORD-MIN instead, the integer 2 would be returned. The examples above might be
more realistic if Arg1, Arg2, and Arg3 were successive elements of an array (table).
If you specify a national item for any argument, you must specify all arguments as class national.
Related tasks
“Performing arithmetic” on page 55
“Processing table items using intrinsic functions” on page 87
“Returning variable results with alphanumeric or national functions” on page 119
Related references
MAX (Enterprise COBOL for z/OS Language Reference)
MIN (Enterprise COBOL for z/OS Language Reference)
ORD-MAX (Enterprise COBOL for z/OS Language Reference)
ORD-MIN (Enterprise COBOL for z/OS Language Reference)
This code has the following results, which are similar to the first set of results except that these are for
national characters:
• R2 is evaluated to be larger than R1.
• The string NX"0066 0020 0020 0020 0020" (the equivalent in national characters of 'fbbbb', where
b represents a blank space), shown here in hexadecimal notation with added spaces for readability, is
moved to R3. The unfilled character positions in R3 are padded with national spaces.
• L evaluates to the value 5, the length in national character positions of R2.
You might be dealing with variable-length output from alphanumeric or national functions. Plan your
program accordingly. For example, you might need to think about using variable-length files when the
records that you are writing could be of different lengths:
File Section.
FD Output-File Recording Mode V.
01 Short-Customer-Record Pic X(50).
01 Long-Customer-Record Pic X(70).
Working-Storage Section.
01 R1 Pic x(50).
01 R2 Pic x(70).
. . .
If R1 > R2
Write Short-Customer-Record from R1
Else
Write Long-Customer-Record from R2
End-if
Related tasks
“Finding the largest or smallest data item” on page 118
“Performing arithmetic” on page 55
Related references
MAX (Enterprise COBOL for z/OS Language Reference)
120 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Move Customer-name To Customer-record(1:Function Length(Customer-name))
Related tasks
“Performing arithmetic” on page 55
“Creating variable-length tables (DEPENDING ON)” on page 78
“Processing table items using intrinsic functions” on page 87
Related references
BYTE-LENGTH (Enterprise COBOL for z/OS Language Reference)
LENGTH (Enterprise COBOL for z/OS Language Reference)
LENGTH OF (Enterprise COBOL for z/OS Language Reference)
YYYYMMDDhhmmsshh
You can instead use the WHEN-COMPILED special register to determine the date and time of compilation
in the following format:
MM/DD/YYhh.mm.ss
The WHEN-COMPILED special register supports only a two-digit year, and does not carry fractions of a
second. You can use this special register only as the sending field in a MOVE statement.
Related references
WHEN-COMPILED (Enterprise COBOL for z/OS Language Reference)
Use these COBOL facilities to code and compile programs that process national data:
• Data types and literals:
– Character data types, defined with the USAGE NATIONAL clause and a PICTURE clause that defines
data of category national, national-edited, or numeric-edited
– Numeric data types, defined with the USAGE NATIONAL clause and a PICTURE clause that defines
a numeric data item (a national decimal item) or an external floating-point data item (a national
floating-point item)
– National literals, specified with literal prefix N or NX
– Figurative constant ALL national-literal
– Figurative constants QUOTE, SPACE, HIGH-VALUE, LOW-VALUE, or ZERO, which have national
character (UTF-16) values when used in national-character contexts
• The COBOL statements shown in the related reference below about COBOL statements and national
data
• Intrinsic functions:
– NATIONAL-OF to convert an alphanumeric or double-byte character set (DBCS) character string to
USAGE NATIONAL (UTF-16)
– DISPLAY-OF to convert a national character string to USAGE DISPLAY in a selected code page
(EBCDIC, ASCII, EUC, or UTF-8)
– The other intrinsic functions shown in the related reference below about intrinsic functions and
national data
• The GROUP-USAGE NATIONAL clause to define groups that contain only USAGE NATIONAL data items
and that behave like elementary category national items in most operations
• Compiler options:
– CODEPAGE to specify the code page to use for alphanumeric and DBCS data in your program
– NSYMBOL to control whether national or DBCS processing is used for the N symbol in literals and
PICTURE clauses
You can also take advantage of implicit conversions of alphanumeric or DBCS data items to national
representation. The compiler performs such conversions (in most cases) when you move these items to
national data items, or compare these items with national data items.
UTF-8 is a variable-width Unicode encoding that is popular for data transmission and World Wide Web-
related data formats such as HTML and JSON. Using UTF-8, you can develop software that will work with
various national languages.
Use these COBOL facilities to code and compile programs that process UTF-8 data:
• Data types and literals:
– Character data types, defined with the USAGE UTF-8 clause and a PICTURE clause that defines data
of category UTF-8
– UTF-8 literals, specified with literal prefix U or UX
Related tasks
“Using national data (Unicode) in COBOL” on page 125
“Converting to or from national (Unicode) representation” on page 134
“Processing UTF-8 data using UTF-16 (national) data types” on page 153
“Processing Chinese GB 18030 data” on page 157
“Comparing national (UTF-16) data” on page 140
“Coding for use of DBCS
support” on page 158
Appendix B, “Converting double-byte
character set (DBCS) data,” on page 803
Related references
“COBOL statements and national data” on page 127
“Intrinsic functions and national data” on page 130
“CODEPAGE” on page 353
“NSYMBOL” on page 387
Classes and categories of data (Enterprise COBOL for z/OS Language Reference)
Data categories and PICTURE rules
(Enterprise COBOL for z/OS Language Reference)
MOVE statement (Enterprise COBOL for z/OS Language Reference)
General relation conditions (Enterprise COBOL for z/OS Language Reference)
124 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
bit pattern, or code point. Each code page also has a coded character set identifier (CCSID), which is a
value from 1 to 65,536.
Unicode has several encoding schemes, called Unicode Transformation Format (UTF), such as UTF-8,
UTF-16, and UTF-32. Enterprise COBOL uses UTF-16 (CCSID 1200) in big-endian format as the
representation for national literals and data items that have USAGE NATIONAL. Enterprise COBOL uses
UTF-8 (CCSID 1208) as the representation for UTF-8 literals and data items that have USAGE UTF-8.
UTF-8 represents ASCII invariant characters a-z, A-Z, 0-9, and certain special characters such as ' @ , .
+ - = / * ( ) as UX'nn' where X'nn' is the representation of the character in ASCII. UTF-16 represents
these characters as NX'00nn'.
For example, the string 'ABC' is represented in UTF-16 as NX'004100420043'. In UTF-8, 'ABC' is
represented as X'414243'.
One or more encoding units are used to represent a character from a coded character set. For UTF-16,
an encoding unit takes 2 bytes of storage. Any character defined in any EBCDIC, ASCII, or EUC code
page is represented in one UTF-16 encoding unit when the character is converted to the national data
representation.
Cross-platform considerations: Enterprise COBOL and COBOL for AIX® support UTF-16 in big-endian
format in national data. If you are porting Unicode data that is encoded in UTF-16LE representation to
Enterprise COBOL from another platform, you must convert that data to UTF-16 in big-endian format to
process the data as national data.
Related tasks
“Converting to or from national (Unicode) representation” on page 134
Related references
“Storage of character data” on page 139
Character sets and code pages (Enterprise COBOL for z/OS Language Reference)
Related concepts
“Unicode and the encoding of language characters” on page 124
“National groups” on page 133
Related tasks
“Defining national data items” on page 126
“Using national literals” on page 126
“Using national-character figurative constants” on page 132
“Defining national numeric data items” on page 132
“Using national groups” on page 137
“Converting to or from national (Unicode) representation” on page 134
“Comparing national (UTF-16) data” on page 140
Related tasks
“Displaying numeric data” on page 45
Related references
“NSYMBOL” on page 387
BLANK WHEN ZERO clause (Enterprise COBOL for z/OS Language Reference)
126 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Each of the following MOVE statements sets the national data item Y to the UTF-16 value of the characters
'AB':
Do not use alphanumeric hexadecimal literals in contexts that call for national literals, because such
usage is easily misunderstood. For example, the following statement also results in moving the UTF-16
characters 'AB' (not the hexadecimal bit pattern C1C2) to Y, where Y is defined as USAGE NATIONAL:
Move X"C1C2" to Y
You cannot use national literals in the SPECIAL-NAMES paragraph or as program-names. You can use
a national literal to name an object-oriented method in the METHOD-ID paragraph or to specify a method-
name in an INVOKE statement.
Related tasks
“Using literals” on page 25
Related references
“NSYMBOL” on page 387
National literals (Enterprise COBOL for z/OS Language Reference)
128 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 15. COBOL statements and national data (continued)
COBOL Can be national Comment For more information
statement
MULTIPLY All identifiers can be “Using COMPUTE and other
numeric items that arithmetic statements” on page 55
have USAGE NATIONAL.
identifier-3 (GIVING) can
be numeric-edited with
USAGE NATIONAL.
SEARCH ALL Both the key data The key data item and “Doing a binary search (SEARCH
(binary search) item and its object of its object of comparison ALL)” on page 86
comparison must be compatible
according to the rules of
comparison. If the object
of comparison is of class
national, the key must be
also.
SORT Sort keys The COLLATING “Setting sort or merge criteria” on
SEQUENCE phrase does page 229
not apply.
STRING All identifiers and literals. If identifier-3, the “Joining data items (STRING)” on
(identifier-4, the POINTER receiving data item, is page 103
integer data item, can national, all identifiers
have USAGE NATIONAL.) and literals (other than
identifier-4, the POINTER
identifier) must be
national.
SUBTRACT All identifiers can be “Using COMPUTE and other
numeric items that arithmetic statements” on page 55
have USAGE NATIONAL.
identifier-3 (GIVING) can
be numeric-edited with
USAGE NATIONAL.
UNSTRING All identifiers and If identifier-4, a receiving “Splitting data items (UNSTRING)” on
literals. (identifier-6 and data item, has USAGE page 105
identifier-7, the COUNT NATIONAL, the sending
and TALLYING integer data item and each
data items, respectively, delimiter must have
can have USAGE USAGE NATIONAL, and
NATIONAL.) each literal must be
national.
XML identifier-1 (the generated Chapter 38, “Producing XML output,”
GENERATE XML document); on page 663
identifier-2 (the source
field or fields); identifier-4
or literal-4 (the
namespace identifier);
identifier-5 or literal-5 (the
namespace prefix)
Related tasks
“Defining numeric data” on page 43
“Displaying numeric data” on page 45
“Using national data (Unicode) in COBOL” on page 125
“Comparing national (UTF-16) data” on page 140
Related references
“CODEPAGE” on page 353
Classes and categories of data (Enterprise COBOL for z/OS Language Reference)
130 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 16. Intrinsic functions and national character data (continued)
Intrinsic function Function type For more information
LENGTH Integer “Finding the length of data items” on page 120
LOWER-CASE, UPPER-CASE National “Changing case (UPPER-CASE, LOWER-CASE)” on page
114
NUMVAL, NUMVAL-C, NUMVAL- Numeric “Converting to numbers (NUMVAL, NUMVAL-C, NUMVAL-
F F)” on page 115
MAX, MIN National “Finding the largest or smallest data item” on page 118
ORD-MAX, ORD-MIN Integer “Finding the largest or smallest data item” on page 118
REVERSE Alphanumeric or REVERSE (Enterprise COBOL for z/OS Language Reference)
national
SECONDS-FORM- Numeric SECONDS-FROM-FORMATTED-TIME (Enterprise COBOL
FORMATTED-TIME for z/OS Language Reference)
TEST-FORMATTED- Integer TEST-FORMATTED-DATETIME (Enterprise COBOL for z/OS
DATETIME Language Reference)
TEST-NUMVAL, TEST- Integer • TEST-NUMVAL (Enterprise COBOL for z/OS Language
NUMVAL-C, TEST-NUMVAL-F Reference)
• TEST-NUMVAL-C (Enterprise COBOL for z/OS Language
Reference)
• TEST-NUMVAL-F (Enterprise COBOL for z/OS Language
Reference)
You can use national decimal arguments wherever zoned decimal arguments are allowed. You can use
national floating-point arguments wherever display floating-point arguments are allowed. (See the related
reference below about arguments for a complete list of intrinsic functions that can take integer or numeric
arguments.)
Related tasks
“Defining numeric data” on page 43
“Using national data (Unicode) in COBOL” on page 125
Related references
Arguments (Enterprise COBOL for z/OS Language Reference)
Classes and categories of data (Enterprise COBOL for z/OS Language Reference)
Intrinsic functions (Enterprise COBOL for z/OS Language Reference)
You can use the figurative constants QUOTE, SPACE, HIGH-VALUE, LOW-VALUE, or ZERO in a context that
requires national characters, such as a MOVE statement, an implicit move, or a relation condition that has
national operands. In these contexts, the figurative constant represents a national-character (UTF-16)
value.
When you use the figurative constant QUOTE in a context that requires national characters, and the
QUOTE compiler option is in effect, its value is NX'0022'. If the APOST compiler option is in effect, its
value is NX'0027'.
When you use the figurative constant HIGH-VALUE in a context that requires national characters, its
value is NX'FFFF'. When you use LOW-VALUE in a context that requires national characters, its value is
NX'0000'.
Restrictions: You must not use HIGH-VALUE or the value assigned from HIGH-VALUE in a way that
results in conversion of the value from one data representation to another (for example, between
USAGE DISPLAY and USAGE NATIONAL). X'FF' (the value of HIGH-VALUE in an alphanumeric context
when the EBCDIC collating sequence is being used) does not represent a valid EBCDIC character,
and NX'FFFF' does not represent a valid national character. Conversion of such a value to another
representation results in a substitution character being used (not X'FF' or NX'FFFF'). Consider the
following example:
The IF statement above evaluates as false even though each of its operands was set to HIGH-VALUE.
Before an elementary alphanumeric operand is compared to a national operand, the alphanumeric
operand is treated as though it were moved to a temporary national data item, and the alphanumeric
characters are converted to the corresponding national characters. When X'FF' is converted to UTF-16,
however, the UTF-16 item gets a substitution character value and so does not compare equally to
NX'FFFF'.
Related tasks
“Converting to or from national (Unicode) representation” on page 134
“Comparing national (UTF-16) data” on page 140
Related references
Figurative constants (Enterprise COBOL for z/OS Language Reference)
DISPLAY-OF (Enterprise COBOL for z/OS Language Reference)
Support for Unicode: Using Unicode Services
To define a national decimal item, code a PICTURE clause that contains only the symbols 9, P, S, and V. If
the PICTURE clause contains S, the SIGN IS SEPARATE clause must be in effect for that item.
To define a national floating-point item, code a PICTURE clause that defines a floating-point item (for
example, +99999.9E-99).
132 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
You can use national decimal items in the same way that you use zoned decimal items. You can use
national floating-point items in the same way that you use display floating-point items.
Related tasks
“Defining numeric data” on page 43
“Displaying numeric data” on page 45
Related references
SIGN clause (Enterprise COBOL for z/OS Language Reference)
National groups
National groups, which are specified either explicitly or implicitly with the GROUP-USAGE NATIONAL
clause, contain only data items that have USAGE NATIONAL. In most cases, a national group item is
processed as though it were redefined as an elementary category national item described as PIC N(m),
where m is the number of national (UTF-16) characters in the group.
For some operations on national groups, however (just as for some operations on alphanumeric groups),
group semantics apply. Such operations (for example, MOVE CORRESPONDING and INITIALIZE)
recognize or process the elementary items within the national group.
Where possible, use national groups instead of alphanumeric groups that contain USAGE NATIONAL
items. National groups provide several advantages for the processing of national data compared to the
processing of national data within alphanumeric groups:
• When you move a national group to a longer data item that has USAGE NATIONAL, the receiving item is
padded with national characters. By contrast, if you move an alphanumeric group that contains national
characters to a longer alphanumeric group that contains national characters, alphanumeric spaces are
used for padding. As a result, mishandling of data items could occur.
• When you move a national group to a shorter data item that has USAGE NATIONAL, the national
group is truncated at national-character boundaries. By contrast, if you move an alphanumeric group
that contains national characters to a shorter alphanumeric group that contains national characters,
truncation might occur between the 2 bytes of a national character.
• When you move a national group to a national-edited or numeric-edited item, the content of the group is
edited. By contrast, if you move an alphanumeric group to an edited item, no editing takes place.
• When you use a national group as an operand in a STRING, UNSTRING, or INSPECT statement:
– The group content is processed as national characters rather than as single-byte characters.
– TALLYING and POINTER operands operate at the logical level of national characters.
– The national group operand is supported with a mixture of other national operand types.
By contrast, if you use an alphanumeric group that contains national characters in these contexts, the
characters are processed byte by byte. As a result, invalid handling or corruption of data could occur.
USAGE NATIONAL groups: A group item can specify the USAGE NATIONAL clause at the group level
as a convenient shorthand for the USAGE of each of the elementary data items within the group. Such
a group is not a national group, however, but an alphanumeric group, and behaves in many operations,
such as moves and compares, like an elementary data item of USAGE DISPLAY (except that no editing or
conversion of data occurs).
Related tasks
“Assigning values to group data items (MOVE)” on page 33
“Joining data items (STRING)” on page 103
“Splitting data items (UNSTRING)” on page 105
“Tallying and replacing data items (INSPECT)” on page 112
“Using national groups” on page 137
You can implicitly convert alphabetic, alphanumeric, UTF-8, DBCS, or integer data to national data by
using the MOVE statement. Implicit conversions also take place in other COBOL statements, such as IF
statements that compare an alphanumeric data item with a data item that has USAGE NATIONAL.
You can explicitly convert to and from national data items by using the intrinsic functions NATIONAL-OF
and DISPLAY-OF, respectively. By using these intrinsic functions, you can specify a code page for the
conversion that is different from the code page that is in effect with the CODEPAGE compiler option.
Related tasks
“Converting alphanumeric, DBCS, and integer to national (MOVE)” on page 134
“Converting alphanumeric or DBCS to national (NATIONAL-OF)” on page 135
“Converting national to alphanumeric (DISPLAY-OF)” on page 135
“Overriding the default code page” on page 135
“Comparing national (UTF-16) data” on page 140
Related references
“CODEPAGE” on page 353
“Conversion exceptions” on page 136
You can move the following kinds of data to category national or national-edited data items, and thus
convert the data to national representation:
• Alphabetic
• Alphanumeric
• Alphanumeric-edited
• UTF-8
• DBCS
• Integer of USAGE DISPLAY
• Numeric-edited of USAGE DISPLAY
You can likewise move the following kinds of data to numeric-edited data items that have USAGE
NATIONAL:
• Alphanumeric
• Display floating-point (floating-point of USAGE DISPLAY)
• Numeric-edited of USAGE DISPLAY
• Integer of USAGE DISPLAY
For complete rules about moves to national data, see the related reference about the MOVE statement.
For example, the MOVE statement below moves the alphanumeric literal "AB" to the national data item
UTF16-Data:
134 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
After the MOVE statement above, UTF16-Data contains NX'00410042', the national representation of
the alphanumeric characters 'AB'.
If padding is required in a receiving data item that has USAGE NATIONAL, the default UTF-16 space
character (NX'0020') is used. If truncation is required, it occurs at the boundary of a national-character
position.
Related tasks
“Assigning values to elementary
data items (MOVE)” on page 32
“Assigning values to group data items (MOVE)” on page 33
“Displaying numeric data” on page 45
“Coding for use of DBCS
support” on page 158
Related references
MOVE statement (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Processing UTF-8 data using UTF-16 (national) data types” on page 153
“Processing Chinese GB 18030 data” on page 157
“Processing alphanumeric data items that contain DBCS data” on page 160
Related references
“CODEPAGE” on page 353
NATIONAL-OF (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Processing UTF-8 data using UTF-16 (national) data types” on page 153
“Processing Chinese GB 18030 data” on page 157
Related references
DISPLAY-OF (Enterprise COBOL for z/OS Language Reference)
Related references
“CODEPAGE” on page 353
Conversion exceptions
Implicit or explicit conversion between national data and alphanumeric data can fail and generate a
severity-3 Language Environment condition.
Failure can occur if the code page that you specified implicitly or explicitly is not a valid code page.
A character that does not have a counterpart in the target CCSID does not result in a conversion
exception. Such a character is converted to a substitution character in the target code page.
Related references
“CODEPAGE” on page 353
CBL CODEPAGE(00037)
* . . .
01 Data-in-Unicode pic N(100) usage national.
01 Data-in-Greek pic X(100).
01 other-data-in-US-English pic X(12) value "PRICE in $ =".
* . . .
Read Greek-file into Data-in-Greek
Move function National-of(Data-in-Greek, 00875)
to Data-in-Unicode
* . . . process Data-in-Unicode here . . .
Move function Display-of(Data-in-Unicode, 00875)
to Data-in-Greek
Write Greek-record from Data-in-Greek
The example above works correctly because the input code page is specified. Data-in-Greek is
converted as data represented in CCSID 00875 (Greek). However, the following statement results in an
incorrect conversion unless all the characters in the item happen to be among those that have a common
representation in both the Greek and the English code pages:
The MOVE statement above converts Data-in-Greek to Unicode representation based on the CCSID
00037 (U.S. English) to UTF-16 conversion. This conversion does not produce the expected results
because Data-in-Greek is encoded in CCSID 00875.
If you can correctly set the CODEPAGE compiler option to CCSID 00875 (that is, the rest of your program
also handles EBCDIC data in Greek), you can code the same example correctly as follows:
CBL CODEPAGE(00875)
* . . .
01 Data-in-Unicode pic N(100) usage national.
01 Data-in-Greek pic X(100).
* . . .
Read Greek-file into Data-in-Greek
* . . . process Data-in-Greek here ...
* . . . or do the following (if need to process data in Unicode):
136 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Move Data-in-Greek to Data-in-Unicode
* . . . process Data-in-Unicode
Move function Display-of(Data-in-Unicode) to Data-in-Greek
Write Greek-record from Data-in-Greek
In the example above, Nat-Group-1 is a national group, and its subordinate groups Group-1 and
Group-2 are also national groups. A GROUP-USAGE NATIONAL clause is implied for Group-1, and
USAGE NATIONAL is implied for the subordinate items in Group-1. Month, DayOf, and Year are national
decimal items, and Amount is a numeric-edited item that has USAGE NATIONAL.
You can subordinate national groups within alphanumeric groups as in the following example:
01 Alpha-Group-1.
02 Group-1.
04 Month PIC 99.
04 DayOf PIC 99.
04 Year PIC 9999.
02 Group-2 GROUP-USAGE NATIONAL.
04 Amount PIC 9(4).99.
In the example above, Alpha-Group-1 and Group-1 are alphanumeric groups; USAGE DISPLAY is
implied for the subordinate items in Group-1. (If Alpha-Group-1 specified USAGE NATIONAL at the
group level, USAGE NATIONAL would be implied for each of the subordinate items in Group-1. However,
Alpha-Group-1 and Group-1 would be alphanumeric groups, not national groups, and would behave
like alphanumeric groups during operations such as moves and compares.) Group-2 is a national group,
and USAGE NATIONAL is implied for the numeric-edited item Amount.
You cannot subordinate alphanumeric groups within national groups. All elementary items within a
national group must be explicitly or implicitly described as USAGE NATIONAL, and all group items within
a national group must be explicitly or implicitly described as GROUP-USAGE NATIONAL.
Related concepts
“National groups” on page 133
Related tasks
“Using national groups as elementary items” on page 138
“Using national groups as group items” on page 138
Related references
GROUP-USAGE clause (Enterprise COBOL for z/OS Language Reference)
If Group-1 were instead an alphanumeric group in which each of its subordinate items had USAGE
NATIONAL (specified either explicitly with a USAGE NATIONAL clause on each elementary item, or
implicitly with a USAGE NATIONAL clause at the group level), a group move, rather than an elementary
move, would occur. Neither editing nor conversion would take place during the move. The value in the first
eight character positions of Edited-date after the move would be 06232010 in national characters, and
the value in the remaining two character positions would be 4 bytes of alphanumeric spaces.
Related tasks
“Assigning values to group data items (MOVE)” on page 33
“Comparing national data and alphanumeric-group operands” on page 142
“Using national groups as group items” on page 138
Related references
MOVE statement (Enterprise COBOL for z/OS Language Reference)
In the following example, an INITIALIZE statement that acts upon national group item Group-OneN
causes the value 15 in national characters to be moved to only the numeric items in the group:
Because only Trans-quanN in Group-OneN above is numeric, only Trans-quanN receives the value 15.
The other subordinate items are unchanged.
The table below summarizes the cases where national groups are processed with group semantics.
Table 17. National group items that are processed with group semantics
Language feature Uses of national group items Comment
CORRESPONDING phrase Specify a national group item for Elementary items within the
of the ADD, SUBTRACT, processing as a group in accordance national group are processed like
or MOVE statement with the rules of the CORRESPONDING elementary items that have USAGE
phrase. NATIONAL within an alphanumeric
group.
138 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 17. National group items that are processed with group semantics (continued)
Language feature Uses of national group items Comment
Host variable in EXEC Specify a national group item as a host The national group item is in effect
SQL statement variable. shorthand for the set of host
variables that are subordinate to
the group item.
INITIALIZE statement Specify a national group for processing Elementary items within the
as a group in accordance with the rules national group are initialized like
of the INITIALIZE statement. elementary items that have USAGE
NATIONAL within an alphanumeric
group.
Name qualification Use the name of a national group item Follow the same rules
to qualify the names of elementary data for qualification as for an
items and of subordinate group items in alphanumeric group.
the national group.
THROUGH phrase of the To specify a national group item in the The result is an alphanumeric
RENAMES clause THROUGH phrase, use the same rules as group item.
for an alphanumeric group item.
FROM phrase of the XML Specify a national group item in the Elementary items within the
GENERATE statement FROM phrase for processing as a group national group are processed like
in accordance with the rules of the XML elementary items that have USAGE
GENERATE statement. NATIONAL within an alphanumeric
group.
Related tasks
“Initializing a structure (INITIALIZE)” on page 31
“Initializing a table (INITIALIZE)” on page 73
“Assigning values to elementary
data items (MOVE)” on page 32
“Assigning values to group data items (MOVE)” on page 33
“Finding the length of data items” on page 120
“Generating XML output” on page 663
“Using national group items in SQL statements” on page 508
Related references
Qualification (Enterprise COBOL for z/OS Language Reference)
RENAMES clause (Enterprise COBOL for z/OS Language Reference)
Table 18. Encoding and size of alphanumeric, DBCS, and national data
Characteristic DISPLAY DISPLAY-1 NATIONAL
Character encoding unit 1 byte 2 bytes 2 bytes
Code page EBCDIC EBCDIC DBCS UTF-16BE1
Encoding units per graphic 1 1 1 or 22
character
Bytes per graphic character 1 byte 2 bytes 2 or 4 bytes
1. Use the CODEPAGE compiler option to specify the EBCDIC code page that is applicable to
alphanumeric or DBCS data.
2. Most characters are represented in UTF-16 using one encoding unit. In particular, the following
characters are represented using a single UTF-16 encoding unit per character:
• COBOL characters A-Z, a-z, 0-9, space, + - * / = $ , ; . " ( ) > < :'
• All characters that are converted from an EBCDIC or ASCII code page
Related concepts
“Unicode and the encoding of language characters” on page 124
Related tasks
“Comparing two class national operands” on page 140
“Comparing class national and class numeric operands” on page 141
“Comparing national numeric and other numeric operands” on page 141
“Comparing national and other character-string operands” on page 141
“Comparing national data and alphanumeric-group operands” on page 142
Related references
Relation conditions (Enterprise COBOL for z/OS Language Reference)
General relation conditions (Enterprise COBOL for z/OS Language Reference)
National comparisons (Enterprise COBOL for z/OS Language Reference)
Group comparisons (Enterprise COBOL for z/OS Language Reference)
Either operand (or both) can be any of the following types of items:
• A national group
• An elementary category national or national-edited data item
• A numeric-edited data item that has USAGE NATIONAL
One of the operands can instead be a national literal or a national intrinsic function.
140 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
When you compare two class national operands that have the same length, they are determined to be
equal if all pairs of the corresponding characters are equal. Otherwise, comparison of the binary values of
the first pair of unequal characters determines the operand with the larger binary value.
When you compare operands that have unequal lengths, the shorter operand is treated as if it were
padded on the right with default UTF-16 space characters (NX'0020') to the length of the longer
operand.
The PROGRAM COLLATING SEQUENCE clause does not affect the comparison of two class national
operands.
Related concepts
“National groups” on page 133
Related tasks
“Using national groups” on page 137
Related references
National comparisons (Enterprise COBOL for z/OS Language Reference)
You can also compare national literals or class national data items to floating-point data items (that is,
display floating-point or national floating-point items).
Numeric operands are converted to national (UTF-16) representation if they are not already in national
representation. A comparison is made of the national character values of the operands.
Related references
General relation conditions (Enterprise COBOL for z/OS Language Reference)
You can compare the algebraic values of numeric operands regardless of their USAGE. Thus you can
compare a national decimal item or a national floating-point item with a binary item, an internal-decimal
item, a zoned decimal item, a display floating-point item, or any other numeric item.
Related tasks
“Defining national numeric data items” on page 132
Related references
General relation conditions (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Using national-character figurative constants” on page 132
Related references
National comparisons (Enterprise COBOL for z/OS Language Reference)
Neither operand is converted. The national operand is treated as if it were moved to an alphanumeric
group item of the same size in bytes as the national operand, and the two groups are compared.
An alphanumeric comparison is done regardless of the representation of the subordinate items in the
alphanumeric group operand.
For example, Group-XN is an alphanumeric group that consists of two subordinate items that have USAGE
NATIONAL:
01 Group-XN.
02 TransCode PIC NN Value "AB" Usage National.
02 Quantity PIC 999 Value 123 Usage National.
. . .
If N"AB123" = Group-XN Then Display "EQUAL"
Else Display "NOT EQUAL".
When the IF statement above is executed, the 10 bytes of the national literal N"AB123" are compared
byte by byte to the content of Group-XN. The items compare equally, and "EQUAL" is displayed.
Related references
Group comparisons (Enterprise COBOL for z/OS Language Reference)
Related references
“Defining UTF-8 data items” on page 142
“Using UTF-8 literals” on page 144
“COBOL statements and UTF-8 data items” on page 145
“Intrinsic functions support for UTF-8 data items” on page 146
“Db2 considerations” on page 147
142 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
This type of UTF-8 data item is defined when the PICTURE clause contains one or more 'U' characters,
or a single 'U' character followed by a repetition factor, and neither the BYTE-LENGTH phrase of the
PICTURE clause nor the DYNAMIC LENGTH clause is specified.
Each 'U' character in the PICTURE clause corresponds to one UTF-8 character, which in Enterprise
COBOL is treated as the equivalent of a single Unicode code point. The UTF-8 encoding of a character
varies in length and it is always between one and four bytes.
The following code fragment illustrates two different fixed character-length UTF-8 data item definitions:
01 u1 pic u(10). *> fixed character-length UTF-8 data item holding 10 UTF-8 characters (40
bytes reserved)
01 u2 pic uuuu. *> fixed character-length UTF-8 data item holding 4 UTF-8 characters (16
bytes reserved)
For fixed character-length UTF-8 data items, the number of bytes reserved for the data item in memory
is 4 × n, where n is the number of characters specified in the definition of the item. Note that, due to
the varying length nature of the UTF-8 encoding, even after moving n characters to a UTF-8 data item
of length n, it is not necessarily the case that all 4 × n reserved bytes are needed to hold the data. It
depends on the size of each character in the data.
During moves, the fixed character-length UTF-8 data items are always padded with UTF-8 blanks (x'20')
to the maximum byte-length of the data item. When truncation is performed on the fixed character-
length UTF-8 data item, it is done on a character boundary.
Whenever a fixed character-length UTF-8 data item is used as a sender, the byte-length of the item is
computed at run time based on its known fixed-character length so that the number of characters used
in the operation is the same as the number of characters indicated in the item definition.
• Fixed byte-length UTF-8 data items
This type of UTF-8 data item is defined when the PICTURE clause contains a single 'U' character and
the BYTE-LENGTH phrase of the PICTURE clause is specified. This phrase indicates that the data item
is a fixed byte-length UTF-8 item consisting of exactly n valid UTF-8 bytes. Note that, due to the varying
length nature of the UTF-8 encoding, the number of characters in the data item at any time is variable
and depends on the size of each character, but should always be in the range [ceil(4/n), n] , where ceil is
the mathematical function that returns the least integer greater than its argument.
The following code fragment illustrates two different fixed byte-length UTF-8 data item definitions:
When truncation is needed for a fixed byte-length UTF-8 data item, it is done at a character boundary
and the data item is always padded out with UTF-8 spaces (x'20) to the specified byte length of n.
Whenever a fixed byte-length UTF-8 data item is used as a sender, the byte-length of the item is always
taken to be n.
Fixed byte-length UTF-8 data items are provided for compatibility with the Db2®, DFSORT, and MQ
products, all of which provide support for fixed byte-length UTF-8 data strings. For example, to use a
COBOL UTF-8 data item as a Db2 host variable that corresponds to a CHAR(n) column in a Unicode
table, the data item must contain the BYTE-LENGTH phrase of the PICTURE clause. Similarly, DSFSORT
only supports UTF-8 sort key parts that have a fixed byte-length and therefore fixed byte-length UTF-8
data items in COBOL are strongly recommended for sort and merge keys.
• Dynamic-length UTF-8 data items
UTF-8 data items can be declared with the DYNAMIC LENGTH clause, which is a natural fit for UTF-8
data items since they vary in byte length. In this case, there is no restriction on the number of
characters in the data item and the number of bytes is only limited when there is a LIMIT phrase
of the DYNAMIC LENGTH clause.
When a UTF-8 data item defined with the DYNAMIC LENGTH clause requires truncation due to the
LIMIT phrase, truncation is performed at the UTF-8 character level.
01 u1 pic u dynamic length limit 10. *> dynamic-length UTF-8 data item
The following rules apply to data items declared with the 'U' pic symbol:
• UTF-8 data items can be elementary data items.
• UTF-8 data items can appear in groups, including file records, except where the data item is dynamic
length, which is not supported in file records.
• Group-items can be UTF-8 items via the UTF-8 phrase of the GROUP-USAGE clause.
Note: The groups defined with the GROUP-USAGE UTF-8 clause can only contain UTF-8 items defined
with the BYTE-LENGTH phrase of the PICTURE clause. No other classes of data items are permitted.
• Condition variables associated with condition names (level 88 items) can be UTF-8.
• The VALUE clause for UTF-8 data items accepts alphanumeric, national and UTF-8 literals. In the
alphanumeric case, the literal is automatically converted from EBCDIC to UTF-8.
• UTF-8 support does not include support for the following types of data items:
– UTF-8 edited, UTF-8 numeric-edited
– UTF-8 decimal
– UTF-8 external float
Note: The USAGE UTF-8 clause can only appear in data definitions for data items declared with the 'U'
pic symbol, i.e., numeric items cannot be defined with USAGE UTF-8.
The following code fragment illustrates valid and invalid UTF-8 data item definitions:
Examples of valid UTF-8 data item definitions:
144 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
– character-data is converted from EBCDIC to UTF-8.
– character-data may contain double-byte EBCDIC characters, but those characters must be
delimited by shift-out and shift-in characters.
– The maximum number of Unicode code points that can be represented in a basic UTF-8 literal
can vary depending on the size of each UTF-8 character. However, before truncation occurs, a
maximum of 160 bytes after UTF-8 conversion is allowed.
– character-data can contain the following Unicode escape sequences:
- \uhhhh, where each h represents a hexadecimal digit in the range ‘0’ to ‘9’, ‘a’ to ‘f’, and ‘A’ to
‘F’. This Unicode escape sequence represents a Unicode code point from the Basic Multilingual
Plane (BMP) (that is, Unicode code points in the range U+0000 through U+FFFF).
- \U00hhhhhh, where each h represents a hexadecimal digit in the range ‘0’ to ‘9’, ‘a’ to ‘f’, and ‘A’
to ‘F’. This Unicode escape sequence can represent any legal Unicode code point, including code
points from the Supplementary Planes, i.e., Unicode code points in the range U+10000 through
U+10FFFF (for example, an emoji symbol).
Notes:
- Code points U+D800 through U+DFFF are reserved for the high and low halves of surrogate pairs
used by UTF-16. There is no legal encoding of these Unicode code points in UTF-8 and hence
\uD800 through \uDFFF and \U0000D800 through \U0000DFFF cannot be specified as Unicode
escape sequences in UTF-8 literals.
- To avoid having a string of characters of the form \uhhhh or \U00hhhhhh in a UTF-8 literal to be
interpreted as a Unicode escape sequence, the escape character ‘\’ can itself be escaped with ‘\’
in order to be interpreted literally. Thus, the sequence \\u00E9 will not be treated as a Unicode
escape sequence.
– Wherever a Unicode escape sequence appears in a basic UTF-8 literal, it is replaced by the
compiler with the UTF-8 encoding for the Unicode code point corresponding to the escape
sequence. This makes it convenient to represent general Unicode code points in the literal using
only EBCDIC characters. For example, u’caf\u00E9’ represents the string ‘café’.
2. Hexadecimal UTF-8 literal
• ux'hexadecimal-digits'
– hexadecimal-digits are converted to a sequence of bytes in order to be used verbatim as the
UTF-8 literal value.
– A minimum of 2 hexadecimal digits and up to a maximum of 320 hexadecimal digits are allowed.
Note: The sequence of bytes represented by hexadecimal-digits is validated to ensure that it
contains a legal sequence of UTF-8 bytes.
Related tasks
“Processing UTF-8 data using UTF-16 (national) data types” on page 153
146 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
• LENGTH
• LOWER-CASE1
• NATIONAL-OF
• SECONDS-FROM-FORMATTED-TIME
• TEST-FORMATTED-DATETIME
• TRIM1
• ULENGTH
• UPOS
• UPPER-CASE1
• USUBSTR1
• USUPPLEMENTARY
• UVALID
• UWIDTH
1. This intrinsic function returns a result of category UTF-8 when the input argument contains UTF-8 data
items.
Related references
Intrinsic functions (Enterprise COBOL for z/OS Language Reference)
Db2 considerations
The codepage of Db2 host variables is governed by various factors such as CODEPAGE, SQLCCSID,
and DSNHDECP file. However, for host variables declared as UTF-8, these are overridden and the Db2
coprocessor assumes that the item has a CCSID of 1208.
Only UTF-8 data items declared with the BYTE-LENGTH phrase of the PICTURE clause can be used as
Db2 host variables. In this case, when the host variable corresponds to a CHAR column in a Db2 table,
the byte length of the CHAR column and the number of bytes specified in the BYTE-LENGTH phrase of the
PICTURE clause should match to avoid unexpected truncation or padding of data.
Note: The Db2 precompiler cannot be used with a COBOL program containing UTF-8 data items.
You can use the figurative constants QUOTE, SPACE, HIGH-VALUE, LOW-VALUE, or ZERO in a context that
requires UTF-8 characters, such as a MOVE statement, an implicit move, or a relation condition that has
UTF-8 operands. In these contexts, the figurative constant represents a UTF-8-character (UTF-8) value.
When you use the figurative constant QUOTE in a context that requires UTF-8 characters, and the QUOTE
compiler option is in effect, its value is UX'22'. If the APOST compiler option is in effect, its value is
UX'27'.
When you use the figurative constant HIGH-VALUE in a context that requires UTF-8 characters, its
value is UTF-8 character UX'F48FBFBF' corresponding to Unicode code point U+10FFFF, except when
HIGH-VALUE is used in a move or compare operation with a fixed byte-length UTF-8 data item that has a
length that is not a multiple of 4 bytes. In that case, when HIGH-VALUE is moved into or compared against
the final 3, 2, or 1 byte(s) of the UTF-8 data item, the value of HIGH-VALUE is UX'EFBFBF' (U+FFFF),
UX'DFBF' (U+07FF), and UX'7F' (U+007F), respectively.
When you use LOW-VALUE in a context that requires UTF-8 characters, its value is UX'00'.
Related tasks
“Converting to or from UTF-8 (Unicode) representation” on page 150
“Comparing UTF-8 data” on page 151
Related references
Figurative constants (Enterprise COBOL for z/OS Language Reference)
DISPLAY-OF (Enterprise COBOL for z/OS Language Reference)
Support for Unicode: Using Unicode Services
In this example, u1(3:2) starts at character position 3, which is the 4th byte of the data item. This is
because 'é' has a 2-byte encoding in UTF-8 and 'c' and 'r' both have 1-byte encodings in UTF-8.
Example 2
In this example, u1(3:2) starts at character position 3, which is the 3rd byte of the data item. This is
because 'e', 'c', and 'r' all have 1-byte encodings in UTF-8.
• The actual byte length of a UTF-8 reference modification cannot be determined at compile time and
must be determined from its character length at run time, even when the character length of the
reference modifier is specified as a literal.
Example 3
In this example, u1(3:2) is 2 UTF-8 characters in length but 3 bytes in length because 'f' has a 1-byte
encoding in UTF-8 and 'é' has a 2-byte encoding in UTF-8.
Example 4
In this example, u1(3:2) is 2 UTF-8 characters in length but 2 bytes in length because both 'f' and 'e'
have a 1-byte encoding in UTF-8.
148 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
• When a reference modified UTF-8 data item is a receiver in a MOVE statement, the number of bytes
that make up the substring indicated by the reference modification may not be the same after the
move as before the move. For example, if the substring has a length of 4 characters, those 4 characters
might be represented by 12 bytes before the move, but after the move, those 4 characters could be
represented by only 4 bytes, or as many as 16 bytes. It depends on the UTF-8 sender in the move.
When this situation occurs the remaining data after the substring will automatically be shifted left if
the new substring has fewer bytes than it originally had, and the remaining bytes will be shifted right
if the new substring has more bytes than it originally had. In the latter case, it is possible that some
characters in the remaining portion of the underlying data item may be truncated. However, truncation
can only happen if the underlying UTF-8 data item is defined with the BYTE-LENGTH phrase of the
PICTURE clause. In the case of fixed character-length UTF-8 items, there will always be enough space
to accommodate the right-shift without truncation.
Example 5
01 u1 pic u(13) value 'Ol\u00e9, Ol\u00e9, Ol\u00e9'. *> Olé, Olé, Olé
:
move 'abcdef' to u1(3:6)
In this example, u1(3:6) represents 'é, Olé', which is 8 bytes long. After the move, the 8-byte substring
represented by the reference modification is replaced with 'abcdef' which is only 6 bytes long in
UTF-8. This means that the remaining characters ', Olé' in the underlying data item located immediately
following the reference modified portion will be shifted left in memory 2 bytes as a result of the move.
Example 6
01 u1 pic u(13) value 'Ol\u00e9, Ol\u00e9, Ol\u00e9'. *> Olé, Olé, Olé
:
move '\u00e9\u00e9\u00e9\u00e9\u00e9\u00e9' to u1(3:6)
In this example, u1(3:6) represents 'é, Olé' which is 8 bytes long. After the move, the 8-byte substring
represented by the reference modification is replaced with 'éééééé' which is 12 bytes long in UTF-8.
This means that the remaining characters ', Olé' in the underlying data item located immediately
following the reference modified portion will be shifted right in memory 4 bytes as a result of the move.
Related references
“Reference modifiers” on page 110
UTF-8 groups
UTF-8 groups are specified with the GROUP-USAGE UTF-8 clause. These groups can contain fixed
byte-length UTF-8 data items (items defined as PIC U BYTE-LENGTH n) or dynamic-length data items
(items defined as PIC U DYNAMIC). Fixed character-length UTF-8 data items are not permitted. If the
group contains only fixed byte-length UTF-8 data items then, in most cases, the group is processed as
though it were redefined as an elementary category UTF-8 item described as PIC U BYTE-LENGTH m,
where m is the total byte length of all items in the group.
For some operations on UTF-8 groups, however (just as for some operations on alphanumeric groups),
group semantics apply. Such operations (for example, MOVE CORRESPONDING and INITIALIZE)
recognize or process the elementary items within the UTF-8 group.
In use cases where the current limitation of UTF-8 groups is acceptable, that is, they can only contain
fixed byte-length UTF-8 data items, UTF-8 groups provide several advantages for the processing of UTF-8
data compared to the processing of UTF-8 data within alphanumeric groups:
• When you move a UTF-8 group to a longer data item that has USAGE UTF-8, the receiving item is
padded with UTF-8 characters. By contrast, if you move an alphanumeric group that contains UTF-8
characters to a longer alphanumeric group that contains UTF-8 characters, alphanumeric spaces are
used for padding. As a result, mishandling of data items could occur.
• When you move a UTF-8 group to a shorter data item that has USAGE UTF-8, the UTF-8 group is
truncated at UTF-8-character boundaries. By contrast, if you move an alphanumeric group that contains
Related tasks
“Assigning values to group data items (MOVE)” on page 33
Related references
GROUP-USAGE clause (Enterprise COBOL for z/OS Language Reference)
You can implicitly convert alphabetic or national data to UTF-8 data by using the MOVE statement.
Implicit conversions also take place in other COBOL statements, such as IF statements that compare an
alphanumeric data item with a data item that has USAGE UTF-8.
You can explicitly convert UTF-16 data to UTF-8 data and UTF-8 data to alphanumeric data by using the
DISPLAY-OF intrinsic function. You can also explicitly convert UTF-8 data to UTF-16 data by using the
NATIONAL-OF intrinsic function. When using the DISPLAY-OF intrinsic function to convert UTF-16 to
UTF-8, you must specify an output code page of 1208.
Related tasks
“Converting alphanumeric or national to UTF-8 (MOVE)” on page 150
“Converting UTF-8 to national (NATIONAL-OF)” on page 151
“Converting national to UTF-8 and UTF-8 to alphanumeric (DISPLAY-OF)” on page 151
“Overriding the default code page” on page 135
“Comparing UTF-8 data” on page 151
Related references
“CODEPAGE” on page 353
“Conversion exceptions” on page 136
DISPLAY-OF (Enterprise COBOL for z/OS Language Reference)
NATIONAL-OF (Enterprise COBOL for z/OS Language Reference)
You can move the following kinds of data to category UTF-8, and thus convert the data to UTF-8
representation:
• Alphabetic
• Alphanumeric
• Alphanumeric-edited
• Numeric-edited
• National
• National-edited
• Numeric-edited of USAGE NATIONAL
For complete rules about moves to UTF-8 data, see MOVE statement (Enterprise COBOL for z/OS Language
Reference) .
150 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
For example, the following MOVE statement moves the alphanumeric literal "AB" to the UTF-8 data item
UTF8-Data:
After the previous MOVE statement, UTF8-Data contains UX'4142', the UTF-8 representation of the
alphanumeric characters 'AB'.
If padding is required in a receiving data item that has USAGE UTF-8, the default UTF-8 space character
(UX'20') is used. If truncation is required, it occurs at the boundary of a UTF-8 character position.
Related tasks
“Assigning values to elementary
data items (MOVE)” on page 32
“Assigning values to group data items (MOVE)” on page 33
Related references
MOVE statement (Enterprise COBOL for z/OS Language Reference)
Related references
NATIONAL-OF (Enterprise COBOL for z/OS Language Reference)
Related references
DISPLAY-OF (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Comparing two class UTF-8 operands” on page 152
Related references
Relation conditions (Enterprise COBOL for z/OS Language Reference)
General relation conditions (Enterprise COBOL for z/OS Language Reference)
National comparisons (Enterprise COBOL for z/OS Language Reference)
Group comparisons (Enterprise COBOL for z/OS Language Reference)
Related references
UTF-8 comparisons (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Using national-character figurative constants” on page 132
Related references
UTF-8 comparisons (Enterprise COBOL for z/OS Language Reference)
01 Group-XN.
02 TransCode PIC NN Value "AB" Usage National.
152 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
02 Quantity PIC 999 Value 123 Usage National.
. . .
If U"AB123" = Group-XN Then Display "EQUAL"
Else Display "NOT EQUAL".
When the IF statement above is executed, the 5 bytes of the UTF-8 literal U"AB123" are compared byte
by byte with the content of Group-XN. The items compare unequally, and "NOT EQUAL" is displayed.
Related references
Group comparisons (Enterprise COBOL for z/OS Language Reference)
Usage note: Use care if you use reference modification to refer to data encoded in UTF-8. UTF-8
characters are encoded with a varying number of bytes per character. Avoid operations that might split a
multibyte character.
Related tasks
“Referring to substrings of data items” on page 109
“Converting to or from national (Unicode) representation” on page 134
“Parsing XML documents encoded in UTF-8” on page 644
“Using
intrinsic functions to process UTF-8 encoded data” on page 153
checkUTF-8-validity.
Compute u = function UVALID(UTF-8-testStr)
If u not = 0
Display 'checkUTF-8-validity failure:'
Display ' The UTF-8 representation is not valid,'
'starting at byte ' u '.'
Compute v = function ULENGTH(UTF-8-testStr(1:u - 1))
Compute u = function UPOS(UTF-8-testStr v)
Compute w = function UWIDTH(UTF-8-testStr v)
Display ' The ' v 'th and last valid code point starts '
'at byte ' u ' for ' w ' bytes.'
End-if.
In the following string, the sequence that starts with x'F5' is not valid UTF-8 because no byte can have a
value in the range x'F5' to x'FF':
x'6162D0B0E4BA8CF5646364'
checkUTF-8-validity failure:
The UTF-8 representation is not valid, starting at byte 08.
The 04th and last valid code point starts at byte 05 for 03 bytes.
The following code fragment illustrates checking for the presence of a Unicode supplementary code point,
requiring a 4-byte representation in UTF-8:
checkUTF-8-supp.
Compute u = function USUPPLEMENTARY(UTF-8-testStr)
If u not = 0
Display ' checkUTF-8-supp hit:'
Compute v = function ULENGTH(UTF-8-testStr(1:u - 1))
Compute w = function UWIDTH(UTF-8-testStr v + 1)
Display ' The ' v 'th code point of the string'
', starting at byte ' u ','
Display ' is a Unicode supplementary code point, '
'width ' w ' bytes.'
End-if.
In the following string, the sequence x'F0908C82' is a supplementary character (as is any valid UTF-8
sequence beginning with a byte in the range x'F0' to x'F4'):
x'6162D0B0E4BA8CF0908C826364'
154 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
The output from checkUTF-8-supp for this string is as follows:
checkUTF-8-supp hit:
The 04th code point of the string, starting at byte 08,
is a Unicode supplementary code point, width 04 bytes.
Related references
“CODEPAGE” on page 353
Program initials
Program toHex
Identification division.
Program-id. toHex.
Data division.
Working-storage section.
1 hexv.
2 pic x(32) value '000102030405060708090A0B0C0D0E0F'.
2 pic x(32) value '101112131415161718191A1B1C1D1E1F'.
2 pic x(32) value '202122232425262728292A2B2C2D2E2F'.
2 pic x(32) value '303132333435363738393A3B3C3D3E3F'.
2 pic x(32) value '404142434445464748494A4B4C4D4E4F'.
2 pic x(32) value '505152535455565758595A5B5C5D5E5F'.
2 pic x(32) value '606162636465666768696A6B6C6D6E6F'.
156 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
2 pic x(32) value '707172737475767778797A7B7C7D7E7F'.
2 pic x(32) value '808182838485868788898A8B8C8D8E8F'.
2 pic x(32) value '909192939495969798999A9B9C9D9E9F'.
2 pic x(32) value 'A0A1A2A3A4A5A6A7A8A9AAABACADAEAF'.
2 pic x(32) value 'B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF'.
2 pic x(32) value 'C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF'.
2 pic x(32) value 'D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF'.
2 pic x(32) value 'E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF'.
2 pic x(32) value 'F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF'.
1 redefines hexv.
2 hex pic xx occurs 256 times.
Local-storage section.
1 i pic 9(4) binary.
1 j pic 9(4) binary value 0.
1 jx redefines j.
2 pic x.
2 jxd pic x.
Linkage section.
1 ostr.
2 ostrv pic xx occurs 1024 times.
1 istr.
2 istrv pic x occurs 1024 times.
1 len pic 9(9) binary.
Procedure division using ostr istr value len.
If len > 1024
Display '>> Error: length ' len ' greater than toHex '
'supported maximum of 1024.'
Stop run
End-if
Perform with test before varying i from 1 by 1 until i > len
Move 0 to j
Move istrv(i) to jxd
Add 1 to j
Move hex(j) to ostrv(i)
End-perform
Goback
.
End program toHex.
Enterprise COBOL does not have explicit support for GB 18030, but does support the processing of GB
18030 characters in several ways. You can:
• Use DBCS data items to process GB 18030 characters that are represented in CCSID 1388.
• Use national data items to define and process GB 18030 characters that are represented in UTF-16,
CCSID 01200.
• Process data in any code page (including CCSID 1388 or 1392) by converting the data to
UTF-16, processing the UTF-16 data, and then converting the data back to the original code-page
representation.
When you need to process Chinese GB 18030 data that requires conversion, first convert the input data
to UTF-16 in a national data item. After you process the national data item, convert it back to Chinese
GB 18030 for output. For the conversions, use the intrinsic functions NATIONAL-OF and DISPLAY-OF,
respectively, and specify code page 1388 or 1392 as the second argument of each function.
The following example illustrates these conversions:
Related references
“Storage of character data” on page 139
Related tasks
“Defining DBCS data” on page 158
“Using DBCS literals” on page 159
“Testing for valid DBCS characters” on page 159
“Processing alphanumeric data items that contain DBCS data” on page 160
Appendix B, “Converting double-byte
character set (DBCS) data,” on page 803
Related references
“DBCS” on page 360
You can specify a DBCS data item by using the USAGE DISPLAY-1 clause. When you use PICTURE
symbol G, you must specify USAGE DISPLAY-1. When you use PICTURE symbol N but omit the USAGE
clause, USAGE DISPLAY-1 or USAGE NATIONAL is implied depending on the setting of the NSYMBOL
compiler option.
If you use a VALUE clause with the USAGE clause in the definition of a DBCS item, you must specify a
DBCS literal or the figurative constant SPACE or SPACES.
For the purpose of handling reference modifications, each character in a DBCS data item is considered to
occupy the number of bytes that corresponds to the code-page width (that is, 2).
Related references
“NSYMBOL” on page 387
158 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Using DBCS literals
You can use the prefix N or G to represent a DBCS literal.
That is, you can specify a DBCS literal in either of these ways:
• N'dbcs characters' (provided that the compiler option NSYMBOL(DBCS) is in effect)
• G'dbcs characters'
You can use quotation marks (") or apostrophes (') as the delimiters of a DBCS literal irrespective of the
setting of the APOST or QUOTE compiler option. You must code the same opening and closing delimiter for
a DBCS literal.
The shift-out (SO) control character X'0E' must immediately follow the opening delimiter, and the
shift-in (SI) control character X'0F' must immediately precede the closing delimiter.
In addition to DBCS literals, you can use alphanumeric literals to specify any character in one of the
supported code pages. However, any string of DBCS characters that is within an alphanumeric literal must
be delimited by the SO and SI characters, and the DBCS compiler option must be in effect for the SO and
SI characters to be recognized as shift codes.
You cannot continue an alphanumeric literal that contains DBCS characters. The length of a DBCS literal is
likewise limited by the available space in Area B on a single source line. The maximum length of a DBCS
literal is thus 28 double-byte characters.
An alphanumeric literal that contains DBCS characters is processed byte by byte, that is, with semantics
appropriate for single-byte characters, except when it is converted explicitly or implicitly to national data
representation, as for example in an assignment to or comparison with a national data item.
Related tasks
“Using figurative constants” on page 26
Related references
“APOST/QUOTE” on page 347
“DBCS” on page 360
“NSYMBOL” on page 387
DBCS literals (Enterprise COBOL for z/OS Language Reference)
The Kanji class test is done by checking characters for the range X'41' through X'7E' in the first byte
and X'41' through X'FE' in the second byte, plus the space character X'4040'.
The DBCS class test tests for valid graphic characters for the code page.
The DBCS class test is done by checking characters for the range X'41' through X'FE' in both the first
and second byte of each character, plus the space character X'4040'.
Related tasks
“Coding conditional expressions” on page 95
Related references
Class condition (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Joining data items (STRING)” on page 103
“Splitting data items (UNSTRING)” on page 105
“Referring to substrings of data items” on page 109
“Converting to or from national (Unicode) representation” on page 134
160 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Chapter 8. Processing files
Processing data is an essential part of every program. Your program retrieves information, processes it as
you request, and then produces the results.
The source of the information and the target for the results can be one or more of the following items:
• Another program
• Hierarchical or relational database
• Messages from subsystem software
• Direct-access storage device
• Magnetic tape
• Printer
• Terminal
• Card reader or punch
The information as it exists on an external device might be in a physical record or block, a collection of
information that is handled as a unit by the system during input or output operations.
Your COBOL program does not directly handle physical records. It processes logical records. A logical
record can correspond to a complete physical record, part of a physical record, or to parts or all of one or
more physical records. Your COBOL program handles logical records exactly as you have defined them.
In COBOL, a collection of logical records is a file, a sequence of pieces of information that your program
can process.
Related concepts
“File organization and input-output devices” on page 161
Related tasks
“Choosing file organization and access mode” on page 162
“Allocating files” on page 164
“Checking for input or output errors” on page 165
Related tasks
“Allocating files” on page 164
Chapter 9, “Processing QSAM files,” on page 167
Chapter 10, “Processing VSAM files,” on page 189
Chapter 11, “Processing line-sequential files,” on page 215
“Choosing file organization and access mode” on page 162
162 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
• If an application accesses records (whether fixed-length or variable-length) only sequentially and does
not insert records between existing records, a QSAM or VSAM sequential file is the simplest type.
• If you are developing an application for z/OS UNIX file system that sequentially accesses records that
contain only printable characters and certain control characters, line-sequential files work best.
• If an application requires both sequential and random access (whether records are fixed length or
variable length), a VSAM indexed file is the most flexible type.
• If an application inserts and deletes records randomly, a relative file works well.
Consider the following guidelines when choosing access mode:
• If a large percentage of a file is referenced or updated in an application, sequential access is faster than
random or dynamic access.
• If a small percentage of records is processed during each run of an application, use random or dynamic
access.
Table 19. Summary of file organizations, access modes, and record formats of COBOL files
File organization Sequential Random Dynamic Fixed length Variable
access access access length
QSAM (physical sequential) X X X
Line sequential X X1 X
VSAM sequential (ESDS) X X X
VSAM indexed (KSDS) X X X X X
VSAM relative (RRDS) X X X X X
1. The data itself is in variable format but can be read into and written from COBOL fixed-length
records.
Related references
“Format for coding input and output” on page 163
“Control characters in line-sequential files” on page 216
IDENTIFICATION DIVISION.
. . .
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT filename ASSIGN TO assignment-name (1) (2)
ORGANIZATION IS org ACCESS MODE IS access (3) (4)
FILE STATUS IS file-status (5)
. . .
DATA DIVISION.
FILE SECTION.
FD filename
01 recordname (6)
nn . . . fieldlength & type (7) (8)
nn . . . fieldlength & type
. . .
WORKING-STORAGE SECTION
01 file-status PICTURE 99.
. . .
PROCEDURE DIVISION.
. . .
OPEN iomode filename (9)
. . .
READ filename
Related tasks
Chapter 9, “Processing QSAM files,” on page 167
Chapter 10, “Processing VSAM files,” on page 189
Chapter 11, “Processing line-sequential files,” on page 215
Allocating files
For any type of file (sequential, line sequential, indexed, or relative) in your z/OS or z/OS UNIX
applications, you can define the external name with either a ddname or an environment-variable name.
The external name is the name in the assignment-name of the ASSIGN clause.
If the file is in the z/OS UNIX file system, you can use either a DD definition or an environment variable to
define the file by specifying its path name with the PATH keyword.
The environment-variable name must be uppercase. The allowable attributes for its value depend on the
organization of the file being defined.
164 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Because you can define the external name in either of two ways, the COBOL run time goes through the
following steps to find the definition of the file:
1. If the ddname is explicitly allocated, it is used. The definition can be from a DD statement in JCL, an
ALLOCATE command from TSO/E, or a user-initiated dynamic allocation.
2. If the ddname is not explicitly allocated and an environment variable of the same name is set, the
value of the environment variable is used.
The file is dynamically allocated using the attributes specified by the environment variable. At a
minimum, you must specify either the PATH() or DSN() option. All options and attributes must be in
uppercase, except for the path-name suboption of the PATH option, which is case sensitive. You cannot
specify a temporary data-set name in the DSN() option.
File status code 98 results from any of the following cases:
• The contents (including a value of null or all blanks) of the environment variable are not valid.
• The dynamic allocation of the file fails.
• The dynamic deallocation of the file fails.
The COBOL run time checks the contents of the environment variable at each OPEN statement. If
a file with the same external name was dynamically allocated by a previous OPEN statement, and
the contents of the environment variable have changed since that OPEN, the run time dynamically
deallocates the previous allocation and reallocates the file using the options currently set in the
environment variable. If the contents of the environment variable have not changed, the run time uses
the current allocation.
3. If neither a ddname nor an environment variable is defined, the following steps occur:
a) If the allocation is for a QSAM file and the CBLQDA runtime option is in effect, CBLQDA dynamic
allocation processing takes place for those eligible files. This type of "implicit" dynamic allocation
persists for the life of the run unit and cannot be reallocated.
b) Otherwise, the allocation fails.
The COBOL run time deallocates all dynamic allocations at run unit termination, except for implicit
CBLQDA allocations.
Related tasks
“Setting and accessing environment variables” on page 526
“Defining and allocating QSAM files” on page 180
“Dynamically creating QSAM files” on page 177
“Allocating VSAM files” on page 208
Related tasks
“Handling errors in input and output operations” on page 243
“Coding ERROR declaratives” on page 246
“Using file status keys” on page 247
Related concepts
z/OS DFSMS: Using Data Sets (Access methods)
Related tasks
“Defining QSAM files and records in COBOL” on page 167
“Coding input and output statements for QSAM files” on page 176
“Handling errors in QSAM files” on page 179
“Working with QSAM files” on page 180
“Accessing z/OS UNIX files
using QSAM” on page 186
“Processing QSAM ASCII files on tape” on page 187
FILE-CONTROL.
SELECT COMMUTER-FILE-MST
ASSIGN TO S-COMMUTR
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.
The ASSIGN clause name can include an S- before the external name to document that the file is a QSAM
file. Both the ORGANIZATION and ACCESS MODE clauses are optional.
Related tasks
“Establishing record formats” on page 168
“Setting block sizes” on page 174
FILE SECTION.
FD COMMUTER-FILE-MST
RECORDING MODE IS F
BLOCK CONTAINS 0 RECORDS
RECORD CONTAINS 80 CHARACTERS.
01 COMMUTER-RECORD-MST.
05 COMMUTER-NUMBER PIC X(16).
05 COMMUTER-DESCRIPTION PIC X(64).
A recording mode of S is not supported for files in the z/OS UNIX file system. The above example is
appropriate for such a file.
Related concepts
“Logical records” on page 168
Related tasks
“Requesting fixed-length
format” on page 168
“Requesting variable-length format” on page 170
“Requesting spanned format” on page 171
“Requesting undefined format” on page 173
“Defining QSAM files and records in COBOL” on page 167
Related references
“FILE SECTION entries” on page 12
Logical records
COBOL uses the term logical record in a slightly different way than z/OS QSAM.
For format-V and format-S files, a QSAM logical record includes a 4-byte prefix in front of the user data
portion of the record that is not included in the definition of a COBOL logical record.
For format-F and format-U files, and for byte-stream files in the z/OS UNIX file system, the definitions of
QSAM logical record and COBOL logical record are identical.
In this information, QSAM logical record refers to the QSAM definition, and logical record refers to the
COBOL definition.
Related references
“Layout of format-F records” on page 169
“Layout of format-V records” on page 171
“Layout of format-S records” on page 173
“Layout of format-U
records” on page 174
168 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
• Use the RECORD CONTAINS integer clause (format-1 RECORD clause) to indicate the length of the
record in bytes.
When you use this clause, the file is always fixed format with record length integer even if there are
multiple level-01 record description entries with different lengths associated with the file.
• Omit the RECORD CONTAINS integer clause, but code the same fixed size and no OCCURS DEPENDING
ON clause for all level-01 record description entries associated with the file. This fixed size is the record
length.
In an unblocked format-F file, the logical record is the same as the block.
In a blocked format-F file, the number of logical records in a block (the blocking factor) is constant for
every block in the file except the last block, which might be shorter.
Files in the z/OS UNIX file system are never blocked.
Related concepts
“Logical records” on page 168
Related tasks
“Requesting variable-length format” on page 170
“Requesting spanned format” on page 171
“Requesting undefined format” on page 173
“Establishing record formats” on page 168
Related references
“Layout of format-F records” on page 169
Related concepts
“Logical records” on page 168
Related tasks
“Requesting fixed-length
format” on page 168
z/OS DFSMS: Using Data Sets (Fixed-length record formats)
Related references
“Layout of format-V records” on page 171
“Layout of format-S records” on page 173
“Layout of format-U
records” on page 174
Related tasks
“Requesting fixed-length
format” on page 168
“Requesting spanned format” on page 171
“Requesting undefined format” on page 173
“Establishing record formats” on page 168
Related references
“FILE SECTION entries” on page 12
“Layout of format-V records” on page 171
Enterprise COBOL for z/OS Migration Guide (Moving from the
VS COBOL II run time)
170 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Layout of format-V records
Format-V QSAM records have control fields that precede the data. The QSAM logical record length is
determined by adding 4 bytes (for the control fields) to the record length defined in your program.
However, you must not include these 4 bytes in the description of the record and record length.
CC
The first 4 bytes of each block contain control information.
LL Represents 2 bytes designating the length of the block (including the CC field).
BB Represents 2 bytes reserved for system use.
cc
The first 4 bytes of each logical record contain control information.
ll Represents 2 bytes designating the logical record length (including the cc field).
bb Represents 2 bytes reserved for system use.
The block length is determined as follows:
• Unblocked format-V records: CC + cc + the data portion
• Blocked format-V records: CC + the cc of each record + the data portion of each record
The operating system provides the control bytes when the file is written; the control byte fields do not
appear in the description of the logical record in the DATA DIVISION of your program. COBOL allocates
input and output buffers that are large enough to accommodate the control bytes. These control fields
in the buffer are not available for you to use in your program. When variable-length records are written
on unit record devices, control bytes are neither printed nor punched. They appear however on other
external storage devices, as well as in buffer areas of storage. If you move V-mode records from an input
buffer to a WORKING-STORAGE area, the records will be moved without the control bytes.
Files in the z/OS UNIX file system are never blocked.
Related concepts
“Logical records” on page 168
Related tasks
“Requesting variable-length format” on page 170
Related references
“Layout of format-F records” on page 169
“Layout of format-S records” on page 173
“Layout of format-U
records” on page 174
Related concepts
“Logical records” on page 168
“Spanned blocked and
unblocked files” on page 172
Related tasks
“Requesting fixed-length
format” on page 168
“Requesting variable-length format” on page 170
“Requesting undefined format” on page 173
“Establishing record formats” on page 168
Related references
“FILE SECTION entries” on page 12
“Layout of format-S records” on page 173
Related concepts
“Logical records” on page 168
Related tasks
“Requesting spanned format” on page 171
172 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Layout of format-S records
Spanned records are preceded by control fields, as explained below.
Each block is preceded by a 4-byte block descriptor field ('BDF' in the image above). There is only one
block descriptor field at the beginning of each physical block.
Each segment of a record in a block is preceded by a 4-byte segment descriptor field ('SDF' in the image)
even if the segment is the entire record. There is one segment descriptor field for each record segment
in the block. The segment descriptor field also indicates whether the segment is the first, the last, or an
intermediate segment.
You do not describe these fields in the DATA DIVISION, and the fields are not available for you to use in
your COBOL program.
Related tasks
“Requesting spanned format” on page 171
Related references
“Layout of format-F records” on page 169
“Layout of format-V records” on page 171
“Layout of format-U
records” on page 174
Related tasks
“Requesting fixed-length
format” on page 168
“Requesting variable-length format” on page 170
“Requesting spanned format” on page 171
“Establishing record formats” on page 168
Related references
“FILE SECTION entries” on page 12
“Layout of format-U
records” on page 174
Related concepts
“Logical records” on page 168
Related tasks
“Requesting undefined format” on page 173
Related references
“Layout of format-F records” on page 169
“Layout of format-V records” on page 171
“Layout of format-S records” on page 173
174 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Letting z/OS determine block size: To maximize performance, do not explicitly set the block size for
a blocked file in your COBOL source program. For new blocked data sets, it is simpler to allow z/OS to
supply a system-determined block size. To use this feature, follow these guidelines:
• Code BLOCK CONTAINS 0 in your source program or compile with the BLOCK0 option. For details
about BLOCK0, see “BLOCK0” on page 350.
• Do not code RECORD CONTAINS 0 in your source program.
• Do not code a BLKSIZE value in the JCL DD statement.
Setting block size explicitly: If you prefer to set a block size explicitly, your program will be most flexible
if you follow these guidelines:
• Code BLOCK CONTAINS 0 in your source program or compile with the BLOCK0 option.
• Code a BLKSIZE value in the ddname definition (the JCL DD statement).
For extended-format data sets on z/OS, z/OS DFSMS adds a 32-byte block suffix to the physical record.
If you specify a block size explicitly (using JCL or ISPF), do not include the size of this block suffix in
the block size. This block suffix is not available for you to use in your program. z/OS DFSMS allocates
the space used to read in the block suffix. However, when you calculate how many blocks of an extended-
format data set will fit on a track of a direct-access device, you need to include the size of the block suffix
in the block size.
If you specify a block size that is larger than 32760 directly in the BLOCK CONTAINS clause or indirectly
with the use of BLOCK CONTAINS n RECORDS, the OPEN of the data set fails with file status code 90
unless you define the data set to be on tape.
For existing blocked data sets, it is simplest to:
• Code BLOCK CONTAINS 0 in your source program or compile with the BLOCK0 option.
• Not code a BLKSIZE value in the ddname definition.
When you omit the BLKSIZE from the ddname definition, the block size is automatically obtained by the
system from the data-set label.
Taking advantage of LBI: You can improve the performance of tape data sets by using the large block
interface (LBI) for large block sizes. When the LBI is available, the COBOL run time automatically uses this
facility for those tape files for which you use system-determined block size. LBI is also used for those files
for which you explicitly define a block size in JCL or a BLOCK CONTAINS clause. Use of the LBI allows
block sizes to exceed 32760 if the tape device supports it.
The LBI is not used in all cases. An attempt to use a block size greater than 32760 in the following cases
is diagnosed at compile time or results in a failure at OPEN:
• Spanned records
• OPEN I-O
Using a block size that exceeds 32760 might result in your not being able to read the tape on another
system. A tape that you create with a block size greater than 32760 can be read only on a system that has
a tape device that supports block sizes greater than 32760. If you specify a block size that is too large for
the file, the device, or the operating system level, a runtime message is issued.
To limit a system-determined block size to 32760, do not specify BLKSIZE anywhere, and set one of the
following items to 32760:
• The BLKSZLIM keyword on the DD statement for the data set
• BLKSZLIM for the data class by using the BLKSZLIM keyword (must be set by your systems
programmer)
• A block-size limit for the system in the DEVSUPxx member of SYS1.PARMLIB by using the keyword
TAPEBLKSZLIM (must be set by your systems programmer)
The block-size limit is the first nonzero value that the compiler finds by checking these items.
Related tasks
“Defining QSAM files and records in COBOL” on page 167
z/OS DFSMS: Using Data Sets
Related references
“FILE SECTION entries” on page 12
“BLOCK0” on page 350
BLOCK CONTAINS clause (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Opening QSAM files” on page 177
“Dynamically creating QSAM files” on page 177
“Adding records to QSAM files” on page 178
“Updating QSAM files” on page 178
“Writing QSAM files to a printer or spooled data set” on page 178
“Closing QSAM files” on page 179
176 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Related references
OPEN statement (Enterprise COBOL for z/OS Language Reference)
READ statement (Enterprise COBOL for z/OS Language Reference)
WRITE statement (Enterprise COBOL for z/OS Language Reference)
REWRITE statement (Enterprise COBOL for z/OS Language Reference)
CLOSE statement (Enterprise COBOL for z/OS Language Reference)
File status key (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Dynamically creating QSAM files” on page 177
“Ensuring that file attributes match your program” on page 183
Related references
OPEN statement (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Opening QSAM files” on page 177
Related references
READ statement (Enterprise COBOL for z/OS Language Reference)
WRITE statement (Enterprise COBOL for z/OS Language Reference)
You cannot open as I-O an extended format data set that you allocate in compressed format.
Related references
REWRITE statement (Enterprise COBOL for z/OS Language Reference)
Controlling the page size: Use the LINAGE clause of the FD entry to control the size of your printed page:
the number of lines in the top and bottom margins and in the footing area of the page. When you use the
LINAGE clause, COBOL handles the file as if you had also requested the ADV compiler option.
If you use the LINAGE clause in combination with WRITE BEFORE|AFTER ADVANCING nn LINES, be
careful about the values you set. With the ADVANCING nn LINES phrase, COBOL first calculates the
sum of LINAGE-COUNTER plus nn. Subsequent actions depend on the size of nn. The END-OF-PAGE
imperative phrase is performed after the LINAGE-COUNTER is increased. Consequently, the LINAGE-
COUNTER could be pointing to the next logical page instead of to the current footing area when the
END-OF-PAGE phrase is performed.
AT END-OF-PAGE or NOT AT END-OF-PAGE imperative phrases are performed only if the write
operation completes successfully. If the write operation is unsuccessful, control is passed to the end
of the WRITE statement, and all conditional phrases are omitted.
Controlling the vertical positioning of records: Use the WRITE ADVANCING statement to control the
vertical positioning of each record you write on a printed page.
178 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
BEFORE ADVANCING prints the record before the page is advanced. AFTER ADVANCING prints the record
after the page is advanced.
Specify the number of lines the page is advanced with an integer (or an identifier with a mnemonic-name)
following ADVANCING. If you omit the ADVANCING phrase from a WRITE statement, the effect is as if you
had coded:
Related references
WRITE statement (Enterprise COBOL for z/OS Language Reference)
Related references
CLOSE statement (Enterprise COBOL for z/OS Language Reference)
COBOL provides these ways for you to intercept and handle certain QSAM input and output errors:
• End-of-file phrase (AT END)
• EXCEPTION/ERROR declarative
• FILE STATUS clause
Related tasks
“Handling errors in input and output operations” on page 243
Related references
“Allocation of buffers for QSAM files” on page 186
180 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
You can use either an environment variable or a DD definition to define a file in the z/OS UNIX file system.
To do so, define one of the following items with a name that matches the external name in the ASSIGN
clause:
• A DD allocation that uses PATH='absolute-path-name' and FILEDATA=BINARY
• An environment variable with a value PATH(pathname), where pathname is an absolute path name
(starting with /)
For compatibility with releases of COBOL before COBOL for OS/390 & VM 2.2, you can also specify
FILEDATA=TEXT when using a DD allocation for z/OS UNIX files, but this use is not recommended. To
process text files in the z/OS UNIX file system, use LINE SEQUENTIAL organization. If you do use QSAM
to process text files in the z/OS UNIX file system, you cannot use environment variables to define the files.
When you define a QSAM file, use the parameters as shown below.
Some of the information about the QSAM file must always be coded in the FILE-CONTROL paragraph, the
FD entry, and other COBOL clauses. Other information must be coded in the DD statement or environment
variable for output files. For input files, the system can obtain information from the file label (for standard
label files). If DCB information is provided in the DD statement for input files, it overrides information on
the data-set label. For example, the amount of space allocated for a new direct-access device file can be
set in the DD statement by the SPACE parameter.
You cannot express certain characteristics of QSAM files in the COBOL language, but you can code them in
the DD statement for the file by using the DCB parameter. Use the subparameters of the DCB parameter to
provide information that the system needs for completing the data set definition, including the following
items:
• Block size (BLKSIZE=), if BLOCK CONTAINS 0 RECORDS or BLOCK0 option was specified at compile
time (recommended)
• Options to be executed if an error occurs in reading or writing a record
• TRACK OVERFLOW or standard blocks
• Mode of operation for a card reader or punch
Related tasks
“Setting block sizes” on page 174
“Defining QSAM files and records in COBOL” on page 167
“Allocating files” on page 164
Related references
“BLOCK0” on page 350
“Parameters for creating
QSAM files” on page 182
MVS Program Management: User's Guide and Reference
Related tasks
“Defining and allocating QSAM files” on page 180
182 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Noncataloged files
Some information is stored in the file label, but you must code the unit and volume information, and
the dsname and disposition.
If you are using JCL, and you created the file in the current job step or in a previous job step in the current
job, you can refer to the previous DD statement for most of the data set information. You do, however,
need to code DSNAME and DISP.
Related references
“Parameters for retrieving
QSAM files” on page 183
Related tasks
“Retrieving QSAM files” on page 182
If you have not made a file available with a DD statement or a TSO ALLOCATE command, and your COBOL
program specifies that the file be created, Enterprise COBOL dynamically allocates the file. When the file
is opened, the file attributes that are coded in your program are used. You do not have to worry about file
attribute conflicts.
Remember that information in the JCL or environment variable overrides information in the data-set label.
Related tasks
“Processing existing files” on page 184
Related references
“FILE SECTION entries” on page 12
The easiest way to define variable-length (format-V) records in a program is to use the RECORD IS
VARYING FROM integer-1 TO integer-2 clause in the FD entry and set an appropriate value for integer-2.
Express® the integer sizes in bytes regardless of the underlying USAGE of the data items in the record. For
example, assume that you determine that the length attribute of the data set is 104 bytes (LRECL=104).
Remembering that the maximum record length is determined from the RECORD IS VARYING clause and
not from the level-01 record descriptions, you could define a format-V file in your program with this code:
FILE SECTION.
FD COMMUTER-FILE-MST
RECORDING MODE IS V
RECORD IS VARYING FROM 4 TO 100 CHARACTERS.
01 COMMUTER-RECORD-A PIC X(4).
01 COMMUTER-RECORD-B PIC X(75).
Assume that the existing file in the previous example was format-U instead of format-V. If the 104 bytes
are all user data, you could define the file in your program with this code:
FILE SECTION.
FD COMMUTER-FILE-MST
RECORDING MODE IS U
RECORD IS VARYING FROM 4 TO 104 CHARACTERS.
01 COMMUTER-RECORD-A PIC X(4).
01 COMMUTER-RECORD-B PIC X(75).
To define fixed-length records in your program, either code the RECORD CONTAINS integer clause, or
omit this clause and code all level-01 record descriptions to be the same fixed size. In either case, use a
value that equals the value of the length attribute of the data set. If you intend to use the same program
to process different files at run time, and those files have differing fixed lengths, avoid record-length
conflicts by coding RECORD CONTAINS 0.
If the existing file is an ASCII data set (DCB=(OPTCD=Q)), you must use the CODE-SET clause in the FD
entry for the file.
Related tasks
“Processing new files” on page 185
“Requesting fixed-length
format” on page 168
“Requesting variable-length format” on page 170
“Requesting undefined format” on page 173
“Opening QSAM files” on page 177
184 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Related references
“FILE SECTION entries” on page 12
FILE SECTION.
FD COMMUTER-FILE-MST
RECORDING MODE IS V
RECORD CONTAINS 10 TO 50 CHARACTERS.
01 COMMUTER-RECORD-A PIC X(10).
01 COMMUTER-RECORD-B PIC X(50).
Related tasks
“Processing existing files” on page 184
“Requesting fixed-length
format” on page 168
“Requesting variable-length format” on page 170
“Requesting undefined format” on page 173
“Opening QSAM files” on page 177
“Dynamically creating QSAM files” on page 177
Related references
“FILE SECTION entries” on page 12
Related tasks
z/OS DFSMS: Using Data Sets
Related concepts
“Storage and its addressability” on page 39
Related tasks
“Using striped extended-format QSAM data sets” on page 185
186 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
– Record-length conflict
– Record-type conflict (fixed as opposed to variable)
• A READ returns the number of bytes of the maximum logical record size for the file except for the last
record, which might be shorter.
For example, suppose that a file definition has level-01 record descriptions of 3, 5, and 10 bytes long,
and you write the following three records: 'abc', 'defgh', and 'ijklmnopqr', in that order. The first READ of
this file returns 'abcdefghij', the second READ returns 'klmnopqr ', and the third READ results in the AT
END condition.
For compatibility with releases of IBM COBOL before COBOL for OS/390 & VM 2.2, you can also specify
FILEDATA=TEXT when using a DD allocation for z/OS UNIX files, but this use is not recommended. To
process text files in the z/OS UNIX file system, use LINE SEQUENTIAL organization. If you use QSAM to
process text files in the z/OS UNIX file system, you cannot use environment variables to define the files.
Related tasks
“Allocating files” on page 164
“Defining and allocating QSAM files” on page 180
z/OS DFSMS: Using Data Sets (Using HFS data sets)
ALPHABET-NAME IS STANDARD-1
CODE-SET IS ALPHABET-NAME
Defining the record formats: Process QSAM ASCII tape files with any of these record formats:
• Fixed length (format F)
• Undefined (format U)
• Variable length (format V)
If you use variable-length records, you cannot explicitly code format D; instead, code RECORDING MODE
V. The format information is internally converted to D mode. D-mode records have a 4-byte record
descriptor for each record.
Defining the ddname: Under z/OS, processing ASCII files requires special JCL coding. Code these
subparameters of the DCB parameter in the DD statement:
BUFOFF=[L|n]
L
A 4-byte block prefix that contains the block length (including the block prefix)
n
The length of the block prefix:
n
The size of the block, including the length of the block prefix
LABEL=[AL|AUL|NL]
AL
American National Standard (ANS) labels
AUL
ANS and user labels
NL
No labels
OPTCD=Q
Q
This value is required for ASCII files and is the default if the file is created using Enterprise COBOL.
Related references
z/OS DFSMS: Using Data Sets (Character data conversion)
188 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Chapter 10. Processing VSAM files
Virtual storage access method (VSAM) is an access method for files on direct-access storage devices.
With VSAM you can load files, retrieve records from files, update files, and add, replace, and delete
records in files.
VSAM processing has these advantages over QSAM:
• Protection of data against unauthorized access
• Compatibility across systems
• Independence of devices (no need to be concerned with block size and other control information)
• Simpler JCL (information needed by the system is provided in integrated catalogs)
• Ability to use indexed file organization or relative file organization
The following table shows how VSAM terms differ from COBOL terms and other terms that you might be
familiar with.
The term file in this VSAM documentation refers to either a COBOL file or a VSAM data set.
If you have complex requirements or frequently use VSAM, see the VSAM publications for your operating
system.
Related concepts
“VSAM files” on page 190
Related tasks
“Defining VSAM file organization and records” on page 191
“Coding input and output statements for VSAM files” on page 196
“Handling errors in VSAM files” on page 204
“Protecting VSAM files with a password” on page 204
“Working with VSAM data sets under z/OS and z/OS UNIX” on page 205
“Improving VSAM performance” on page 211
VSAM files
The physical organization of VSAM data sets differs considerably from the organizations used by other
access methods.
VSAM data sets are held in control intervals (CI) and control areas (CA). The size of the CI and CA is
normally determined by the access method; and the way in which they are used is not visible to you.
You can use three types of file organization with VSAM:
VSAM sequential file organization
(Also referred to as VSAM ESDS (entry-sequenced data set) organization.) In VSAM sequential file
organization, the records are stored in the order in which they were entered.
VSAM entry-sequenced data sets are equivalent to QSAM sequential files. The order of the records is
fixed.
VSAM indexed file organization
(Also referred to as VSAM KSDS (key-sequenced data set) organization.) In a VSAM indexed file
(KSDS), the records are ordered according to the collating sequence of an embedded prime key field,
which you define. The prime key consists of one or more consecutive characters in the records. The
prime key uniquely identifies the record and determines the sequence in which it is accessed with
respect to other records. A prime key for a record might be, for example, an employee number or an
invoice number.
VSAM relative file organization
(Also referred to as VSAM fixed-length or variable-length RRDS (relative-record data set) organization.)
A VSAM relative-record data set (RRDS) contains records ordered by their relative key. The relative key
is the relative record number, which represents the location of the record relative to where the file
begins. The relative record number identifies the fixed- or variable-length record.
In a VSAM fixed-length RRDS, records are placed in a series of fixed-length slots in storage. Each
slot is associated with a relative record number. For example, in a fixed-length RRDS that contains 10
slots, the first slot has a relative record number of 1, and the tenth slot has a relative record number of
10.
In a VSAM variable-length RRDS, the records are ordered according to their relative record number.
Records are stored and retrieved according to the relative record number that you set.
Throughout this information, the term VSAM relative-record data set (or RRDS) is used to mean both
relative-record data sets with fixed-length records and with variable-length records, unless they need
to be differentiated.
The following table compares the characteristics of the different types of VSAM data sets.
190 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 23. Comparison of VSAM data-set types (continued)
Characteristic Entry-sequenced data Key-sequenced data set Relative-record data set
set (ESDS) (KSDS) (RRDS)
Alternate indexes Can have one or Can have one or more Cannot have alternate
more alternate indexes, alternate indexes indexes
although not supported in
COBOL
Relative byte RBA cannot change. RBA can change. RRN cannot change.
address (RBA) and
relative record
number (RRN) of a
record
Space for adding Uses space at the end of Uses distributed free space For fixed-length RRDS, uses
records the data set for inserting records and empty slots in the data set
changing their lengths in
For variable-length RRDS,
place
uses distributed free space
and changes the lengths of
added records in place
Space from deleting You cannot delete a Space from a deleted Space from a deleted record
records record, but you can reuse or shortened record is can be reused.
its space for a record of automatically reclaimed in a
the same length. control interval.
Spanned records Can have spanned records Can have spanned records Cannot have spanned records
Reuse as work file Can be reused unless it Can be reused unless it Can be reused
has an alternate index, has an alternate index, is
is associated with key associated with key ranges,
ranges, or exceeds 123 or exceeds 123 extents per
extents per volume volume
Related tasks
“Specifying sequential organization for VSAM files” on page 192
“Specifying indexed organization for VSAM files” on page 192
“Specifying relative organization for VSAM files” on page 193
“Defining VSAM files” on page 205
Table 24. VSAM file organization, access mode, and record format
File organization Sequential Random Dynamic Fixed length Variable
access access access length
VSAM sequential (ESDS) Yes No No Yes Yes
Related tasks
“Specifying sequential organization for VSAM files” on page 192
“Specifying indexed organization for VSAM files” on page 192
“Specifying relative organization for VSAM files” on page 193
“Specifying access modes for VSAM files” on page 194
“Defining record lengths for VSAM files” on page 195
“Using file status keys” on page 247
“Using VSAM status codes (VSAM files only)” on page 248
“Defining VSAM files” on page 205
SELECT S-FILE
ASSIGN TO SEQUENTIAL-AS-FILE
ORGANIZATION IS SEQUENTIAL
ACCESS IS SEQUENTIAL
FILE STATUS IS FSTAT-CODE VSAM-CODE.
Related concepts
“VSAM files” on page 190
In the example above, data-name is the name of the prime key field as you define it in the record
description entry in the DATA DIVISION. The prime key data item can be class alphabetic, alphanumeric,
DBCS, numeric, national, or UTF-8. If it has USAGE NATIONAL, the prime key can be category national,
or can be a national-edited, numeric-edited, national decimal, or national floating-point data item. The
collation of record keys is based on the binary value of the keys regardless of the class or category of the
keys.
The following example shows the statements for a VSAM indexed file (KSDS) that is accessed dynamically.
In addition to the primary key, COMMUTER-NO, an alternate key, LOCATION-NO, is specified:
SELECT I-FILE
ASSIGN TO INDEXED-FILE
ORGANIZATION IS INDEXED
ACCESS IS DYNAMIC
RECORD KEY IS IFILE-RECORD-KEY
192 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
ALTERNATE RECORD KEY IS IFILE-ALTREC-KEY
FILE STATUS IS FSTAT-CODE VSAM-CODE.
Related concepts
“VSAM files” on page 190
Related tasks
“Using alternate keys” on page 193
“Using an alternate index” on page 193
Related references
RECORD KEY clause (Enterprise COBOL for z/OS Language Reference)
Classes and categories of data (Enterprise COBOL for z/OS Language Reference)
In the example above, data-name is the name of the alternate key field as you define it in the record
description entry in the DATA DIVISION. Alternate key data items, like prime key data items, can be
class alphabetic, alphanumeric, DBCS, numeric, national, or UTF-8. The collation of alternate keys is
based on the binary value of the keys regardless of the class or category of the keys.
Related tasks
“Creating alternate indexes” on page 206
SELECT R-FILE
ASSIGN TO RELATIVE-FILE
ORGANIZATION IS RELATIVE
ACCESS IS RANDOM
RELATIVE KEY IS RFILE-RELATIVE-KEY
FILE STATUS IS FSTAT-CODE VSAM-CODE.
You can use a randomizing routine to associate a key value in each record with the relative record number
for that record. Although there are many techniques to convert a record key to a relative record number,
Related concepts
“VSAM files” on page 190
“Fixed-length and variable-length RRDS” on page 194
Related tasks
“Using variable-length RRDS” on page 194
“Defining VSAM files” on page 205
Related tasks
“Defining VSAM files” on page 205
Related references
z/OS DFSMS: Access Method Services for Catalogs
Related tasks
“Reading records from a VSAM file” on page 201
194 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Example: using dynamic access with VSAM files
Suppose that you have an indexed file of employee records, and the employee's hourly wage forms the
record key.
If your program processes those employees who earn between $15.00 and $20.00 per hour and those
who earn $25.00 per hour and above, using dynamic access of VSAM files, the program would:
1. Retrieve the first record randomly (with a random-retrieval READ) based on the key of 1500.
2. Read sequentially (using READ NEXT) until the salary field exceeds 2000.
3. Retrieve the next record randomly, based on a key of 2500.
4. Read sequentially until the end of the file.
Related tasks
“Reading records from a VSAM file” on page 201
Related tasks
“Defining fixed-length
records” on page 195
“Defining variable-length
records” on page 196
Related references
“FILE SECTION entries” on page 12
Enterprise COBOL for z/OS Migration Guide
Related references
RECORD clause (Enterprise COBOL for z/OS Language Reference)
When you specify a READ INTO statement for a format-V file, the record size that is read for that file is
used in the MOVE statement generated by the compiler. Consequently, you might not get the result you
expect if the record read in does not correspond to the level-01 record description. All other rules of the
MOVE statement apply. For example, when you specify a MOVE statement for a format-V record read in by
the READ statement, the size of the record corresponds to its level-01 record description.
Related references
RECORD clause (Enterprise COBOL for z/OS Language Reference)
196 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
All of the following factors determine which input and output statements you can use for a given VSAM
data set:
• Access mode (sequential, random, or dynamic)
• File organization (ESDS, KSDS, or RRDS)
• Mode of OPEN statement (INPUT, OUTPUT, I-O, or EXTEND)
The following table shows the possible combinations of statements and open modes for sequential files
(ESDS). The X indicates that you can use a statement with the open mode shown at the top of the column.
The following table shows the possible combinations of statements and open modes that you can use
with indexed (KSDS) files and relative (RRDS) files. The X indicates that you can use the statement with
the open mode shown at the top of the column.
Table 28. I/O statements for VSAM relative and indexed files
Access mode COBOL statement OPEN INPUT OPEN OUTPUT OPEN I-O OPEN EXTEND
Sequential OPEN X X X X
WRITE X X
START X X
READ X X
REWRITE X
DELETE X
CLOSE X X X X
Random OPEN X X X
WRITE X X
START
READ X X
REWRITE X
DELETE X
CLOSE X X X
The fields that you code in the FILE STATUS clause are updated by VSAM after each input-output
statement to indicate the success or failure of the operation.
Related concepts
“File position indicator” on page 198
Related tasks
“Opening a file (ESDS, KSDS, or RRDS)” on page 198
“Reading records from a VSAM file” on page 201
“Updating records in a VSAM file” on page 201
“Adding records to a VSAM file” on page 202
“Replacing records in a VSAM file” on page 203
“Deleting records from a VSAM file” on page 203
“Closing VSAM files” on page 203
Related references
File status key (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Reading records from a VSAM file” on page 201
198 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
COBOL program. Mismatches in the following items result in a file status key 39 and the failure of the
OPEN statement:
• Attributes for file organization (sequential, relative, or indexed)
• Prime record key
• Alternate record keys
• Maximum record size
• Record type (fixed or variable)
How you code the OPEN statement for a VSAM file depends on whether the file is empty (a file that has
never contained records) or loaded. For either type of file, your program should check the file status key
after each OPEN statement.
Note: The VSAMOPENFS option affects the file status key reported from successful OPEN statements
on VSAM files. If the VSAMOPENFS(COMPAT) option is in effect, you will get the status value of 97
when a VSAM OPEN statement is successfully verified. For details about the VSAMOPENFS option, see
“VSAMOPENFS” on page 424.
Related tasks
“Opening an empty file” on page 199
“Opening a loaded file (a file with records)” on page 200
Related references
“Statements to load records into a VSAM file” on page 200
“VSAMOPENFS” on page 424
When you are loading an extended-format VSAM data set, file status 30 will occur for the OPEN if z/OS
DFSMS system-managed buffering sets the buffering to local shared resources (LSR). To successfully load
the VSAM data set in this case, specify ACCBIAS=USER in the DD AMP parameter for the VSAM data set to
bypass system-managed buffering.
Loading a VSAM data set with access method services: You can load or update a VSAM data set by
using the access method services REPRO command. Use REPRO whenever possible.
Related tasks
“Opening a loaded file (a file with records)” on page 200
Related references
“Statements to load records into a VSAM file” on page 200
z/OS DFSMS: Access Method Services for Catalogs (REPRO)
Related tasks
“Opening an empty file” on page 199
“Updating records in a VSAM file” on page 201
200 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
If you open a VSAM key-sequenced file as EXTEND, each record you add must have a record key higher
than the highest record in the file.
Related tasks
“Opening an empty file” on page 199
“Working with VSAM data sets under z/OS and z/OS UNIX” on page 205
Related references
“Statements to load records into a VSAM file” on page 200
z/OS DFSMS: Access Method Services for Catalogs
Sequentially
According to the ascending order of the key you are using, the RECORD KEY or the ALTERNATE
RECORD KEY, beginning at the current position of the file position indicator for indexed files, or
according to ascending relative record locations for relative files
Randomly
In any order, depending on how you set the RECORD KEY or ALTERNATE RECORD KEY or the
RELATIVE KEY before your READ request
Dynamically
Mixed sequential and random
With dynamic access, you can switch between reading a specific record directly and reading records
sequentially, by using READ NEXT for sequential retrieval and READ for random retrieval (by key).
When you want to read sequentially, beginning at a specific record, use START before the READ NEXT
statement to set the file position indicator to point to a particular record. When you code START followed
by READ NEXT, the next record is read and the file position indicator is reset to the next record. You can
move the file position indicator randomly by using START, but all reading is done sequentially from that
point.
When a direct READ is performed for a VSAM indexed file, based on an alternate index for which
duplicates exist, only the first record in the data set (base cluster) with that alternate key value is
retrieved. You need a series of READ NEXT statements to retrieve each of the data set records with the
same alternate key. A file status code of 02 is returned if there are more records with the same alternate
key value to be read; a code of 00 is returned when the last record with that key value has been read.
Related concepts
“File position indicator” on page 198
Related tasks
“Specifying access modes for VSAM files” on page 194
or or or
Related references
“Statements to load records into a VSAM file” on page 200
Adding records sequentially: Use ACCESS IS SEQUENTIAL and code the WRITE statement to add
records sequentially to the end of a VSAM file that has been opened with either OUTPUT or EXTEND.
Sequential files are always written sequentially.
202 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
For indexed files, you must write new records in ascending key sequence. If you open the file EXTEND,
the record keys of the records to be added must be higher than the highest primary record key on the file
when you opened the file.
For relative files, the records must be in sequence. If you include a RELATIVE KEY data item in the
SELECT clause, the relative record number of the record to be written is placed in that data item.
Adding records randomly or dynamically: When you write records to an indexed data set and ACCESS
IS RANDOM or ACCESS IS DYNAMIC, you can write the records in any order.
Related tasks
“Handling errors in input and output operations” on page 243
“Using VSAM status codes (VSAM files only)” on page 248
Related references
z/OS DFSMS Macro Instructions for Data Sets (VSAM macro return and
reason codes)
204 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
If your program only retrieves records and does not update them, you need only the read password. If
your program loads files or updates them, you need to specify the update password that was cataloged.
For indexed files, the PASSWORD data item for the RECORD KEY must contain the valid password before
the file can be successfully opened.
If you password-protect a VSAM indexed file, you must also password-protect each alternate index in
order to be fully password protected. Where you place the PASSWORD clause is important because each
alternate index has its own password. The PASSWORD clause must directly follow the key clause to which
it applies.
. . .
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT LIBFILE
ASSIGN TO PAYMAST
ORGANIZATION IS INDEXED
RECORD KEY IS EMPL-NUM
PASSWORD IS BASE-PASS
ALTERNATE RECORD KEY IS EMPL-PHONE
PASSWORD IS PATH1-PASS
. . .
WORKING-STORAGE SECTION.
01 BASE-PASS PIC X(8) VALUE "25BSREAD".
01 PATH1-PASS PIC X(8) VALUE "25ATREAD".
Working with VSAM data sets under z/OS and z/OS UNIX
Be aware of special coding considerations for VSAM files under z/OS and z/OS UNIX for access method
services (IDCAMS) commands, environment variables, and JCL.
A VSAM file is available if all of the following conditions are true:
• You define it using access method services.
• You define it for your program by providing a DD statement, an environment variable, or an ALLOCATE
command.
• It has previously contained a record.
A VSAM file is unavailable if it has never contained a record, even if you have defined the file.
You always get a return code of zero on completion of the OPEN statement for a VSAM sequential file.
Use the access method services REPRO command to empty a file. Deleting records in this manner resets
the high-use relative byte address (RBA) of the file to zero. The file is effectively empty and appears to
COBOL as if it never contained a record.
Related tasks
“Defining files to the operating system” on page 8
“Defining VSAM files” on page 205
“Creating alternate indexes” on page 206
“Allocating VSAM files” on page 208
“Sharing VSAM files through
RLS” on page 209
If you define a data set in this way, all records are padded to the fixed slot size n. If you use the RECORD
IS VARYING ON data-name form of the RECORD clause, a WRITE or REWRITE uses the length specified
in DEPENDING ON data-name as the length of the record to be transferred by VSAM. This data is then
padded to the fixed slot size. READ statements always return the fixed slot size in the DEPENDING ON
data-name.
• For VSAM variable-length relative-record data sets (RRDS), specify the average size COBOL record
expected and the maximum size COBOL record expected:
The average size COBOL record expected must be less than the maximum size COBOL record expected.
Related tasks
“Creating alternate indexes” on page 206
“Allocating VSAM files” on page 208
“Specifying relative organization for VSAM files” on page 193
Related references
z/OS DFSMS: Access Method Services for Catalogs
206 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Because an alternate index is, in practice, a VSAM data set that contains pointers to the keys of a VSAM
data set, you must define the alternate index and the alternate index path (the entity that establishes the
relationship between the alternate index and the prime index). After you define an alternate index, make a
catalog entry to establish the relationship (or path) between the alternate index and its base cluster. This
path allows you to access the records of the base cluster through the alternate keys.
To use an alternate index, do these steps:
1. Define the alternate index by using the DEFINE ALTERNATEINDEX command. In it, specify these
items:
• Name of the alternate index
• Name of its related VSAM indexed data set
• Location in the record of any alternate indexes and whether they are unique
• Whether alternate indexes are to be updated when the data set is changed
• Name of the catalog to contain this definition and its password (can use default name)
In your COBOL program, the alternate index is identified solely by the ALTERNATE RECORD KEY
clause in the FILE-CONTROL paragraph. The ALTERNATE RECORD KEY definitions must match the
definitions in the catalog entry. Any password entries that you cataloged should be coded directly after
the ALTERNATE RECORD KEY phrase.
2. Relate the alternate index to the base cluster (the data set to which the alternate index gives you
access) by using the DEFINE PATH command. In it, specify these items:
• Name of the path
• Alternate index to which the path is related
• Name of the catalog that contains the alternate index
The base cluster and alternate index are described by entries in the same catalog.
3. Load the VSAM indexed data set.
4. Build the alternate index by using (typically) the BLDINDEX command. Identify the input file as the
indexed data set (base cluster) and the output file as the alternate index or its path. BLDINDEX reads
all the records in the VSAM indexed data set (or base cluster) and extracts the data needed to build the
alternate index.
Alternatively, you can use the runtime option AIXBLD to build the alternate index at run time. However,
this option might adversely affect performance.
“Example: entries for alternate indexes” on page 207
Related tasks
“Using an alternate index” on page 193
Related references
Language Environment Programming Reference (AIXBLD (COBOL only))
(1)
The base cluster name is clustername.
(2)
The name of the first alternate index path is path1.
(3)
The name of the second alternate index path is path2.
(4)
The ddname or environment variable name for the base cluster is specified with the ASSIGN clause.
(5)
Passwords immediately follow their indexes.
(6)
The key EM-PHONE relates to the first alternate index.
(7)
The key EM-CITY relates to the second alternate index.
Related tasks
“Creating alternate indexes” on page 206
//ddname DD DSN=dsname,DISP=SHR,AMP=AMORG
export evname="DSN(dsname),SHR"
In either case, dsname must be the same as the name used in the access method services DEFINE
CLUSTER or DEFINE PATH command. DISP must be OLD or SHR because the data set is already
cataloged. If you specify MOD when using JCL, the data set is treated as OLD.
AMP is a VSAM JCL parameter that supplements the information that the program supplies about the data
set. AMP takes effect when your program opens the VSAM file. Any information that you set through the
AMP parameter takes precedence over the information that is in the catalog or that the program supplies.
The AMP parameter is required only under the following circumstances:
• You use a dummy VSAM data set. For example,
208 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
//ddname DD DUMMY,AMP=AMORG
//ddname DD DSN=VSAM.dsname,DISP=SHR,
// AMP=('BUFNI=4,BUFND=8')
You cannot specify AMP if you allocate a VSAM data set with an environment variable.
For a VSAM base cluster, specify the same system-name (ddname or environment variable name) that you
specify in the ASSIGN clause after the SELECT clause.
When you use alternate indexes in your COBOL program, you must specify not only a system-name (using
a DD statement or environment variable) for the base cluster, but also a system-name for each alternate
index path. No language mechanism exists to explicitly declare system-names for alternate index paths
within the program. Therefore, you must adhere to the following guidelines for forming the system-name
(ddname or environment variable name) for each alternate index path:
• Concatenate the base cluster name with an integer.
• Begin with 1 for the path associated with the first alternate record defined for the file in your program
(ALTERNATE RECORD KEY clause of the FILE-CONTROL paragraph).
• Increment by 1 for the path associated with each successive alternate record definition for that file.
For example, if the system-name of a base cluster is ABCD, the system-name for the first alternate index
path defined for the file in your program is ABCD1, the system-name for the second alternate index path is
ABCD2, and so on.
If the length of the base cluster system-name together with the sequence number exceeds eight
characters, the base cluster portion of the system-name is truncated on the right to reduce the
concatenated result to eight characters. For example, if the system-name of a base cluster is ABCDEFGH,
the system name of the first alternate index path is ABCDEFG1, the tenth is ABCDEF10, and so on.
Related tasks
“Allocating files” on page 164
Related references
MVS Program Management: User's Guide and Reference
Related tasks
“Preventing update problems with VSAM files in RLS mode” on page 210
“Handling errors in VSAM
files in RLS mode” on page 210
Related references
“Restrictions when using RLS” on page 210
Related tasks
“Using VSAM status codes (VSAM files only)” on page 248
210 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Allocation of record areas for VSAM files
For reentrant COBOL programs, the record areas for VSAM files are allocated above the 16 MB line by
default.
If you specify the DATA(24) compiler option, the VSAM record areas and other dynamic storage areas are
allocated in storage below 16 MB.
Programs that pass data in VSAM file records as CALL...USING parameters to AMODE 24 subprograms
are impacted. You can recompile such programs with the DATA(24) compiler option, or use the Language
Environment HEAP runtime option, to ensure that the records are addressable by the AMODE 24
programs.
Loading records, Use the access methods service The REPRO command can update an indexed
using access REPRO command when: data set as fast or faster than any COBOL
methods services program under these conditions.
• The target indexed data set
already contains records.
• The input sequential data set
contains records to be updated
or inserted into the indexed data
set.
If you use a COBOL program to
load the file, use OPEN OUTPUT
and ACCESS SEQUENTIAL.
File access modes For best performance, access Dynamic access is less efficient than
records sequentially. sequential access, but more efficient than
random access. Random access results in
increased EXCPs because VSAM must access
the index for each request.
Related tasks
“Specifying access modes for VSAM files” on page 194
z/OS DFSMS: Using Data Sets (Building a resource pool, Selecting the optimal
percentage of free space)
Related references
z/OS DFSMS: Access Method Services for Catalogs
212 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
• Volume size multiplied by 59
For example, a 4 KB CI size yields a maximum data set size of 16 TB, and a 32 KB CI size yields a
maximum data set size of 128 TB. A 4 KB CI size is preferred by many applications for performance
reasons. For extended-format data sets that grow beyond 4 GB, the processing time does not increase.
Extended addressability is also supported for programs compiled with earlier versions: VS COBOL II
programs compiled with RES and any later compilers.
Extended addressability and extended format are not the same concept. Extended format is a
prerequisite for extended addressability. Extended format is a technique that affects the way of storing
count key data (CKD) in a 3390/3380 logical track. Extended format implements data striping and
increases the performance and the reliability of an I/O operation. If a data set is allocated as an
extended-format data set, 32 bytes are added to each physical block.
Restriction: Extended addressability was introduced for KSDS data sets in DFSMS/MVS 1.3. Since
DFSMS/MVS 1.4, extended addressability is supported in record level sharing (RLS). With DFSMS/MVS
1.5, support for extended addressability is extended to all other VSAM record organizations.
Related tasks
z/OS DFSMS: Using Data Sets
Related tasks
“Defining line-sequential files and records in COBOL” on page 215
“Allocating line-sequential files” on page 216
“Coding input-output statements for line-sequential files” on page 217
“Handling errors in line-sequential files” on page 219
UNIX System Services User's Guide
FILE-CONTROL.
SELECT COMMUTER-FILE
ASSIGN TO COMMUTR
ORGANIZATION IS LINE SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS ECODE.
The ASSIGN assignment-name clause must not include an organization field (S- or AS-) before the
external name. The ACCESS phrase and the FILE STATUS clause are optional.
Related tasks
“Describing the structure of a line-sequential file” on page 215
“Allocating line-sequential files” on page 216
“Coding input-output statements for line-sequential files” on page 217
Related references
“Control characters in line-sequential files” on page 216
FILE SECTION.
FD COMMUTER-FILE
RECORD CONTAINS 80 CHARACTERS.
01 COMMUTER-RECORD.
05 COMMUTER-NUMBER PIC X(16).
05 COMMUTER-DESCRIPTION PIC X(64).
FILE SECTION.
FD COMMUTER-FILE
RECORD VARYING FROM 16 TO 80 CHARACTERS.
01 COMMUTER-RECORD.
05 COMMUTER-NUMBER PIC X(16).
05 COMMUTER-DESCRIPTION PIC X(64).
If you code the same fixed size and no OCCURS DEPENDING ON clause for any level-01 record
description entries associated with the file, that fixed size is the logical record length. However, because
blanks at the end of a record are not written to the file, the physical records might be of varying lengths.
Related tasks
“Allocating line-sequential files” on page 216
“Coding input-output statements for line-sequential files” on page 217
Related references
Data division--file description entries
(Enterprise COBOL for z/OS Language Reference)
216 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
For example, to have your program use z/OS UNIX file /u/myfiles/commuterfile for a COBOL file
that has an assignment-name of COMMUTR, you can use the following command:
export COMMUTR="PATH(/u/myfiles/commuterfile)"
Related tasks
“Allocating files” on page 164
“Defining line-sequential files and records in COBOL” on page 215
Related references
MVS Program Management: User's Guide and Reference
Related tasks
“Defining line-sequential files and records in COBOL” on page 215
“Describing the structure of a line-sequential file” on page 215
“Opening line-sequential
files” on page 217
“Reading records from line-sequential
files” on page 218
“Adding records to line-sequential files” on page 218
“Closing line-sequential
files” on page 219
“Handling errors in line-sequential files” on page 219
Related references
OPEN statement (Enterprise COBOL for z/OS Language Reference)
READ statement (Enterprise COBOL for z/OS Language Reference)
WRITE statement (Enterprise COBOL for z/OS Language Reference)
CLOSE statement (Enterprise COBOL for z/OS Language Reference)
Related references
OPEN statement (Enterprise COBOL for z/OS Language Reference)
CLOSE statement (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Opening line-sequential
files” on page 217
“Adding records to line-sequential files” on page 218
“Closing line-sequential
files” on page 219
“Allocating line-sequential files” on page 216
Related references
OPEN statement (Enterprise COBOL for z/OS Language Reference)
WRITE statement (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Opening line-sequential
files” on page 217
218 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
“Reading records from line-sequential
files” on page 218
“Closing line-sequential
files” on page 219
“Allocating line-sequential files” on page 216
Related references
OPEN statement (Enterprise COBOL for z/OS Language Reference)
WRITE statement (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Opening line-sequential
files” on page 217
“Reading records from line-sequential
files” on page 218
“Adding records to line-sequential files” on page 218
“Allocating line-sequential files” on page 216
Related references
CLOSE statement (Enterprise COBOL for z/OS Language Reference)
COBOL provides these language elements for intercepting and handling certain line-sequential input and
output errors:
• End-of-file phrase (AT END)
• EXCEPTION/ERROR declarative
• FILE STATUS clause
If you do not use one of these techniques, an error in processing input or output raises a Language
Environment condition.
If you use the FILE STATUS clause, be sure to check the key and take appropriate action based on its
value. If you do not check the key, your program might continue, but the results will probably not be what
you expected.
220 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Chapter 12. Sorting and merging files
You can arrange records in a particular sequence by using a SORT or MERGE statement. You can mix SORT
and MERGE statements in the same COBOL program.
Note: The SORT statement, sort processes, and sort restrictions that are described in this topic relate to
the format 1 SORT statement only. For more information about sorting a table by using the format 2 SORT
statement, see “Sorting a table” on page 87.
SORT statement
Accepts input (from a file or an internal procedure) that is not in sequence, and produces output (to a
file or an internal procedure) in a requested sequence. You can add, delete, or change records before
or after they are sorted.
MERGE statement
Compares records from two or more sequenced files and combines them in order. You can add,
delete, or change records after they are merged.
A program can contain any number of sort and merge operations. They can be the same operation
performed many times or different operations. However, one operation must finish before another begins.
With Enterprise COBOL, your IBM licensed program for sorting and merging must be DFSORT or an
equivalent. Where DFSORT is mentioned, you can use any equivalent sort or merge product.
COBOL programs that contain SORT or MERGE statements can reside above or below the 16 MB line.
The steps you take to sort or merge are generally as follows:
1. Describe the sort or merge file to be used for sorting or merging.
2. Describe the input to be sorted or merged. If you want to process the records before you sort them,
code an input procedure.
3. Describe the output from sorting or merging. If you want to process the records after you sort or merge
them, code an output procedure.
4. Request the sort or merge.
5. Determine whether the sort or merge operation was successful.
Restrictions:
• You cannot run a COBOL program that contains SORT or MERGE statements under z/OS UNIX. This
restriction includes BPXBATCH.
• You cannot use SORT or MERGE statements in programs compiled with the THREAD option. This includes
programs that use object-oriented syntax and multithreaded applications, both of which require the
THREAD option.In addition, the COBOL program that uses SORT or MERGE statements cannot call
directly or indirectly other applications that require z/OS Unix System Services or applications that use
multithreading. For example, the JVM uses both of them.
• You cannot use the DFSORT conventional technique. The conventional technique is used in the following
cases:
– The NOBLKSET option is specified. BLKSET is the default when invoking DFSORT.
– Tape device is used for intermediate work storage.
– L5 is used in the RECORD statement of DFSORT OPTION control. L5 specifies the average record
length. Instead of using L5, the same can be specified by using the AVGRLEN=n statement.
To assist migration of legacy COBOL programs, toleration runtime APARs PH20569(z/OS 2.2) and
PH21261(z/OS 2.3/2.4) are provided for programs running in AMODE 31. There is no toleration for
AMODE 64. For details, see Using DFSORT option NOBLKSET (Enterprise COBOL Migration Guide).
Related tasks
“Sorting
a table” on page 87
“Describing the sort or merge file” on page 222
“Describing the input to sorting or merging” on page 223
“Describing the output from sorting or merging” on page 225
“Requesting the sort or merge” on page 228
“Determining whether the sort or merge was successful” on page 231
“Stopping a sort or merge operation prematurely” on page 232
“Improving sort performance with FASTSRT” on page 232
“Controlling sort behavior” on page 235
DFSORT Application Programming Guide
Related references
“CICS SORT application
restrictions” on page 238
SORT statement (Enterprise COBOL for z/OS Language Reference)
MERGE statement (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Setting sort or merge criteria” on page 229
Related references
SORT statement (Enterprise COBOL for z/OS Language Reference)
MERGE statement (Enterprise COBOL for z/OS Language Reference)
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
222 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
FILE-CONTROL.
SELECT Sort-Work-1 ASSIGN TO SortFile.
Sort-Work-1 is the name of the file in your program. Use this name to refer to the file.
2. Describe the sort file in an SD entry in the FILE SECTION of the DATA DIVISION. Every SD entry
must contain a record description. For example:
DATA DIVISION.
FILE SECTION.
SD Sort-Work-1
RECORD CONTAINS 100 CHARACTERS.
01 SORT-WORK-1-AREA.
05 SORT-KEY-1 PIC X(10).
05 SORT-KEY-2 PIC X(10).
05 FILLER PIC X(80).
The file described in an SD entry is the working file used for a sort or merge operation. You cannot perform
any input or output operations on this file and you do not need to provide a ddname definition for it.
Related references
“FILE SECTION entries” on page 12
1. Write one or more SELECT clauses in the FILE-CONTROL paragraph of the ENVIRONMENT DIVISION
to name the input files. For example:
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT Input-File ASSIGN TO InFile.
Input-File is the name of the file in your program. Use this name to refer to the file.
2. Describe the input file (or files when merging) in an FD entry in the FILE SECTION of the DATA
DIVISION. For example:
DATA DIVISION.
FILE SECTION.
FD Input-File
LABEL RECORDS ARE STANDARD
BLOCK CONTAINS 0 CHARACTERS
RECORDING MODE IS F
RECORD CONTAINS 100 CHARACTERS.
01 Input-Record PIC X(100).
Related tasks
“Coding the input procedure” on page 224
“Requesting the sort or merge” on page 228
Related references
“FILE SECTION entries” on page 12
ID Division.
Program-ID. SmplSort.
Environment Division.
Related tasks
“Requesting the sort or merge” on page 228
SORT SORT-WORK-2
ON ASCENDING KEY SORT-KEY
INPUT PROCEDURE 600-SORT3-INPUT-PROC
. . .
600-SORT3-INPUT-PROC SECTION.
PERFORM WITH TEST AFTER
VARYING X1 FROM 1 BY 1 UNTIL X1 = 100
RELEASE SORT-WORK-2-AREA FROM TABLE-ENTRY (X1)
END-PERFORM.
To transfer records to the sort program, all input procedures must contain at least one RELEASE or
RELEASE FROM statement. To release A from X, for example, you can code:
MOVE X TO A.
RELEASE A.
224 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Alternatively, you can code:
RELEASE A FROM X.
The following table compares the RELEASE and RELEASE FROM statements.
MOVE SORT-EXT-RECORD
TO SORT-RECORD PERFORM RELEASE-SORT-RECORD
PERFORM RELEASE-SORT-RECORD . . .
. . . RELEASE-SORT-RECORD.
RELEASE-SORT-RECORD. RELEASE SORT-RECORD
RELEASE SORT-RECORD FROM SORT-EXT-RECORD
Related references
“Restrictions on input and output procedures” on page 227
RELEASE statement (Enterprise COBOL for z/OS Language Reference)
1. Write a SELECT clause in the FILE-CONTROL paragraph of the ENVIRONMENT DIVISION to name the
output file. For example:
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT Output-File ASSIGN TO OutFile.
Output-File is the name of the file in your program. Use this name to refer to the file.
2. Describe the output file (or files when merging) in an FD entry in the FILE SECTION of the DATA
DIVISION. For example:
DATA DIVISION.
FILE SECTION.
FD Output-File
LABEL RECORDS ARE STANDARD
BLOCK CONTAINS 0 CHARACTERS
RECORDING MODE IS F
RECORD CONTAINS 100 CHARACTERS.
01 Output-Record PIC X(100).
Related tasks
“Coding the output procedure” on page 225
“Requesting the sort or merge” on page 228
Related references
“FILE SECTION entries” on page 12
Related references
“Restrictions on input and output procedures” on page 227
RETURN statement (Enterprise COBOL for z/OS Language Reference)
IDENTIFICATION DIVISION.
DATA DIVISION.
FILE SECTION.
SD OUR-FILE.
01 OUR-SORT-REC.
03 SORT-KEY PIC X(10).
03 FILLER PIC X(70).
. . .
WORKING-STORAGE SECTION.
01 WS-SORT-REC PIC X(80).
01 END-OF-SORT-FILE-INDICATOR PIC X VALUE 'N'.
88 NO-MORE-SORT-RECORDS VALUE 'Y'.
. . .
PROCEDURE DIVISION.
A-CONTROL SECTION.
SORT OUR-FILE ON ASCENDING KEY SORT-KEY
INPUT PROCEDURE IS B-INPUT
OUTPUT PROCEDURE IS C-OUTPUT.
. . .
B-INPUT SECTION.
MOVE . . .. . .. TO WS-SORT-REC.
RELEASE OUR-SORT-REC FROM WS-SORT-REC.
. . .
C-OUTPUT SECTION.
DISPLAY 'STARTING READS OF SORTED RECORDS: '.
RETURN OUR-FILE
AT END
SET NO-MORE-SORT-RECORDS TO TRUE.
PERFORM WITH TEST BEFORE UNTIL NO-MORE-SORT-RECORDS
IF SORT-RETURN = 0 THEN
DISPLAY 'OUR-SORT-REC = ' OUR-SORT-REC
RETURN OUR-FILE
AT END
SET NO-MORE-SORT-RECORDS TO TRUE
END-IF
END-PERFORM.
226 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Restrictions on input and output procedures
Several restrictions apply to each input or output procedure called by SORT and to each output procedure
called by MERGE.
Observe these restrictions:
• The procedure must not contain any SORT or MERGE statements.
Restriction: In an input or output procedure, you can call a program that follows standard linkage
conventions. However, the called program cannot issue a SORT, MERGE, RELEASE, or RETURN
statement.
• You can use ALTER, GO TO, and PERFORM statements in the procedure to refer to procedure-names
outside the input or output procedure. However, control must return to the input or output procedure
after a GO TO or PERFORM statement.
• The remainder of the PROCEDURE DIVISION must not contain any transfers of control to points inside
the input or output procedure (with the exception of the return of control from a declarative section).
• In an input or output procedure, you can call a program that follows standard linkage conventions.
However, the called program cannot issue a SORT or MERGE statement.
• During a SORT or MERGE operation, the SD data item is used. You must not use it in the output procedure
before the first RETURN executes. If you move data into this record area before the first RETURN
statement, the first record to be returned will be overwritten.
• Language Environment condition handling does not let user-written condition handlers be established in
an input or output procedure.
Related tasks
“Coding the input procedure” on page 224
“Coding the output procedure” on page 225
Language Environment Programming Guide (Preparing to link-edit and run)
Related tasks
“Controlling sort behavior” on page 235
“Using checkpoint/restart with DFSORT” on page 237
Related tasks
“Changing DFSORT defaults with control statements” on page 236
“Controlling sort behavior” on page 235
SORT Sort-Work-1
ON ASCENDING KEY Sort-Key-1
USING Input-File
GIVING Output-File.
For SORT . . . USING or MERGE . . . USING, the compiler generates an input procedure to open
the file (files), read the records, release the records to the sort or merge program, and close the file (files).
The file (files) must not be open when the SORT or MERGE statement begins execution. For SORT . . .
GIVING or MERGE . . . GIVING, the compiler generates an output procedure to open the file, return
the records, write the records, and close the file. The file must not be open when the SORT or MERGE
statement begins execution.
The USING or GIVING files in a SORT or MERGE statement can be sequential files residing in the z/OS
UNIX file system.
“Example: describing sort and input files for SORT” on page 223
You can also use the FASTSRT compiler option to let IBM DFSORT, or an equivalent product, perform sort
input and output instead of the Enterprise COBOL compiler (along with Language Environment run time).
Using FASTSRT improves the performance of most sort operations. For details, see “FASTSRT” on page
369.
If you want an input procedure to be performed on the sort records before they are sorted, use
SORT . . . INPUT PROCEDURE. If you want an output procedure to be performed on the sorted
records, use SORT . . . OUTPUT PROCEDURE. For example:
SORT Sort-Work-1
ON ASCENDING KEY Sort-Key-1
INPUT PROCEDURE EditInputRecords
OUTPUT PROCEDURE FormatData.
228 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Restriction: You cannot use an input procedure with the MERGE statement. The source of input to the
merge operation must be a collection of already sorted files. However, if you want an output procedure to
be performed on the merged records, use MERGE . . . OUTPUT PROCEDURE. For example:
MERGE Merge-Work
ON ASCENDING KEY Merge-Key
USING Input-File-1 Input-File-2 Input-File-3
OUTPUT PROCEDURE ProcessOutput.
In the FILE SECTION, you must define Merge-Work in an SD entry, and the input files in FD entries.
Related tasks
“Defining sort and merge data sets” on page 227
Related references
SORT statement (Enterprise COBOL for z/OS Language Reference)
MERGE statement (Enterprise COBOL for z/OS Language Reference)
The collation order for national keys is determined by the binary order of the keys. If you specify a
national data item as a key, any COLLATING SEQUENCE phrase in the SORT or MERGE statement does not
apply to that key.
You can mix SORT and MERGE statements in the same COBOL program. A program can perform any
number of sort or merge operations. However, one operation must end before another can begin.
Related tasks
“Sorting
a table” on page 87
Related references
DFSORT Application Programming Guide (SORT control statement)
DATA DIVISION.
. . .
SD SORT-FILE
RECORD CONTAINS 115 CHARACTERS
DATA RECORD SORT-RECORD.
01 SORT-RECORD.
05 SORT-KEY.
10 SORT-SHIFT PIC X(1).
10 SORT-GRID-LOCATION PIC X(2).
10 SORT-REPORT PIC X(3).
05 SORT-EXT-RECORD.
10 SORT-EXT-EMPLOYEE-NUM PIC X(6).
10 SORT-EXT-NAME PIC X(30).
10 FILLER PIC X(73).
. . .
WORKING-STORAGE SECTION.
01 TAB1.
05 TAB-ENTRY OCCURS 10 TIMES
INDEXED BY TAB-INDX.
10 WS-SHIFT PIC X(1).
10 WS-GRID-LOCATION PIC X(2).
10 WS-REPORT PIC X(3).
10 WS-EXT-EMPLOYEE-NUM PIC X(6).
10 WS-EXT-NAME PIC X(30).
10 FILLER PIC X(73).
. . .
PROCEDURE DIVISION.
. . .
*****************************************************************************
* This SORT statement will do a 'table sort' using Format 1 SORT, and will *
* sort records in SORT-FILE in an ascending sequence based on the data *
* in sort keys SORT-GRID-LOCATION (primary) and SORT-SHIFT (secondary). *
* The source of the file records is data in table TAB-ENTRY *
* which is acquired in the input procedure 600-SORT3-INPUT and then *
* output back to the table in the output procedure 700-SORT3-OUTPUT. *
*****************************************************************************
SORT SORT-FILE
ON ASCENDING KEY SORT-GRID-LOCATION SORT-
SHIFT
INPUT PROCEDURE 600-SORT3-INPUT
OUTPUT PROCEDURE 700-SORT3-OUTPUT.
. . .
600-SORT3-INPUT.
PERFORM VARYING TAB-INDX FROM 1 BY 1 UNTIL TAB-INDX > 10
RELEASE SORT-RECORD FROM TAB-ENTRY(TAB-INDX)
END-PERFORM.
. . .
700-SORT3-OUTPUT.
PERFORM VARYING TAB-INDX FROM 1 BY 1 UNTIL TAB-INDX > 10
RETURN SORT-FILE INTO TAB-ENTRY(TAB-INDX)
AT END DISPLAY 'Out Of Records In SORT File'
END-RETURN
END-PERFORM.
Related tasks
“Requesting the sort or merge” on page 228
230 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Choosing alternate collating sequences
You can sort or merge records on the EBCDIC or ASCII collating sequence, or on another collating
sequence. The default collating sequence is EBCDIC unless you code the PROGRAM COLLATING
SEQUENCE clause in the OBJECT-COMPUTER paragraph.
To override the default sequence, use the COLLATING SEQUENCE phrase of the SORT or MERGE
statement. You can use different collating sequences for each SORT or MERGE statement in your program.
The PROGRAM COLLATING SEQUENCE clause and the COLLATING SEQUENCE phrase apply only to keys
of class alphabetic or alphanumeric.
When you sort or merge an ASCII file, you have to request the ASCII collating sequence. To do so, code
the COLLATING SEQUENCE phrase of the SORT or MERGE statement, and define the alphabet-name as
STANDARD-1 in the SPECIAL-NAMES paragraph.
Related tasks
“Specifying the collating sequence” on page 7
“Setting sort or merge criteria” on page 229
Related references
OBJECT-COMPUTER paragraph (Enterprise COBOL for z/OS Language Reference)
SORT statement (Enterprise COBOL for z/OS Language Reference)
Classes and categories of data (Enterprise COBOL for z/OS Language Reference)
Related references
DFSORT Application Programming Guide (OPTION control statement)
SORT SORT-WORK-2
ON ASCENDING KEY SORT-KEY
INPUT PROCEDURE IS 600-SORT3-INPUT-PROC
OUTPUT PROCEDURE IS 700-SORT3-OUTPUT-PROC.
IF SORT-RETURN NOT=0
DISPLAY "SORT ENDED ABNORMALLY. SORT-RETURN = " SORT-RETURN.
. . .
600-SORT3-INPUT-PROC SECTION.
. . .
700-SORT3-OUTPUT-PROC SECTION.
. . .
If you do not reference SORT-RETURN anywhere in your program, the COBOL run time tests the
completion code. If it is 16, COBOL issues a runtime diagnostic message.
If you test SORT-RETURN for one or more (but not necessarily all) SORT or MERGE statements, the COBOL
run time does not check the completion code.
Related tasks
“Checking for sort errors with NOFASTSRT” on page 234
“Controlling sort behavior” on page 235
Related references
DFSORT Application Programming Guide (DFSORT messages and return codes)
Related references
“FASTSRT” on page 369
“FASTSRT requirements for JCL” on page 232
“FASTSRT requirements for sort input and output files” on page 233
232 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
FASTSRT requirements for sort input and output files
If you specify FASTSRT but your code does not meet FASTSRT requirements, the compiler issues a
message and the COBOL run time performs the I/O instead. Your program will not experience the
performance improvements that are otherwise possible.
Note: The "sort input and output files" that is described in this topic relates to the format 1 SORT
statement only.
To use FASTSRT, you must describe and process the input files to the sort and the output files from the
sort in these ways:
• You can name only one input file in the USING phrase. You can name only one output file in the GIVING
phrase.
• You cannot use an input procedure on an input file nor an output procedure on an output file.
Instead of using input or output procedures, you might be able to use these DFSORT control
statements:
– INREC
– OUTFILE
– OUTREC
– INCLUDE
– OMIT
– STOPAFT
– SKIPREC
– SUM
Many DFSORT functions perform the same operations that are common in input or output procedures.
Code the appropriate DFSORT control statements instead, and place them either in the IGZSRTCD or
SORTCNTL data set.
• Do not code the LINAGE clause for the output FD entry.
• Do not code any INPUT declarative (for input files), OUTPUT declarative (for output files), or file-specific
declaratives (for either input or output files) to apply to any FDs used in the sort.
• Do not use a variable relative file as the input or output file.
• Do not use a line-sequential file as the input or output file.
• For either an input or an output file, the record descriptions of the SD and FD entry must define the same
format (fixed or variable), and the largest records of the SD and FD entry must define the same record
length.
If you code a RELATIVE KEY clause for an output file, it will not be set by the sort.
Performance tip: If you block your input and output records, the sort performance could be significantly
improved.
QSAM requirements
• QSAM files must have a record format of fixed, variable, or spanned.
• A QSAM input file can be empty.
• To use the same QSAM file for both input and output, you must describe the file using two different DD
statements. For example, in the FILE-CONTROL SECTION you might code this:
In the DATA DIVISION, you would have an FD entry for both FILE-IN and FILE-OUT, where FILE-IN
and FILE-OUT are identical except for their names.
SORT file-name
ASCENDING KEY data-name-1
USING FILE-IN GIVING FILE-OUT
Then in your JCL, assuming that data set INOUT has been cataloged, you would code:
//INPUTF DD DSN=INOUT,DISP=SHR
//OUTPUTF DD DSN=INOUT,DISP=SHR
On the other hand, if you code the same file-name in the USING and GIVING phrases, or assign the
input and output files the same ddname, then the file can be accepted for FASTSRT either for input
or output, but not both. If no other conditions disqualify the file from being eligible for FASTSRT on
input, then the file will be accepted for FASTSRT on input, but not on output. If the file was found to be
ineligible for FASTSRT on input, it might be eligible for FASTSRT on output.
A QSAM file that qualifies for FASTSRT can be accessed by the COBOL program while the format 1 SORT
statement is being performed. For example, if the file is used for FASTSRT on input, you can access it in
an output procedure; if it is used for FASTSRT on output, you can access it in an input procedure.
VSAM requirements
• A VSAM input file must not be empty.
• VSAM files cannot be password-protected.
• You cannot name the same VSAM file in both the USING and GIVING phrases.
• A VSAM file that qualifies for FASTSRT cannot be accessed by the COBOL program until the format 1
SORT statement processing is completed. For example, if the file qualifies for FASTSRT on input, you
cannot access it in an output procedure and vice versa. (If you do so, OPEN fails.)
Related tasks
DFSORT Application Programming Guide
Table 32. Methods for checking for sort errors with NOFASTSRT
FILE STATUS ERROR Then do:
clause? declarative?
No No No special coding. Any failure during the sort process causes the
program to end abnormally.
Yes No Test the SORT-RETURN special register after the format 1 SORT
statement, and test the file status key. (Not recommended if you
want complete file-status checking, because the file status code is
set but COBOL cannot check it.)
234 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 32. Methods for checking for sort errors with NOFASTSRT (continued)
FILE STATUS ERROR Then do:
clause? declarative?
Maybe Yes In the ERROR declarative, set the SORT-RETURN special register to
16 to stop the sort process and indicate that it was not successful.
Test the SORT-RETURN special register after the format 1 SORT
statement.
Related tasks
“Determining whether the sort or merge was successful” on page 231
“Using file status keys” on page 247
“Coding ERROR declaratives” on page 246
“Stopping a sort or merge operation prematurely” on page 232
Sort special registers: SORT-CONTROL is an eight-character COBOL special register that contains the
ddname of the sort control statement file. If you do not want to use the default ddname IGZSRTCD, assign
to SORT-CONTROL the ddname of the data set that contains your sort control statements.
The SORT-CORE-SIZE, SORT-FILE-SIZE, SORT-MESSAGE, and SORT-MODE-SIZE special registers are
used in the SORT interface if you assign them nondefault values. At run time, however, any parameters in
control statements in the sort control statement data set override corresponding settings in the special
registers, and a message to that effect is issued.
You can use the SORT-RETURN special register to determine whether the sort or merge was successful
and to stop a sort or merge operation prematurely.
A compiler warning message (W-level) is issued for each sort special register that you set in a program.
Related references
“Default characteristics of the IGZSRTCD data set” on page 236
Related tasks
“Controlling sort behavior” on page 235
DFSORT Application Programming Guide (Using DFSORT program
control statements)
Related references
“Default characteristics of the IGZSRTCD data set” on page 236
Related tasks
“Controlling sort behavior” on page 235
236 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
For a specific sort or merge operation, you can override the DFSORT storage values set at installation. To
do so, code the MAINSIZE and RESINV keywords on the OPTION control statement in the sort control
statement data set, or use the SORT-CORE-SIZE special register.
Be careful not to override the storage allocation to the extent that all the free space in the region is used
for sort operations for your COBOL program.
Related tasks
“Controlling sort behavior” on page 235
DFSORT Installation and Customization
Related references
DFSORT Application Programming Guide (OPTION control statement)
Related tasks
“Controlling sort behavior” on page 235
“Coding the input procedure” on page 224
DFSORT Application Programming Guide
RERUN ON assignment-name
3. Code the CKPT (or CHKPT) keyword on an OPTION control statement in the sort control statement data
set (default ddname IGZSRTCD).
Related concepts
Chapter 47, “Interrupts and checkpoint/restart,” on page 757
Related tasks
“Changing DFSORT defaults with control statements” on page 236
“Setting checkpoints” on page 757
Related references
“HGPR” on page 372
RETURN-CODE (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Coding the input procedure” on page 224
“Coding the output procedure” on page 225
“Coding COBOL programs to run under CICS” on page 495
Related references
“CICS SORT application
restrictions” on page 238
“CICS reserved-word table” on page 502
238 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Related references
“CICS reserved-word table” on page 502
Put code in your programs that anticipates possible system or runtime problems. If you do not include
such code, output data or files could be corrupted, and the user might not even be aware that there is a
problem.
The error-handling code can take actions such as handling the situation, issuing a message, or halting the
program. You might for example create error-detection routines for data-entry errors or for errors as your
installation defines them. In any event, coding a warning message is a good idea.
Enterprise COBOL contains special elements to help you anticipate and correct error conditions:
• User-requested dumps
• ON OVERFLOW in STRING and UNSTRING operations
• ON SIZE ERROR in arithmetic operations
• Elements for handling input or output errors
• ON EXCEPTION or ON OVERFLOW in CALL statements
• User-written routines for handling errors
Related tasks
“Handling errors in joining and splitting strings” on page 242
“Handling errors in arithmetic operations” on page 242
“Handling errors in input and output operations” on page 243
“Handling errors when calling programs” on page 251
“Writing routines for handling errors” on page 252
Requesting dumps
You can cause a formatted dump of the Language Environment runtime environment and the member
language libraries at any prespecified point in your program by coding a call to the Language Environment
callable service CEE3DMP.
To have symbolic variables included in the formatted dump, compile with the TEST compiler option and
use the VARIABLES subparameter of CEE3DMP. You can also request, through runtime options, that a
dump be produced for error conditions of your choosing.
You can cause a system dump at any prespecified point in your program. Request an abend without
cleanup by calling the Language Environment service CEE3ABD with a cleanup value of zero. This callable
service stops the run unit immediately, and a system dump is requested when the abend is issued.
Related references
“TEST” on page 414
Language Environment Debugging Guide
Language Environment Programming Reference (CEE3DMP--generate dump)
These are the data values before and after the statement is performed:
Because String-ptr has a value (0) that falls short of the receiving field, an overflow condition occurs
and the STRING operation is not completed. (Overflow would also occur if String-ptr were greater
than 9.) If ON OVERFLOW had not been specified, you would not be notified that the contents of Item-4
remained unchanged.
242 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Example: checking for division by zero
The following example shows how you can code an ON SIZE ERROR imperative statement so that the
program issues an informative message if division by zero occurs.
DIVIDE-TOTAL-COST.
DIVIDE TOTAL-COST BY NUMBER-PURCHASED
GIVING ANSWER
ON SIZE ERROR
DISPLAY "ERROR IN DIVIDE-TOTAL-COST PARAGRAPH"
DISPLAY "SPENT " TOTAL-COST, " FOR " NUMBER-PURCHASED
PERFORM FINISH
END-DIVIDE
. . .
FINISH.
STOP RUN.
If division by zero occurs, the program writes a message and halts program execution.
244 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
*Possible phrases for QSAM are AT END, AT END-OF-PAGE, and INVALID KEY; for line sequential, AT
END.
**You need to write the code to test the file status key.
***Execution of your COBOL program continues after the input or output statement that caused the error.
Related tasks
“Using the end-of-file condition (AT END)” on page 246
“Coding ERROR declaratives” on page 246
“Using file status keys” on page 247
“Handling errors in QSAM files” on page 179
“Using VSAM status codes (VSAM files only)” on page 248
“Handling errors in line-sequential files” on page 219
“Coding INVALID KEY phrases” on page 250
Related references
File status key (Enterprise COBOL for z/OS Language Reference)
Any NOT AT END phrase is performed only if the READ statement completes successfully. If the READ
operation fails because of a condition other than end-of-file, neither the AT END nor the NOT AT END
phrase is performed. Instead, control passes to the end of the READ statement after any associated
declarative procedure is performed.
You might choose not to code either an AT END phrase or an EXCEPTION declarative procedure, but to
code a status key clause for the file instead. In that case, control passes to the next sequential instruction
after the input or output statement that detected the end-of-file condition. At that place, have some code
that takes appropriate action.
Related references
AT END phrases (Enterprise COBOL for z/OS Language Reference)
Declaratives.
D1 section.
Use after standard error procedure on F1
Read F2.
. . .
D2 section.
Use after standard error procedure on F2
Read F1.
246 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
. . .
End declaratives.
. . .
Rewrite R1.
Rewrite R2.
When this program is running on two threads, the following sequence of events could occur:
1. Thread 1: Rewrite R1 acquires lock on F1 and encounters I/O error.
2. Thread 1: Enter declarative D1, holding lock on F1.
3. Thread 2: Rewrite R2 acquires lock on F2 and encounters I/O error.
4. Thread 2: Enter declarative D2.
5. Thread 1: Read F2 from declarative D1; wait on F2 lock held by thread 2.
6. Thread 2: Read F1 from declarative D2; wait on F1 lock held by thread 1.
7. Deadlock.
Related references
EXCEPTION/ERROR declarative (Enterprise COBOL for z/OS Language Reference)
WORKING-STORAGE SECTION.
01 data-name-1 PIC 9(2) USAGE NATIONAL.
Specify the file status key data-name-1 as a two-character category alphanumeric or category national
item, or as a two-digit zoned decimal or national decimal item. This data-name-1 cannot be variably
located.
Your program can check the file status key to discover whether an error occurred, and, if so, what type of
error occurred. For example, suppose that a FILE STATUS clause is coded like this:
Related tasks
“Using VSAM status codes (VSAM files only)” on page 248
“Coding INVALID KEY phrases” on page 250
“Finding and handling input-output errors” on page 445
Related references
FILE STATUS clause (Enterprise COBOL for z/OS Language Reference)
File status key (Enterprise COBOL for z/OS Language Reference)
IDENTIFICATION DIVISION.
PROGRAM-ID. SIMCHK.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT MAINFILE ASSIGN TO AS-MAINA
FILE STATUS IS MAIN-CHECK-KEY
. . .
DATA DIVISION.
. . .
WORKING-STORAGE SECTION.
01 MAIN-CHECK-KEY PIC X(2).
. . .
PROCEDURE DIVISION.
OPEN INPUT MAINFILE
IF MAIN-CHECK-KEY NOT = "00"
DISPLAY "Nonzero file status returned from OPEN " MAIN-CHECK-KEY
. . .
The data item data-name-1 shown above specifies the COBOL file status key, which you define as a
two-character alphanumeric or national data item, or as a two-digit zoned decimal or national decimal
item.
248 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
The data item data-name-8 specifies the VSAM status code, which you define as a 6-byte alphanumeric
group data item that has three subordinate 2-byte binary fields. The VSAM status code contains
meaningful values when the COBOL file status key is not 0.
You can define data-name-8 in the WORKING-STORAGE SECTION, as in VSAM-CODE below.
01 RETURN-STATUS.
05 FS-CODE PIC X(2).
05 VSAM-CODE.
10 VSAM-R15-RETURN PIC S9(4) Usage Comp-5.
10 VSAM-FUNCTION PIC S9(4) Usage Comp-5.
10 VSAM-FEEDBACK PIC S9(4) Usage Comp-5.
Enterprise COBOL uses data-name-8 to pass information supplied by VSAM. In the following example,
FS-CODE corresponds to data-name-1 and VSAM-CODE corresponds to data-name-8:
Related references
FILE STATUS clause (Enterprise COBOL for z/OS Language Reference)
File status key (Enterprise COBOL for z/OS Language Reference)
z/OS DFSMS Macro Instructions for Data Sets (VSAM macro return and
reason codes)
IDENTIFICATION DIVISION.
PROGRAM-ID. EXAMPLE.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT VSAMFILE ASSIGN TO VSAMFILE
ORGANIZATION IS INDEXED
ACCESS DYNAMIC
RECORD KEY IS VSAMFILE-KEY
FILE STATUS IS FS-CODE VSAM-CODE.
DATA DIVISION.
FILE SECTION.
FD VSAMFILE
RECORD 30.
01 VSAMFILE-REC.
10 VSAMFILE-KEY PIC X(6).
10 FILLER PIC X(24).
WORKING-STORAGE SECTION.
01 RETURN-STATUS.
IF FS-CODE = "00"
PERFORM READ-NEXT UNTIL FS-CODE NOT = "00"
END-IF.
CLOSE VSAMFILE.
STOP RUN.
READ-NEXT.
READ VSAMFILE NEXT.
DISPLAY "READ NEXT VSAMFILE FS-CODE: " FS-CODE.
IF FS-CODE NOT = "00"
PERFORM VSAM-CODE-DISPLAY
ELSE
DISPLAY VSAMFILE-REC
END-IF.
VSAM-CODE-DISPLAY.
DISPLAY "VSAM-CODE ==>"
" RETURN: " VSAM-RETURN-CODE,
" COMPONENT: " VSAM-COMPONENT-CODE,
" REASON: " VSAM-REASON-CODE.
Below is a sample of the output from the example program that checks VSAM status-code information:
250 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
If you code INVALID KEY in a statement that causes an INVALID KEY condition, control is transferred
to the INVALID KEY imperative statement. Any ERROR declaratives that you coded are not performed.
If you code a NOT INVALID KEY phrase, it is performed only if the statement completes successfully.
If the operation fails because of a condition other than INVALID KEY, neither the INVALID KEY nor
the NOT INVALID KEY phrase is performed. Instead, after the program performs any associated ERROR
declaratives, control passes to the end of the statement.
“Example: FILE STATUS and INVALID KEY” on page 251
.
. (read the update transaction record)
.
MOVE "TRUE" TO TRANSACTION-MATCH
MOVE UPDATE-CUSTOMER-NUMBER TO MAIN-CUSTOMER-NUMBER
READ MAIN-CUSTOMER-FILE INTO WS-CUSTOMER-RECORD
INVALID KEY
DISPLAY "MAIN CUSTOMER RECORD NOT FOUND"
DISPLAY "FILE STATUS CODE IS: " CUSTOMER-FILE-STATUS
MOVE "FALSE" TO TRANSACTION-MATCH
END-READ
The ON EXCEPTION phrase applies only to the availability of the called program on its initial load. If the
called program is loaded but fails for any other reason (such as initialization), the ON EXCEPTION phrase
is not performed.
Related references
Enterprise COBOL for z/OS Migration Guide
Related tasks
“Using procedure and function pointers” on page 557
Related references
“OPTIMIZE” on page 395
252 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Part 2. Compiling and debugging your program
Related tasks
“Compiling with JCL” on page 255
“Compiling under TSO” on page 262
Chapter 15, “Compiling under z/OS UNIX,” on page 283
“Starting the compiler from an assembler program” on page 264
“Defining compiler input and output” on page 266
“Specifying compiler options under z/OS” on page 273
“Compiling multiple programs
(batch compilation)” on page 276
“Correcting errors in your source program” on page 280
Related references
Chapter 20, “Compiler-directing statements,” on page 439
“Data sets used by the compiler under z/OS” on page 267
“Compiler options and compiler output under z/OS” on page 275
Related tasks
“Using a cataloged procedure” on page 256
“Writing JCL to compile programs” on page 260
“Specifying compiler options under z/OS” on page 273
“Specifying compiler options in a batch compilation” on page 278
“Compiling programs to create
DLLs” on page 580
Related references
“Data sets used by the compiler under z/OS” on page 267
//JOB1 JOB1
//STEPA EXEC PROC=IGYWC
//COBOL.SYSIN DD *
000100 IDENTIFICATION DIVISION
* (the source code)
. . .
/*
You can omit /* after the source code. If your source code is stored in a data set, replace SYSIN DD *
with appropriate parameters that describe the data set.
You can use these procedures with any of the job schedulers that are part of z/OS. When a scheduler
encounters parameters that it does not require, the scheduler either ignores them or substitutes
alternative parameters.
If the compiler options are not explicitly supplied with the procedure, default options established at the
installation apply. You can override these default options by using an EXEC statement that includes the
required options.
You can specify data sets to be in the z/OS UNIX file system by overriding the corresponding DD
statement. However, the compiler utility files (SYSUTx) and copy libraries (SYSLIB) you specify must
be MVS data sets.
Additional details about invoking cataloged procedures, overriding and adding to EXEC statements, and
overriding and adding to DD statements are in the Language Environment information.
Related tasks
Language Environment Programming Guide
Related references
“Compile procedure (IGYWC)” on page 257
“Compile and link-edit procedure (IGYWCL)” on page 258
“Compile, link-edit, and run procedure (IGYWCLG)” on page 259
MVS Program Management: User's Guide and Reference
256 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Compile procedure (IGYWC)
IGYWC is a single-step cataloged procedure for compiling a program. It produces an object module. The
compile steps in all other cataloged procedures that invoke the compiler are similar.
You must supply the following DD statement, indicating the location of the source program, in the input
stream:
If you use copybooks in the program that you are compiling, you must also supply a DD statement for
SYSLIB or other libraries that you specify in COPY statements. For example:
//COBOL.SYSLIB DD DISP=SHR,DSN=DEPT88.BOBS.COBLIB
(1)
STEPLIB can be installation-dependent.
“Example: JCL for compiling in the z/OS UNIX file system” on page 257
//UNIXDEMO JOB ,
// TIME=(1),MSGLEVEL=(1,1),MSGCLASS=H,CLASS=A,REGION=50M,
// NOTIFY=&SYSUID,USER=&SYSUID
//COMPILE EXEC IGYWC,
// PARM.COBOL='LIST,MAP,RENT,FLAG(I,I),XREF,ADATA'
//SYSPRINT DD PATH='/u/userid/cobol/demo.lst', (1)
(1)
PATH specifies the path name of a file in the z/OS UNIX file system.
(2)
PATHOPTS indicates the access for the file (such as read or read-write) and sets the status for the file
(such as append, create, or truncate).
(3)
PATHMODE indicates the permissions, or file access attributes, to be set when a file is created.
(4)
FILEDATA specifies whether the data is to be treated as text or as binary.
You can use a mixture of files in the z/OS UNIX file system (PATH='unix-directory-path') and traditional
MVS data sets (DSN=mvs-data-set-name) in the compilation DD statements (shown in this example as
overrides). However, the compiler utility files (DD statements SYSUTx) and COPY libraries (DD statements
SYSLIB) must be MVS data sets.
Related references
“Data sets used by the compiler under z/OS” on page 267
UNIX System Services Command Reference
MVS JCL Reference
If the program uses copybooks, you must also supply a DD statement for SYSLIB or other libraries that
you specify in COPY statements. For example:
//COBOL.SYSLIB DD DISP=SHR,DSN=DEPT88.BOBS.COBLIB
258 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
//* CALLER MUST ALSO SUPPLY //COBOL.SYSLIB DD . . . for COPY statements
//*
//COBOL EXEC PGM=IGYCRCTL,REGION=0M
//STEPLIB DD DSNAME=&LNGPRFX..SIGYCOMP,DISP=SHR (1)
// DD DSNAME=&LIBPRFX..SCEERUN,DISP=SHR
// DD DSNAME=&LIBPRFX..SCEERUN2,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSLIN DD DSNAME=&&LOADSET,UNIT=SYSALLDA,
// DISP=(MOD,PASS),SPACE=(CYL,(1,1)),
//SYSUT1 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSUT2 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSUT3 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSUT4 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSUT5 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSUT6 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSUT7 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSUT8 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSUT9 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSUT10 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSUT11 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSUT12 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSUT13 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSUT14 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSUT15 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSMDECK DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//LKED EXEC PGM=IEWBLINK,COND=(8,LT,COBOL),REGION=0M
//SYSLIB DD DSNAME=&LIBPRFX..SCEELKEX,DISP=SHR (2)
// DD DSNAME=&LIBPRFX..SCEELKED,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSLIN DD DSNAME=&&LOADSET,DISP=(OLD,DELETE)
// DD DDNAME=SYSIN
//SYSLMOD DD DSNAME=&PGMLIB(&GOPGM),
// SPACE=(CYL,(3,1,1)),
// UNIT=SYSALLDA,DISP=(MOD,PASS),DSNTYPE=LIBRARY
//SYSUT1 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
(1)
STEPLIB can be installation-dependent.
(2)
SYSLIB can be installation-dependent.
If the program uses copybooks, you must also supply a DD statement for SYSLIB or other libraries that
you specify in COPY statements. For example:
//COBOL.SYSLIB DD DISP=SHR,DSN=DEPT88.BOBS.COBLIB
(1)
STEPLIB can be installation-dependent.
(2)
SYSLIB can be installation-dependent.
In the procedure to run a program (GO statement), a valid DDName is up to 8 characters in length.
In the ENVIRONMENT DIVISION of the COBOL program, there is a FILE CONTROL paragraph whose
assignment-name should match the DDName. For example:
//GO.DDName DD DSN=data-set-name
260 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
//SYSUT12 DD UNIT=SYSALLDA,SPACE=(subparms)
//SYSUT13 DD UNIT=SYSALLDA,SPACE=(subparms)
//SYSUT14 DD UNIT=SYSALLDA,SPACE=(subparms)
//SYSUT15 DD UNIT=SYSALLDA,SPACE=(subparms)
//SYSMDECK DD UNIT=SYSALLDA,SPACE=(subparms)
//SYSPRINT DD SYSOUT=A (5)
//SYSLIN DD DSNAME=MYPROG,UNIT=SYSALLDA, (6)
// DISP=(MOD,PASS),SPACE=(subparms)
//SYSIN DD DSNAME=dsname,UNIT=device, (7)
VOLUME=(subparms),DISP=SHR
(1)
The JOB statement indicates the beginning of a job.
(2)
The EXEC statement specifies that the Enterprise COBOL compiler (IGYCRCTL) is to be invoked.
(3)
This DD statement defines the data set where the Enterprise COBOL compiler resides.
The Language Environment SCEERUN and SCEERUN2 data sets must be included in the concatenation
(together with the compiler SIGYCOMP data set), unless the Language Environment data sets are
available in the LNKLST.
(4)
The SYSUT DD statements define the utility data sets that the compiler will use to process the source
program. All SYSUT files must be on direct-access storage devices.
(5)
The SYSPRINT DD statement defines the data set that receives output from compiler options such as
LIST and MAP. SYSOUT=A is the standard designation for data sets whose destination is the system
output device.
(6)
The SYSLIN DD statement defines the data set (the object module) that receives output from the
OBJECT compiler option.
(7)
The SYSIN DD statement defines the data set (source code) to be used as input to the job step.
You can use a mixture of files in the z/OS UNIX file system (PATH='unix-directory-path') and traditional
MVS data sets (DSN=mvs-data-set-name) in the compilation DD statements for the following data sets:
• Sources files
• Object files
• Listings
• ADATA files
• Debug files
• Executable modules
However, the compiler utility files (DD statements SYSUTx) and COPY libraries (DD statement SYSLIB)
must be MVS data sets.
For more examples about the cataloged procedures in JCL, refer to “Using a cataloged procedure” on
page 256 and its following topics.
Related references
MVS JCL Reference
MVS Program Management: User's Guide and Reference
(1)
JOB1 is the name of the job.
(2)
STEP1 is the name of the sole job step in the job. The EXEC statement also specifies that the
generated object code should be placed on disk or tape (to be used as input to the link step).
(3)
The asterisk indicates that the input data set follows in the input stream.
(4)
The delimiter statement /* separates data from subsequent control statements in the input stream.
CALL 'IGY.V6R4M0.SIGYCOMP(IGYCRCTL)'
262 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
You can specify the ALLOCATE and CALL commands on the TSO command line, or, if you are not using
z/OS UNIX files, you can include them in a CLIST.
You can allocate z/OS UNIX files for all the compiler data sets except the SYSUTx utility data sets and the
SYSLIB libraries. ALLOCATE statements have the following form:
“Example: ALLOCATE and CALL for compiling under TSO” on page 263
“Example: CLIST for compiling under TSO” on page 264
Related references
“Data sets used by the compiler under z/OS” on page 267
[READY]
ALLOCATE FILE(SYSUT1) CYLINDERS SPACE(1 1)
[READY]
ALLOCATE FILE(SYSUT2) CYLINDERS SPACE(1 1)
[READY]
ALLOCATE FILE(SYSUT3) CYLINDERS SPACE(1 1)
[READY]
ALLOCATE FILE(SYSUT4) CYLINDERS SPACE(1 1)
[READY]
ALLOCATE FILE(SYSUT5) CYLINDERS SPACE(1 1)
[READY]
ALLOCATE FILE(SYSUT6) CYLINDERS SPACE(1 1)
[READY]
ALLOCATE FILE(SYSUT7) CYLINDERS SPACE(1 1)
[READY]
ALLOCATE FILE(SYSUT8) CYLINDERS SPACE(1 1)
[READY]
ALLOCATE FILE(SYSUT9) CYLINDERS SPACE(1 1)
[READY]
ALLOCATE FILE(SYSUT10) CYLINDERS SPACE(1 1)
[READY]
ALLOCATE FILE(SYSUT11) CYLINDERS SPACE(1 1)
[READY]
ALLOCATE FILE(SYSUT12) CYLINDERS SPACE(1 1)
[READY]
ALLOCATE FILE(SYSUT13) CYLINDERS SPACE(1 1)
[READY]
ALLOCATE FILE(SYSUT14) CYLINDERS SPACE(1 1)
[READY]
ALLOCATE FILE(SYSUT15) CYLINDERS SPACE(1 1)
[READY]
ALLOCATE FILE(SYSMDECK) CYLINDERS SPACE(1 1)
[READY]
ALLOCATE FILE(SYSPRINT) SYSOUT
[READY]
ALLOCATE FILE(SYSTERM) DATASET(*)
[READY]
ALLOCATE FILE(SYSLIN) DATASET(PROG2.OBJ) NEW TRACKS SPACE(3,3)
[READY]
ALLOCATE FILE(SYSIN) DATASET(PROG2.COBOL) SHR
[READY]
CALL 'IGY.V6R4M0.SIGYCOMP(IGYCRCTL)' 'LIST,NOCOMPILE(S),OBJECT,FLAG(E,E),TERMINAL'
.
(COBOL listings and messages)
.
[READY]
FREE
FILE(SYSUT1,SYSUT2,SYSUT3,SYSUT4,SYSUT5,SYSUT6,SYSUT7,SYSUT8,SYSUT9,SYSUT10,SYSUT11,SYSUT12,
SYSUT13,SYSUT14,SYSUT15,SYSMDECK,SYSPRINT,SYSTERM,+
SYSIN,SYSLIN)
[READY]
PROC 1 MEM
CONTROL LIST
FREE F(SYSUT1)
FREE F(SYSUT2)
FREE F(SYSUT3)
FREE F(SYSUT4)
FREE F(SYSUT5)
FREE F(SYSUT6)
FREE F(SYSUT7)
FREE F(SYSUT8)
FREE F(SYSUT9)
FREE F(SYSUT10)
FREE F(SYSUT11)
FREE F(SYSUT12)
FREE F(SYSUT13)
FREE F(SYSUT14)
FREE F(SYSUT15)
FREE F(SYSMDECK)
FREE F(SYSPRINT)
FREE F(SYSIN)
FREE F(SYSLIN)
ALLOC F(SYSPRINT) SYSOUT
ALLOC F(SYSIN) DA(COBOL.SOURCE(&MEM)) SHR REUSE
ALLOC F(SYSLIN) DA(COBOL.OBJECT(&MEM)) OLD REUSE
ALLOC F(SYSUT1) NEW SPACE(1,1) CYL UNIT(SYSALLDA)
ALLOC F(SYSUT2) NEW SPACE(1,1) CYL UNIT(SYSALLDA)
ALLOC F(SYSUT3) NEW SPACE(1,1) CYL UNIT(SYSALLDA)
ALLOC F(SYSUT4) NEW SPACE(1,1) CYL UNIT(SYSALLDA)
ALLOC F(SYSUT5) NEW SPACE(1,1) CYL UNIT(SYSALLDA)
ALLOC F(SYSUT6) NEW SPACE(1,1) CYL UNIT(SYSALLDA)
ALLOC F(SYSUT7) NEW SPACE(1,1) CYL UNIT(SYSALLDA)
ALLOC F(SYSUT8) NEW SPACE(1,1) CYL UNIT(SYSALLDA)
ALLOC F(SYSUT9) NEW SPACE(1,1) CYL UNIT(SYSALLDA)
ALLOC F(SYSUT10) NEW SPACE(1,1) CYL UNIT(SYSALLDA)
ALLOC F(SYSUT11) NEW SPACE(1,1) CYL UNIT(SYSALLDA)
ALLOC F(SYSUT12) NEW SPACE(1,1) CYL UNIT(SYSALLDA)
ALLOC F(SYSUT13) NEW SPACE(1,1) CYL UNIT(SYSALLDA)
ALLOC F(SYSUT14) NEW SPACE(1,1) CYL UNIT(SYSALLDA)
ALLOC F(SYSUT15) NEW SPACE(1,1) CYL UNIT(SYSALLDA)
ALLOC F(SYSMDECK) NEW SPACE(1,1) CYL UNIT(SYSALLDA)
CALL 'IGY.V6R4M0.SIGYCOMP(IGYCRCTL)'
Related references
TSO/E Command Reference
EP
Specifies the symbolic name of the compiler. The control program (from the library directory entry)
determines the entry point at which the program should begin running.
PARAM
Specifies, as a sublist, address parameters to be passed from the assembler program to the compiler.
The first fullword in the address parameter list contains the address of the COBOL optionlist. The
second fullword contains the address of the ddnamelist.
264 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
optionlist
Specifies the address of a variable-length list that contains the COBOL options specified for
compilation. This address must be written even if no list is provided.
The optionlist must begin on a halfword boundary. The 2 high-order bytes contain a count of the
number of bytes in the remainder of the list. If no options are specified, the count must be zero. The
optionlist is freeform, with each field separated from the next by a comma. No blanks or zeros should
appear. The compiler recognizes only the first 100 characters.
ddnamelist
Specifies the address of a variable-length list that contains alternative ddnames for the data sets used
during compiler processing. If standard ddnames are used, the ddnamelist can be omitted.
The ddnamelist must begin on a halfword boundary. The 2 high-order bytes contain a count of the
number of bytes in the remainder of the list. Each name of less than 8 bytes must be left justified and
padded with blanks. If an alternate ddname is omitted from the list, the standard name is assumed. If
the name is omitted, the 8-byte entry must contain binary zeros. You can omit names from the end by
shortening the list.
All SYSUTn data sets specified must be on direct-access storage devices and have physical sequential
organization. They must not reside in the z/OS UNIX file system.
The following table shows the sequence of the 8-byte entries in the ddnamelist.
Alternative ddname 8-byte entry Name for which alternative ddname is substituted
1 SYSLIN
2 Not applicable
3 Not applicable
4 SYSLIB
5 SYSIN
6 SYSPRINT
7 SYSPUNCH
8 SYSUT1
9 SYSUT2
10 SYSUT3
11 SYSUT4
12 SYSTERM
13 SYSUT5
14 SYSUT6
15 SYSUT7
16 SYSADATA
17 SYSJAVA
18 SYSDEBUG
19 SYSMDECK
20 DBRMLIB
21 SYSOPTF
22 SYSUT8
VL
Specifies that the sign bit is to be set to 1 in the last fullword of the address parameter list.
When the compiler completes processing, it puts a return code in register 15.
Related tasks
“Defining compiler input and output” on page 266
Related references
“Data sets used by the compiler under z/OS” on page 267
“Compiler options and compiler output under z/OS” on page 275
Related tasks
“Defining the source code data set (SYSIN)” on page 269
“Defining a compiler-option data set (SYSOPTF)” on page 270
“Specifying source libraries (SYSLIB)” on page 270
“Defining the output data set (SYSPRINT)” on page 271
“Directing compiler messages to your terminal (SYSTERM)” on page 271
“Creating object code (SYSLIN or SYSPUNCH)” on page 271
“Defining an associated-data file (SYSADATA)” on page 272
“Defining the Java-source
output file (SYSJAVA)” on page 272
“Defining the library-processing output file (SYSMDECK)” on page 273
Related references
“Data sets used by the compiler under z/OS” on page 267
“Compiler options and compiler output under z/OS” on page 275
266 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Data sets used by the compiler under z/OS
The following table lists the function, device requirements, and allowable device classes for each data set
that the compiler uses.
1. You can use the EXIT option to provide user exits from these data sets.
2. Utility data sets must be single volume, and cannot have DSNTYPE=LARGE (SYSUT1 - SYSUT15).
Related references
“Logical record length and block size” on page 269
“EXIT” on page 367
268 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Logical record length and block size
For compiler data sets other than the work data sets (SYSUTn) and z/OS UNIX files, you can set the block
size by using the BLKSIZE subparameter of the DCB parameter. The value must be permissible for the
device on which the data set resides. The values you set depend on whether the data sets are fixed length
or variable length.
For fixed-length records (RECFM=F or RECFM=FB), LRECL is the logical record length; and BLKSIZE
equals LRECL multiplied by n where n is equal to the blocking factor.
The following table shows the defined values for the fixed-length data sets. In general, you should not
change these values, but you can change the value for the following data sets:
• SYSDEBUG: You can specify any LRECL in the listed range, with 1024 recommended.
• SYSPRINT, SYSDEBUG: You can specify BLKSIZE=0, which results in a system-determined block size.
1. n = blocking factor
2. If you specify BLKSIZE=0, the system determines the block size.
3. The default LRECL for SYSDEBUG is 1024.
For variable-length records (RECFM=V), LRECL is the logical record length, and BLKSIZE equals LRECL
plus 4.
//SYSIN DD DSNAME=dsname,UNIT=SYSSQ,VOLUME=(subparms),DISP=SHR
You can place your source code or BASIS statement directly in the input stream. To do so, use this SYSIN
DD statement:
//SYSIN DD *
//SYSOPTF DD DSNAME=dsname,UNIT=SYSDA,VOLUME=(subparms),DISP=SHR
To use a compiler-option data set, specify OPTFILE either as a compiler invocation option or in a
PROCESS or CBL statement in your source program.
Within the SYSOPTF data set:
• Specify compiler options in free form between columns 2 and 72, using the same syntax as you use for
invocation options or for compiler options in a PROCESS or CBL statement.
• Code an asterisk (*) in column 1 to cause a line to be treated as a comment.
• Optionally code sequence numbers in columns 73 through 80; those columns are ignored.
You can optionally place the compiler options directly in the input stream after the SYSOPTF DD
statement if you compile using the OPTFILE option:
You can concatenate multiple SYSOPTF DD statements if you have multiple compiler-option data sets:
//SYSOPTF DD DSNAME=dsname1, . . .
// DD DSNAME=dsname2, . . .
Compiler options that are in later data sets in the concatenation take precedence over options in earlier
data sets in the concatenation.
Related references
“Logical record length and block size” on page 269
“OPTFILE” on page 394
//SYSLIB DD DSNAME=copylibname,DISP=SHR
//SYSLIB DD DSNAME=PROJECT.USERLIB,DISP=SHR
// DD DSNAME=SYSTEM.COPYX,DISP=SHR
Libraries are on direct-access storage devices. They cannot be in the z/OS UNIX file system when you
compile with JCL or under TSO.
270 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Defining the output data set (SYSPRINT)
You can use ddname SYSPRINT to produce a listing. The listing includes the results of the default or
requested options of the PARM parameter (that is, diagnostic messages and the object-code listing).
You can direct the output to a SYSOUT data set, a printer, a direct-access storage device, or a magnetic-
tape device. For example:
//SYSPRINT DD SYSOUT=A
The SYSPRINT data set can be a sequential data set, a PDS or PDSE member, or a z/OS UNIX file. For
details about how to specify the record format, record length, and block size of the SYSPRINT data set,
see the related reference below.
Related references
“Logical record length and block size” on page 269
You can define SYSTERM in various other ways, for example to a SYSOUT data set, a data set on disk, a file
in the z/OS UNIX file system, or to another print class.
//SYSLIN DD DSNAME=dsname,UNIT=SYSDA,
// SPACE=(subparms),DISP=(MOD,PASS)
Use the DISP parameter of the SYSLIN DD statement to indicate whether the object code data set is to
be:
• Passed to the binder (linkage-editor)
• Cataloged
• Kept
• Added to an existing cataloged library
In the example above, the data is created and passed to another job step, the binder (linkage-editor) job
step.
Your installation might use the DECK option and the SYSPUNCH DD statement. B is the standard output
class for punch data sets:
//SYSPUNCH DD SYSOUT=B
You do not need the SYSLIN DD statement if the NOOBJECT option is in effect. You do not need the
SYSPUNCH DD statement if the NODECK option is in effect.
Related references
“OBJECT” on page 393
“DECK” on page 360
//SYSADATA DD DSNAME=dsname,UNIT=SYSDA
The SYSADATA file will be a sequential file that contains specific record types that have information about
the program that is collected during compilation. The file can be a traditional MVS data set or a z/OS UNIX
file.
Related references
“ADATA” on page 345
//SYSJAVA DD PATH='/u/userid/java/Classname.java',
// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
// PATHMODE=SIRWXU,
// FILEDATA=TEXT
Related tasks
“Compiling OO applications in JCL or TSO/E” on page 295
//SYSDEBUG DD DSNAME=dsname,UNIT=SYSDA
The SYSDEBUG data set can be a sequential data set, a PDS or PDSE member, or an HFS file. For details
about how to specify the record format, record length, and block size of the SYSDEBUG data set, see the
related reference below about logical record length and block size.
Language Environment uses SYSDEBUG for its dump services. If the TEST|
NOTEST(...,SEPARATE(DSNAME),...) compiler option is in effect, the SYSDEBUG dataset name is
stored in the object program and is used as the default at run time. You can change the name of that data
set at run time by using the SYSDEBUG COBOL debug file user exit, IGZIUXB. You can direct IBM z/OS
Debugger to a renamed data set using the SET DEFAULT LISTINGS command, user exit EQAUEDAT, or
the EQADEBUG DD statement.
The dataset name that you specify in DDNAME SYSDEBUG might be used by several IBM products,
including Language Environment, IBM z/OS Debugger , Fault Analyzer, and Application Performance
Analyzer. For details, see the documentation of those individual products.
Related tasks
Language Environment Customization (Modifying the COBOL debug file name)
IBM z/OS Debugger User's Guide (How does Debug Tool locate COBOL and PL/I
separate debug files)
Related references
“Logical record length and block size” on page 269
“TEST” on page 414
272 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Defining the library-processing output file (SYSMDECK)
The SYSMDECK DD allocation is required for all compilations. If you specify the MDECK compiler option,
the SYSMDECK DD allocation must specify a permanent MVS data set or a z/OS UNIX file. However, if you
use the NOMDECK option, SYSMDECK can alternatively be specified as a utility (temporary) data set.
The following example specifies a permanent dataset name:
//SYSMDECK DD DSNAME=dsname,UNIT=SYSDA
//SYSMDECK DD PATH='/path/filename.dek',
//FILEDATA=TEXT,
//PATHOPTS=(ORDWR,OCREAT,OTRUNC),
//PATHMODE=(SIRUSR,SIWUSR)
//SYSMDECK DD UNIT=SYSALLDA
The SYSMDECK file will contain a copy of the updated input source after library processing, that is, the
result of COPY, BASIS, REPLACE, EXEC SQL INCLUDE, and EXEC SQLIMS INCLUDE statements.
Related references
“MDECK” on page 386
The compiler recognizes the options in the following order of precedence from highest to lowest:
1. Installation defaults that are fixed by your site
2. Values of the BUFSIZE, OUTDD, SQL, and SQLIMS compiler options in effect for the first program in a
batch
3. Options specified on PROCESS (or CBL) statements, preceding the IDENTIFICATION DIVISION
4. Options specified on the compiler invocation (JCL PARM parameter or the TSO CALL command)
5. Installation defaults that are not fixed
This order of precedence also determines which options are in effect when conflicting or mutually
exclusive options are specified.
The precedence of options in a SYSOPTF data set depends on where you specify the OPTFILE compiler
option. For example, if you specify OPTFILE in a PROCESS statement, the SYSOPTF options supersede
the options that you specify in the compiler invocation. For further details, see the related reference
below about the OPTFILE option.
Related tasks
“Defining a compiler-option data set (SYSOPTF)” on page 270
“Specifying compiler options in the PROCESS (CBL) statement” on page 274
“Specifying compiler options in a batch compilation” on page 278
Related references
“Compiler options and compiler output under z/OS” on page 275
“COBOL compiler options” on page 339
“Conflicting compiler options” on page 344
“OPTFILE” on page 394
CBL options-list
If you do not use a sequence field, you can start a PROCESS statement in column 1 or after. If you use
a sequence field, the sequence number must start in column 1 and must contain six characters; the first
character must be numeric. If used with a sequence field, PROCESS can start in column 8 or after.
You can use CBL as a synonym for PROCESS. CBL can likewise start in column 1 or after if you do not use a
sequence field. If used with a sequence field, CBL can start in column 8 or after.
You must end PROCESS and CBL statements at or before column 72.
Use one or more blanks to separate a PROCESS or CBL statement from the first option in options-list.
Separate options with a comma or a blank. Do not insert spaces between individual options and their
suboptions.
You can code more than one PROCESS or CBL statement. If you do so, the statements must follow one
another with no intervening statements. You cannot continue options across multiple PROCESS or CBL
statements.
Your programming organization can inhibit the use of PROCESS (CBL) statements by using the default
options module of the COBOL compiler. If PROCESS or CBL statements that are not allowed by the
organization are found in a COBOL program, the COBOL compiler generates error diagnostics.
Related references
Reference format (Enterprise COBOL for z/OS Language Reference)
CBL (PROCESS) statement (Enterprise COBOL for z/OS Language Reference)
274 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Example: specifying compiler options using JCL
The following example shows how to specify compiler options under z/OS using JCL.
. . .
//STEP1 EXEC PGM=IGYCRCTL,
// PARM='LIST,NOCOMPILE(S),OBJECT,FLAG(E,E)'
. . .
[READY]
CALL 'SYS1.LINKLIB(IGYCRCTL)' 'LIST,NOCOMPILE(S),OBJECT,FLAG(E,E)'
Listing output from compilation will be in the data set defined by SYSPRINT; object output will be in
SYSLIN or SYSPUNCH. Progress and diagnostic messages can be directed to the SYSTERM data set and
included in the SYSPRINT data set. The database request module (DBRM) is the data set defined in
DBRMLIB. The separate debug file is the data set defined in SYSDEBUG.
Save the listings you produced during compilation. You can use them during the testing of your work if you
need to debug or tune. You might also use the listings for diagnosis and debugging after the application is
in production.
After compilation, fix any errors that the compiler found in your program. If no errors were detected, you
can go to the next step in the process: binding (link-editing) your program. (If you used compiler options
to suppress object code generation, you must recompile to obtain object code.)
Related tasks
Language Environment Programming Guide (Preparing to link-edit and run)
Related references
“Messages and listings
for compiler-detected errors” on page 281
“COBOL compiler options” on page 339
276 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Use the END PROGRAM marker to terminate each program in the sequence except the last program in the
batch (for which the END PROGRAM marker is optional). Alternatively, you can precede each program in
the sequence with a CBL or PROCESS statement.
If you omit the END PROGRAM marker from a program (other than the last program in a sequence of
separate programs), the next program in the sequence will be nested in the preceding program. An error
can occur in either of the following situations:
• A PROCESS statement is in a program that is now nested.
• A CBL statement is not coded entirely in the sequence number area (columns 1 through 6).
If a CBL statement is coded entirely in the sequence number area (columns 1 through 6), no error
message is issued for the CBL statement because it is considered a label for the source statement line.
“Example: batch compilation” on page 277
Related tasks
“Specifying compiler options in a batch compilation” on page 278
Related references
“NAME” on page 387
(1)
The data-set name for the LKED step SYSLMOD is changed to the temporary name &&GOSET, without
any member name.
Related references
Language Environment Programming Guide (IBM-supplied cataloged procedures)
You should be aware of the effect of certain compiler options on the precedence of compiler option
settings for each program in the batch sequence. Compiler options are recognized in the following order of
precedence, from highest to lowest:
1. Installation defaults that are fixed at your site
2. Values of the BUFSIZE, DEFINE, OUTDD, SQL, SQLIMS, and TEST compiler options in effect for the first
program in the batch
3. Options on CBL or PROCESS statements, if any, for the current program
4. Options specified in the compiler invocation (JCL PARM or TSO CALL)
5. Installation defaults that are not fixed
If any program in the batch sequence requires the BUFSIZE, DEFINE, OUTDD, SQL, SQLIMS, or TEST
option, that option must be in effect for the first program in the batch sequence. (When processing BASIS,
COPY, or REPLACE statements, the compiler handles all programs in the batch as a single input file.)
If you specify the option for the batch, you cannot change the NUMBER and SEQUENCE options during the
batch compilation. The compiler treats all programs in the batch as a single input file during NUMBER and
SEQUENCE processing under the option; therefore, the sequence numbers of the entire input file must be
in ascending order.
If the compiler diagnoses the LANGUAGE option on the CBL or PROCESS statement as an error, the
language selection reverts to what was in effect before the compiler encountered the first CBL or
PROCESS statement. The language in effect during a batch compilation conforms to the rules of
processing CBL or PROCESS statements in that environment.
Related references
“DEFINE” on page 360
PP 5655-EC6 IBM Enterprise COBOL for z/OS 6.4.0 PXXXXXX Date 05/31/2022. . .
278 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Invocation parameters:
NOTERM
PROCESS(CBL) statements:
CBL CURRENCY,FLAG(I,I)
Options in effect: All options are installation defaults unless otherwise noted:
NOADATA
ADV
QUOTE
ARITH(COMPAT)
NOAWO
NOBLOCK0
BUFSIZE(4096)
. . .
CURRENCY Process option PROGRAM 1
. . .
FLAG(I,I) Process option PROGRAM 1
. . .
NOTERM INVOCATION option
. . .
End of compilation for program 1
. . .
PP 5655-EC6 IBM Enterprise COBOL for z/OS 6.4.0 PXXXXXX Date 05/31/2022. . .
PROCESS(CBL) statements:
CBL APOST
Options in effect:
NOADATA
ADV
APOST Process option PROGRAM 2
ARITH(COMPAT)
NOAWO
NOBLOCK0
BUFSIZE(4096)
. . .
NOCURRENCY Installation default option for PROGRAM 2
. . .
FLAG(I) Installation default option
. . .
NOTERM INVOCATION option remains in effect
. . .
End of compilation for program 2
(1)
The installation default is EN. The invocation option was XX, a nonexistent language. EN is the
language in effect.
Related tasks
“Generating a list of compiler
messages” on page 281
Related references
“Messages and listings
for compiler-detected errors” on page 281
280 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Generating a list of compiler messages
You can generate a complete listing of compiler diagnostic messages with their message numbers,
severities, and text by compiling a program that has program-name ERRMSG.
You can code just the PROGRAM-ID paragraph, as shown below, and omit the rest of the program.
Identification Division.
Program-ID. ErrMsg.
Related tasks
“Customizing compiler-message severities” on page 835
Related references
“Messages and listings
for compiler-detected errors” on page 281
“Format of compiler diagnostic messages” on page 281
Related tasks
“Correcting errors in your source program” on page 280
“Generating a list of compiler
messages” on page 281
Related references
“Format of compiler diagnostic messages” on page 281
“Severity codes for
compiler diagnostic messages” on page 282
“FLAG” on page 369
nnnnnn
The number of the source statement of the last line that the compiler was processing. Source
statement numbers are listed on the source printout of your program. If you specified the NUMBER
option at compile time, the numbers are the original source program numbers. If you specified
NONUMBER, the numbers are those generated by the compiler.
IGY
A prefix that identifies that the message was issued by the COBOL compiler.
Related references
“Severity codes for
compiler diagnostic messages” on page 282
“FLAG” on page 369
The final return code at the end of compilation is generally the highest return code that occurred for any
message during the compilation.
You can suppress compiler diagnostic messages or change their severities, however, which can have an
effect upon the final compilation return code. For details, see the related information.
Related tasks
“Customizing compiler-message severities” on page 835
Related references
“Processing of MSGEXIT” on page 833
282 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Chapter 15. Compiling under z/OS UNIX
Compile Enterprise COBOL programs under z/OS UNIX by using the cob2 command. Under z/OS UNIX,
you can compile any COBOL program that you can compile under z/OS. The object code generated by the
COBOL compiler can run under z/OS.
As part of the compilation step, you define the files needed for the compilation, and specify any compiler
options or compiler-directing statements that are necessary for your program and for the output that you
want.
The main job of the compiler is to translate COBOL programs into language that the computer can
process (object code). The compiler also lists errors in source statements and provides supplementary
information to help you debug and tune programs.
Related tasks
“Setting environment variables under z/OS UNIX” on page 283
“Specifying compiler options under z/OS UNIX” on page 284
“Compiling and linking with the cob2 command” on page 285
“Compiling using scripts” on page 290
“Compiling, linking, and running OO applications under z/OS UNIX” on page 291
Related references
“Data sets used by the compiler under z/OS” on page 267
“Compiler options and compiler output under z/OS” on page 275
export SYSLIB=/u/mystuff/copybooks
The value that you assign to an environment variable can include other environment variables or the
variable itself. The values of these variables apply only when you compile from the shell where you issue
the export command. If you do not set an environment variable, either a default value is applied or the
variable is not defined. The environment-variable names must be uppercase.
The environment variables that you can set for use by the compiler are as follows:
COBOPT
Specify compiler options separated by blanks or commas. Separate suboptions with commas. Blanks
at the beginning or the end of the variable value are ignored. Delimit the list of options with quotation
marks if it contains blanks or characters that are significant to the z/OS UNIX shell. For example:
COBOL_INSTALL_DIR
The cob2 utility and related files are normally installed under the HFS directory /usr/lpp/IBM/
cobol/igyv6r4. If the cob2 utility is installed somewhere else on your system, it is necessary to set
the COBOL_INSTALL_DIR environment variable to that location in order to use the utility.
SYSLIB
Specify paths to directories to be used in searching for COBOL copybooks if you do not specify
an explicit library-name in the COPY statement. Separate multiple paths with a colon. Paths are
Related tasks
“Specifying compiler options under z/OS UNIX” on page 284
“Compiling and linking with the cob2 command” on page 285
“Setting and accessing environment variables” on page 526
Related references
Chapter 20, “Compiler-directing statements,” on page 439
“COBOL compiler options” on page 339
COPY statement (Enterprise COBOL for z/OS Language Reference)
284 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
6. Installation defaults that are not fixed
Restrictions:
• The SQL coprocessor can be used with a compile job initiated from z/OS UNIX. All the following
conditions must be met for this to work:
– The Db2 data set that contains the Db2 coprocessor services must be included in your STEPLIB,
unless these services are in the LNKLST. Typically, this data set is called xxxxxx.SDSNLOAD. For
example, for DB2® 11 it might be DSNB10.SDSNLOAD, but your installation might have changed the
name.
– The SQL compiler option must be specified.
– The -dbrmlib option of cob2 must be specified. Suppose that file is the name of the input COBOL
file to compile:
- Use dbrmlib=xxx to direct the database request module (DBRM) to an existing PDS data set,
where a new member named file will be created.
- Use -dbrmlib (without =xxx) to send the DBRM to an HFS file named file.dbrm.
The separate SQL precompiler does not run under z/OS UNIX.
• Do not use the SQLIMS compiler option under z/OS UNIX.
• The OPTFILE option is ignored when you compile using the cob2 command under z/OS UNIX.
You can use the COBOPT environment variable, which provides a capability that is comparable to
OPTFILE, instead.
Related tasks
“Specifying compiler options in the PROCESS (CBL) statement” on page 274
“Setting environment variables under z/OS UNIX” on page 283
“Compiling and linking with the cob2 command” on page 285
Related references
“Conflicting compiler options” on page 344
“COBOL compiler options” on page 339
export STEPLIB=IGY.V6R4M0.SIGYCOMP
The cob2 command implicitly uses the z/OS UNIX shell command c89 for the link step. c89 is the shell
interface to the linker (the z/OS program management binder).
The default location for compiler input and output is the current directory.
Only files with the suffix .cbl are passed to the compiler; cob2 passes all other files to the linker.
Related tasks
“Creating a DLL under z/OS UNIX” on page 286
“Preparing OO applications under z/OS UNIX” on page 292
UNIX System Services User's Guide
Related references
“cob2 syntax and options” on page 287
“cob2 input and output files” on page 289
UNIX System Services Command Reference
“Example: using cob2 to compile and link under z/OS UNIX” on page 286
Related tasks
Chapter 30, “Creating a DLL or a DLL
application,” on page 579
“Compiling programs to create
DLLs” on page 580
Related references
“cob2 syntax and options” on page 287
“cob2 input and output files” on page 289
cob2 -c alpha.cbl
286 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
• To compile two files called alpha.cbl and beta.cbl, enter:
This command creates alpha.o and beta.o, then links alpha.o, beta.o, and the COBOL libraries. If the link
step is successful, it produces an executable program named gamma.
• To compile alpha.cbl with the LIST and NOADATA options, enter:
• To compile alpha.cbl with the SQL option so that the database request module (DBRM) is written to
member "alpha" of the existing PDS data set USER.COBOL.DBRMLIB, enter:
Note: The SQL coprocessor must be in your STEPLIB in order for this to work.
• To compile alpha.cbl with the SQL option so that the database request module (DBRM) is written to
z/OS UNIX file alpha.dbrm, enter:
Note: The SQL coprocessor must be in your STEPLIB in order for this to work, and you need to use the
SQL coprocessor for Db2 12 with APAR PI88171 applied.
If you specify cob2 without any options or input files, the compiler manual page will be displayed.
-bxxx
Passes the string xxx to the linker as parameters. xxx is a list of linker options in name=value format,
separated by commas. You must spell out both the name and the value in full (except for the special
cases noted below). The name and value are case insensitive. Do not use any spaces between -b and
xxx.
If you do not specify a value for an option, a default value of YES is used except for the following
options, which have the indicated default values:
• LIST=NOIMPORT
• ALIASES=ALL
• COMPAT=CURRENT
• DYNAM=DLL
288 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
-M
Generates a make dependency file that contains the path and file names of all the z/OS UNIX-based
copybook files for the source files that are input to the compiler. Here is sample output:
mkdepend.o: mkdepend.cbl
mkdepend.o: /home/usera/test/f171592/WSCOPY1.cpy
mkdepend.o: /home/usera/test/f171592/PDCOPY1.cpy
mkdepend.o: /home/usera/test/f171592/PDCOPY2.cpy
-o xxx
Names the object module xxx. If the -o option is not used, the name of the object module is a.out.
-qxxx
Passes xxx to the compiler, where xxx is a list of compiler options separated by blanks or commas.
Enclose xxx in quotation marks if a parenthesis is part of the option or suboption, or if you use blanks
to separate options. Do not insert spaces between -q and xxx.
-v
Displays the generated commands that are issued by cob2 for the compile and link steps, including
the options being passed, and executes them. Here is sample output:
-#
Displays compile and link steps, but does not execute them.
-?
Displays the manual page of the compiler. If you specify cob2 -?, regardless of whether you provide
input files, the compiler manual page is displayed and the compilation stops. This option has the same
effect as -help.
Related tasks
“Compiling and linking with the cob2 command” on page 285
“Creating a DLL under z/OS UNIX” on page 286
“Setting environment variables under z/OS UNIX” on page 283
If you use the cob2 command, the following files are created in the current directory.
Related tasks
“Compiling and linking with the cob2 command” on page 285
Related references
“ADATA” on page 345
“MDECK” on page 386
“TEST” on page 414
UNIX System Services Command Reference
290 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Chapter 16. Compiling, linking, and running OO
applications
It is recommended that you compile, link, and run object-oriented (OO) applications in the z/OS UNIX
environment. However, with certain limitations explained in the Related tasks, it is possible to compile,
link, and run OO COBOL applications by using standard batch JCL or TSO/E commands.
Related tasks
“Compiling, linking, and running OO applications under z/OS UNIX” on page 291
“Compiling, linking, and running OO applications in JCL or TSO/E” on page 295
“Using Java SDKs
for z/OS” on page 298
Related tasks
“Compiling OO applications under z/OS UNIX” on page 291
“Preparing OO applications under z/OS UNIX” on page 292
“Running OO applications under z/OS UNIX” on page 293
Related tasks
Chapter 15, “Compiling under z/OS UNIX,” on page 283
“Preparing OO applications under z/OS UNIX” on page 292
“Running OO applications under z/OS UNIX” on page 293
“Setting and accessing environment variables” on page 526
“Accessing JNI services” on page 719
After you issue the cob2 and javac commands successfully, you have the executable components for
the program: the executable DLL module libClassname.so and the class file Classname.class. All
files from these commands are generated in the current working directory.
“Example: compiling and linking a COBOL class definition under z/OS UNIX” on page 293
Related tasks
Chapter 15, “Compiling under z/OS UNIX,” on page 283
“REPOSITORY paragraph for defining a class” on page 684
Related references
“cob2 syntax and options” on page 287
“Object-oriented syntax, and Java 6
or later” on page 299
292 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Example: compiling and linking a COBOL class definition under z/OS UNIX
This example illustrates the commands that you use and the files that are produced when you compile
and link a COBOL class definition, Manager.cbl, using z/OS UNIX shell commands.
The class file Manager.class and the DLL module libManager.so are the executable components of
the application, and are generated in the current working directory.
Related tasks
“Running OO applications that start with a main method” on page 294
“Running OO applications that start with a COBOL program” on page 294
“Running J2EE COBOL clients” on page 294
Chapter 25, “Running COBOL programs under z/OS UNIX,” on page 525
“Setting and accessing environment variables” on page 526
Chapter 39, “Writing object-oriented programs,” on page 679
“Structuring OO applications” on page 715
For details about the options that the JVM supports, see the output from the java -h command, or see
the Related references.
Related references
IBM SDK for Java - Tools Documentation
WebSphere for z/OS: Applications (Java Naming and Directory Interface (JNDI))
Related tasks
“Using Java SDKs
for z/OS” on page 298
Chapter 25, “Running COBOL programs under z/OS UNIX,” on page 525
“Setting and accessing environment variables” on page 526
Related references
IBM SDK for Java - Tools Documentation
WebSphere for z/OS: Applications (Java Naming and Directory Interface (JNDI))
294 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Before you run a COBOL J2EE client, you must set the Java system property java.naming.factory.initial to
access WebSphere naming services. For example:
export COBJVMINITOPTIONS
="-Djava.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory"
Related tasks
“Compiling OO applications in JCL or TSO/E” on page 295
“Preparing and running OO applications in JCL or TSO/E” on page 296
“Compiling, linking, and running OO applications under z/OS UNIX” on page 291
//SYSJAVA DD PATH='/u/userid/java/Classname.java',
// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
// PATHMODE=SIRWXU,
// FILEDATA=TEXT
Do not edit this generated Java class definition in any way. If you change the COBOL class definition, you
must regenerate both the object file and the Java class definition by recompiling the updated COBOL class
definition.
Compile Java class definitions by using the javac command from a z/OS UNIX shell command prompt, or
by using the BPXBATCH utility.
“Example: compiling, linking, and running an OO application using JCL” on page 297
Related tasks
“Compiling with JCL” on page 255
“Compiling under TSO” on page 262
“Specifying source libraries (SYSLIB)” on page 270
“Defining the Java-source
Related references
“DBCS” on page 360
“DLL” on page 363
“RENT” on page 401
“THREAD” on page 418
Appendix F, “JNI.cpy copybook,” on page 847
UNIX System Services User's Guide (The BPXBATCH utility)
INCLUDE '/usr/lpp/java/IBM/J8.0/bin/j9vm/libjvm.x'
INCLUDE '/usr/lpp/cobol/igyv6r4/lib/igzcjava.x'
• Create a file that contains the environment variable settings that are required for Java. For example, a
file /u/userid/javaenv might contain the three lines shown below to set the PATH, LIBPATH, and
CLASSPATH environment variables.
PATH=/bin:/usr/lpp/java/IBM/J8.0/bin
LIBPATH=/lib:/usr/lib:/usr/lpp/java/IBM/J8.0/bin:/usr/lpp/java/IBM/J8.0/bin/j9vm
CLASSPATH=.:/u/userid/applications
To customize the initialization of the JVM that will be used by the application, you can set the
COBJVMINITOPTIONS environment variable in the same file. For example, to access enterprise beans
that run in a WebSphere server, you must set the Java system property java.naming.factory.initial. For
details, see the related task about running OO applications.
When you run an OO application that starts with a COBOL program by using standard batch JCL or the
TSO/E CALL command, follow these guidelines:
• Use the _CEE_ENVFILE environment variable to indicate the location of the file that contains the
environment variable settings required by Java. Set _CEE_ENVFILE by using the ENVAR runtime option.
• Specify the POSIX(ON) and XPLINK(ON) runtime option.
• Use DD statements to specify files in the z/OS UNIX file system for the standard input, output, and error
streams for Java:
– JAVAIN DD for the input from statements such as c=System.in.read();
296 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
– JAVAOUT DD for the output from statements such as System.out.println(string);
– JAVAERR DD for the output from statements such as System.err.println(string);
• Ensure that the SCEERUN2 and SCEERUN load libraries are available in the system library search order,
for example, by using a STEPLIB DD statement.
“Example: compiling, linking, and running an OO application using JCL” on page 297
Related tasks
“Preparing OO applications under z/OS UNIX” on page 292
“Running OO applications under z/OS UNIX” on page 293
“Structuring OO applications” on page 715
UNIX System Services User's Guide (The BPXBATCH utility)
Language Environment Programming Guide (Running an application under batch)
Related references
XL C/C++ Programming Guide (_CEE_ENVFILE)
Language Environment Programming Reference (ENVAR)
//TSTHELLO JOB ,
// TIME=(1),MSGLEVEL=(1,1),MSGCLASS=H,CLASS=A,REGION=200M,
// NOTIFY=&SYSUID,USER=&SYSUID
//*
// SET COBPRFX='IGY.V6R4M0'
// SET LIBPRFX='CEE'
//*
//COMPILE EXEC PGM=IGYCRCTL,
//SYSLIN DD DSNAME=&&OBJECT(TSTHELLO),UNIT=VIO,DISP=(NEW,PASS),
// SPACE=(CYL,(1,1,1))
//SYSPRINT DD SYSOUT=*
//STEPLIB DD DSN=&COBPRFX..SIGYCOMP,DISP=SHR
// DD DSN=&LIBPRFX..SCEERUN,DISP=SHR
// DD DSN=&LIBPRFX..SCEERUN2,DISP=SHR
//SYSUT1 DD UNIT=VIO,SPACE=(CYL,(1,1))
//SYSUT2 DD UNIT=VIO,SPACE=(CYL,(1,1))
//SYSUT3 DD UNIT=VIO,SPACE=(CYL,(1,1))
//SYSUT4 DD UNIT=VIO,SPACE=(CYL,(1,1))
//SYSUT5 DD UNIT=VIO,SPACE=(CYL,(1,1))
//SYSUT6 DD UNIT=VIO,SPACE=(CYL,(1,1))
//SYSUT7 DD UNIT=VIO,SPACE=(CYL,(1,1))
//SYSUT8 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSUT9 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSUT10 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSUT11 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSUT12 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSUT13 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSUT14 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSUT15 DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSMDECK DD UNIT=SYSALLDA,SPACE=(CYL,(1,1))
//SYSIN DD *
cbl dll,thread
Identification division.
Program-id. "TSTHELLO" recursive.
Environment division.
Configuration section.
Repository.
Class HelloJ is "HelloJ".
class HelloJ {
public static void sayHello() {
System.out.println("Hello World, from Java!");
}
}
HelloJ.java is compiled with the javac command. The resulting .class file resides in the z/OS UNIX
file system directory u/userid/ootest/tsthello, which is specified in the CLASSPATH environment
variable in the environment variable settings file.
PATH=/bin:/usr/lpp/java/IBM/J8.0/bin
LIBPATH=/lib:/usr/lib:/usr/lpp/java/IBM/J8.0/bin:/usr/lpp/java/IBM/J8.0/bin/j9vm
CLASSPATH=.:/u/userid/ootest/tsthello
298 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
When you are running an application under z/OS UNIX, you can set the XPLINK(ON) option by using the
_CEE_RUNOPTS environment variable as follows:
_CEE_RUNOPTS="XPLINK(ON)"
Exporting _CEE_RUNOPTS="XPLINK(ON)" so that it is in effect for the entire z/OS UNIX shell session is
not recommended, however. Suppose for example that an OO COBOL application starts with a COBOL
program called App1Driver. One way to limit the effect of the XPLINK option to the execution of
the App1Driver application is to set the _CEE_RUNOPTS variable on the command-line invocation of
App1Driver as follows:
_CEE_RUNOPTS="XPLINK(ON)" App1Driver
Related tasks
“Running OO applications under z/OS UNIX” on page 293
“Setting and accessing environment variables” on page 526
Related references
“Object-oriented syntax, and Java 6
or later” on page 299
“Runtime environment variables” on page 527
Language Environment Programming Reference (XPLINK)
XL C/C++ Programming Guide (_CEE_RUNOPTS)
Related tasks
“Preparing OO applications under z/OS UNIX” on page 292
302 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Preparing to compile, bind, and run non-OO COBOL applications
that interoperate with Java
This section discusses prerequisites for building and running non-OO COBOL programs that interoperate
with Java.
In the discussion, compiling and linking will be done from z/OS UNIX using the cob2 utility, and building
the stub program DLL needed at run time by the application will be done from z/OS UNIX using the cjbuild
utility. However, examples of how to send both the program objects and DLL to an MVS data set are
provided.
Note: Both cob2 and the cjbuild utility exist in the bin directory of your COBOL install directory in the z/OS
UNIX file system. The default location is /usr/lpp/cobol/igyvXrY, where X is the compiler version
and Y is the compiler release. This directory must be included in your UNIX PATH environment variable.
The cjbuild utility is provided as a UNIX only utility, but it can be launched from JCL using BPXBATCH.
Ensure that the JAVA_HOME environment variable is set to the Java SDK installation directory on your
system. For example, if you use Java 8, the directory might be /usr/lpp/java/IBM/J8.0 for AMODE
31 (31-bit) Java, and /usr/lpp/java/IBM/J8.0_64 for AMODE 64 (64-bit) Java.
Note: You can choose any method to compile and link parts, such as JCL and z/OS UNIX command line.
The z/OS UNIX method is used because UNIX is a natural environment for Java.
Chapter 17. Compiling, linking, and running non-OO COBOL applications that interoperate with Java 303
For the COBPROD application, the following commands build the COBOL files, instructing the compiler to
send any generated stub files and Java files to the z/OS UNIX directory ${HOME}/jtoc/docs.
Since you are compiling these programs with the default LP(32) option by default, the compiler assumes
you are targeting 31-bit Java. To target 64-bit Java instead of 31-bit Java, you would simply change the
compile commands to include the JAVA64 suboption of the JAVAIOP option.
Note: If this application starts on the Java side, there is no need to specify the JVMINIOPTIONS
suboption, since it is Java that starts the JVM.
Related references
JAVAIOP
“Example: COBPROD application - building and running” on page 308
JAVA-CALLABLE (Enterprise COBOL for z/OS Language Reference)
JAVA-SHAREABLE (Enterprise COBOL for z/OS Language Reference)
The table lists a summary of the arguments passed to cjbuild in this example and their meanings:
304 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 43.
Augments Meanings
-v Verbose output. The actual commands to compile
and link the DLL and build any related Java source
files are displayed, for example, cob2, javac, etc.
Verbose output is strongly recommended.
-d “//COBOL.LOAD”
or
-d “//‘USER.COBOL.LOAD’”
Chapter 17. Compiling, linking, and running non-OO COBOL applications that interoperate with Java 305
Table 43. (continued)
Augments Meanings
-p enterprise.COBOL Tells cjbuild the package name to which the progs
and strg classes are to belong. The progs and
strg classes provide the interface from Java
to COBOL native methods and COBOL working-
storage items, respectively.
Default: enterprise.COBOL
To output the DLL to an MVS data set called USER.COBOL.LOAD, issue the following command:
Note: When the DLL is output to an MVS data set, make sure that data set is included in your STEPLIB at
run time; otherwise, the JVM won’t be able to locate it. When the DLL is output to a z/OS UNIX directory,
that directory must be specified to the JVM using its java.library.path property.
When cjbuild runs, three Java files are also created and compiled:
• cobol.java
• progs.java
• strg.java
These files contain the Java classes progs and strg that provide the interfaces that allow you to access
COBOL native methods and working-storage items. These class names are qualified by whatever package
name you specified using the -p option.
For example, in this case, since -p specifies enterprise.COBOL as the package name, you can access
native methods and WORKING-STORAGE items as follows in their Java program:
• enterprise.COBOL.progs.COBPROD
• enterprise.COBOL.strg.COBPROD
Any COBOL program that contains the JAVA-SHAREABLE directive will also generate a Java file that
defines classes that can be used from a Java application to interface directly with COBOL WORKING-
STORAGE memory. These Java files will be identified from the corresponding COBOL program name in the
methods file and will be automatically built by cjbuild. The resulting class files will be placed in a directory
indicated by the -j option of cjbuild. Alternatively, consider specifying the -r/--jar <jar-file>
option instead to build all the .class files generated into a single .jar file with the name <jar-file>.
An example output of the cjbuild utility:
PROGRAM_FILE = none
LIB_BASE_NAME = app1
COBOL_DIR = ./out
DLL_OUT_DIR = //COBOL.LOAD
JAVA_CLASS_DIR = ./class
JAVA_SRC_DIR = .
JAR_FILE = libapp1.jar
PACKAGE_NAME = enterprise.COBOL
INTEROP_MODE = MIX_31_64
JAVA_HOME: /usr/lpp/java/J11.0_64
COBOL_INSTALL_DIR: /home/userid/cobol/igyv6r4
306 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
# Compiling native method call stub COBPROD_java_native_app1
/home/userid/cobol/igyv6r4/bin/cob2 -qlist -qopt(1),nsymbol(national),dbcs,dispsign(sep) -c ./
COBPROD_java_native_app1.cbl -I /home/userid/cobol/igyv6r4/include
# Command return code 0
Related references
JAVAIOP
“cjbuild command reference
” on page 330
“Example: COBPROD application - building and running” on page 308
JAVA-CALLABLE (Enterprise COBOL for z/OS Language Reference)
JAVA-SHAREABLE (Enterprise COBOL for z/OS Language Reference)
Chapter 17. Compiling, linking, and running non-OO COBOL applications that interoperate with Java 307
Note: If the -d option of cjbuild indicates that the output DLL is to be written to a data set, then the side
deck should also be available in a data set with the same name as the output data set, except that the last
name part is replaced with EXP. For example, if the DLL was written to data set USER.COBOL.LOAD, then
the side deck file would be available in a data set called USER.COBOL.EXP. cjbuild will always guarantee
that a copy of the side deck is available in the z/OS UNIX directory from which the cjbuild utility is run.
Use the following commands to link the COBOL programs cobprod and addlist, sending the resulting
program objects to MVS data set USER.COBOL.LOAD. Run the commands from the directory of stub files:
Related references
“Example: COBPROD application - building and running” on page 308
import enterprise.COBOL.*;
308 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
cobprod.cbl
COBOL program that initializes WORKING-STORAGE with a table of product information that can be
accessed from Java.
addlist.cbl
COBOL program that adds a list of prices together and dumps the resulting value to the terminal by
making a call back to Java.
CobProd.java
Defines the Cobprod Java class that is the Java-based demo driver.
The following script files for building and running the COBPROD application are also provided:
build.sh
A shell script for building the COBPROD application. Instructions for building using the script are
contained in the script itself.
Invoke build.sh at the z/OS UNIX command line. A mixed AMODE application (AMODE 31 COBOL
and AMODE 64 Java) will be built.
makefile
As an alternative to the build.sh script, a makefile is provided to demonstrate how a makefile could
be used to build an interoperable application for those that prefer makefiles. For the makefile build, a
mixed AMODE application (AMODE 31 COBOL, AMODE 64 Java) is always built.
Initiate a makefile-based build by issuing the following command at the z/OS UNIX command line in a
directory that contains the makefile:
make
run.sh
A shell script for running the interoperable application. Works for applications built using either
build.sh or makefile. See the script for details about how to run it.
Other miscellaneous files are provided:
README
Contains detailed information about building and running the COBPROD application.
cobprod.cbl
*********************************************************************
* *
* IBM Enterprise COBOL for z/OS *
* Version 6 Release 4 Modification 0 *
* *
* LICENSED MATERIALS - PROPERTY OF IBM. *
* *
* 5655-EC6 COPYRIGHT IBM CORP. 2022, 2024 *
* *
* US GOVERNMENT USERS RESTRICTED RIGHTS - USE, *
* DUPLICATION OR DISCLOSURE RESTRICTED BY GSA *
* ADP SCHEDULE CONTRACT WITH IBM CORP. *
* *
*********************************************************************
* cobprod initializes a working-storage item with some
* product information to be shared with Java
identification division.
program-id. cobprod.
data division.
working-storage section.
* Product info table, shared with Java
* NOTE: This is for demonstration purposes only.
* Data should NOT be placed in your COBOL program code.
01 prod-list-size pic s9(9) comp-5 value 5.
01 prod-info-data.
03 filler.
05 filler pic x(20) value 'chair'.
05 filler pic s9(9)v9(2) value 29.99.
03 filler.
05 filler pic x(20) value 'table'.
05 filler pic s9(9)v9(2) value 45.98.
03 filler.
Chapter 17. Compiling, linking, and running non-OO COBOL applications that interoperate with Java 309
05 filler pic x(20) value 'bed'.
05 filler pic s9(9)v9(2) value 149.45.
03 filler.
05 filler pic x(20) value 'blanket'.
05 filler pic s9(9)v9(2) value 19.99.
03 filler.
05 filler pic x(20) value 'sofa'.
05 filler pic s9(9)v9(2) value 239.99.
* Make this table directly accessible to Java
>>java-shareable on
01 prod-info redefines prod-info-data.
03 prod-list occurs 5 times.
05 prod-name pic x(20).
05 prod-price pic s9(9)v9(2).
>>java-shareable off
linkage section.
01 prod-list-size-out pic s9(9) comp-5.
>>java-callable
procedure division returning prod-list-size-out.
MainProgram.
* Populate table
move prod-list-size to prod-list-size-out
goback.
end program cobprod.
addlist.cbl
cbl pgmname(longmixed)
*********************************************************************
* *
* IBM Enterprise COBOL for z/OS *
* Version 6 Release 4 Modification 0 *
* *
* LICENSED MATERIALS - PROPERTY OF IBM. *
* *
* 5655-EC6 COPYRIGHT IBM CORP. 2022, 2024 *
* *
* US GOVERNMENT USERS RESTRICTED RIGHTS - USE, *
* DUPLICATION OR DISCLOSURE RESTRICTED BY GSA *
* ADP SCHEDULE CONTRACT WITH IBM CORP. *
* *
*********************************************************************
* Receives a list of decimal items and calculates
* and returns the sum. Maxium list size 3
identification division.
program-id. 'addlist'.
data division.
working-storage section.
local-storage section.
01 idx pic s9(9) comp-5.
linkage section.
01 pricelist.
03 price pic s9(9)v9(2) comp-3 occurs 3 times.
01 listsize pic s9(9) comp-5.
01 result pic s9(9)v9(2) comp-3.
>>java-callable
procedure division using by reference pricelist
by value listsize
returning result.
MainProgram.
* Compute sum of list
display '<<COBOL: addlist: entered>>'
compute result = 0
CobProd.java
//*******************************************************************
// *
310 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
// IBM Enterprise COBOL for z/OS *
// Version 6 Release 4 Modification 0 *
// *
// LICENSED MATERIALS - PROPERTY OF IBM. *
// *
// 5655-EC6 COPYRIGHT IBM CORP. 2022, 2024 *
// *
// US GOVERNMENT USERS RESTRICTED RIGHTS - USE, *
// DUPLICATION OR DISCLOSURE RESTRICTED BY GSA *
// ADP SCHEDULE CONTRACT WITH IBM CORP. *
// *
//*******************************************************************
import enterprise.COBOL.*;
import java.math.*;
System.out.println();
System.out.println("Java: Access COBOL product info from COBPROD");
System.out.println(enterprise.COBOL.strg.COBPROD.PROD_INFO.PROD_LIST[i].PROD_PRICE.get());
}
System.out.println();
System.out.println();
System.out.println("Java: Price of chair+table+sofa is: $" + result);
System.out.println();
System.out.println("<<Java: CobProd.main: exited>>");
}
}
build.sh
#!/bin/sh
###############################################################################
#
# IBM Enterprise COBOL for z/OS
# Version 6 Release 4 Modification 0
#
# LICENSED MATERIALS - PROPERTY OF IBM.
#
# 5655-EC6 COPYRIGHT IBM CORP. 2022, 2024
#
# US GOVERNMENT USERS RESTRICTED RIGHTS - USE,
# DUPLICATION OR DISCLOSURE RESTRICTED BY GSA
# ADP SCHEDULE CONTRACT WITH IBM CORP.
#
###############################################################################
##############################################################################
# Build script for the COBOL/Java interoperability demo COBPROD
##############################################################################
Chapter 17. Compiling, linking, and running non-OO COBOL applications that interoperate with Java 311
#
# Invocation:
# -----------
#
# build.sh - build mixed amode interoperable application
#
# NOTE:
# -----
#
# 1) Make sure cjbuild and cob2 are in your PATH before running this script
#
# 2) Make sure JAVA_HOME is set appropriately
#
# 3) Make sure your STEPLIB includes an Enterprise COBOL V6.4 or later
# compiler and a runtime that is sufficient to run COBOL programs
# compiled with the Enterprise COBOL V6.4 or later compiler
#
# 4) You must have an existing data set to receive COBOL program objects
# and DLLs and it must be called <USER>.COBOL.LOAD, where <USER> is
# your high-level qualifier
#
##############################################################################
if [ -z $STEPLIB ]; then
echo "STEPLIB environment variable must be set"
exit 1
fi
if [ -z $JAVA_HOME ]; then
echo "JAVA_HOME environment variable must be set"
exit 1;
fi
OUT_DIR=./out
CLASSOUT_DIR=./class
makefile
###############################################################################
# Makefile for the COBOL/Java interoperability demo COBPROD (Mixed 31/64 mode)
###############################################################################
#
# NOTE:
# -----
#
# 1) Make sure cjbuild and cob2 are in your PATH before using this makefile
#
# 2) Make sure your STEPLIB is set to include an Enterprise V6.4 or later
# compiler and runtime
#
312 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
# 3) Make sure JAVA_HOME points to your 64-bit Java JDK
#
# e.g., JAVA_HOME=/usr/lpp/java/IBM/J8.0_64 or
# JAVA_HOME=/usr/lpp/java/IBM/J11.0_64
#
# 4) You must have an existing data set to receive COBOL program objects
# and DLLs and it must be called <USER>.COBOL.LOAD, where <USER> is
# your high-level qualifier
#
##############################################################################
MYSTEPLIB=$(USER).COBOL.LOAD:$(STEPLIB)
OUT_DIR=./out
CLASSOUT_DIR=./class
MYCLASSPATH=$(CLASSOUT_DIR):$(CLASSPATH)
setup:
@rm -fr out class
@mkdir -m 0755 out class
cobprod: cobprod.o
STEPLIB=$(MYSTEPLIB) cob2 cobprod.o -o "//COBOL.LOAD(cobprod)" libapp1.x
cobprod.o: cobprod.cbl
STEPLIB=$(MYSTEPLIB) cob2 -c cobprod.cbl "-qjavaiop(OUTPATH('$(OUT_DIR)'),JAVA64)"
addlist.o: addlist.cbl
STEPLIB=$(MYSTEPLIB) cob2 -c addlist.cbl "-qjavaiop(OUTPATH('$(OUT_DIR)'),JAVA64)"
CobProd.class: CobProd.java
CLASSPATH=$(MYCLASSPATH) $(JAVA_HOME)/bin/javac -d $(CLASSOUT_DIR) CobProd.java
clean:
rm -fr *_java_native* *WS.java *WS_base.java *.o *.class *.sig CEEDUMP.* Java.* *.x
*.so Snap.* javacore.* jitdump.* *.lst
rm -fr cobol.java progs.java strg.java
rm -fr LIBAPP1* libapp1*
rm -fr out
rm -fr class
run.sh
#!/bin/sh
###############################################################################
#
# IBM Enterprise COBOL for z/OS
# Version 6 Release 4 Modification 0
#
# LICENSED MATERIALS - PROPERTY OF IBM.
#
# 5655-EC6 COPYRIGHT IBM CORP. 2022, 2024
#
# US GOVERNMENT USERS RESTRICTED RIGHTS - USE,
# DUPLICATION OR DISCLOSURE RESTRICTED BY GSA
# ADP SCHEDULE CONTRACT WITH IBM CORP.
#
###############################################################################
###############################################################################
# Run script for the COBOL/Java interoperability demo COBPROD
###############################################################################
#
# NOTE:
# -----
#
# 1) Make sure your STEPLIB includes an Enterprise COBOL runtime
# that is sufficient to run programs compiled with the Enterprise
# COBOL V6.4 or later compiler.
#
# The dataset <USER>.COBOL.LOAD that received the program objects
# and DLL for your interoperable application during the build
# step must also be included in your STEPLIB. We have added this
Chapter 17. Compiling, linking, and running non-OO COBOL applications that interoperate with Java 313
# in automatically for you below.
#
# 2) Set JAVA_HOME to an appropriate 64-bit Java SDK:
#
# e.g., JAVA_HOME=/usr/lpp/java/IBM/J8.0_64 or
# JAVA_HOME=/usr/lpp/java/IBM/J11.0_64
#
# 3) If you modify this example so that cjbuild stores the DLL it
# produces to a z/OS UNIX directory, then you need to modify
# the last line of this script to the following:
#
# ${JAVA_HOME}/bin/java -Djava.library.path=<dll_out_dir> CobProd
#
###############################################################################
if [ -z $STEPLIB ]; then
echo "STEPLIB environment variable must be set"
exit 1
fi
if [ -z $JAVA_HOME ]; then
echo "JAVA_HOME environment variable must be set"
exit 1
fi
export STEPLIB=${USER}.COBOL.LOAD:${STEPLIB}
export CLASSPATH=.:./libapp1.jar:${CLASSPATH}
export IBM_JAVA_OPTIONS="-XX:+Enable3164Interoperability"
export _CEE_RUNOPTS="POSIX(ON)"
export LIBPATH=.:${JAVA_HOME}/lib/s390x/j9vm:${JAVA_HOME}/lib/s390x/:${JAVA_HOME}/bin/j9vm:$
{JAVA_HOME}/lib/j9vm:${LIBPATH}
${JAVA_HOME}/bin/java CobProd
Related references
Chapter 17, “Compiling, linking, and running non-OO COBOL applications that interoperate with Java,” on
page 301
“Sample JCL for building and running the COBPROD application” on page 314
314 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
• The LNGPRFX and LIBPRFX JCL variables are set appropriately to indicate your compiler and
runtime levels respectively.
3. Before the JCL is run for the first time, you must ensure that the two COBOL user source files in the
COBPROD application are copied to a data set with name USERID.COBOL.COBOL where USERID is the
user id of the account from which the JCL will be run. If a differently named data set is desired, the JCL
must be modified accordingly. The two user source files are:
• cobprod.cbl
• addlist.cbl
and they exist in the COBPROD application demo directory:
demo/cobol_java_interop_sample
which is located in the COBOL install directory in the z/OS UNIX file system, which typically
has a path such as /usr/lpp/cobol/igyv6r4. Copying these files to the data set can be
done using the following z/OS UNIX commands, assuming you run the commands from the
cobol_java_interop_sample directory:
cp cobprod.cbl “//’USERID.COBOL.COBOL(COBPROD)’”
cp addlist.cbl “//’USERID.COBOL.COBOL(ADDLIST)’”
Note: In a production build environment, it is most likely that your user COBOL source files are already
located in a data set. This extra copying is only needed for building these demo files which happen to
reside in the COBOL install directory in the z/OS UNIX file system.
4. The provided JCL makes use of the BPXBATCH utility to run z/OS UNIX commands from JCL.
BPXBPATCH causes a z/OS UNIX shell to be started, which in turn causes the .profile file in
your z/OS UNIX home directory to be “sourced” (that is, loaded into your environment and run). It is
common in some z/OS UNIX environments for other non-default UNIX shells to be started at the end
of the .profile file using the command:
exec <alternative-shell-program>
Note: If a non-default shell is not executed from your .profile, you may safely ignore the rest of this
point.
A non-default shell is simply a shell program that is not the default shell set for your system, which is
usually the sh UNIX command. This could cause a problem with BPXPATCH. A reliable way to prevent
such a problem is to ensure that your custom shell program is only run if you are running an interactive
shell session. This can be achieved by guarding the exec command in your .profile file as follows:
If this method does not work for some reason, the sample JCL sets a shell variable called
NO_CUSTOM_SHELL that can be used by the user in their .profile to prevent the custom shell from
running. The shell code would look like the following:
5. It is important to set the JAVA_HOME environment variable in the .profile file in the z/OS UNIX home
directory of the user that is running the JCL. The line to add to the .profile file to ensure the 31-bit
COBPROD application in the sample JCL runs successfully is:
export JAVA_HOME=/usr/lpp/java/IBM/J8.0
Chapter 17. Compiling, linking, and running non-OO COBOL applications that interoperate with Java 315
Note: Failure to do this could result in STEP 2 of the JCL failing to launch the cjbuild utility, which is a
Java program.
Output from a successful run of the application
When the application runs successfully from the JCL, the job log should contain the following output:
316 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
//* linking object files from user programs and also from
//* linking the object files associated with stub programs
//* into a DLL.
//*
//* A PDS data set (FB 80) called userid.COBOL.EXP must also
//* exist prior to running this JCL. This data set will
//* receive the side deck for the DLL produced by cjbuild
//* and is used during subsequent link steps.
//*
//* 4) You must ensure the following JCL variables are set below,
//* which control various build parameters. This includes the
//* z/OS UNIX directory into which stub files will be generated
//* by the compiler and the z/OS UNIX work directory to be
//* used by the cjbuild utility. The cjbuild utility uses this
//* directory to build the DLL needed for the interoperable
//* application.
//*
//* For this sample, we assume the z/OS UNIX directory
//* structure to be used for building the application is as
//* follows:
//*
//* /home/userid/jtoc/cobprod
//* - main work directory
//* /home/userid/jtoc/cobprod/out
//* - stub file output directory (compiler places stub
//* files here)
//* /home/userid/jtoc/cobprod/class
//* - directory where cjbuild places any generated .class
//* files
//*
//* The following variables must be set:
//*
//* JAVAHOME
//* ZFSCBDIR
//* OUTDIR
//* INTMODE
//* WORKDIR
//* CLASSOUT
//* JVSRCOUT
//* PKGNAME
//* DLLNAME
//*
//* See below for detailed descriptions of how to set these
//* variables. Example values are provided.
//*
//* NOTE: z/OS UNIX directories for stub files and the work
//* directory for cjbuild do not have to exist. The
//* JCL below create the directories if they do not
//* exist prior to running this job (see STEP 0).
//*
//*********************************************************************
// EXPORT SYMLIST=*
//*********************************************************************
//* Set compiler and run time library levels below
//*******************************************************************
// SET LIBPRFX='CEE'
// SET LNGPRFX='COBOL.COMPILER'
//*******************************************************************
//* JAVAHOME: Set this to your Java home directory. This will be used
//* to set the JAVA_HOME environment variable needed by
//* Java operations
//*******************************************************************
// SET JAVAHOME='/usr/lpp/java/J11.0_64'
//*******************************************************************
//* ZFSCBDIR: This should point to the location of your COBOL zFS
//* install directory (e.g., /usr/lpp/cobol/igyv6r4)
//*
//* The bin directory of this directory is where the cob2
//* and cjbuild utilities reside. They will be needed
//* when building the interoperable application
//*******************************************************************
// SET ZFSCBDIR='/home/userid/cobol/igyv6r4'
//*******************************************************************
//* OUTDIR: Set this to the z/OS UNIX directory that will receive
//* the stub files and other artifact files generated by
//* the COBOL compiler compiling programs that contain
//* the JAVA-CALLABLE and JAVA-SHAREABLE directives or
//* programs that make calls to Java using a CALL statement
//* of the form:
//*
//* CALL 'Java.class-name.static-method-name' ...
//*
Chapter 17. Compiling, linking, and running non-OO COBOL applications that interoperate with Java 317
//* The cjbuild uility (see STEP 2) will get the files from
//* this directory (see --coboldir option) so the directory
//* specified for OUTDIR should be used both in the OUTPATH
//* suboption of JAVAIOP when compiling the user COBOL
//* program as well as the --coboldir option of cjbuild.
//*******************************************************************
// SET OUTDIR='/home/userid/jtoc/cobprod/out'
//*******************************************************************
//* INTMODE: Set this to the interoperability mode to be used
//* by your application (needed by the cjbuild utility)
//*
//* PURE31 - AMODE 31 COBOL, AMODE 31 Java
//* PURE64 - AMODE 64 COBOL, AMODE 64 Java
//* MIX_31_64 - AMODE 31 COBOL, AMODE 64 Java
//*
//* NOTE: if you specify MIX_31_64, you must add the
//* JAVA64 suboption to the JAVAIOP option of
//* all related user COBOL programs.
//*******************************************************************
// SET INTMODE='MIX_31_64'
//*******************************************************************
//* WORKDIR: Set this to the z/OS UNIX directory to be used as a work
//* directory for building the interoperable application.
//* cjbuild will be run from this directory and basic
//* artifact files it generates (object files, listing,
//* etc.) go to this directory automatically.
//*******************************************************************
// SET WORKDIR='/home/userid/jtoc/cobprod'
//*******************************************************************
//* CLASSOUT: Set this to the directory you want any .class files
//* generated by cjbuild to go. These are the .class
//* files for Java accessor classes for JAVA-SHAREABLE
//* items, and also .class files for any Java files
//* generated by cjbuild, such as cobol.java, progs.java,
//* and strg.java.
//*******************************************************************
// SET CLASSOUT='/home/userid/jtoc/cobprod/class'
//*******************************************************************
//* JVSRCOUT: Set this to the directory you want any .java files
//* generated by cjbuild to go (cobol.java, progs.java,
//* strg.java).
//*******************************************************************
// SET JVSRCOUT='/home/userid/jtoc/cobprod'
//*******************************************************************
//* PKGNAME: Set this to the name of the Java package that you
//* want the 'progs' and 'strg' class to be a part of.
//* The default is enterprise.COBOL. This affects how
//* COBOL programs are invoked from Java. e.g., if the
//* package name is enterprise.COBOL., then you would
//* invoke a COBOL program called PROG1 as follows:
//*
//* enterprise.COBOL.progs.PROG1();
//*******************************************************************
// SET PKGNAME='enterprise.COBOL'
//*******************************************************************
//* DLLNAME: The name of the DLL that cjbuild creates and which
//* is needed at runtime when interoperable activities
//* occur in the application.
//*
//* If the DLL is targeted for a data set (which is
//* the usual way, see --dlloutdir option of cjbuild)
//* then the DLL will be stored as a member of the
//* specified data set, and is called LIB<DLLNAME>.
//*
//* If the DLL is targeted to the z/OS UNIX file system,
//* it will be called lib<dllname>.so.
//*******************************************************************
// SET DLLNAME=APP1
//*******************************************************************
//PROCLIB JCLLIB ORDER=(&LNGPRFX..SIGYPROC)
//*******************************************************************
//*******************************************************************
//* STEP 0: Ensure required z/OS UNIX directories exist
//*******************************************************************
//*******************************************************************
//CRDIRS EXEC PGM=BPXBATCH
//STDPARM DD *,SYMBOLS=EXECSYS
SH mkdir -p &OUTDIR;
mkdir -p &WORKDIR;
mkdir -p &CLASSOUT;
mkdir -p &JVSRCOUT
/*
318 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//STDENV DD *
NO_CUSTOM_SHELL=1
/*
//*******************************************************************
//*******************************************************************
//* STEP 1: Compile user COBOL programs, specifying JAVAIOP option
//*******************************************************************
//*******************************************************************
// SET INFILE='COBPROD'
//*******************************************************************
// IF (CRDIRS.RUN AND (CRDIRS.RC EQ 0)) THEN
//COBOL1 EXEC IGYWC,
// LNGPRFX=&LNGPRFX,
// LIBPRFX=&LIBPRFX,
// PARM.COBOL='OPTFILE'
//SYSLIB DD DSN=&SYSUID..COBOL.COBOL,DISP=SHR
//SYSIN DD DSN=&SYSUID..COBOL.COBOL(&INFILE),DISP=SHR
//SYSLIN DD DSN=&SYSUID..COBOL.OBJECT(&INFILE),DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSOPTF DD *,SYMBOLS=EXECSYS
JAVAIOP(OUTPATH('&OUTDIR'),JAVA64)
/*
//SYSOUT DD SYSOUT=*
// ENDIF
//*******************************************************************
// SET INFILE='ADDLIST'
//*******************************************************************
// IF (COBOL1.COBOL.RUN AND (COBOL1.COBOL.RC EQ 0)) THEN
//COBOL2 EXEC IGYWC,
// LNGPRFX=&LNGPRFX,
// LIBPRFX=&LIBPRFX,
// PARM.COBOL='OPTFILE'
//SYSLIB DD DSN=&SYSUID..COBOL.COBOL,DISP=SHR
//SYSIN DD DSN=&SYSUID..COBOL.COBOL(&INFILE),DISP=SHR
//SYSLIN DD DSN=&SYSUID..COBOL.OBJECT(&INFILE),DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSOPTF DD *,SYMBOLS=EXECSYS
JAVAIOP(OUTPATH('&OUTDIR'),JAVA64)
/*
//SYSOUT DD SYSOUT=*
// ENDIF
//*******************************************************************
//* STEP 2: Build stub file DLL using cjbuild
//*******************************************************************
// IF (COBOL2.COBOL.RUN AND (COBOL2.COBOL.RC EQ 0)) THEN
//CJBUILD EXEC PGM=BPXBATCH
//STDPARM DD *,SYMBOLS=EXECSYS
SH export JAVA_HOME=&JAVAHOME;
PATH=.:/bin:/usr/bin:/usr/local/bin:&ZFSCBDIR/bin;
cd &WORKDIR;
&ZFSCBDIR/bin/cjbuild
-v
--coboldir &OUTDIR
--dlloutdir "//'&SYSUID..COBOL.LOAD'"
--mode &INTMODE
--pkgname &PKGNAME
--javaclassdir &CLASSOUT
--javasrcdir &JVSRCOUT
&DLLNAME
/*
//STEPLIB DD DSN=&LNGPRFX..SIGYCOMP,DISP=SHR
// DD DSN=&LIBPRFX..SCEERUN,DISP=SHR
// DD DSN=&LIBPRFX..SCEERUN2,DISP=SHR
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//STDENV DD *,SYMBOLS=EXECSYS
NO_CUSTOM_SHELL=1
_C89_LSYSLIB=&LIBPRFX..SCEELKED
/*
// ENDIF
//*******************************************************************
//*******************************************************************
//* STEP 3: Link user programs. User programs may call out to
//* programs in the DLL produced by cjbuild in STEP 2
//* thus should be linked with the side deck produced in
//* that step
//*******************************************************************
//*******************************************************************
// SET INFILE='COBPROD'
Chapter 17. Compiling, linking, and running non-OO COBOL applications that interoperate with Java 319
//*******************************************************************
// IF (CJBUILD.RUN AND (CJBUILD.RC EQ 0)) THEN
//LKED1 EXEC PGM=IEWL,
// PARM='RENT,LIST,LET,DYNAM(DLL),CASE(MIXED)'
//SYSLIB DD DSN=&LIBPRFX..SCEELKED,DISP=SHR
// DD DSN=&LIBPRFX..SCEELKEX,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSTERM DD SYSOUT=*
//SYSLMOD DD DSN=&SYSUID..COBOL.LOAD(&INFILE),DISP=SHR
//SYSDEFSD DD DUMMY
//OBJMOD DD DSN=&SYSUID..COBOL.OBJECT(&INFILE),DISP=SHR
//SIDEDK DD DSN=&SYSUID..COBOL.EXP(LIB&DLLNAME),DISP=SHR
//SYSLIN DD *
INCLUDE OBJMOD
INCLUDE SIDEDK
/*
// ENDIF
//*******************************************************************
// SET INFILE='ADDLIST'
//*******************************************************************
// IF (LKED1.RUN AND (LKED1.RC EQ 0)) THEN
//LKED2 EXEC PGM=IEWL,
// PARM='RENT,LIST,LET,DYNAM(DLL),CASE(MIXED)'
//SYSLIB DD DSN=&LIBPRFX..SCEELKED,DISP=SHR
// DD DSN=&LIBPRFX..SCEELKEX,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSTERM DD SYSOUT=*
//SYSLMOD DD DSN=&SYSUID..COBOL.LOAD(&INFILE),DISP=SHR
//SYSDEFSD DD DUMMY
//OBJMOD DD DSN=&SYSUID..COBOL.OBJECT(&INFILE),DISP=SHR
//SIDEDK DD DSN=&SYSUID..COBOL.EXP(LIB&DLLNAME),DISP=SHR
//SYSLIN DD *
INCLUDE OBJMOD
INCLUDE SIDEDK
/*
// ENDIF
//*******************************************************************
//*******************************************************************
//* STEP 4: Builds Java application
//*******************************************************************
//*******************************************************************
// IF (LKED2.RUN AND (LKED2.RC EQ 0)) THEN
//BLDJAVA EXEC PGM=BPXBATSL
//STDPARM DD *,SYMBOLS=EXECSYS
PGM &JAVAHOME/bin/javac
-d &CLASSOUT
&ZFSCBDIR/demo/cobol_java_interop_sample/CobProd.java
/*
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//STDENV DD *,SYMBOLS=EXECSYS
JAVA_HOME=&JAVAHOME
CLASSPATH=.:&CLASSOUT
PATH=.:/bin:/usr/bin:/usr/local/bin:&ZFSCBDIR/bin
/*
// ENDIF
//*******************************************************************
//*******************************************************************
//* STEP 5: Run COBOL/Java interoperable application
//*******************************************************************
//*******************************************************************
// IF (BLDJAVA.RUN AND (BLDJAVA.RC EQ 0)) THEN
//GO EXEC PGM=BPXBATSL
//STDPARM DD *,SYMBOLS=EXECSYS
PGM &JAVAHOME/bin/java CobProd
/*
//STEPLIB DD DSN=&SYSUID..COBOL.LOAD,DISP=SHR
// DD DSN=&LNGPRFX..SIGYCOMP,DISP=SHR
// DD DSN=&LIBPRFX..SCEERUN,DISP=SHR
// DD DSN=&LIBPRFX..SCEERUN2,DISP=SHR
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//STDENV DD *,SYMBOLS=EXECSYS
JAVA_HOME=&JAVAHOME
PATH=.:/bin:/usr/bin:/usr/local/bin:&ZFSCBDIR/bin
_C89_LSYSLIB=&LIBPRFX..SCEELKED
CLASSPATH=.:&CLASSOUT
_CEE_RUNOPTS=POSIX(ON)
IBM_JAVA_OPTIONS=-XX:+Enable3164Interoperability
/*
// ENDIF
320 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Related references
Chapter 17, “Compiling, linking, and running non-OO COBOL applications that interoperate with Java,” on
page 301
cbl pgmname(longmixed)
*********************************************************************
* *
* IBM Enterprise COBOL for z/OS *
* Version 6 Release 4 Modification 0 *
* *
* LICENSED MATERIALS - PROPERTY OF IBM. *
* *
* 5655-EC6 COPYRIGHT IBM CORP. 2024 *
* *
* US GOVERNMENT USERS RESTRICTED RIGHTS - USE, *
* DUPLICATION OR DISCLOSURE RESTRICTED BY GSA *
* ADP SCHEDULE CONTRACT WITH IBM CORP. *
* *
*********************************************************************
* Simple program that calls a static Java method passing a
* a group argument that is passed to Java as a byte array (byte[])
identification division.
program-id. 'prog1'.
data division.
working-storage section.
01 g1.
03 num1 pic s9(9) comp-5 value 5112.
03 num2 pic s9(9) comp-5 value -38236.
Chapter 17. Compiling, linking, and running non-OO COBOL applications that interoperate with Java 321
03 msg pic n(24) national value "Hello, from COBOL prog1!".
procedure division.
MainProgram.
display '<<Entering COBOL program: prog1>>'
call 'Java.myjavaapps.TestApp.doStuff' using g1
on exception
display 'Error calling myjavaapps.TestApp.doStuff'
end-call
display '<<Exiting COBOL program: prog1>>'
goback.
end program 'prog1'.
TestApp.java
//*******************************************************************
// *
// IBM Enterprise COBOL for z/OS *
// Version 6 Release 4 Modification 0 *
// *
// LICENSED MATERIALS - PROPERTY OF IBM. *
// *
// 5655-EC6 COPYRIGHT IBM CORP. 2024 *
// *
// US GOVERNMENT USERS RESTRICTED RIGHTS - USE, *
// DUPLICATION OR DISCLOSURE RESTRICTED BY GSA *
// ADP SCHEDULE CONTRACT WITH IBM CORP. *
// *
//*******************************************************************
package myjavaapps;
import java.math.*;
import com.ibm.jzos.ZUtil;
import java.nio.charset.StandardCharsets;
import java.nio.*;
build.sh
#!/bin/sh
###############################################################################
#
# IBM Enterprise COBOL for z/OS
# Version 6 Release 4 Modification 0
#
# LICENSED MATERIALS - PROPERTY OF IBM.
#
# 5655-EC6 COPYRIGHT IBM CORP. 2024
#
# US GOVERNMENT USERS RESTRICTED RIGHTS - USE,
# DUPLICATION OR DISCLOSURE RESTRICTED BY GSA
# ADP SCHEDULE CONTRACT WITH IBM CORP.
#
###############################################################################
##############################################################################
# Build script for the COBOL/Java interoperability demo
##############################################################################
#
# Invocation:
322 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
# -----------
#
# build.sh - build mixed amode interoperable application
#
# NOTE:
# -----
#
# 1) Make sure cjbuild and cob2 are in your PATH before running this script
#
# 2) Make sure JAVA_HOME is set appropriately
#
# 3) Make sure your STEPLIB includes an Enterprise COBOL V6.4 or later
# compiler and a runtime that is sufficient to run COBOL programs
# compiled with the Enterprise COBOL V6.4 or later compiler
#
# 4) You must have an existing data set to receive the DLL built
# by cjuild, and the data set must be called <USER>.COBOL.LOAD,
# where <USER> is your high-level qualifier
#
##############################################################################
if [ -z $STEPLIB ]; then
echo "STEPLIB environment variable must be set"
exit 1
fi
if [ -z $JAVA_HOME ]; then
echo "JAVA_HOME environment variable must be set"
exit 1;
fi
OUT_DIR=./out
CLASSOUT_DIR=./class
run.sh
#!/bin/sh
###############################################################################
#
# IBM Enterprise COBOL for z/OS
# Version 6 Release 4 Modification 0
#
# LICENSED MATERIALS - PROPERTY OF IBM.
#
# 5655-EC6 COPYRIGHT IBM CORP. 2022, 2024
#
# US GOVERNMENT USERS RESTRICTED RIGHTS - USE,
# DUPLICATION OR DISCLOSURE RESTRICTED BY GSA
# ADP SCHEDULE CONTRACT WITH IBM CORP.
#
Chapter 17. Compiling, linking, and running non-OO COBOL applications that interoperate with Java 323
###############################################################################
###############################################################################
# Run script for the COBOL/Java interoperability demo
###############################################################################
#
# NOTE:
# -----
#
# 1) Make sure your STEPLIB includes an Enterprise COBOL runtime
# that is sufficient to run programs compiled with the Enterprise
# COBOL V6.4 or later compiler.
#
# The dataset <USER>.COBOL.LOAD that received the program objects
# and DLL for your interoperable application during the build
# step must also be included in your STEPLIB. We have added this
# in automatically for you below.
#
# 2) Set JAVA_HOME to an appropriate 64-bit Java SDK:
#
# e.g., JAVA_HOME=/usr/lpp/java/IBM/J8.0_64 or
# JAVA_HOME=/usr/lpp/java/IBM/J11.0_64
#
###############################################################################
if [ -z $STEPLIB ]; then
echo "STEPLIB environment variable must be set"
exit 1
fi
if [ -z $JAVA_HOME ]; then
echo "JAVA_HOME environment variable must be set"
exit 1
fi
./prog1
Related references
“Sample JCL for building and running the COBOL-calls-java application” on page 324
324 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
//* IBM Enterprise COBOL for z/OS */
//********************************************************************/
//********************************************************************/
//* *
//* LICENSED MATERIALS -- PROPERTY OF IBM. *
//* *
//* 5655-EC6 *
//* COPYRIGHT IBM CORP. 2024 *
//* *
//* US GOVERNMENT USERS RESTRICTED RIGHTS - USE, DUPLICATION OR *
//* DISCLOSURE RESTRICTED BY GSA ADP SCHEDULE CONTRACT WITH IBM *
//* CORP. *
//* *
//********************************************************************/
//*********************************************************************
//*
//* Sample JCL for building and running a non-OO COBOL/Java
//* interoperable application starting on the COBOL side with
//* COBOL calling a static Java method.
//*
//*********************************************************************
//*
//* Prerequisites:
//*
//* 1) User COBOL source files must be copied to data set:
//* USER.COBOL.COBOL.
//*
//* 2) A PDSE data set named USER.COBOL.OBJECT must exist
//* to receive object program files generated by the COBOL
//* compiler.
//*
//* 3) A PDSE data set USER.COBOL.LOAD must exist to receive
//* program object files. These program objects come from
//* linking object files from user programs and also from
//* linking the object files associated with stub programs
//* into a DLL.
//*
//* A PDS data set (FB 80) called USER.COBOL.EXP must also
//* exist prior to running this JCL. This data set will
//* receive the side deck for the DLL produced by cjbuild
//* and is used during subsequent link steps.
//*
//* 4) You must ensure the following JCL variables are set below,
//* which control various build parameters. This includes the
//* z/OS UNIX directory into which stub files will be generated
//* by the compiler and the z/OS UNIX work directory to be
//* used by the cjbuild utility. The cjbuild utility uses this
//* directory to build the DLL needed for the interoperable
//* application.
//*
//* For this sample, we assume the z/OS UNIX directory
//* structure to be used for building the application is as
//* follows:
//*
//* /home/userid/jtoc/test/simple/ccj/work
//* - main work directory
//* /home/userid/jtoc/test/simple/ccj/out
//* - stub file output directory (compiler places stub
//* files here)
//* /home/userid/jtoc/test/simple/ccj/class
//* - directory where cjbuild places any generated .class
//* files
//*
//* The following variables must be set:
//*
//* JAVAHOME
//* ZFSCBDIR
//* OUTDIR
//* INTMODE
//* WORKDIR
//* CLASSOUT
//* JVSRCOUT
//* PKGNAME
//* DLLNAME
//*
//* See below for detailed descriptions of how to set these
//* variables. Example values are provided.
//*
//* NOTE: z/OS UNIX directories for stub files and the work
//* directory for cjbuild do not have to exist. The
//* JCL below create the directories if they do not
//* exist prior to running this job (see STEP 0).
Chapter 17. Compiling, linking, and running non-OO COBOL applications that interoperate with Java 325
//*
//*********************************************************************
// EXPORT SYMLIST=*
//*********************************************************************
//* Set compiler and run time library levels below
//*******************************************************************
// SET LIBPRFX='CEE'
// SET LNGPRFX='COBOL.COMPILER'
//*******************************************************************
//* JAVAHOME: Set this to your Java home directory. This will be used
//* to set the JAVA_HOME environment variable needed by
//* Java operations
//*******************************************************************
// SET JAVAHOME='/usr/lpp/java/J11.0_64'
//*******************************************************************
//* ZFSCBDIR: This should point to the location of your COBOL zFS
//* install directory (e.g., /usr/lpp/cobol/igyv6r4)
//*
//* The bin directory of this directory is where the cob2
//* and cjbuild utilities reside. They will be needed
//* when building the interoperable application
//*******************************************************************
// SET ZFSCBDIR='/home/userid/cobol/igyv6r4'
//*******************************************************************
//* OUTDIR: Set this to the z/OS UNIX directory that will receive
//* the stub files and other artifact files generated by
//* the COBOL compiler compiling programs that contain
//* the JAVA-CALLABLE and JAVA-SHAREABLE directives or
//* programs that make calls to Java using a CALL statement
//* of the form:
//*
//* CALL 'Java.class-name.static-method-name' ...
//*
//* The cjbuild uility (see STEP 2) will get the files from
//* this directory (see --coboldir option) so the directory
//* specified for OUTDIR should be used both in the OUTPATH
//* suboption of JAVAIOP when compiling the user COBOL
//* program as well as the --coboldir option of cjbuild.
//*******************************************************************
// SET OUTDIR='/home/userid/jtoc/test/sample2/out'
//*******************************************************************
//* INTMODE: Set this to the interoperability mode to be used
//* by your application (needed by the cjbuild utility)
//*
//* PURE31 - AMODE 31 COBOL, AMODE 31 Java
//* PURE64 - AMODE 64 COBOL, AMODE 64 Java
//* MIX_31_64 - AMODE 31 COBOL, AMODE 64 Java
//*
//* NOTE: if you specify MIX_31_64, you must add the
//* JAVA64 suboption to the JAVAIOP option of
//* all related user COBOL programs.
//*******************************************************************
// SET INTMODE='MIX_31_64'
//*******************************************************************
//* WORKDIR: Set this to the z/OS UNIX directory to be used as a work
//* directory for building the interoperable application.
//* cjbuild will be run from this directory and basic
//* artifact files it generates (object files, listing,
//* etc.) go to this directory automatically.
//*
//* This is where the "methods" file will be located for
//* this sample.
//*******************************************************************
// SET WORKDIR='/home/userid/jtoc/test/sample2'
//*******************************************************************
//* CLASSOUT: Set this to the directory you want any .class files
//* generated by cjbuild to go. These are the .class
//* files for Java accessor classes for JAVA-SHAREABLE
//* items, and also .class files for any Java files
//* generated by cjbuild, such as cobol.java, progs.java,
//* and strg.java.
//*******************************************************************
// SET CLASSOUT='/home/userid/jtoc/test/sample2/class'
//*******************************************************************
//* JVSRCOUT: Set this to the directory you want any .java files
//* generated by cjbuild to go (cobol.java, progs.java,
//* strg.java).
//*******************************************************************
// SET JVSRCOUT='/home/userid/jtoc/test/sample2'
//*******************************************************************
//* PKGNAME: Set this to the name of the Java package that you
//* want the 'progs' and 'strg' class to be a part of.
326 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
//* The default is enterprise.COBOL. This affects how
//* COBOL programs are invoked from Java. e.g., if the
//* package name is enterprise.COBOL., then you would
//* invoke a COBOL program called PROG1 as follows:
//*
//* enterprise.COBOL.progs.PROG1();
//*******************************************************************
// SET PKGNAME='enterprise.COBOL'
//*******************************************************************
//* DLLNAME: The name of the DLL that cjbuild creates and which
//* is needed at runtime when interoperable activities
//* occur in the application.
//*
//* If the DLL is targeted for a data set (which is
//* the usual way, see --dlloutdir option of cjbuild)
//* then the DLL will be stored as a member of the
//* specified data set, and is called LIB<DLLNAME>.
//*
//* If the DLL is targeted to the z/OS UNIX file system,
//* it will be called lib<dllname>.so.
//*******************************************************************
// SET DLLNAME=APP1
//*******************************************************************
//PROCLIB JCLLIB ORDER=(&LNGPRFX..SIGYPROC)
//*******************************************************************
//*******************************************************************
//* STEP 0: Ensure required z/OS UNIX directories exist
//*******************************************************************
//*******************************************************************
//CRDIRS EXEC PGM=BPXBATCH
//STDPARM DD *,SYMBOLS=EXECSYS
SH mkdir -p &OUTDIR;
mkdir -p &WORKDIR;
mkdir -p &CLASSOUT;
mkdir -p &JVSRCOUT
/*
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//STDENV DD *
NO_CUSTOM_SHELL=1
/*
//*******************************************************************
//*******************************************************************
//* STEP 1: Compile user COBOL programs, specifying JAVAIOP option
//*******************************************************************
//*******************************************************************
// SET INFILE='PROG1'
//*******************************************************************
// IF (CRDIRS.RUN AND (CRDIRS.RC EQ 0)) THEN
//COBOL1 EXEC IGYWC,
// LNGPRFX=&LNGPRFX,
// LIBPRFX=&LIBPRFX,
// PARM.COBOL='OPTFILE'
//SYSLIB DD DSN=&SYSUID..COBOL.COBOL,DISP=SHR
//SYSIN DD DSN=&SYSUID..COBOL.COBOL(&INFILE),DISP=SHR
//SYSLIN DD DSN=&SYSUID..COBOL.OBJECT(&INFILE),DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSOPTF DD *,SYMBOLS=EXECSYS
JAVAIOP(OUTPATH('&OUTDIR'),JAVA64)
/*
//SYSOUT DD SYSOUT=*
// ENDIF
//*******************************************************************
//* STEP 2: Build stub file DLL using cjbuild
//*******************************************************************
// IF (COBOL1.COBOL.RUN AND (COBOL1.COBOL.RC EQ 0)) THEN
//CJBUILD EXEC PGM=BPXBATCH
//STDPARM DD *,SYMBOLS=EXECSYS
SH export JAVA_HOME=&JAVAHOME;
PATH=.:/bin:/usr/bin:/usr/local/bin:&ZFSCBDIR/bin;
cd &WORKDIR;
&ZFSCBDIR/bin/cjbuild
-v
--coboldir &OUTDIR
--dlloutdir "//'&SYSUID..COBOL.LOAD'"
--pkgname &PKGNAME
--javaclassdir &CLASSOUT
--javasrcdir &JVSRCOUT
--mode &INTMODE
&DLLNAME
/*
Chapter 17. Compiling, linking, and running non-OO COBOL applications that interoperate with Java 327
//STEPLIB DD DSN=&LNGPRFX..SIGYCOMP,DISP=SHR
// DD DSN=&LIBPRFX..SCEERUN,DISP=SHR
// DD DSN=&LIBPRFX..SCEERUN2,DISP=SHR
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//STDENV DD *,SYMBOLS=EXECSYS
NO_CUSTOM_SHELL=1
_C89_LSYSLIB=&LIBPRFX..SCEELKED
/*
// ENDIF
//*******************************************************************
//*******************************************************************
//* STEP 3: Link user programs. User programs may call out to
//* programs in the DLL produced by cjbuild in STEP 2
//* thus should be linked with the side deck produced in
//* that step
//*******************************************************************
//*******************************************************************
// SET INFILE='PROG1'
//*******************************************************************
// IF (CJBUILD.RUN AND (CJBUILD.RC EQ 0)) THEN
//LKED1 EXEC PGM=IEWL,
// PARM='RENT,LIST,LET,DYNAM(DLL),CASE(MIXED)'
//SYSLIB DD DSN=&LIBPRFX..SCEELKED,DISP=SHR
// DD DSN=&LIBPRFX..SCEELKEX,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSTERM DD SYSOUT=*
//SYSLMOD DD DSN=&SYSUID..COBOL.LOAD(&INFILE),DISP=SHR
//SYSDEFSD DD DUMMY
//OBJMOD DD DSN=&SYSUID..COBOL.OBJECT(&INFILE),DISP=SHR
//SIDEDK DD DSN=&SYSUID..COBOL.EXP(LIB&DLLNAME),DISP=SHR
//SYSLIN DD *
INCLUDE OBJMOD
INCLUDE SIDEDK
/*
// ENDIF
//*******************************************************************
//*******************************************************************
//* STEP 4: Builds Java application
//*******************************************************************
//*******************************************************************
// IF (LKED1.RUN AND (LKED1.RC EQ 0)) THEN
//BLDJAVA EXEC PGM=BPXBATSL
//STDPARM DD *,SYMBOLS=EXECSYS
PGM &JAVAHOME/bin/javac
-d &CLASSOUT
&WORKDIR/TestApp.java
/*
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//STDENV DD *,SYMBOLS=EXECSYS
JAVA_HOME=&JAVAHOME
CLASSPATH=.:&CLASSOUT
PATH=.:/bin:/usr/bin:/usr/local/bin:&ZFSCBDIR/bin
/*
// ENDIF
//*******************************************************************
//*******************************************************************
//* STEP 5: Run COBOL/Java interoperable application
//*******************************************************************
//*******************************************************************
// IF (BLDJAVA.RUN AND (BLDJAVA.RC EQ 0)) THEN
//GO EXEC PGM=PROG1
//STEPLIB DD DSN=&SYSUID..COBOL.LOAD,DISP=SHR
// DD DSN=&LNGPRFX..SIGYCOMP,DISP=SHR
// DD DSN=&LIBPRFX..SCEERUN,DISP=SHR
// DD DSN=&LIBPRFX..SCEERUN2,DISP=SHR
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//CEEOPTS DD *,SYMBOLS=EXECSYS
POSIX(ON)
ENVAR(
"JAVA_HOME=&JAVAHOME",
"IBM_JAVA_OPTIONS=-XX:+Enable3164Interoperability",
"PATH=.:/bin:/usr/bin:/usr/local/bin",
"CLASSPATH=&CLASSOUT",
"LIBPATH=&JAVAHOME/lib:&JAVAHOME/lib/j9vm")
/*
// ENDIF
328 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Related references
“Example: COBOL-calls-Java application - building and running” on page 321
Troubleshooting
You can use the following methods to troubleshoot issues when building and running non-OO COBOL
applications that interoperate with Java.
1. Make sure that cob2 and cjbuild are in your PATH environment variable. When building from the JCL,
just make sure you set the ZFSCBDIR JCL variable correctly in the script, which is the location of your
zFS COBOL install directory.
2. Make sure that JAVA_HOME is set in your environment and points to an appropriate Java JDK. For
example:
export JAVA_HOME=/usr/lpp/java/IBM/J8.0_64
or:
export JAVA_HOME=/usr/lpp/java/IBM/J11.0_64
When building and running from JCL, make sure the JAVAHOME JCL variable is set properly.
3. Make sure the following environment variables are set at run time:
For z/OS UNIX scripts:
export IBM_JAVA_OPTIONS="-XX:+Enable3164Interoperability"
export _CEE_RUNOPTS="POSIX(ON)"
If running from JCL, make sure your CEEOPTS DD is handled similar to the following:
//CEEOPTS DD *,SYMBOLS=EXECSYS
POSIX(ON)
ENVAR(
"JAVA_HOME=&JAVAHOME",
"IBM_JAVA_OPTIONS=-XX:+Enable3164Interoperability",
"PATH=.:/bin:/usr/bin:/usr/local/bin",
"CLASSPATH=&CLASSOUT",
"LIBPATH=&JAVAHOME/lib:&JAVAHOME/lib/j9vm")
4. If you have an application that starts on the COBOL side and calls Java and Java displays to the
terminal, but you do not see the output when running from JCL, try adding the following line at the top
of your Java program:
ZUtil.redirectStandardStreams();
5. If you encounter linking errors during execution of the cjbuild utility, try adding the following export to
your environment:
export _C89_LSYSLIB=CEE.SCEELKED
Note: If you have your runtime datasets installed under a different HLQ, then use the corresponding
SCEELKED for those datasets instead.
Link error messages:
Chapter 17. Compiling, linking, and running non-OO COBOL applications that interoperate with Java 329
DESIGNATED CALL LIBRARY.
IEW2456E 9207 SYMBOL IGZXDED UNRESOLVED. MEMBER COULD NOT BE INCLUDED FROM THE
DESIGNATED CALL LIBRARY.
IEW2638S 5384 AN EXECUTABLE VERSION OF MODULE *NULL* EXISTS AND CANNOT BE
REPLACED BY THE NON-EXECUTABLE MODULE JUST CREATED.
FSUM3065 The LINKEDIT step ended with return code 12.
export LIBPATH=${JAVA_HOME}/lib/s390x/j9vm:${JAVA_HOME}/lib/s390x/:${LIBPATH}
For mixed AMODE applications running on Java 11, set LIBPATH as follows:
export LIBPATH=${JAVA_HOME}/lib:${JAVA_HOME}/lib/j9vm:${LIBPATH}
In both cases, set the following environment variable at run time for mixed AMODE Java interoperable
COBOL applications:
export IBM_JAVA_OPTIONS="-XX:+Enable3164Interoperability"
cjbuild [-hv]
[-c/--coboldir <cobol-dir>]
[-d/--dlloutdir <dll-out-dir>]
[-i/--progid <program-id>] ...
[-j/--javaclassdir <java-class-dir>]
[-m/--mode PURE31|PURE64|MIX_31_64]
[-p/--pkgname <package-name>]
[-r/--jar <jar-file>]
[-s/--javasrcdir <java-src-dir>]
[<program-file>] <lib-base-name>
where:
<program-file>
Note: This argument was called <methods-file> in previous versions of cjbuild and was a mandatory
argument. It is now optional.
Optional input file containing a list of COBOL programs in the interoperable application whose stub
files in the COBOL artifact directory (indicated by the -c/--coboldir option) are to be processed
by cjbuild. When <program-file> is not specified, and -i is also not specified, all stub files in
the directory are processed. The programs listed should be those programs in the application that
330 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
have interoperability features, such as the >>JAVA-CALLABLE directive, the >>JAVA-SHAREABLE
directive, or CALL statements of the form:
CALL 'Java.<java-class-name>.<java-static-method-name>'
Programs compiled with the >>JAVA-CALLABLE directive will be grouped into a class called
'progs' in the specified package (see -p), and data items that fall under the scope of a >>JAVA-
SHAREABLEdirective in any of the listed COBOL programs will be grouped into a class called 'strg' in
the specified package. For example, the contents of the program file for an application consisting of
two Java-callable COBOL programs COBPROG1 and COBPROG2, one of which makes a call to a static
Java method 'Java.com.acme.MyClass.myMethod' would look as follows:
COBPROG1
COBPROG2
<lib-base-name>
Used to create the name of the DLL that contains the stub code needed at run time by the
interoperable application (both Java and COBOL may need this DLL). This name is also used as
the base name for the .jar file created when the -r/--jar option is not specified and the .jar file name
defaults. For example, If <lib-base-name> is app1, then the DLL will be called libapp1.so if the
argument to the -d option is a z/OS UNIX directory, or LIBAPP1 if the argument to the -d option is
an MVS PDS data set. The .jar file created when the --jar <jar-file> option is not specified is
libapp1.jar.
See the following table for the options in cjbuild command reference:
//<DATASET-NAME>
For example:
//COBOL.LOAD or //'USER.COBOL.LOAD'
Chapter 17. Compiling, linking, and running non-OO COBOL applications that interoperate with Java 331
Table 44. Options and descriptions (continued)
Options Descriptions
--progid <program-id> Indicates the name of a COBOL program whose
-i stub files in the directory indicated by the -c/--
coboldir option are to be processed by cjbuild.
The option can be specified multiple times, once
for each program to be included in cjbuild's
processing. It is similar to the <program-file>
argument, which serves the same purpose, but
-i allows you to provide the same information to
cjbuild on the command line instead of in an input
file.
<program-id> corresponds to the name of the
COBOL program as specified in the program-id
clause of the program. If the name is specified
without quotes in the COBOL program, then the
name should be specified with all upper case
letters in the -i option. If the name is specified as
a literal in the COBOL program, then the case of
characters specified in the -i option should match
exactly with the program-id clause in the COBOL
program.
Default: N/A
--jar <jar-file> Create a Java .jar file from any .class files
-r generated from compiling Java source files
produced by the COBOL compiler and cjbuild.
The .jar file will have the name as indicated by the
<jar-file> argument.
The .jar file should be in your Java CLASSPATH at
run time.
Default: a jar file with name lib<lib-base-
name>.jar is created in the current directory.
332 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 44. Options and descriptions (continued)
Options Descriptions
--mode <PURE31|PURE64|MIX_31_64> Java/COBOL interoperability mode.
-m <PURE31|PURE64|MIX_31_64>
Specify PURE31 for AMODE 31 COBOL/31-bit Java
application.
Specify PURE64 for AMODE 64 COBOL/64-bit Java
application.
Specify MIX_31_64 for AMODE 31 COBOL/64-bit
Java application.
Note: You must build COBOL files with
JAVAIOP(JAVA64) option for MIX_31_64 mode
applications.
Default: PURE31
com.acme.COBOL.myapp1
com.acme.COBOL.myapp1.cobol
com.acme.COBOL.myapp1.progs
com.acme.COBOL.myapp1.strg
Default: enterprise.COBOL
Related tasks
Chapter 17, “Compiling, linking, and running non-OO COBOL applications that interoperate with Java,” on
page 301
“Example: COBPROD application - building and running” on page 308
Related references
JAVA-CALLABLE (Enterprise COBOL for z/OS Language Reference)
JAVA-SHAREABLE (Enterprise COBOL for z/OS Language Reference)
CALL statement (Enterprise COBOL for z/OS Language Reference)
Chapter 17. Compiling, linking, and running non-OO COBOL applications that interoperate with Java 333
334 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Chapter 18. Compiling, binding, and running COBOL
AMODE 64 applications
You can compile, bind, and run Enterprise COBOL AMODE 64 applications under z/OS environment using
JCL, TSO commands, CLISTs, or ISPF panels. The process is almost the same as the corresponding tasks
for COBOL AMODE 31 applications. See related tasks for key differences and limitations.
Related tasks
“Compiling and binding AMODE 64 programs under z/OS” on page 335
“DLL considerations” on page 336
“Running COBOL AMODE 64 applications” on page 337
“Specifying COBOL only runtime options” on page 337
You can explicitly specify the binder output file by using the -o option. The following cob2 command
generates the executable file hello.exe.
Other compiler options can be specified by using the -q option in the same way as using cob2 command
with AMODE 31. For example, the following command invokes the COBOL compiler by using SOURCE and
LIST options:
Note that -q64 is the short form of the compiler option LP(64) in the cob2 command line. It must
be specified on its own in the cob2 command line, separate from other compiler option specifications.
Instead of -q64, you can use LP(64) directly with other compiler options:
Correspondingly, the -q32 is the short form of the compiler option LP(32). If cob2 is invoked without
explicitly specifying -q64 or -q32, the default is -q32.
Environment variables
In addition to the environment variables supported with AMODE 31, the following two additional
environment variables are supported for AMODE 64:
_C89_L6SYSLIB
Specifies the library dataset concatenations of SYSLIB DD to be used by the bind step. Dataset
names are separated by colons. For example, the following environment variable setting
export _C89_L6SYSLIB=MYSAMPLE.SCEEBND2:CEE.SCEEBND2
336 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
gives the following SYSLIB DD concatenation in the bind step:
//SYSLIB DD DSN=MYSAMPLE.SCEEBND2,DISP=SHR
// DD DSN=CEE.SCEEBND2,DISP=SHR
export _C89_L6SYSLIB=CEE.SCEEBND2
_C89_L6SYSIX
Specifies the side-deck dataset concatenations of SYSLIN to be used by the bind step. Dataset names
are separated by colons. For example, the following environment variable setting
export _C89_L6SYSIX="MYSAMPLE.SCEELIB(CELQV004):CEE.SCEELIB(CELQV004)"
//SYSLIN DD DSN=MYSAMPLE.SCEELIB(CELQV004),DISP=SHR
// DD DSN=CEE.SCEELIB(CELQV004),DISP=SHR
export _C89_L6SYSIX="CEE.SCEELIB(CELQV004)"
//…
//IGZOPTS DD *
DEBUG,CBLQDA(ON)
/*
//*
The option syntax is the same as the corresponding specifications in AMODE 31 using the Language
Environment CEEOPTS DD statements.
When running the program under z/OS UNIX environment, you can specify the COBOL only runtime
options using the _IGZ_RUNOPTS environment variable. The option syntax is the same as their
corresponding specifications in AMODE 31 using the LE environment variable _CEE_RUNOPTS. The
example below specifies the DEBUG and CBLQDA options:
export _IGZ_RUNOPTS=”DEBUG,CBLQDA(ON)”
AMODE 64 COBOL only runtime options can only be specified using these two methods. For more
information about how to specify COBOL runtime options, see “Specifying COBOL runtime options” on
page 432.
Note: The CBLOPTS runtime option is not supported in AMODE 64. When specifying Language
Environment runtime option on the parameter string of the main program, runtime options must be
Chapter 18. Compiling, binding, and running COBOL AMODE 64 applications 337
specified before program arguments. This behavior is consistent with other Language Environment high-
level languages. The example below shows the JCL for invoking a COBOL main program with program
argument '20190901' and runtime option POSIX(ON):
338 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Chapter 19. COBOL compiler and runtime options
This section provides detailed information on the options available for the COBOL compiler and COBOL
runtime environment.
340 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 45. Compiler options (continued)
Aspect of your Compiler option Default Option abbreviations
program
Object code “ADV” on page 346 ADV None
control
“AFP” on page 346 AFP(NOVOLATILE) None
“ARCH” on page 347 ARCH(10) None
“AWO” on page 350 NOAWO None
“BLOCK0” on page 350 NOBLOCK0 None
“DEFINE” on page 360 NODEFINE DEF | NODEF
“DISPSIGN” on page 362 DISPSIGN(COMPAT) DS(S | C)
“DLL” on page 363 NODLL None
“EXPORTALL” on page 369 NOEXPORTALL EXP | NOEXP
“FASTSRT” on page 369 NOFASTSRT FSRT | NOFSRT
“HGPR” on page 372 HGPR(PRESERVE) None
“INITIAL” on page 374 NOINITIAL None
“INLINE” on page 375 INLINE INL | NOINL
“INVDATA” on page 376 NOINVDATA NOINV | INVD(FNC |
NOFNC,CS | NOCS)
“JAVAIOP” on page 379 NOJAVAIOP JIOP | NOJIOP
“LP” on page 383 LP(32) None
“MAXPCF” on page 385 MAXPCF(100000) None
“NUMCHECK” on page 388 NONUMCHECK NC | NONC
“NUMPROC” on page 392 NUMPROC(NOPFD) None
“OPTIMIZE” on page 395 OPTIMIZE(0) OPT(n)
“OUTDD” on page 396 OUTDD(SYSOUT) OUT
“PARMCHECK” on page 397 NOPARMCHECK PC | NOPC
“TRUNC” on page 419 TRUNC(STD) None
“TUNE” on page 421 TUNE(10) if ARCH is None
not specified. The default
TUNE level must match
the ARCH level if ARCH is
specified.
“VLR” on page 422 VLR(STD) VLR(C | S)
“ZONECHECK” on page 427 NOZONECHECK NOZC | ZC(MSG) | ZC(ABD)
“ZONEDATA” on page 428 ZONEDATA(PFD) ZD(PFD) | ZD(MIG) |
ZD(NOPFD)
“ZWB” on page 431 ZWB None
Installation defaults: The default compiler options that were set up when your compiler was installed
are in effect for your program unless you override those options. (In some installations, certain compiler
options are fixed so that you cannot override them. If you have problems with the default options, contact
342 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
your system administrator.) To determine which are the default options, run a test compilation without
specifying any compiler options. The output listing lists the default options in effect at your site.
Nonoverridable options: In some installations, certain compiler options are fixed so that you cannot
override them. If you have problems with those options, contact your system administrator.
Option specification: Compiler options and suboptions are not case sensitive.
Performance considerations: The AFP, ARCH, ARITH, AWO, BLOCK0, DYNAM, FASTSRT, HGPR, MAXPCF,
NUMCHECK, NUMPROC, OPTIMIZE, PARMCHECK, RENT, SQLCCSID, SSRANGE, STGOPT, TEST, THREAD,
TRUNC, TUNE, ZONECHECK, and INVDATA compiler options can affect runtime performance.
Related tasks
Chapter 14, “Compiling under z/OS,” on page 255
“Compiling under TSO” on page 262
Chapter 15, “Compiling under z/OS UNIX,” on page 283
Chapter 49, “Tuning your program,” on page 771
Related references
“Conflicting compiler options” on page 344
Chapter 20, “Compiler-directing statements,” on page 439
“Option settings for 85 COBOL Standard conformance” on page 343
“Performance-related compiler options” on page 778
344 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 46. Mutually exclusive compiler options (continued)
Specified Ignored1 Forced on1
NORENT RMODE(ANY) RMODE(24)
LP(64) LP(32)
NSYMBOL(NATIONAL) NODBCS DBCS
OBJECT DECK NODECK
OFFSET LIST NOLIST
PGMNAME(LM | LU) NAME NONAME
RMODE(24) LP(64) LP(32)
SMARTBIN LP(64) LP(32)
SOURCE(HEX) NUMBER NONUMBER
SEQUENCE NOSEQUENCE
SQLIMS LP(64) LP(32)
TEST NOOBJECT and NODECK OBJECT and NODECK
THREAD INITIAL NOINITIAL
NORENT RENT
LP(64) LP(32)
WORD FLAGSTD NOFLAGSTD
Related tasks
“Specifying compiler options under z/OS” on page 273
“Specifying compiler options in a batch compilation” on page 278
“Specifying compiler options under z/OS UNIX” on page 284
Related references
“OPTFILE” on page 394
ADATA
Use ADATA when you want the compiler to create a SYSADATA file that contains records of additional
compilation information.
ADATA
Related references
“Setting environment variables under z/OS UNIX” on page 283
“cob2 syntax and options” on page 287
Appendix G, “COBOL SYSADATA file contents,” on page 851
ADV
ADV has meaning only if you use WRITE . . . ADVANCING in your source code. With ADV in effect, the
compiler adds 1 byte to the record length to account for the printer control character.
NOADV
AFP
The AFP option controls the compiler usage of the Additional Floating Point (AFP) registers that are
provided by IBM z/Architecture processors.
AFP( VOLATILE )
346 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
compiler can generate more efficient code sequences for programs with floating point operations. It is
the normal z/OS architecture convention.
AMODE 64 considerations: When the LP(64) compiler option is in effect, the AFP(VOLATILE) option is
not supported. If the AFP(VOLATILE) option is specified explicitly, a warning message is issued and the
setting is discarded.
APOST/QUOTE
Use APOST if you want the figurative constant [ALL] QUOTE or [ALL] QUOTES to represent one or more
apostrophe (') characters. Use QUOTE if you want the figurative constant [ALL] QUOTE or [ALL] QUOTES to
represent one or more quotation mark (") characters.
APOST
ARCH
The ARCH option specifies the machine architecture for which the executable program instructions are to
be generated.
ARCH( 11 )
12
13
14
348 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
For more information about these facilities, see IBM z/Architecture Principles of Operation.
Related references
“TUNE” on page 421
ARITH
ARITH affects the maximum number of digits that you can code for numeric items, and the number of
digits used in fixed-point intermediate results.
ARITH( EXTEND )
CBL ARITH(EXTEND)
IDENTIFICATION DIVISION.
PROGRAM-ID. SAMPLE
DATE-COMPILED.
ENVIRONMENT DIVISION.
PROCEDURE DIVISION.
GOBACK.
Related concepts
Appendix A, “Intermediate results and arithmetic precision,” on page 793
“Conversions and precision” on page 52
AWO
If you specify AWO, an implicit APPLY WRITE-ONLY clause is activated for all QSAM files in the program
that have blocked variable-length records.
AWO
Related tasks
“Optimizing buffer and device space” on page 10
Related references
“BLOCK0” on page 350
APPLY WRITE-ONLY clause (Enterprise COBOL for z/OS Language Reference)
BLOCK0
Use BLOCK0 to change the compiler default for QSAM files from unblocked to blocked (as if BLOCK
CONTAINS 0 were specified) and thus gain the benefit of system-determined blocking for output files.
BLOCK0
350 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Specifying BLOCK0 activates an implicit BLOCK CONTAINS 0 clause for each file in the program that
meets the following three criteria:
• The FILE-CONTROL paragraph either specifies ORGANIZATION SEQUENTIAL or omits the
ORGANIZATION clause.
• The FD entry does not specify RECORDING MODE U.
• The FD entry does not specify a BLOCK CONTAINS clause.
Files for which the resulting BLOCK CONTAINS 0 clause is in effect have a blocking factor that is
determined at run time from the data definition or from the data-set characteristics.
Interaction of the APPLY WRITE-ONLY clause and the AWO compiler option with BLOCK0:
• If NOBLOCK0 is in effect, and the file description of a file that meets the three criteria listed above
specifies APPLY WRITE-ONLY, the compiler issues an error message because APPLY WRITE-ONLY
applies only to blocked files. But if BLOCK0 is in effect, the result is that the file is blocked, and the
APPLY WRITE-ONLY clause is therefore accepted.
• AWO applies to any QSAM files that have blocked variable-length records. If BLOCK0 is in effect, the
result is that more files might be blocked than if NOBLOCK0 were in effect; thus AWO might apply to more
files than it otherwise would.
Specifying BLOCK0 for existing programs might result in a change of behavior, and in some cases produce
undesirable results for files opened as INPUT. For example:
• The OPEN INPUT statement fails for files for which no block size can be determined.
• Programs that continue after handling nonzero FILE STATUS codes for files opened as INPUT might
abnormally terminate when executing subsequent I/O statements on those files.
For these reasons, after compiling with BLOCK0 you should investigate and test the effects on your
program.
For recommendations about blocking, see the related reference from the Enterprise COBOL for z/OS
Migration Guide (in the information about migrating from CMPR2 to NOCMPR2).
Related tasks
“Optimizing buffer and device space” on page 10
“Setting block sizes” on page 174
Related references
“AWO” on page 350
APPLY WRITE-ONLY clause (Enterprise COBOL for z/OS Language Reference)
BLOCK CONTAINS clause (Enterprise COBOL for z/OS Language Reference)
Enterprise COBOL for z/OS Migration Guide
(Recommendation for DCB= parameters of JCL)
BUFSIZE
Use BUFSIZE to allocate an amount of main storage to the buffer for each compiler work data set.
Usually, a large buffer size improves the performance of the compiler.
BUFSIZE( nnnK )
CICS
The CICS compiler option enables the integrated CICS translator and lets you specify CICS suboptions.
You must use the CICS option if your COBOL source program contains EXEC CICS or EXEC DLI
statements and the program has not been processed by the separate CICS translator.
CICS
("CICS-suboption-string ")
The compiler passes the following suboption string to the integrated CICS translator:
The concatenated strings are delimited with single spaces as shown. If multiple instances of the same
CICS suboption are found, the last specification of that suboption in the concatenated string prevails. The
compiler limits the size of the concatenated suboption string to 4 KB.
AMODE 64 considerations: When the LP(64) compiler option is in effect, the CICS option is not
supported. If the CICS option is specified explicitly, a warning message is issued and the setting is
discarded.
Note: The CICS compiler option can only be specified for the first program in a sequence of programs
(batch compilation). If you specify CICS in a CBL or PROCESS statement for a program other than the first
program in the sequence, you will receive a compiler diagnostic message.
Related concepts
“Integrated CICS translator” on page 500
352 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Related tasks
“Compiling with the CICS option” on page 499
“Separating CICS suboptions” on page 500
Defining translator options (Developing CICS Applications)
Related references
“Conflicting compiler options” on page 344
CODEPAGE
Use CODEPAGE to specify the coded character set identifier (CCSID) for an EBCDIC code page for
processing compile-time and runtime COBOL operations that are sensitive to character encoding.
354 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Note: If you specify the TEST option, you must set the CODEPAGE option to the CCSID that is used for
the COBOL source program. In particular, programs that use Japanese characters in DBCS literals or DBCS
user-defined words must be compiled with the CODEPAGE option set to a Japanese codepage CCSID.
Note for Db2 users: IBM recommends that you use the COBOL CCSID value the same as Db2 DSNHDECP
value and/or the value for precompiler CCSID option.
Related concepts
“COBOL and Db2 CCSID
determination” on page 510
Related tasks
“Using currency signs” on page 64
Chapter 37, “Processing XML input,” on page 623
Chapter 38, “Producing XML output,” on page 663
Related references
“CURRENCY” on page 358
“SQLCCSID” on page 409
“TEST” on page 414
“The encoding of XML documents” on page 640
Characters (Enterprise COBOL for z/OS Language Reference)
COMPILE
Use the COMPILE option only if you want to force full compilation even in the presence of serious errors.
All diagnostics and object code will be generated. Do not try to run the object code if the compilation
resulted in serious errors: the results could be unpredictable or an abnormal termination could occur.
NOCOMPILE( E )
COMPILE
NOCOMPILE
Use NOCOMPILE without any suboption to request a syntax check (only diagnostics produced, no object
code). If you use NOCOMPILE without any suboption, several compiler options will have no effect because
no object code will be produced, for example: DECK, LIST, OBJECT, OFFSET, OPTIMIZE, SSRANGE, and
TEST.
Use NOCOMPILE with suboption W, E, or S for conditional full compilation. Full compilation (diagnosis and
object code) will stop when the compiler finds an error of the level you specify (or higher), and only syntax
checking will continue.
Related tasks
“Finding coding errors” on page 448
Related references
“Messages and listings
for compiler-detected errors” on page 281
CONDCOMP( SKIPSRC )
Related references
Example: conditional compilation output
COPYLOC
Use the COPYLOC compiler option to add either a PDSE (or PDS) dataset or z/OS UNIX directory as an
additional location to be searched for copy members during the library phase. The location specified by
the COPYLOC option is added to the end of the order of locations to search for copy members. For details,
see COPY member search order in the Enterprise COBOL for z/OS Language Reference.
COPYLOC is introduced in Enterprise COBOL V6.2 with the PTF for APAR PI91584 installed.
SYSLIB ,
COPYLOC ( DSN ( dataset-name ) )
library-name , PATH ( unix-directory-name )
356 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
unix-directory-name
The name of a z/OS UNIX directory in which the compiler should search for copy members when
processing COPY statements that refer to library library-name. The specified path must not exceed
64 characters. To specify a lowercase path, which is standard for z/OS UNIX, the path should be
surrounded in quotes. Otherwise, the path name will be converted to uppercase.
Multiple instances of the COPYLOC option are supported. There is no limit on the number of z/OS UNIX
directories that can be specified, but there is a limit of 256 datasets that can be specified for searching.
Copy locations will be searched in the order that they are specified via the COPYLOC option. This provides
users the ability to mix PDSE (or PDS) locations and z/OS UNIX directories in the search.
If the NOCOPYLOC option is specified, any previous instances of the COPYLOC option are ignored.
To control the searching of copy member locations exclusively using the COPYLOC option, you should
avoid using any of the existing methods for indicating copybook locations, such as, allocating datasets to
a ddname in JCL, or specifying the -I option of the cob2 command. If the compiler is invoked from cob2,
you should also avoid keeping copy members in the current directory, because the current directory will
always be searched before the COPYLOC locations are being searched.
Tip: You might find it convenient to control searching of copy members exclusively using the COPYLOC
option, especially when the compiler is invoked from the cob2 command.
When COPYLOC options are specified in CBL statements, they can be used only on the first program of a
batch program. Therefore, if a file has multiple COBOL programs in it, there can be CBL statements with
COPYLOC options preceding the first program, but not the other programs. The COPYLOC options specified
for the first program (and COPYLOC options specified in PARM of JCL or COPYLOC options specified as
cob2 command options under z/OS UNIX) apply to all programs in a file. The copy locations specified
in COPYLOC options found in CBL cards will be searched after copy locations found in COPYLOC options
specified as invocation parameters.
Example
COPYLOC(MYLIB,DSN(USERID.COBOL.COPYLIB1))
COPYLOC(MYLIB,PATH('/home/userid/copylib1'))
COPYLOC(MYLIB,DSN(USERID.COBOL.COPYLIB2))
For COPY statements that reference library name MYLIB explicitly, if the preceding options were specified
in a single invocation of the compiler and a copy member could not be found in the locations specified in
JCL (or in locations indicated for a cob2 compile), additional searching for the copy member will be done
in the following places sequentially:
1. USERID.COBOL.COPYLIB1 dataset
2. z/OS UNIX directory /home/userid/copylib1
3. USERID.COBOL.COPYLIB2 dataset
related references
COPY statement (Enterprise COBOL for z/OS Language Reference)
COPY member search order (Enterprise COBOL for z/OS Language Reference)
ALOWCOPYLOC (Enterprise COBOL Customization Guide)
COPYRIGHT
Use COPYRIGHT to place a string in the object module if the object module is generated. If the object is
linked into a program object, the string is loaded into memory with that program object.
CURRENCY
You can use the CURRENCY option to provide an alternate default currency symbol to be used for a COBOL
program. (The default currency symbol is the dollar sign ($).)
CURRENCY( literal )
Related tasks
“Using currency signs” on page 64
358 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
DATA
The DATA option affects whether storage for dynamic data areas and other dynamic runtime storage is
obtained from above or below the 16 MB line.
DATA( 24 )
Related concepts
“Storage and its addressability” on page 39
Related tasks
“Making programs reentrant” on page 560
Language Environment Programming Guide (Using runtime options)
Related references
“Allocation of buffers for QSAM files” on page 186
“RENT” on page 401
ALLOCATE statement (Enterprise COBOL for z/OS Language Reference)
NODBCS
With DBCS in effect, the double-byte portion of the literal is syntax-checked and the literal remains
category alphanumeric.
Related references
“Conflicting compiler options” on page 344
DECK
Use DECK to produce object code in the form of 80-column records. If you use the DECK option, be certain
that SYSPUNCH is defined in your JCL for compilation.
DECK
Related tasks
“Creating object code (SYSLIN or SYSPUNCH)” on page 271
DEFINE
Use the DEFINE compiler option to assign a literal value to a compilation variable that is defined in
the program by using the DEFINE directive with the PARAMETER phrase. The literal value provided for
the compilation variable in the DEFINE option is sometimes referred to as a "parameter value" for the
corresponding compilation variable. Compilation variables can be used within any of the conditional
compilation directives, including DEFINE, EVALUATE, and IF. When a conditional compilation variable
appears in a conditional compilation directive, it is treated as a symbolic reference to the literal value it
currently represents.
The DEFINE compiler option provides a way for you to assign values to compilation variables from outside
the program source. If that is not needed, it is sufficient to use the DEFINE directive within program
source to define compilation variables.
360 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
DEFINE option syntax
NODEFINE
DEFINE( compilation-variable-name-1 )
= literal-1
1
,
Notes:
1You cannot use "=" if you are invoking the COBOL compiler from the z/OS UNIX shell via the cob2
command.
DEFINE(foo)
Related references
Conditional compilation (Enterprise COBOL for z/OS Language Reference)
DEFINE (Enterprise COBOL for z/OS Language Reference)
DIAGTRUNC
Related concepts
“Formats for numeric data” on page 47
“Reference modifiers” on page 110
Related references
“TRUNC” on page 419
DISPSIGN
The DISPSIGN option controls output formatting for DISPLAY of signed numeric items.
DISPSIGN( SEP )
362 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
The following example shows the DISPLAY output with the DISPSIGN(COMPAT) option or the
DISPSIGN(SEP) option specified:
Table 48. DISPLAY output with the DISPSIGN(COMPAT) option or the DISPSIGN(SEP) option specified:
Data items DISPLAY output with the DISPLAY output with
DISPSIGN(COMPAT) option the DISPSIGN(SEP) option
specified specified
Unsigned binary 111 111
Positive binary 111 +111
Negative binary 11J -111
Unsigned packed-decimal 222 222
Positive packed-decimal 222 +222
Negative packed-decimal 22K -222
Zoned-decimal unsigned 333 333
Zoned-decimal trailing positive 33C +333
Zoned-decimal trailing negative 33L -333
Zoned-decimal leading positive C33 +333
Zoned-decimal leading negative L33 -333
DLL
Use DLL to instruct the compiler to generate an object module that is enabled for dynamic link library
(DLL) support. DLL enablement is required if the program will be part of a DLL, will reference DLLs, or if
the program contains object-oriented COBOL syntax such as INVOKE statements or class definitions.
Note: The DLL option can be overridden for particular CALL statements by using the CALLINTERFACE
directive.
DLL
Link-edit considerations: COBOL programs that are compiled with the DLL option must be link-edited
with the RENT and AMODE 31 link-edit options.
NODLL instructs the compiler to generate an object module that is not enabled for DLL usage.
AMODE 64 considerations: When the LP(64) compiler option is in effect, the DLL and NODLL options are
ignored and the default NODLL is effectively set because object files generated using LP(64) are always
DLL enabled. They can be linked as DLL or non-DLL.
The EXPORTALL option is supported. Use this option to export symbols from programs when building
DLLs.
#!/bin/sh
# Build SUB1 as a DLL program and link it into a DLL called mylibdll.so,
# which will be written to the current directory
cob2 sub1.cbl -o libmydll.so "-qdll,exportall,rent,list" -bdll
# Build PROG1 with the DLL compiler option as it will be making a call
# to program SUB1 which resides in DLL mylibdll.so, but PROG1 itself
# is not linked as a DLL -- it is linked as a non-DLL program.
# Note that PROG1 must be linked with the side deck mylibdll.x produced
# in the previous step in order for the symbol SUB1 to be resolved
cob2 prog1.cbl -o prog1 libmydll.x "-qdll,list"
echo ""
# Run PROG1
./prog1
Entered PROG1
Calling DLL routine SUB1 from PROG1
Entered DLL routine SUB1
Exited DLL routine SUB1
Exited PROG1
After PROG1 and SUB1 are compiled and linked, the following files exist in the current z/OS UNIX
directory:
prog1.cbl:
identification division.
program-id. prog1.
data division.
364 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
working-storage section.
procedure division.
MainProgram.
display "Entered PROG1"
display "Calling DLL routine SUB1 from PROG1"
call 'SUB1'
display "Exited PROG1"
goback.
end program prog1.
sub1.cbl:
identification division.
program-id. sub1.
data division.
working-storage section.
procedure division.
MainProgram.
display 'Entered DLL routine SUB1'
display 'Exited DLL routine SUB1'
goback.
end program sub1.
Related tasks
“Making dynamic calls” on page 548
Related references
“Conflicting compiler options” on page 344
CALLINTERFACE (Enterprise COBOL for z/OS Language Reference)
DUMP
Use DUMP to produce a system dump at compile time for an internal compiler error.
DUMP
This situation does not represent a compiler error. Using the NODUMP option will allow the compiler to
issue message IGYOP3124-W and continue processing.
Related tasks
Language Environment Debugging Guide (Understanding abend codes)
Related references
“Conflicting compiler options” on page 344
DYNAM
Use DYNAM to cause nonnested, separately compiled programs invoked through the CALL literal
statement to be loaded for CALL, and deleted for CANCEL, dynamically at run time.
Note: The DYNAM option can be overridden for particular CALL statements by using the CALLINTERFACE
directive.
CALL identifier statements always result in a runtime load of the target program and are not affected by
this option.
DYNAM
Related tasks
“Making both static and dynamic calls” on page 552
“Choosing the DYNAM or NODYNAM compiler option” on page 515
Related references
“Conflicting compiler options” on page 344
CALLINTERFACE (Enterprise COBOL for z/OS Language Reference)
366 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
EXIT
Use the EXIT option to provide user-supplied modules in place of various compiler functions.
For compiler input, use the INEXIT and LIBEXIT suboptions to provide modules in place of SYSIN and
SYSLIB (or copy library), respectively.
Note: If INEXIT or LIBEXIT is used, the 'Source' view for your debug session will not be available. If you
choose the 'Show Source' feature of 'Switch View' with Debug for z/OS, it will not work because there is no
source file.
For compiler output, use the PRTEXIT suboption to provide a module in place of SYSPRINT.
To provide a module that will be called for each SYSADATA record immediately after the record has been
written out to the file, use the ADEXIT suboption.
To customize compiler messages (change their severity or suppress them, including converting FIPS
(FLAGSTD) messages to diagnostic messages to which you assign a severity), use the MSGEXIT suboption.
The module that you provide to customize the messages will be called each time the compiler issues a
diagnostic message or a FIPS message.
EXIT( )
INEXIT( mod1)
str1,
NOINEXIT
LIBEXIT( mod2)
str2,
NOLIBEXIT
PRTEXIT( mod3)
str3,
NOPRTEXIT
ADEXIT( mod4)
str4,
NOADEXIT
MSGEXIT( mod5)
str5,
NOMSGEXIT
Related references
“Conflicting compiler options” on page 344
“FLAGSTD” on page 370
Appendix E, “EXIT compiler option,” on page 825
368 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
EXPORTALL
Use EXPORTALL to instruct the compiler to automatically export the PROGRAM-ID name and each
alternate entry-point name from each program definition when the object deck is link-edited to form
a DLL.
EXPORTALL
Related references
“Conflicting compiler options” on page 344
FASTSRT
Use FASTSRT to let IBM DFSORT, or an equivalent product, perform sort input and output instead of
Enterprise COBOL. It applies only to sorting files by using the format 1 SORT (that is, file SORT) statement.
FASTSRT
Related tasks
“Improving sort performance with FASTSRT” on page 232
FLAG
Use FLAG(x) to produce diagnostic messages at the end of the source listing for errors of a severity level
x or above.
NOFLAG
When FLAG(x,y) is in effect, most messages of severity y and above are embedded in the listing after
the line that caused the message. Messages with the IGYCB prefix will never be embedded in the source.
(See the related reference below for information about messages for exceptions.)
Use NOFLAG to suppress error flagging. NOFLAG does not suppress error messages for compiler options.
Embedded messages
• Embedding level-U messages is not recommended. The specification of embedded level-U messages is
accepted, but does not produce any messages in the source.
• The FLAG option does not affect diagnostic messages that are produced before the compiler options are
processed.
• Diagnostic messages that are produced during processing of compiler options, CBL or PROCESS
statements, or BASIS, COPY, or REPLACE statements are not embedded in the source listing. All such
messages appear at the beginning of the compiler output.
• Diagnostic messages with the IGYCB prefix are not embedded in the source listing. All such messages
appear at the end of the compiler output, regardless of the setting of the FLAG option.
• Messages that are produced during processing of the *CONTROL or *CBL statement are not embedded
in the source listing.
Related references
“Messages and listings
for compiler-detected errors” on page 281
FLAGSTD
Use FLAGSTD to specify the level or subset of the 85 COBOL Standard to be regarded as conforming, and
to get informational messages about the 85 COBOL Standard elements that are included in your program.
You can specify any of the following items for flagging:
• A selected Federal Information Processing Standard (FIPS) COBOL subset
• Any of the optional modules
• Obsolete language elements
• Any combination of subset and optional modules
• Any combination of subset and obsolete elements
• IBM extensions (these are flagged any time that FLAGSTD is specified, and identified as "nonconforming
nonstandard")
370 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
FLAGSTD option syntax
NOFLAGSTD
FLAGSTD( x )
yy ,O
3 1 1 1
You can convert FIPS informational messages into diagnostic messages, and can suppress FIPS
messages, by using the MSGEXIT suboption of the EXIT compiler option. For details, see the related
reference about the processing of MSGEXIT, and see the related task.
Related tasks
“Customizing compiler-message severities” on page 835
Related references
“Conflicting compiler options” on page 344
“Processing of MSGEXIT” on page 833
HGPR
The HGPR option controls the compiler usage of the 64-bit registers provided by IBM z/Architecture
processors.
HGPR( NOPRESERVE )
Related tasks
“Using COBOL user exit routines with DFSORT” on page 237
372 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
INITCHECK
Use the INITCHECK option to have the compiler check for uninitialized data items and issue warning
messages when they are used without being initialized.
INITCHECK
LAX
( )
STRICT
PROCEDURE DIVISION.
IF Y > 5
MOVE 2 TO Z
END-IF
DISPLAY Z
Z is initialized on one path to the DISPLAY statement but not the other, so if INITCHECK(LAX) is
in effect, a warning message will be issued for Y only, while INITCHECK(STRICT) will also issue a
warning message for Z.
Restrictions:
• The INITCHECK option analyzes data items in the WORKING-STORAGE SECTION and LOCAL-STORAGE
SECTION only. In particular, it does not analyze data items in the LINKAGE SECTION or FILE
SECTION.
• The INITCHECK analysis does not track external or global data items.
• The INITCHECK analysis does not track individual elements in tables independently. Instead, if one
element of a table is initialized, all corresponding elements of the table are considered to be initialized.
This applies to both fixed-length and variable-length tables.
• The INITCHECK analysis does not track the initialization of items if it happens through a pointer. For
example, if a pointer to an uninitialized data item is created by using ADDRESS-OF, and that data item is
initialized through that pointer, the INITCHECK analysis might also issue a warning message.
INITIAL
The INITIAL compiler option causes a program and all of its nested programs to behave as if the IS
INITIAL clause was specified on the PROGRAM-ID paragraph.
INITIAL
374 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
INLINE
The INLINE compiler option controls whether the inlining of procedures (paragraphs or sections)
referenced by PERFORM statements in the source program is allowed.
NOINLINE
Related references
INLINE directive (Enterprise COBOL for z/OS Language Reference)
INTDATE
INTDATE(ANSI) instructs the compiler to use the 85 COBOL Standard starting date for integer dates
used with date intrinsic functions. Day 1 is Jan 1, 1601. INTDATE(LILIAN) instructs the compiler to use
the Language Environment Lilian starting date for integer dates used with date intrinsic functions. Day 1 is
Oct 15, 1582.
INTDATE( LILIAN )
Related tasks
“Using date callable services” on page 59
INVDATA
The INVDATA option tells the compiler whether the data in USAGE DISPLAY and PACKED-DECIMAL data
items is valid, and if not, what the behavior of the compiler should be.
Because most users have valid data in their USAGE DISPLAY and USAGE PACKED-DECIMAL data items,
they should use NOINVDATA, even if they use NUMPROC(NOPFD). Even if you find that your programs are
processing invalid data at run time with the NUMCHECK compiler option, you should change your programs
to avoid processing invalid data and use NOINVDATA.
Note: The goal of the INVDATA option is to provide a behavior that is as compatible as possible with the
behavior of programs compiled with COBOL 4 or earlier versions in cases of invalid numeric data. When
discrepancies are found, this option will be updated in favor of making the behavior more closely match
the behavior of COBOL 4 or earlier versions.
When the INVDATA option is in effect, the compiler will avoid performing known optimizations that might
produce a different result than COBOL 4 or earlier versions when a zoned decimal or packed decimal data
item has invalid digits or an invalid sign code, or when a zoned decimal data item has invalid zone bits.
The following table provides a quick reference on how to set the INVDATA and NUMPROC options when
migrating to COBOL 6.2 or later versions from earlier versions of COBOL, depending on the default value
of the NUMPROC option that was used in the earlier version of COBOL and whether or not you have invalid
data.
Table 49. Setting INVDATA and NUMPROC options when migrating from earlier COBOL versions
COBOL versions Invalid data NUMPROC/ZONEDATA used INVDATA and NUMPROC
present? in COBOL 6.1 or earlier settings in COBOL 6.2 or
versions later versions
Pre-COBOL 5 No NUMPROC(MIG) NOINVDATA,NUMPROC(NOP
FD)
Pre-COBOL 5 No NUMPROC(NOPFD) NOINVDATA,NUMPROC(NOP
FD)
Pre-COBOL 5 No NUMPROC(PFD) NOINVDATA,NUMPROC(PFD
)
Pre-COBOL 5 Yes NUMPROC(MIG) INVDATA(FORCENUMCMP,
NOCLEANSIGN),NUMPROC(
NOPFD)
Pre-COBOL 5 Yes NUMPROC(NOPFD) INVDATA(NOFORCENUMCM
P,CLEANSIGN),NUMPROC(
NOPFD) or
INVDATA,NUMPROC(NOPFD
)
Pre-COBOL 5 Yes NUMPROC(PFD) INVDATA(NOFORCENUMCM
P,CLEANSIGN),NUMPROC(
PFD) or
INVDATA,NUMPROC(PFD)
COBOL 5 or later No ZONEDATA(PFD) NOINVDATA
376 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 49. Setting INVDATA and NUMPROC options when migrating from earlier COBOL versions
(continued)
COBOL versions Invalid data NUMPROC/ZONEDATA used INVDATA and NUMPROC
present? in COBOL 6.1 or earlier settings in COBOL 6.2 or
versions later versions
COBOL 5 or later Yes ZONEDATA(NOPFD) INVDATA(NOFORCENUMCM
P,CLEANSIGN) or simply
INVDATA
COBOL 5 or later Yes ZONEDATA(MIG) INVDATA(FORCENUMCMP,
CLEANSIGN)1
INVDATA
,
CLEANSIGN
( NOCLEANSIGN )
NOFORCENUMCMP
FORCENUMCMP
In this example,
• With COBOL 4 or earlier versions, the test is true if the NUMPROC(MIG) option is used, and false for
NUMPROC(NOPFD | PFD).
• With 6.2 or later versions:
– When you use NOINVDATA, the test is true at OPT(0) and false at OPT(1 | 2).
– When you use INVDATA(NOFORCENUMCMP), the test is false at any OPT setting.
In all, to ease your migration to COBOL 6:
• If your digits, sign codes, and zone bits are valid, use NOINVDATA, and if you used NUMPROC(PFD) or
NUMPROC(NOPFD) in COBOL 4 or earlier versions, then use the same NUMPROC setting when you use
378 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
COBOL 6; if you used NUMPROC(MIG) in COBOL 4 or earlier versions, then use NUMPROC(NOPFD) when
you use COBOL 6.
• If you have invalid digits, invalid sign codes, or invalid zone bits in your data, change your programs or
systems so that your programs do not have invalid data in numeric data items at run time. Once you
have corrected your programs or systems, you can use the preferred NOINVDATA option. Only if you
cannot contain this work and must continue to run with invalid data, consider the following choices for
INVDATA:
– If you are migrating from COBOL 4 or earlier versions and used NUMPROC(MIG) with COBOL 4,
then use INVDATA(FORCENUMCMP,NOCLEANSIGN) and NUMPROC(NOPFD) with COBOL 6.2 or later
versions to most closely mimic the previous NUMPROC(MIG) behavior when invalid data is present.
– If you are migrating from COBOL 4 or earlier versions and used NUMPROC(NOPFD) with COBOL
4, then use INVDATA(NOFORCENUMCMP,CLEANSIGN) (or simply INVDATA) and NUMPROC(NOPFD)
with COBOL 6.
– If you are migrating from COBOL 4 or earlier versions and used NUMPROC(PFD) with COBOL 4,
then use INVDATA(NOFORCENUMCMP,CLEANSIGN) (or simply INVDATA) and NUMPROC(PFD) with
COBOL 6.
Notes:
• If you completed migration from COBOL 4 or earlier versions to COBOL 5 or 6 in the past and used
the deprecated ZONEDATA(MIG) option in COBOL 5 or 6 and are satisfied with the behavior, use
INVDATA(FORCENUMCMP,CLEANSIGN) instead of ZONEDATA(MIG).
• It is not always possible to entirely match the behavior of the old compiler even with these options
when faced with clearly invalid data. For example, even for comparisons, INVDATA(NOFORCENUMCMP)
does not give the same result in all cases as COBOL 4.
Performance considerations: NOINVDATA gives better runtime performance than INVDATA does.
INVDATA disables some of the optimizations that NUMPROC(PFD) can give.
related tasks
“Checking for incompatible data (numeric class test)” on page 53
related references
“NUMCHECK” on page 388
“NUMPROC” on page 392
JAVAIOP
The JAVAIOP option controls the behavior of COBOL programs that interoperate with Java though the
JAVA-CALLABLE or JAVA-SHAREABLE directives or by calling Java static methods using the CALL
statement.
NOJVMINITOPTIONS
JVMINITOPTIONS ( jvm-init-string )
NOJAVA64
JAVA64
Related tasks
CALL statement (Enterprise COBOL for z/OS Language Reference)
JAVA-CALLABLE (Enterprise COBOL for z/OS Language Reference)
JAVA-SHAREABLE (Enterprise COBOL for z/OS Language Reference)
380 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
LANGUAGE
Use the LANGUAGE option to select the language in which compiler output will be printed. The information
that will be printed in the selected language includes diagnostic messages, source listing page and scale
headers, FIPS message headers, message summary headers, compilation summary, and headers and
notations that result from the selection of certain compiler options (MAP, XREF, VBREF, and FLAGSTD).
1. If your installation's system programmer has provided a language other than those described, you
must specify at least the first two characters of this other language's name.
2. To specify a language other than UENGLISH, the appropriate language feature must be installed.
3. To change to uppercase English or Japanese compiler messages, in addition to using the LANGUAGE
compiler option, you must also set the Language Environment runtime option NATLANG at compile
time. We recommend using CEEOPTS DD in the compile JCL.
For example, to change messages to Japanese, use the LANGUAGE(JA) compiler option and also
specify the NATLANG LE runtime option at compile time:
//CEEOPTS DD *
NATLANG(JPN)
/*
If the LANGUAGE option is changed at compile time (using CBL or PROCESS statements), some initial text
will be printed using the language that was in effect at the time the compiler was started.
NATLANG: The NATLANG runtime option allows you to control the national language to be used for
the runtime environment, including error messages, month names, and day-of-the-week names. The
LANGUAGE compiler option and the NATLANG runtime option act independently of each other. You can use
them together with neither taking precedence over the other.
LINECOUNT
Use LINECOUNT(nnn) to specify the number of lines to be printed on each page of the compilation listing,
or use LINECOUNT(0) to suppress pagination.
LIST
Use the LIST compiler option to produce a listing of the assembler-language expansion of your source
code.
LIST
Related tasks
“Getting listings” on page 453
Related references
“Conflicting compiler options” on page 344
*CONTROL (*CBL) statement (Enterprise COBOL for z/OS Language Reference)
382 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
LP
Use the LP compiler option to indicate whether a AMODE 31 (31-bit) or AMODE 64 (64-bit) program
should be generated with the related language features enabled.
LP option syntax
32
LP( 64 )
related references
“Specifying compiler options under z/OS” on page 273
“Specifying compiler options in the PROCESS (CBL) statement” on page 274
“Compiling multiple programs
(batch compilation)” on page 276
MAP
HEX
( DEC )
When the MAP(HEX | DEC) option is in effect, you also get an embedded MAP report in the source code
listing. The condensed MAP information is shown to the right of data-name definitions in the WORKING-
STORAGE SECTION, FILE SECTION, LOCAL-STORAGE SECTION, and LINKAGE SECTION of the DATA
DIVISION. When both XREF data and an embedded MAP summary are on the same line, the embedded
MAP summary is listed first.
“Example: MAP output” on page 459
Related concepts
Chapter 21, “Debugging,” on page 443
Related tasks
“Getting listings” on page 453
Related references
*CONTROL (*CBL) statement (Enterprise COBOL for z/OS Language Reference)
384 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
MAXPCF
Use the MAXPCF option to specify a maximum program complexity factor value. The program complexity
factor (PCF) is computed by the compiler and the computed value is in the listing file. If the PCF of your
program exceeds the maximum value, the compiler will automatically reduce the optimization level to
speed up the compilation and use less storage. Therefore, when you compile a suite of programs, you do
not have to specify an OPTIMIZE option value for each program.
Related references
“OPTIMIZE” on page 395
MDECK
COMPILE
( NOCOMPILE )
386 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
For a batch compilation (multiple COBOL source programs in a single input file), a single MDECK output file
that contains the complete expanded source is created.
Any SEQUENCE compiler-option processing is reflected in the MDECK file.
COPY statements are included in the MDECK file as comments.
Related tasks
“Starting the compiler from an assembler program” on page 264
“Defining the library-processing output file (SYSMDECK)” on page 273
Related references
“Conflicting compiler options” on page 344
Chapter 20, “Compiler-directing statements,” on page 439
NAME
Use NAME to generate a link-edit NAME card for each object module. You can also use NAME to generate
names for each program object when you are doing batch compilations.
When NAME is specified, a NAME card is appended to each object module that is created. Program object
names are formed using the rules for forming module names from PROGRAM-ID statements.
NAME
NOALIAS
( ALIAS )
Related references
PROGRAM-ID paragraph (Enterprise COBOL for z/OS Language Reference)
NSYMBOL
The NSYMBOL option controls the interpretation of the N symbol used in literals and PICTURE clauses,
indicating whether national or DBCS processing is assumed.
NSYMBOL( DBCS )
Related references
“Conflicting compiler options” on page 344
NUMBER
Use the NUMBER compiler option if you have line numbers in your source code and want those numbers to
be used in error messages and SOURCE, MAP, LIST, and XREF listings.
NUMBER
NUMCHECK
The NUMCHECK compiler option tells the compiler whether to generate extra code to validate data items
when they are used as sending data items. For zoned decimal (numeric USAGE DISPLAY) and packed
decimal (COMP-3) data items, the compiler generates implicit numeric class tests for each sending field.
For alphanumeric senders whose contents are being moved to a numeric receiver, the compiler treats the
sender as a numeric integer so NUMCHECK generates an implicit numeric class test for each alphanumeric
sender. For binary data items, the compiler generates SIZE ERROR checking to see whether the data
item has more digits than its PICTURE clause allows.
The NUMCHECK option is updated to remove redundant checks for invalid data, thus improving runtime
performance. There may be fewer runtime messages than before.
388 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
The analysis done to remove redundant checks is more involved at OPT(1|2) than at OPT(0). OPT(0)
does a simpler form of the analysis to keep compilation time as low as possible. There may be fewer
messages at higher OPT levels.
When the compiler is able to determine at compile time that a check will always find invalid data, a
compile-time message is produced and the runtime check is removed. (See MSG|ABD below.)
NUMCHECK
,
( ZON )
,
( ALPHNUM )
NOALPHNUM
LAX
STRICT
NOZON
PAC
NOPAC
BIN
( TRUNCBIN )
NOTRUNCBIN
NOBIN
MSG
ABD
ADD A TO B
DIVIDE A INTO B
COMPUTE B = A + B
In this case, data item NUM2-PART3 will be treated by NUMCHECK as a signed zoned decimal data
item because its last byte overlaps the last byte of NUM1, which is a signed trailing overpunch
zoned decimal item. Thus, the following values of NUM2-PART3 are all considered valid:
- x'F1F2F3F4F5F6F7F8'
- x'F1F2F3F4F5F6F7C8'
- x'F1F2F3F4F5F6F7D8'
.
• A zoned decimal data item redefines a numeric-edited data item that may contain leading spaces,
as indicated by the Z symbol in the numeric-edited item’s PICTURE string, and the leading bytes of
the zoned decimal data item overlap some or all of the leading bytes of the numeric-edited item. In
this case, NUMCHECK will tolerate spaces in the leading bytes of the zoned decimal data item that
overlap those bytes of the numeric-edited item that permit spaces.
Notes:
– The numeric-edited item that is redefined must be a level-01 or level-77 item. The zoned decimal
item can be a level-01 or level-77 item or can be a subordinate item in a group.
390 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
– If the zoned decimal item is signed, it must be signed trailing overpunch.
– The first byte of the zoned decimal item must overlap the first byte of the numeric-edited item to
be considered eligible for this treatment, but the zoned decimal item does not need to overlap the
entire numeric-edited item. For example:
In this case, NUMCHECK tolerates spaces in the first two bytes of INTVAL because it overlaps the
first two bytes of NUMED which are defined with the Z symbol in its PICTURE string. Thus, the
following values of INTVAL are all considered valid:
- x'F1F2F3F4'
- x'40F1F2F3'
- x'4040F1F2'
Note that for performance reasons, mixes of spaces and non-spaces are tolerated in the leading
bytes, thus x’F140F1F2’ is also considered valid.
• A zoned decimal data item is moved to a zoned or alphanumeric data item. In this case, NUMCHECK
will not check the sender of the move. However, if the sender is subsequently used in a numeric
context, it will be checked.
If ZON(STRICT) is specified, NUMCHECK does not consider any data items that a zoned decimal data
item might redefine, and strict checking of the zoned decimal data is performed as usual.
Note: The ZON(LAXREDEF|STRICTREDEF) option is deprecated but is tolerated for compatibility,
and it is replaced by the ZON(LAX|STRICT) option.
PAC | NOPAC
Specifying PAC causes the compiler to generate code for an implicit numeric class test for packed
decimal (COMP-3) data items that are used as sending data items in COBOL statements. For packed
decimal data items that have an even number of digits, the unused bits are checked for ones.
Restriction: For CALL statements, NUMCHECK(ZON) and NUMCHECK(PAC) check BY CONTENT data
items that are zoned decimal or packed decimal, but they do not check BY REFERENCE parameters.
(Neither zoned decimal nor packed decimal data items can be specified in a BY VALUE phrase.)
BIN(TRUNCBIN|NOTRUNCBIN) | NOBIN
Specifying BIN causes the compiler to generate code similar to ON SIZE ERROR to test if binary data
items contents are bigger than the PICTURE clause. This extra code will be generated only for binary
data items that are used as sending data items, and COMP-5 data items will not get this ON SIZE
ERROR code generated.
When BIN(TRUNCBIN) is in effect, the checking code is generated for binary data items, even when
the TRUNC(BIN) compiler option is in effect. Note that BIN(TRUNCBIN) is the default when no
suboption for BIN is specified.
When BIN(NOTRUNCBIN) is in effect, the checking code is not generated for binary items when the
TRUNC(BIN) compiler option is in effect.
Note: BIN(NOTRUNCBIN) is useful for users who want to make NUMCHECK(..., BIN, ...) a fixed
option in their default options, but do not want the checking to be done for modules that are compiled
with the TRUNC(BIN) option in effect.
MSG | ABD
Determines whether the message issued for invalid data is a warning level message to continue
processing or a terminating level message to cause an abend:
• If MSG is in effect, a runtime warning message with the line number, data item name, data item
content, and program name is issued. Also, the affected statements will still be executed.
Related tasks
“Checking for incompatible data (numeric class test)” on page 53
Related references
“NUMPROC” on page 392
“TRUNC” on page 419
“ZONECHECK” on page 427
“INVDATA” on page 376
NUMPROC
Use NUMPROC(NOPFD) if your internal decimal and zoned decimal data might use nonpreferred signs.
NUMPROC( PFD )
392 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Sign representation is affected not only by the NUMPROC option, but also by the NUMCLS installation
option.
Related tasks
“Checking for incompatible data (numeric class test)” on page 53
Related references
“Sign representation of zoned and packed-decimal data” on page 53
OBJECT
Use OBJECT to write the generated object code to a file to be used as input for the binder.
NOOBJECT
Related references
“Conflicting compiler options” on page 344
OFFSET
Use OFFSET to produce a condensed PROCEDURE DIVISION listing.
OFFSET
Related references
“Conflicting compiler options” on page 344
“Example: OFFSET compiler output” on page 487
OPTFILE
Use OPTFILE to enable the specifying of COBOL compiler options in a data set. Using a compiler-option
data set circumvents the 100-character limit on options specified in a JCL PARM string.
Related tasks
“Starting the compiler from an assembler program” on page 264
“Defining a compiler-option data set (SYSOPTF)” on page 270
“Specifying compiler options under z/OS” on page 273
Chapter 15, “Compiling under z/OS UNIX,” on page 283
Related references
“Conflicting compiler options” on page 344
394 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
OPTIMIZE
Use OPTIMIZE to reduce the run time of your object program. Optimization might also reduce the amount
of storage your object program uses.
OPTIMIZE ( 1 )
Related concepts
“Optimization” on page 776
Related tasks
“Writing routines for handling errors” on page 252
Related references
“Conflicting compiler options” on page 344
“INLINE” on page 375
“MAXPCF” on page 385
“TEST” on page 414
“STGOPT” on page 412
VOLATILE clause (Enterprise COBOL for z/OS Language Reference)
OUTDD
Use OUTDD to specify that you want DISPLAY output that is directed to the system logical output device
to go to a specific ddname.
You can specify a file in the z/OS UNIX file system with the ddname named in OUTDD. To understand
where output is directed when this ddname is not allocated, see the related task about displaying data.
Related tasks
“Displaying data on the system logical output device” on page 36
“Coding COBOL programs to run under CICS” on page 495
Related references
Language Environment Programming Reference (MSGFILE)
396 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
PARMCHECK
The PARMCHECK option tells the compiler to generate an extra data item following the last item in
WORKING-STORAGE. This buffer data item is then used at run time to check whether a called subprogram
corrupted data beyond the end of WORKING-STORAGE.
When a calling program is compiled with PARMCHECK, the compiler generates a buffer following the last
data item in the WORKING-STORAGE section. At run time, before each call, the buffer is set to ALL x'AA'.
After each call, the buffer is checked to see whether it was changed. The PARMCHECK option can help with
your migration from COBOL 4 and earlier compilers to COBOL 6 and later compilers, and can also be used
to clean up and check for good programming practices.
PARMCHECK
( MSG )
ABD ,n
Related references
CALL statement (Enterprise COBOL for z/OS Language Reference)
PGMNAME( LONGMIXED )
LONGUPPER
PGMNAME(COMPAT)
With PGMNAME(COMPAT), program-names and user-defined function-names are handled in a manner
compatible with older versions of COBOL compilers:
• The program-name can be up to 30 characters in length.
• All the characters used in the name must be alphabetic, digits, the hyphen, or the underscore, except
that if the program-name is a literal and is in the outermost program, then the literal can also contain
the extension characters @, #, and $, and the first character can be an underscore.
• At least one character must be alphabetic.
• The hyphen cannot be used as the first or last character.
External program-names and external user-defined function-names are processed by the compiler as
follows:
• They are folded to uppercase.
• They are truncated to eight characters.
• Hyphens are translated to zero (0).
• If the first character is not alphabetic, and is not an underscore, it is converted as follows:
– 1-9 are translated to A-I.
– Anything else is translated to J.
398 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
PGMNAME(LONGUPPER)
With PGMNAME(LONGUPPER), program-names that are specified in the PROGRAM-ID paragraph as COBOL
user-defined words, or user-defined function-names that are specified in the FUNCTION-ID paragraph as
COBOL user-defined words, must follow the normal COBOL rules for forming a user-defined word:
• The program-name can be up to 30 characters in length.
• All the characters used in the name must be alphabetic, digits, the hyphen, or the underscore.
• At least one character must be alphabetic.
• The hyphen cannot be used as the first or last character.
• The underscore cannot be used as the first character.
When a program-name is specified as a literal, in either a definition or a reference, then:
• The program-name can be up to 160 characters in length.
• All the characters used in the name must be alphabetic, digits, the hyphen, or the underscore.
• At least one character must be alphabetic.
• The hyphen cannot be used as the first or last character.
• The underscore can be used in any position.
External program-names and external user-defined function-names are processed by the compiler as
follows:
• They are folded to uppercase.
• Hyphens are translated to zero (0).
• If the first character is not alphabetic, and is not an underscore, it is converted as follows:
– 1-9 are translated to A-I.
– Anything else is translated to J.
Names of nested programs are folded to uppercase by the compiler but otherwise are processed as is,
without truncation or translation.
PGMNAME(LONGMIXED)
With PGMNAME(LONGMIXED), program-names are processed as is, without truncation, translation, or
folding to uppercase.
If you want to use a PROGRAM-ID that is longer than eight characters, enclose it in single quotation marks
or apostrophes (') and use PGMNAME(LONGMIXED).
With PGMNAME(LONGMIXED), all program-name definitions must be specified using the literal format
of the program-name in the PROGRAM-ID paragraph or ENTRY statement. The literal user for a program-
name can contain any character in the range X'41'-X'FE'.
With PGMNAME(LONGMIXED), all user-defined function definitions must be specified with the AS phrase
in the FUNCTION-ID paragraph. literal-1 of the AS phrase is processed as is, without truncation,
translation, or folding to uppercase.
Usage notes
• The following elements are not affected by the PGMNAME option:
– Class-names and method-names.
– System-names (assignment-names in SELECT . . . ASSIGN, and text-names or library-names in
COPY statements).
– Dynamic calls.
Dynamic calls are resolved with truncation of the program-name to eight characters, folding to
uppercase, and translation of embedded hyphens or a leading digit.
Related references
PROGRAM-ID paragraph (Enterprise COBOL for z/OS Language Reference)
FUNCTION-ID paragraph (Enterprise COBOL for z/OS Language Reference)
QUALIFY
QUALIFY affects qualification rules and controls whether to extend qualification rules so that some data
items that cannot be referenced under COBOL Standard rules can be referenced.
QUALIFY( EXTEND )
01 A.
02 B.
03 C PIC X.
03 A PIC X.
02 C PIC X.
.
.
.
Move space to C of A *> Refers to 02 level C (unique only with
QUALIFY(EXTEND))
Move space to A *> Refers to 01 level A (unique only with
QUALIFY(EXTEND))
Move space to C of B of A *> Refers to 03 level C (unique by COBOL standard
rules)
Move space to C of B *> Refers to 03 level C (unique by COBOL standard
rules)
400 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
RENT
A program compiled as RENT is generated as a reentrant object program. A program compiled as NORENT
is generated as a nonreentrant object program.
Either a reentrant or a nonreentrant program can be invoked as a main program or as a subprogram.
NORENT
Related concepts
“Storage and its addressability” on page 39
Related tasks
“Making programs reentrant” on page 560
DB2 Application Programming and SQL Guide (Using reentrant code)
Related references
“Conflicting compiler options” on page 344
“DATA” on page 359
“RMODE” on page 402
RMODE( 24 )
ANY
Related concepts
“Storage and its addressability” on page 39
Related references
“Allocation of buffers for QSAM files” on page 186
“Conflicting compiler options” on page 344
402 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
RULES
You can use the RULES option to request information about your program from the compiler to improve
the program by flagging certain types of source code at compile time.
ENDPERIOD
RULES ( NOENDPERIOD )
EVENPACK
NOEVENPACK
LAXPERF
NOLAXPERF
SLACKBYTES
NOSLACKBYTES
OMITODOMIN
NOOMITODOMIN
UNREF
NOUNREFALL
NOUNREFSOURCE
LAXREDEF
NOLAXREDEF
404 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
as well as whatever RULES suboptions that were previously specified. If there is no RULES specification
for a suboption, the default will take effect. If a subsequent RULES specification references a previously
specified suboption, then the last specification takes effect.
• You can optionally use the RULES option with the MSGEXIT suboption of the EXIT compiler option to
enforce local coding standards. For example, if you want to ensure that no programmers use periods
instead of explicit scope delimiters to delimit conditional statements, you can change the severity of
the ENDPERIOD message from Warning level (RC=4) to Severe level (RC=12). For a sample of how to
modify the severity of this and other RULES messages, see the sample MSGEXIT in SIGYSAMP called
IGYMSGXT.
Related references
SYNCHRONIZED clause (Enterprise COBOL for z/OS Language Reference)
SEQUENCE
When you use SEQUENCE, the compiler examines columns 1 through 6 to check that the source
statements are arranged in ascending order according to their EBCDIC collating sequence. The compiler
issues a diagnostic message if any statements are not in ascending order.
Source statements with blanks in columns 1 through 6 do not participate in this sequence check and do
not result in messages.
NOSEQUENCE
Related tasks
“Finding line sequence problems” on page 448
SERVICE
Use SERVICE to place a string in the object module if the object module is generated. If the object
module is linked into a program object, the string is loaded into memory with this program object. If the
Language Environment dump includes a traceback, this string is included in that traceback.
SMARTBIN
Use SMARTBIN to instruct the compiler to generate modules containing additional binary metadata that
enables them to be optimized by IBM Automatic Binary Optimizer (ABO) for z/OS 2.2.
NOSMARTBIN
406 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
– VS COBOL II 1.3.x
• COBOL modules that have been processed by CA-Optimizer cannot be optimized by ABO. For these
types of modules, it is recommended to use ABO to optimize the original module created by the COBOL
compiler before it was processed by CA-Optimizer.
Refer to the IBM Automatic Binary Optimizer for z/OS product page for additional information on ABO
benefits.
Related concepts
“Storage and its addressability” on page 39
Related references
“LP” on page 383
SOURCE
Use SOURCE to get a listing of your source program. This listing will include any statements embedded by
PROCESS or COPY statements.
( HEX )
NOSOURCE
== 00006D> IGYPS0086-I "EC" is reserved in ISO/IEC FCD 1989:2002, Programming language COBOL,
and may be reserved in a future release of this compiler.
SPACE
Use SPACE to select single-, double-, or triple-spacing in your source code listing.
SPACE( 2 )
Related references
“SOURCE” on page 407
SQL
Use the SQL compiler option to enable the Db2 coprocessor and to specify Db2 suboptions.
SQL
("DB2-suboption-string ")
408 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
You can partition a long suboption string into multiple suboption strings in multiple CBL statements. For
example:
The Db2 suboptions are concatenated in the order of their appearance. Thus in the example above, the
compiler passes the following suboption string to the Db2 coprocessor:
The concatenated strings are delimited with single spaces as shown. If multiple instances of the same
Db2 option are found, the last specification of each option prevails. The compiler limits the length of the
concatenated Db2 suboption string to 4 KB.
Note: The SQL compiler option can only be specified for the first program in a sequence of programs
(batch compilation). If you specify SQL in a CBL or PROCESS statement for a program other than the first
program in the sequence, you will receive a compiler diagnostic message.
Related concepts
“Db2 coprocessor” on page 505
“COBOL and Db2 CCSID
determination” on page 510
Related tasks
“Compiling with the SQL option” on page 509
“Separating Db2 suboptions” on page 510
Related references
“Conflicting compiler options” on page 344
SQLCCSID
Use the SQLCCSID compiler option to control whether the CODEPAGE compiler option will influence the
processing of SQL statements in your COBOL programs.
NOSQLCCSID
Related concepts
“Db2 coprocessor” on page 505
“COBOL and Db2 CCSID
determination” on page 510
Related tasks
“Programming with the SQLCCSID or NOSQLCCSID option” on page 512
Related references
“Code-page determination for string host variables in SQL statements” on page 511
“CODEPAGE” on page 353
“SQL” on page 408
SQLIMS
Use the SQLIMS compiler option to enable the IMS SQL coprocessor and to specify Information
Management System (IMS) suboptions. You must specify the SQLIMS option if a COBOL source program
contains SQLIMS statements (EXEC SQLIMS statements).
SQLIMS
("IMS-suboption-string ")
Default: NOSQLIMS
Abbreviation: None
If you specify the NOSQLIMS option, any SQLIMS statements that are found in the source program are
diagnosed and discarded.
Use either quotation marks or apostrophes to delimit the string of IMS suboptions.
You can partition a long suboption string into multiple suboption strings in multiple CBL statements. For
example:
The IMS suboptions are concatenated in the order of their appearance. Thus in the proceeding example,
the compiler passes the following suboption strings to the IMS SQL coprocessor:
The concatenated strings are delimited with single spaces as shown. If multiple instances of the same
IMS suboption are found, the last specification of each suboption takes effect. The compiler limits the
length of the concatenated IMS suboption string to 4 KB.
410 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
When the LP(64) compiler option is in effect, the SQLIMS option is not supported. If the option is
specified explicitly by the user, a diagnostic message is emitted.
Note: The SQLIMS compiler option can only be specified for the first program in a sequence of programs
(batch compilation). If you specify SQLIMS in a CBL or PROCESS statement for a program other than the
first program in the sequence, you will receive a compiler diagnostic message.
Related concepts
“IMS SQL
coprocessor” on page 517
Related tasks
“Compiling with the SQLIMS option” on page 519
“Separating IMS suboptions” on page 520
Related references
“Conflicting compiler options” on page 344
SSRANGE
Use SSRANGE to generate code that checks for out-of-range storage references.
SSRANGE ( )
NOZLEN
ZLEN
ABD
MSG
Related concepts
“Reference modifiers” on page 110
Related tasks
“Checking for valid ranges” on page 449
STGOPT
The STGOPT option controls storage optimization.
STGOPT
412 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
In addition, with STGOPT, data items in the LOCAL-STORAGE SECTION can be reordered in memory to
optimize performance.
When NOSTGOPT is in effect, the storage for all data items, including unreferenced data items, is allocated
by the compiler, data items are never reordered to improve performance, and all data items defined with a
VALUE clause are guaranteed to be initialized, even if they are unreferenced.
You can also use the RULES(UNREF | NOUNREFALL | NOUNREFSOURCE) option to control whether to
issue warning messages for unreferenced data items. For details, see “RULES” on page 403.
SUPPRESS
Use the NOSUPPRESS option to ignore the SUPPRESS phrase of all COPY statements in a program so that
copybook information can appear in the listing. The copybook information can be used by debuggers,
tools, and so on, without users needing to modify their source code.
NOSUPPRESS
TERMINAL
Use TERMINAL to send progress and diagnostic messages to the SYSTERM ddname.
TERMINAL
TEST
,
( )
DWARF
NODWARF
EJPD
NOEJPD
SEPARATE
( DSNAME )
NODSNAME
NOSEPARATE
SOURCE
NOSOURCE
DWARF | NODWARF
If TEST(DWARF) is in effect, complete DWARF diagnostic information is included in the object
program, or a separate debug file when the SEPARATE suboption is in effect. This option enables
the best usability for application failure analysis tools, such as CEEDUMP and IBM Fault Analyzer.
When NOTEST(DWARF) is in effect, the debugging information is a subset of the DWARF
information that is available with TEST(DWARF). The DWARF diagnostic information that is produced
when NOTEST(DWARF) is in effect cannot be used with IBM z/OS Debugger. Consider using
NOTEST(DWARF) when use of the debugger is not needed and you want to avoid the performance
implications of the TEST option while having improved usability for application failure analysis tools,
such as CEEDUMP and IBM Fault Analyzer.
Debugging information generated by the compiler is in the industry-standard DWARF format. For
more information about DWARF, see About Common Debug Architecture in the DWARF/ELF Extensions
Library Reference.
If NODWARF is in effect, DWARF diagnostic information is not included in the object program, or written
to a separate debug file.
Notes:
414 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
• SOURCE and SEPARATE are not allowed with NODWARF.
• If you specify the DWARF suboption of TEST or NOTEST, you must set the CODEPAGE option to the
CCSID that is used for the COBOL source program. Programs that use Japanese characters in DBCS
literals or DBCS user-defined words must be compiled with the CODEPAGE option set to a Japanese
codepage CCSID. For more information, see “CODEPAGE” on page 353.
EJPD | NOEJPD
EJPD and NOEJPD control enablement of the IBM z/OS Debugger commands JUMPTO and GOTO in
production debugging sessions. EJPD and NOEJPD only take effect if you specify the TEST option and
a non-zero OPTIMIZE level (OPTIMIZE(1) or OPTIMIZE(2)).
If you specify TEST(EJPD) and a non-zero OPTIMIZE level:
• The JUMPTO and GOTO commands are enabled.
• The amount of program optimization is reduced. Optimization is done within statements, but most
optimizations do not cross statement boundaries.
If you specify TEST(NOEJPD) and a non-zero OPTIMIZE level:
• The JUMPTO and GOTO commands are not enabled, but you can use JUMPTO and GOTO if you use
the SET WARNING OFF IBM z/OS Debugger command. In this scenario, JUMPTO and GOTO will have
unpredictable results.
• The normal amount of program optimization is done.
Note: EJPD is not allowed with NOTEST.
SOURCE | NOSOURCE
If you specify SOURCE, the DWARF debugging information generated by the compiler includes the
expanded source code.
Note: SOURCE is not allowed if NODWARF is specified.
If you specify NOSOURCE, the generated DWARF debugging information does not include the expanded
source code. You will not be able to debug using the IBM z/OS Debugger with TEST(NOSOURCE).
SEPARATE[(DSNAME|NODSNAME)] | NOSEPARATE
The default is SEPARATE(NODSNAME) when SEPARATE is specified with no suboptions.
Specify SEPARATE or SEPARATE(NODSNAME) to control program object size on disk (NOSEPARATE
does not affect the size of the loaded program object) while retaining debugging capability. Generated
DWARF debugging information is written to the SYSDEBUG data set instead of to the object program.
See the section below about controlling module size while retaining debugging capability.
If SEPARATE(DSNAME) is in effect, the SYSDEBUG dataset name used during compilation is stored
in the object program. This name will be used as the default at run time when DWARF information is
required. The dataset name can be overridden by using the SYSDEBUG COBOL debug file user exit,
IGZIUXB. Note that when NODSNAME is in effect, the IGZIUXB user exit provides the only mechanism
of locating the DWARF debugging information for the program.
Notes:
• SEPARATE is not allowed if NODWARF is specified.
• Support for debugging DWARF debugging information in the SYSDEBUG data set requires IBM z/OS
Debugger 14.1 and later:
– IBM Debug for z Systems 14.1 (5655-Q50) (formerly IBM Debug Tool for z/OS) or later
– IBM Developer for z Systems 14.1 (5724-T07) or later
– IBM Application Delivery Foundation for z Systems 3.1 (5655-AC6) or later
Specify NOSEPARATE to include generated DWARF debugging information in the object program.
Controlling module size while retaining debugging capability:
The DWARF suboption of TEST causes the compiler to generate debug information tables that IBM z/OS
Debugger uses to resolve data-names, paragraph-names, and the like. This information can take a lot of
416 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Note: IBM z/OS Debugger is a component of the following products:
• IBM Developer for z/OS Enterprise Edition (included in IBM Application Delivery Foundation for z/OS)
• IBM z/OS Debugger (formerly IBM Debug for z Systems and Debug Tool)
• IBM Developer for z/OS
To find out which IBM debug product best suits your needs, see https://www.ibm.com/docs/developer-
for-zos/latest?topic=debugger-overview-zos.
LLA/VLF managed programs where DWARF diagnostic information is included:
When DWARF diagnostic information is included in the object program because of the
TEST(NOSEPARATE) or other equivalent options and the program is staged to VLF, the information
cannot be extracted from the program. The execution JCL requires the use of the IGZLOAD DD, the
STEPLIB DD, or both to specify the location of any LLA/VLF managed libraries from which the application
will load programs that have been staged to VLF. Otherwise, the COBOL variable information and the
statement numbers in the traceback will be missing in the CEEDUMP and a diagnostic message will
appear in the CEEDUMP. For more information, see Diagnostic messages in CEEDUMPs for IBM Enterprise
COBOL for z/OS at https://www.ibm.com/support/pages/diagnostic-messages-ceedumps-ibm-enterprise-
cobol-zos.
For each program staged to VLF, the following steps are taken to extract the DWARF diagnostic
information:
1. The COBOL Runtime checks for the allocation of the IGZLOAD DD. It then checks if the library is
associated with the IGZLOAD DD contains a member, for example, a COBOL program, whose name
matches the program staged to VLF.
2. If the previous step was unsuccessful because the IGZLOAD DD was not allocated or the member was
not found, the same process is attempted using the STEPLIB DD.
3. If the member is found, and the checksum that is stored with the DWARF diagnostic information
retrieved from the member matches the checksum of the compile unit in the executing program, the
information is extracted from the member.
Note that if duplicate members exist in the IGZLOAD DD concatenation or in the STEPLIB DD
concatenation respectively, the first occurrence in the DD concatenation is used to obtain the
checksum.
A mismatch can occur if a revised copy of the program is placed into a LLA/VLF managed library, but
the environment-appropriate refresh for the staged LLA/VLF program has not been completed.
For example, you can allocate the IGZLOAD DD with DSN=USER.COBOL.LOADLIB when all of the
following conditions are met:
• USER.COBOL.LOADLIB is in LNKLST.
• USER.COBOL.LOADLIB(PGM1) is staged to VLF.
• PGM1 is executed from USER.COBOL.LOADLIB in LNKLST.
If a program is LLA/VLF managed and staged to VLF, and is executed from one of the data sets in LNKLST,
there is a need to allocate the IGZLOAD DD. However, if the program resides in one of the data sets in the
STEPLIB DD, there is no need to allocate the IGZLOAD DD.
Related concepts
DWARF/ELF Extensions Library Reference (About Common Debug
Architecture)
Related tasks
“Defining the debug data set (SYSDEBUG)” on page 272
“Using the debugger” on page 453
Related references
“Logical record length and block size” on page 269
“cob2 input and output files” on page 289
“Conflicting compiler options” on page 344
“OPTIMIZE” on page 395
TEST | NOTEST
(Language Environment Programming Reference)
THREAD
THREAD indicates that a COBOL program is to be enabled for execution in a Language Environment
enclave that has multiple POSIX threads or PL/I tasks.
THREAD
418 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
be called by other programs that are not enabled for multithreading, provided that the application does
not contain multiple POSIX threads or PL/I tasks at run time.
Programs compiled using the THREAD option are supported in the reusable environment that is created by
calling the Language Environment preinitialization routine CEEPIPI. But a reusable environment created
by using the RTEREUS runtime option is not supported for programs compiled using the THREAD option.
Performance consideration: If you use the THREAD option, you can expect some runtime performance
degradation due to the overhead of serialization logic that is automatically generated.
AMODE 64 considerations: The THREAD option is ignored when LP(64) is in effect. If the user explicitly
specifies the THREAD option, an informational message is issued.
Related tasks
Chapter 31, “Preparing COBOL programs for multithreading,” on page 589
Related references
“Conflicting compiler options” on page 344
TRUNC
TRUNC affects the way that binary data is truncated during moves and arithmetic operations.
TRUNC( OPT )
BIN
TRUNC example 1
The following table shows values of the data items after the MOVE statement.
A halfword of storage is allocated for BIN-VAR. The result of this MOVE statement if the program is
compiled with the TRUNC(STD) option is 51; the field is truncated to conform to the PICTURE clause.
If you compile the program with TRUNC(BIN), the result of the MOVE statement is -7621. The reason
for the unusual result is that nonzero high-order digits are truncated. Here, the generated code sequence
would merely move the lower halfword quantity X'E23B' to the receiver. Because the new truncated value
overflows into the sign bit of the binary halfword, the value becomes a negative number.
It is better not to compile this MOVE statement with TRUNC(OPT), because 123451 has greater precision
than the PICTURE clause for BIN-VAR. With TRUNC(OPT), the results are again -7621. This is because
the best performance was obtained by not doing a decimal truncation.
TRUNC example 2
420 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
. . .
MOVE 1234567891 to BIN-VAR
The following table shows values of the data items after the MOVE statement.
When you specify TRUNC(STD), the sending data is truncated to six integer digits to conform to the
PICTURE clause of the BINARY receiver.
When you specify TRUNC(OPT), the compiler assumes the sending data is not larger than the PICTURE
clause precision of the BINARY receiver. The most efficient code sequence in this case is truncation as if
TRUNC(STD) were in effect.
When you specify TRUNC(BIN), no truncation occurs because all of the sending data fits into the binary
fullword allocated for BIN-VAR.
Related concepts
“Formats for numeric data” on page 47
Related tasks
“Compiling with the CICS option” on page 499
Related references
“NUMCHECK” on page 388
VALUE clause (Enterprise COBOL for z/OS Language Reference)
TUNE
The TUNE option specifies the architecture for which the executable program will be optimized.
TUNE( 11 )
12
13
14
Default is: The default TUNE level matches the ARCH level if ARCH is specified. If ARCH is not specified,
both ARCH and TUNE default to 10.
Abbreviations are: None
Current supported architecture levels and groups of models are as follows:
10
Generates code that is optimized for the 2827-xxx (IBM zEnterprise EC12) and 2828-xxx (IBM
zEnterprise BC12) models in IBM z/Architecture mode.
11
Generates code that is optimized for the 2964-xxx (IBM z13) and 2965-xxx (IBM z13s) models in IBM
z/Architecture mode.
Related references
“ARCH” on page 347
VBREF
Use VBREF to get a cross-reference between all statements used in the source program and the line
numbers in which they are used. VBREF also produces a summary of the number of times each statement
was used in the program.
VBREF
VLR
The VLR option affects the file status returned from READ statements for variable-length records when
the length of record returned is inconsistent with the record descriptions. It eases your migration from
422 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
earlier versions to Enterprise COBOL 6, if your programs have READ statements that result in a record
length conflict.
VLR( COMPAT )
FD MYDD
block contains 0 records
record varying in size from 10 to 80
recording mode V.
01 REC-20
02 PIC X(20).
01 REC-50.
02 PIC X(50).
Using VLR(STANDARD) can result in more reliable code and fewer I/O problems because the file status
will tell you when a "wrong length READ" might occur. A new compiler message, MSGIGYP3178, can also
help you avoid I/O problems by telling you if a program has a possibility of a "wrong length READ". This
message can be used to assist with migration from VLR(COMPAT) to VLR(STANDARD) by indicating the
possible "wrong length READ" that you can solve by correcting the File Definition (FD). You can also raise
the severity of the message so that the program must be corrected in order to run. To do this, use the
MSGEXIT suboption of the EXIT compiler option to change the severity of message MSGIGYP3178 from
I (RC=0) to S (RC=12), E (RC=8), or W (RC=4). If you are not interested in seeing this message, you can
suppress the message completely.
Related references
“EXIT” on page 367
Variable length records - wrong length READ
(Enterprise COBOL for z/OS Migration Guide)
VSAMOPENFS
The VSAMOPENFS option affects the user file status reported from successful VSAM OPEN statements that
require verified file integrity check.
VSAMOPENFS( SUCC )
424 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
WORD
Use WORD(xxxx) to specify that an alternate reserved-word table is to be used during compilation.
WORD( xxxx )
Related tasks
“Compiling with the CICS option” on page 499
Related references
“Conflicting compiler options” on page 344
“CICS reserved-word table” on page 502
XMLPARSE
Use XMLPARSE to select the parser to be used for processing XML input, and, therefore, the XML
processing capabilities that are available to your program.
XMLPARSE( COMPAT )
Related tasks
Chapter 37, “Processing XML input,” on page 623
Related references
XML PARSE statement (Enterprise COBOL for z/OS Language Reference)
z/OS XML System Services User's Guide and Reference
XREF
Use XREF to produce a sorted cross-reference listing.
( SHORT )
NOXREF
A section is also included that cross-references COPY or BASIS statements in the program with the data
sets or files from which associated copybooks were obtained.
“Example: XREF output: COPY/BASIS cross-references” on page 485
EBCDIC data-names and procedure-names are listed in alphanumeric order. DBCS data-names and
procedure-names are listed based on their physical order in the program; they are shown before the
EBCDIC data-names and procedure-names unless the DBCSXREF installation option is selected with a
DBCS ordering program. In that case, DBCS data-names and procedure-names are in the order specified
by the DBCS ordering program.
If you use XREF and SOURCE, data-name and procedure-name cross-reference information is printed
on the same line as the original source. Line-number references or other information appears on the
right-hand side of the listing page. On the right of source lines that reference an intrinsic function, the
426 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
letters IFN are printed with the line number of the locations where the function arguments are defined.
Information included in the embedded references lets you know if an identifier is undefined (UND) or
defined more than once (DUP), if items are implicitly defined (IMP) (such as special registers or figurative
constants), or if a program-name is external (EXT).
If you use XREF and NOSOURCE, you get only the sorted cross-reference listing.
XREF(SHORT) prints only the explicitly referenced data items in the cross-reference listing.
XREF(SHORT) applies to DBCS data-names and procedure-names as well as to single-byte names.
NOXREF suppresses this listing.
Usage notes
• Group names used in a MOVE CORRESPONDING statement are in the XREF listing. The elementary
names in those groups are also listed.
• In the data-name XREF listing, line numbers that are preceded by the letter M indicate that the data
item is explicitly modified by a statement on that line.
• XREF listings take additional storage.
• If there is more than one data set in your SYSLIB concatenation, in some cases the COPY/BASIS
cross-reference might be incomplete or missing. This loss can occur if XREF is set only in a CBL or
PROCESS statement, and XREFOPT=NO is set as an installation default or NOXREF is coded in your JCL
PARM parameter.
To ensure that the COPY/BASIS cross-reference is complete, either verify with your system
programmer that XREFOPT=FULL or XREFOPT=SHORT is your installation default, or code the XREF
option in your JCL PARM parameter.
Related concepts
Chapter 21, “Debugging,” on page 443
Related tasks
“Getting listings” on page 453
Related references
Language Environment Debugging Guide (COBOL compiler options)
ZONECHECK
Use the ZONECHECK option to have the compiler generate IF NUMERIC class tests for zoned decimal
data items that are used as sending data items.
Note: ZONECHECK is deprecated but is tolerated for compatibility, and it is replaced by
NUMCHECK(ZON(ALPHNUM)).
ZONECHECK ( MSG )
ABD
ADD A TO B
DIVIDE A INTO B
COMPUTE B = A + B
Related tasks
“Checking for incompatible data (numeric class test)” on page 53
Related references
“NUMCHECK” on page 388
“NUMPROC” on page 392
“ZONEDATA” on page 428
ZONEDATA
The ZONEDATA option tells the compiler whether the data in USAGE DISPLAY and PACKED-DECIMAL
data items is valid, and if not, what the behavior of the compiler should be.
Since most users have valid data in their USAGE DISPLAY and USAGE PACKED-DECIMAL data items,
most users should use ZONEDATA(PFD), even if they use NUMPROC(NOPFD). Even if you find that your
programs are processing invalid data at run time (using the NUMCHECK compiler option), you should
change your programs to avoid processing invalid data, and use ZONEDATA(PFD).
Note: The ZONEDATA option is deprecated but is tolerated for compatibility, and it is replaced by the
INVDATA option.
When the ZONEDATA option is specified, it is mapped to the equivalent INVDATA option as follows:
ZONEDATA(PFD) = NOINVDATA
ZONEDATA(NOPFD) = INVDATA(NOFORCENUMCMP,CLEANSIGN) (or simply INVDATA)
ZONEDATA(MIG) = INVDATA(FORCENUMCMP,CLEANSIGN)
428 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
ZONEDATA option syntax
PFD
ZONEDATA( MIG )
NOPFD
In this example:
• With COBOL 4 (or earlier versions) or earlier versions, the test is true if the NUMPROC(MIG) option is
used, and false for NUMPROC(NOPFD | PFD).
• With COBOL 5 or later versions:
– When using ZONEDATA(PFD), the test is true at OPT(0) and false at OPT(1 | 2).
– When using ZONEDATA(NOPFD), the test is false at any OPT setting.
In all, to ease your migration to COBOL 6:
• If your digits, sign codes, and zone bits are valid, use ZONEDATA(PFD) and the same NUMPROC setting
that you used with COBOL 4 (or earlier versions) when using COBOL 6.
• If you have invalid digits, invalid sign codes, or invalid zone bits in your data, change your programs or
systems so that your programs do not have invalid data in numeric data items at run time.
Once you have corrected your programs or systems, you can use the preferred ZONEDATA(PFD) option.
Only if you cannot contain this work and must continue to run with invalid data, consider the following
choices for ZONEDATA:
– If you used NUMPROC(MIG) with COBOL 4 (or earlier versions) , use ZONEDATA(MIG) and
NUMPROC(NOPFD) with COBOL 6.
– If you used NUMPROC(NOPFD) with COBOL 4 (or earlier versions) , use ZONEDATA(NOPFD) and
NUMPROC(NOPFD) with COBOL 6.
– If you used NUMPROC(PFD) with COBOL 4 (or earlier versions) , use ZONEDATA(NOPFD) and
NUMPROC(PFD) with COBOL 6.
Note: It is not always possible to entirely match the behavior of the old compiler even with these options
when faced with clearly invalid data. For example, even for compares, ZONEDATA(NOPFD) isn't going to
give the same result in all cases as COBOL 4.
Performance considerations: ZONEDATA(PFD) gives better runtime performance than
ZONEDATA(NOPFD | MIG) does. ZONEDATA(NOPFD | MIG) disables some of the optimizations that
NUMPROC(PFD) can give.
Related tasks
“Checking for incompatible data (numeric class test)” on page 53
Related references
“NUMCHECK” on page 388
“NUMPROC” on page 392
“ZONECHECK” on page 427
430 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
ZWB
If you compile using ZWB, the compiler removes the sign from a signed zoned decimal (DISPLAY) field
before comparing this field to an alphanumeric elementary field during execution.
NOZWB
VSAMDYNAMICDIR=ON|OFF Allows you to select the read logic path for VSAM
KSDS/RRDS files that use the Dynamic access
mode. VSAMDYNAMICDIR=OFF is the default.
See “VSAM dynamic access read option
VSAMDYNAMICDIR” on page 434.
DISABLEUOPTREPORT=ON|OFF COBOL Runtime option report is generated by
default if you specify the LE runtime option
RPTOPTS(ON). This report can be turned off with
the use of this option. DISABLEUOPTREPORT=OFF
is the default.
For more details about these options, see Using the Language Environment runtime options in the z/OS
Language Environment Programming Reference.
Related references
"Runtime options that affect runtime performance" in the Performance Tuning Guide
432 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Each runtime option can be specified via a different method. The following tables show how a specific
runtime option can be specified.
Note: The following runtime options are not supported for AMODE 64:
• CBLOPTS
• CBLPSHPOP
• CHECK
• FLOW
• RTEUSE
434 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Building IGZUOPT and IGZQUOPT runtime option control block
The IGZUOPT (for AMODE 31) and IGZQUOPT (for AMODE 64) modules refer to load modules that you
build and provide during COBOL program execution time. These modules are assembler programs that
use the assembler macro IGZXOPT.
The IGZXOPT macro is an assembler macro that is used in an assembler program that must be assembled
and then linked into a load module called either IGZUOPT or IGZQUOPT applications. This load module,
IGZUOPT or IGZQUOPT, must be available in a load module PDS that appears in a STEPLIB DD statement
for your running application. The COBOL runtime searches for this module when needed and based on the
module's settings, sets runtime option control flags. If no such module is found, IBM defaults will prevail.
Important: You should only add this option control block load module into the STEPLIB stream
for applications that are meant to use the specified options. In particular, when you use the
VSAMDYNAMICDIR option, you should be aware of which applications should take advantage of this
feature because it has impact on performance.
Related tasks
“Building IGZUOPT and IGZQUOPT runtime option control block” on page 435
“Suppressing information in CEEDUMP processing (IGZ1OPT)” on page 489
"Requesting QSAM buffers above the line (IGZ3OPT)" in the Migration Guide
"Controlling initialization of QSAM buffer (IGZ4OPT)" in the Migration Guide
“VSAM dynamic access read option VSAMDYNAMICDIR” on page 434
“Disabling COBOL runtime options report option DISABLEUOPTREPORT” on page 434
Examples
The following table has example scenarios for the runtime options:
436 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 58. Examples for AMODE 64 runtime scenarios
Numbers Scenarios Results
Example 3 IGZUOPT module was found. Both COBOL and LE runtime
options reports are generated.
VSAMDYNAMICDIR=ON was
specified.
IN literal-2
TRAILING
COPY INVOICES1Q
COPY "Company-#Employees" IN Personellib
In the IN/OF phrase, library-name is the ddname that identifies the partitioned data set to be copied
from. Use a DD statement such as in the following example to define library-name:
//COPYLIB DD DSNAME=ABC.COB,VOLUME=SER=111111,
// DISP=SHR,UNIT=3380
To specify more than one copy library, use either JCL or a combination of JCL and the IN/OF phrase.
Using just JCL, concatenate data sets in your DD statement for SYSLIB. Alternatively, define multiple
DD statements and include the IN/OF phrase in your COPY statements.
The maximum block size for the copy library depends on the device on which your data set resides.
Compiling in the z/OS UNIX shell:
When you compile using the cob2 command, copybooks are included from the z/OS UNIX file system.
text-name, library-name, and literal-1 and literal-2 are processed as follows:
• User-defined words are folded to uppercase. Literals are not folded. Because UNIX is case sensitive,
if your file-name is lowercase or mixed case, you must specify it as a literal.
• If text-name is a literal and library-name is omitted, text-name is used directly: as a file-name, a
relative path name, or an absolute path name (if the first character is /). For example:
COPY "MyInc"
COPY "x/MyInc"
COPY "/u/user1/MyInc"
• If text-name is a user-defined word, and an environment variable of that name is defined, the value
of the environment variable is used as the name of the file that contains the copybook.
If an environment variable of that name is not defined, the copybook is searched for under the
following names, in this order:
1. text-name.cpy
2. text-name.CPY
3. text-name.cbl
4. text-name.CBL
5. text-name.cob
6. text-name.COB
7. text-name
• If library-name is a literal, it is treated as the actual path, relative or absolute, from which to copy
file text-name.
• If library-name is a user-defined word, it is treated as an environment variable. The value of the
environment variable is used as the path. If the environment variable is not set, an error occurs.
• If both library-name and text-name are specified, the compiler forms the path name for the
copybook by concatenating library-name and text-name with a path separator (/) inserted between
the two values. For example, suppose you have the following setting for COPY MYCOPY OF MYLIB:
export MYCOPY=mystuff/today.cpy
export MYLIB=/u/user1
440 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
These settings result in:
/u/user1/mystuff/today.cpy
If library-name is an environment variable that identifies the path from which copybooks are to be
copied, use an export command to define library-name, as in this example:
export COPYLIB=/u/mystuff/copybooks
The name of the environment variable must be uppercase. To specify more than one copy library, set
the environment variable to multiple path names delimited by colon (:).
If library-name is omitted and text-name is not an absolute path name, the copybook is searched for
in this order:
1. In the current directory
2. In the paths specified on the -I cob2 option
3. In the paths specified in the SYSLIB environment variable
For additional information about the COPY statement, for example, the rules for text replacement, see
the related reference.
DEFINE directive
The DEFINE directive defines or undefines a compilation variable. The compilation variables can
be used within any of the conditional compilation directives (DEFINE, EVALUATE, and IF). The
compilation variable is treated as a symbolic reference to the literal value it currently represents.
DELETE statement
This extended source library statement removes COBOL statements from the BASIS source program.
EJECT statement
This compiler-directing statement specifies that the next source statement is to be printed at the top
of the next page.
ENTER statement
The statement is treated as a comment.
EVALUATE directive
The EVALUATE directive provides a multi-branch method of choosing the source lines to include in a
compilation group.
IF directive
The IF directive provides for a one-way or two-way conditional compilation.
INLINE directive
The INLINE directive lets you selectively prevent the compiler from considering procedures eligible
for inlining.
INSERT statement
This library statement adds COBOL statements to the BASIS source program.
PROCESS (CBL) statement
This statement, which you place before the IDENTIFICATION DIVISION header of an outermost
program, indicates which compiler options are to be used during compilation of the program.
REPLACE statement
This statement is used to replace source program text.
SERVICE LABEL statement
This statement is generated by the CICS translator to indicate control flow, and should be used at the
resume point for a call to CEE3SRP. It is not intended for general use.
SKIP1/2/3 statement
These statements indicate lines to be skipped in the source listing.
Related tasks
“Changing the header of a source listing” on page 5
“Specifying compiler options under z/OS” on page 273
“Specifying compiler options under z/OS UNIX” on page 284
“Setting environment variables under z/OS UNIX” on page 283
“Eliminating repetitive coding” on page 786
Related references
“cob2 syntax and options” on page 287
CALLINTERFACE (Enterprise COBOL for z/OS Language Reference)
DEFINE (Enterprise COBOL for z/OS Language Reference)
EVALUATE (Enterprise COBOL for z/OS Language Reference)
IF (Enterprise COBOL for z/OS Language Reference)
INLINE (Enterprise COBOL for z/OS Language Reference)
COPY statement (Enterprise COBOL for z/OS Language Reference)
442 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Chapter 21. Debugging
You can choose between two different approaches to determine the cause of problems in the behavior of
your application: source-language debugging or interactive debugging.
For source-language debugging, COBOL provides several language elements, compiler options, and listing
outputs that make debugging easier.
If the problem with your program is not easily detected and you do not have a debugger available, you
might need to analyze a storage dump of your program.
For interactive debugging, you can use z/OS Debugger. z/OS Debugger offers these productivity
enhancements:
• Interactive debugging (in full-screen or line mode), or debugging in batch mode
During an interactive full-screen mode session, you can use the full-screen services and session panel
windows on a 3270 device to debug your program while it is running.
• COBOL-like commands
For each high-level language supported, commands for coding actions to be taken at breakpoints are
provided in a syntax similar to that programming language.
• Mixed-language debugging
You can debug an application that contains programs written in a different language. z/OS Debugger
automatically determines the language of the program or subprogram being run.
• COBOL-CICS debugging
z/OS Debugger supports the debugging of CICS applications in both interactive and batch mode.
• Support for remote debugging
You can used the Eclipse-based debug interface and IBM Z Open Debug to debug programs that run on
z/OS.
Note: IBM z/OS Debugger is a common component that is provided in the following products:
• IBM Debug for z/OS, previously known as IBM Debug Tool for z/OS
• IBM Developer for z/OS, previously known as IBM Developer for z Systems and Rational Developer for z
Systems
• IBM Developer for z/OS (Enterprise Edition), which is also provided with the IBM Application Delivery
Foundation for z/OS bundle
• IBM Z and Cloud Modernization Stack
The debug features provided in different products vary. For more information, see Overview of IBM z/OS
Debugger.
Depending on the level of Enterprise COBOL that you are using to create the COBOL application, update
your debugger to a certain version:
• z/OS Debugger 15.0.5 and later supports Enterprise COBOL 6.4 and earlier versions
• z/OS Debugger 14.2 and later supports Enterprise COBOL 6.3 and earlier versions
• z/OS Debugger 14.1 supports Enterprise COBOL 6.2 and earlier versions
• z/OS Debugger 14.0 supports Enterprise COBOL 6.1 and earlier versions
• Debug Tool 13.1 supports Enterprise COBOL 5.1 and earlier versions
Related tasks
“Debugging with source language” on page 444
“Debugging using compiler options” on page 447
“Using the debugger” on page 453
Related references
IBM z/OS Debugger Reference and Messages
Language Environment Debugging Guide (Formatting and analyzing system
dumps, Debugging example COBOL programs)
Related tasks
“Tracing program logic” on page 444
“Finding and handling input-output errors” on page 445
“Validating data” on page 445
“Moving, initializing or setting uninitialized data” on page 445
“Generating information about procedures” on page 446
Related references
Source language debugging (Enterprise COBOL for z/OS Language Reference)
After you are sure that the routine works correctly, disable the DISPLAY statements in one of two ways:
• Put an asterisk in column 7 of each DISPLAY statement line to convert it to a comment line.
• Put a D in column 7 of each DISPLAY statement to convert it to a comment line. When you want
to reactivate these statements, include a WITH DEBUGGING MODE clause in the ENVIRONMENT
DIVISION; the D in column 7 is ignored and the DISPLAY statements are implemented.
444 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Before you put the program into production, delete or disable the debugging aids you used and recompile
the program. The program will run more efficiently and use less storage.
Related concepts
“Scope terminators” on page 20
Related references
DISPLAY statement (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Coding ERROR declaratives” on page 246
“Using file status keys” on page 247
Related references
File status key (Enterprise COBOL for z/OS Language Reference)
Validating data
If you suspect that your program is trying to perform arithmetic on nonnumeric data or is receiving the
wrong type of data on an input record, use the class test (the class condition) to validate the type of data.
You can use the class test to check whether the content of a data item is ALPHABETIC, ALPHABETIC-
LOWER, ALPHABETIC-UPPER, DBCS, KANJI, or NUMERIC. If the data item is described implicitly or
explicitly as USAGE NATIONAL, the class test checks the national character representation of the
characters associated with the specified character class.
You can use the UVALID intrinsic function to check whether a national data item contains valid UTF-16
encoded data, or whether an alphanumeric or alphabetic item contains valid UTF-8 encoded data.
Related tasks
“Coding conditional expressions” on page 95
“Testing for valid DBCS characters” on page 159
Related references
Class condition (Enterprise COBOL for z/OS Language Reference)
UVALID (Enterprise COBOL for z/OS Language Reference)
Related references
INITIALIZE statement (Enterprise COBOL for z/OS Language Reference)
SET statement (Enterprise COBOL for z/OS Language Reference)
“INITCHECK” on page 373
Related references
SOURCE-COMPUTER paragraph (Enterprise COBOL for z/OS Language Reference)
Debugging lines (Enterprise COBOL for z/OS Language Reference)
Debugging sections (Enterprise COBOL for z/OS Language Reference)
DEBUGGING declarative (Enterprise COBOL for z/OS Language Reference)
446 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Environment Division.
. . .
Data Division.
. . .
Working-Storage Section.
. . . (other entries your program needs)
01 Trace-Msg PIC X(30) Value " Trace for Procedure-Name : ".
01 Total PIC 9(9) Value 1.
. . .
Procedure Division.
Declaratives.
Debug-Declaratives Section.
Use For Debugging On Some-Routine.
Debug-Declaratives-Paragraph.
Display Trace-Msg, Debug-Name, Total.
End Declaratives.
Main-Program Section.
. . . (source program statements)
Perform Some-Routine.
. . . (source program statements)
Stop Run.
Some-Routine.
. . . (whatever statements you need in this paragraph)
Add 1 To Total.
Some-Routine-End.
The DISPLAY statement in the DECLARATIVES SECTION issues this message every time the procedure
Some-Routine runs:
The number at the end of the message, 22, is the value accumulated in the data item Total; it indicates
the number of times Some-Routine has run. The statements in the debugging declarative are performed
before the named procedure runs.
You can also use the DISPLAY statement to trace program execution and show the flow through the
program. You do this by dropping Total from the DISPLAY statement and changing the USE FOR
DEBUGGING declarative in the DECLARATIVES SECTION to:
As a result, a message is displayed before each nondebugging procedure in the outermost program runs.
Related tasks
“Finding coding errors” on page 448
“Finding line sequence problems” on page 448
“Checking for invalid COBOL data or invalid COBOL programs” on page 449
“Checking for valid ranges” on page 449
“Selecting the level of
error to be diagnosed” on page 450
“Finding program entity definitions and references” on page 452
“Listing data items” on page 452
“Getting listings” on page 453
Related references
“COBOL compiler options” on page 339
Checking syntax only: To only check the syntax of your program, and not produce object code, use
NOCOMPILE without a suboption. If you also specify the SOURCE option, the compiler produces a listing.
When you specify NOCOMPILE, several compiler options are suppressed. See the related reference below
about the COMPILE option for details.
Compiling conditionally: To compile conditionally, use NOCOMPILE(x), where x is one of the severity
levels of errors. Your program is compiled if all the errors are of a lower severity than x. The severity levels
that you can use, from highest to lowest, are S (severe), E (error), and W (warning).
If an error of level x or higher occurs, the compilation stops and your program is only checked for syntax.
Related references
“COMPILE” on page 355
Related references
“SEQUENCE” on page 405
448 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Checking for invalid COBOL data or invalid COBOL programs
Use INITCHECK and NUMCHECK to determine if your programs process invalid COBOL data at run time.
Use PARMCHECK to determine if your programs have mismatched parameters at run time that causes the
corruption of data beyond the end of WORKING-STORAGE.
The INITCHECK option checks for uninitialized data items and issue warning messages when they are
used without being initialized.
The NUMCHECK option validates the following data items when they are used as sending data items:
• NUMCHECK(ZON) causes the compiler to generate code for an implicit numeric class test for zoned
decimal (numeric USAGE DISPLAY) data items that are used as sending data items in COBOL
statements.
• NUMCHECK(PAC) causes the compiler to generate code for an implicit numeric class test for packed
decimal (COMP-3) data items that are used as sending data items in COBOL statements.
• NUMCHECK(BIN) causes the compiler to generate code similar to ON SIZE ERROR to test if binary data
items contents are bigger than the PICTURE clause. Note that this extra code will be generated only for
binary data items that are used as sending data items, and COMP-5 data items will not get this ON SIZE
ERROR code generated.
The PARMCHECK option finds subprograms that write beyond the end of WORKING-STORAGE. This option
tells the compiler to generate an extra data item following the last item in WORKING-STORAGE that is
then used at run time to check whether a called subprogram corrupted data beyond the end of WORKING-
STORAGE.
Performance consideration: PARMCHECK and NUMCHECK can somewhat degrade performance because
of the extra overhead to check for invalid COBOL data. PARMCHECK will cause the compiler to generate
slower code for programs with CALL statements. NUMCHECK is updated to remove redundant checks
for invalid data, thus improving runtime performance. However, performance is still the best when using
NONUMCHECK, and will be better at OPT(1) and OPT(2) than at OPT(0).
Related references
“INITCHECK” on page 373
“NUMCHECK” on page 388
“PARMCHECK” on page 397
“Performance-related compiler options” on page 778
Related references
“SSRANGE” on page 411
“Performance-related compiler options” on page 778
When you specify the second parameter, each syntax-error message (except a U-level message) is
embedded in the source listing at the point where the compiler had enough information to detect that
error. All embedded messages (except those issued by the library compiler phase) directly follow the
statement to which they refer. The number of the statement that had the error is also included with the
message. Embedded messages are repeated with the rest of the diagnostic messages at the end of the
source listing.
Note: You can suppress some error messages and change the severity of others with the MSGEXIT
suboption of the EXIT option.
When you specify the NOSOURCE compiler option, the syntax-error messages are included only at the end
of the listing. Messages for unrecoverable errors are not embedded in the source listing, because an error
of this severity terminates the compilation.
“Example: embedded messages” on page 451
Related tasks
“Generating a list of compiler
messages” on page 281
Related references
“Severity codes for
compiler diagnostic messages” on page 282
“Messages and listings
for compiler-detected errors” on page 281
“FLAG” on page 369
450 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Example: embedded messages
The following example shows the embedded messages generated by specifying a second parameter to
the FLAG option. Some messages in the summary apply to more than one COBOL statement.
Related tasks
“Getting listings” on page 453
Related references
“XREF” on page 426
*CONTROL NOMAP
01 A
02 B
*CONTROL MAP
Related tasks
“Getting listings” on page 453
452 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Related references
“MAP” on page 384
Related tasks
IBM z/OS Debugger User's Guide (Preparing your program for debugging)
Related references
“TEST” on page 414
Getting listings
Get the information that you need for debugging by requesting the appropriate compiler listing with the
use of compiler options.
Attention: The listings produced by the compiler are not a programming interface and are subject to
change.
To aid in testing and Source listing Copy of your source “SOURCE” on page 407
debugging your program;
to have a record after
the program has been
debugged
To find where a name Sorted cross-reference Data-names, procedure- “XREF” on page 4262,3
is defined, referenced, or listing of names; sorted names, and program-
modified; to determine cross-reference listing of names; references to
the context (such as COPY/BASIS statements these names
whether a statement was and copybook data sets or
COPY/BASIS text-names
used in a PERFORM block) files
and library names, and
in which a procedure is
the data sets or files
referenced; to determine
from which associated
the data set or file from
copybooks were obtained
which a copybook was
obtained Embedded modified
cross-reference provides
line numbers where data-
names and procedure-
names were defined
To find the failing PROCEDURE DIVISION Generated code “LIST” on page 3822,4
statement in a program code and assembler
or the address in storage code produced by the
of a data item that is compiler3
moved while the program
is running
To verify you still have a Condensed PROCEDURE Condensed statement “OFFSET” on page 393
valid logic path after you DIVISION listing listing, global tables,
move or add PROCEDURE WORKING-STORAGE
DIVISION sections information, and literals
To find an instance of a Alphabetic listing of Each statement used, “VBREF” on page 422
certain statement statements number of times each
statement was used, line
numbers where each
statement was used
454 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 60. Using compiler options to get listings (continued)
Use Listing Contents Compiler option
1. To eliminate messages, turn off the options (such as FLAG) that govern the level of compile diagnostic
information. You can also selectively suppress messages by using the MSGEXIT suboption of the EXIT
compiler option.
2. To use your line numbers in the compiled program, use the NUMBER compiler option. The compiler checks
the sequence of your source statement line numbers in columns 1 through 6 as the statements are read in.
When it finds a line number out of sequence, the compiler assigns to it a number with a value one higher
than the line number of the preceding statement. The new value is flagged with two asterisks. A diagnostic
message indicating an out-of-sequence error is included in the compilation listing.
3. The context of the procedure reference is indicated by the characters preceding the line number.
4. You can control the listing of generated object code by selectively placing *CONTROL LIST and *CONTROL
NOLIST (or equivalently, *CBL LIST and *CBL NOLIST) statements in your source. Note that the
*CONTROL statement is different than the PROCESS (or CBL) statement.
The output is generated if:
• You specify the COMPILE option (or the NOCOMPILE(x) option is in effect and an error level x or higher
does not occur).
• You do not specify the OFFSET option. OFFSET and LIST are mutually exclusive options with OFFSET
taking precedence.
Related tasks
“Generating a list of compiler
messages” on page 281
“Reading LIST output” on page 464
Language Environment Debugging Guide (Debugging COBOL programs)
Related references
“Messages and listings
for compiler-detected errors” on page 281
IGYSC3002-I A severe error was found in the program. The "OPTIMIZE" and the "STGOPT" compiler
options were cancelled.
160 IGYDS1089-S "ASSIGNN" was invalid. Scanning was resumed at the next area "A" item, level-number,
456 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
or the start of the next clause.
192 IGYDS1050-E File "LOCATION-FILE" contained no data record descriptions. The file definition was
discarded.
192 IGYGR1207-S The "ASSIGN" clause was missing or invalid in the "SELECT" entry for file "LOCATION-
FILE".
The file definition was discarded.
888 IGYPS2052-S An error was found in the definition of file "LOCATION-FILE". The reference to this
file
was discarded.
1000 IGYPS2121-S "WS-DATE" was not defined as a data-name. The statement was discarded.
1004 IGYPS2053-S An error was found in the definition of file "LOCATION-FILE". This input/output
statement
was discarded.
1015 IGYPS2121-S "LOC-CODE" was not defined as a data-name. The statement was discarded.
1212 IGYPS2121-S "WS-NUMERIC-DATE" was not defined as a data-name. The statement was discarded.
1655 IGYPG3113-W Truncation of high-order digit positions may occur due to precision of intermediate
results
exceeding 30 digits.
Messages Total Informational Warning Error Severe Terminating (6)
Printed: 13 1 1 1 10
* Statistics for COBOL program IGYTCARA: (7)
* Source records = 1755
* Data Division statements = 295
* Procedure Division statements = 479
* Generated COBOL statements = 0
* Program complexity factor = 486
End of compilation 1, program IGYTCARA, highest severity 12. (8)
Return code 12
(1)
Message about options passed to the compiler at compiler invocation. This message does not appear
if no options were passed.
OPTFILE
Requests options from a SYSOPTF data set.
(2)
Options coded in the PROCESS (or CBL) statement.
NOOFFSET
Suppresses a condensed listing of the PROCEDURE DIVISION.
NOMAP
Suppresses a map report of the items defined in the DATA DIVISION.
(3)
Options obtained from the SYSOPTF data set (because the OPTFILE compiler option was specified).
NOLIST
Suppresses an assembler-language expansion of the source code.
TEST
The program was compiled for use with debugging and problem determination tools (such as
Debug Tool and Fault Analyzer) and to get local variables listed in CEEDUMP.
(4)
Status of options at the start of this compilation.
(5)
Program diagnostics. The first message refers you to any library phase diagnostics. Diagnostics for the
library phase are presented at the beginning of the listing.
(6)
Count of diagnostic messages in this program, grouped by severity level.
(1)
LineID PL SL ----+-*A-1-B--+----2----+----3----+----4----+----5----+----6----+----7-|--+----8 Map and Cross Reference
(2) (3) (4)
000870 /****************************************************************
000871 *** D O M A I N L O G I C **
000872 *** **
000873 *** Initialization. Read and process update transactions until **
000874 *** EOE. Close files and stop run. **
000875 *****************************************************************
000876 procedure division.
000877 000-do-main-logic.
000878 display "PROGRAM IGYTCARA - Beginning".
000879 perform 050-create-vsam-main-file. 930
000880 perform 100-initialize-paragraph. 982
000881 read update-transaction-file into ws-transaction-record 203 338
000882 at end
000883 1 IA4390 set transaction-eof to true 253
000884 end-read.
000885 IA4410 perform until transaction-eof 253
000886 1 perform 200-edit-update-transaction 1050
000887 1 IA4430 if no-errors 372
000888 2 perform 300-update-commuter-record 1159
000889 1 else
000890 2 perform 400-print-transaction-errors 1312
000891 1 end-if
000892 1 perform 410-re-initialize-fields 1373
000893 1 IA4480 read update-transaction-file into ws-transaction-record 203 338
000894 1 at end
000895 2 IA4500 set transaction-eof to true 253
000896 1 IA4510 end-read
000897 IA4520 end-perform.
000898 close commuter-file update-transaction-file location-file 180 203 192
000899 print-file. 216
000900
000901 *----------------------------------------------------*
000902 * File status checked after I/O operation. *
000903 *----------------------------------------------------*
000904
000905 IA4600 if not i-o-okay 241
000906 1 display "000-close"
000907 1 move 0000 to comp-code 230
000908 1 IA4620 perform 500-vsam-error 1386
000909 1 perform 900-abnormal-termination 1432
000910 IA4630 end-if.
000911 *********************************************************
000912 * Paragraphs 1100 and 1200 illustrates the intrinsic *
000913 * function computations. *
000914 *********************************************************
000915 perform 1100-print-i-f-headings. 1441
000916 perform 1200-print-i-f-data. 1481
000917 display " ".
000918 display " ".
000919 display "PROGRAM IGYTCARA - Normal end".
000920 stop run.
(1)
Scale line, which labels Area A, Area B, and source-code column numbers
(2)
Source-code line number assigned by the compiler
(3)
Program (PL) and statement (SL) nesting level
(4)
Columns 1 through 6 of program (the sequence number area)
458 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Example: MAP output
The following example shows output from the MAP option. The numbers used in the explanation below
correspond to the numbers that annotate the output.
Example 1
The following example shows the MAP output when SOURCE(DEC) is in effect.
(1)
Data Definition Attribute codes (rightmost column) have the following meanings:
D = Object of OCCURS DEPENDING G = GLOBAL S = Spanned file
E = EXTERNAL O = Has OCCURS clause U = Undefined format file
F = Fixed-length file OG= Group has own length definition V = Variable-length file
FB= Fixed-length blocked file R = REDEFINES VB= Variable-length blocked file
X = Unallocated
(2) (3) (4) (5) (6) (7) (8) (9)
Source Hierarchy and Base Displacement Asmblr Data Data Def
LineID Data Name Locator Structure Definition Data Type Attributes
4 PROGRAM-ID IGYTCARA----------------------------------------------------------------------------------------------------*
58 FD COMMUTER-FILE . . . . . . . . . . . . . . . . BLF=00001 VSAM F
60 1 COMMUTER-RECORD . . . . . . . . . . . . . . . BLF=00001 DS 0CL80 Group
61 2 COMMUTER-KEY. . . . . . . . . . . . . . . . BLF=00001 000000000 DS 16C Display
62 2 FILLER. . . . . . . . . . . . . . . . . . . BLF=00001 000000016 DS 64C Display
64 FD COMMUTER-FILE-MST . . . . . . . . . . . . . . BLF=00002 VSAM F
66 1 COMMUTER-RECORD-MST . . . . . . . . . . . . . BLF=00002 DS 0CL80 Group
67 2 COMMUTER-KEY-MST. . . . . . . . . . . . . . BLF=00002 000000000 DS 16C Display
68 2 FILLER. . . . . . . . . . . . . . . . . . . BLF=00002 000000016 DS 64C Display
140 1 STATUS-AREA . . . . . . . . . . . . . . . . . DS 0CL8 Group
141 2 COMMUTER-FILE-STATUS. . . . . . . . . . . . 000000000 DS 2C Display
142 88 I-O-OKAY. . . . . . . . . . . . . . . . . .
143 2 COMMUTER-VSAM-STATUS. . . . . . . . . . . . 000000002 DS 0CL6 Group
144 3 VSAM-R15-RETURN-CODE. . . . . . . . . . . 000000002 DS 2C Binary
145 3 VSAM-FUNCTION-CODE. . . . . . . . . . . . 000000004 DS 2C Binary
146 3 VSAM-FEEDBACK-CODE. . . . . . . . . . . . 000000006 DS 2C Binary
148 77 UPDATE-FILE-STATUS. . . . . . . . . . . . . . DS 2C Display
149 77 LOCCODE-FILE-STATUS . . . . . . . . . . . . . DS 2C Display
150 77 UPDPRINT-FILE-STATUS. . . . . . . . . . . . . DS 2C Display
152 1 FLAGS . . . . . . . . . . . . . . . . . . . . DS 0CL3 Group
153 2 TRANSACTION-EOF-FLAG. . . . . . . . . . . . 000000000 DS 1C Display
154 88 TRANSACTION-EOF . . . . . . . . . . . . . .
155 2 LOCATION-EOF-FLAG . . . . . . . . . . . . . 000000001 DS 1C Display
156 88 LOCATION-EOF. . . . . . . . . . . . . . . .
157 2 TRANSACTION-MATCH-FLAG. . . . . . . . . . . 000000002 DS 1C Display
158 88 TRANSACTION-MATCH . . . . . . . . . . . . .
159 88 TRANSACTION-MATCH-OFF . . . . . . . . . . .
216 1 WS-COMMUTER-RECORD. . . . . . . . . . . . . . BLX=00001 DS 0CL81 Group E
217 2 WS-COMMUTER-KEY . . . . . . . . . . . . . . BLX=00001 000000000 DS 0CL16 Group E
218 3 WS-COMMUTER-GENERIC-KEY . . . . . . . . . BLX=00001 000000000 DS 0CL5 Group E
219 4 COMMUTER-SHIFT. . . . . . . . . . . . . BLX=00001 000000000 DS 1C Display E
220 4 COMMUTER-HOME-CODE. . . . . . . . . . . BLX=00001 000000001 DS 2C Display E
221 4 COMMUTER-WORK-CODE. . . . . . . . . . . BLX=00001 000000003 DS 2C Display E
222 3 COMMUTER-NAME . . . . . . . . . . . . . . BLX=00001 000000005 DS 9C Display E
223 3 COMMUTER-INITIALS . . . . . . . . . . . . BLX=00001 000000014 DS 2C Display E
224 2 COMMUTER-ADDRESS. . . . . . . . . . . . . . BLX=00001 000000016 DS 18C Display E
225 2 COMMUTER-CITY . . . . . . . . . . . . . . . BLX=00001 000000034 DS 13C Display E
226 2 COMMUTER-STATE. . . . . . . . . . . . . . . BLX=00001 000000047 DS 2C Display E
227 2 COMMUTER-ZIPCODE. . . . . . . . . . . . . . BLX=00001 000000049 DS 3P Packed-Dec E
396 1 DETAIL1-LINE. . . . . . . . . . . . . . . . . BLL=00001 DS 0CL121 Group
397 2 FILLER. . . . . . . . . . . . . . . . . . . BLL=00001 000000000 DS 2C Display
398 2 PRINT-TRANSACTION-CODE. . . . . . . . . . . BLL=00001 000000002 DS 1C Display
399 2 FILLER. . . . . . . . . . . . . . . . . . . BLL=00001 000000003 DS 4C Display
400 2 PRINT-RECORD-TYPE . . . . . . . . . . . . . BLL=00001 000000007 DS 3C Display
401 2 FILLER. . . . . . . . . . . . . . . . . . . BLL=00001 000000010 DS 3C Display
402 2 PRINT-SHIFT . . . . . . . . . . . . . . . . BLL=00001 000000013 DS 1C Display
403 2 FILLER. . . . . . . . . . . . . . . . . . . BLL=00001 000000014 DS 1C Display
404 2 PRINT-HOME-CODE . . . . . . . . . . . . . . BLL=00001 000000015 DS 2C Display
405 2 FILLER. . . . . . . . . . . . . . . . . . . BLL=00001 000000017 DS 1C Display
406 2 PRINT-WORK-CODE . . . . . . . . . . . . . . BLL=00001 000000018 DS 2C Display
407 2 FILLER. . . . . . . . . . . . . . . . . . . BLL=00001 000000020 DS 2C Display
408 2 PRINT-NAME. . . . . . . . . . . . . . . . . BLL=00001 000000022 DS 9C Display
454 1 DETAILX-LINE. . . . . . . . . . . . . . . . . BLL=XXXXX DS 0CL121 Group X
455 2 FILLER. . . . . . . . . . . . . . . . . . . BLL=XXXXX DS 36C Display X
456 2 PRINT-CITY. . . . . . . . . . . . . . . . . BLL=XXXXX DS 13C Display X
457 2 FILLER. . . . . . . . . . . . . . . . . . . BLL=XXXXX DS 3C Display X
458 2 PRINT-STATE . . . . . . . . . . . . . . . . BLL=XXXXX DS 2C Display X
459 2 FILLER. . . . . . . . . . . . . . . . . . . BLL=XXXXX DS 1C Display X
460 2 PRINT-ZIPCODE . . . . . . . . . . . . . . . BLL=XXXXX DS 5C Display X
461 2 FILLER. . . . . . . . . . . . . . . . . . . BLL=XXXXX DS 1C Display X
462 2 PRINT-WORK-PHONE. . . . . . . . . . . . . . BLL=XXXXX DS 14C Display X
463 2 FILLER. . . . . . . . . . . . . . . . . . . BLL=XXXXX DS 1C Display X
464 2 PRINT-WORK-JUNCTION . . . . . . . . . . . . BLL=XXXXX DS 25C Display X
465 2 FILLER. . . . . . . . . . . . . . . . . . . BLL=XXXXX DS 20C Display X (10)
467 1 DETAIL2-LINE. . . . . . . . . . . . . . . . . BLL=00002 DS 0CL121 Group
468 2 FILLER. . . . . . . . . . . . . . . . . . . BLL=00002 000000000 DS 36C Display
469 2 PRINT-CITY. . . . . . . . . . . . . . . . . BLL=00002 000000036 DS 13C Display
470 2 FILLER. . . . . . . . . . . . . . . . . . . BLL=00002 000000049 DS 3C Display
471 2 PRINT-STATE . . . . . . . . . . . . . . . . BLL=00002 000000052 DS 2C Display
472 2 FILLER. . . . . . . . . . . . . . . . . . . BLL=00002 000000054 DS 1C Display
473 2 PRINT-ZIPCODE . . . . . . . . . . . . . . . BLL=00002 000000055 DS 5C Display
474 2 FILLER. . . . . . . . . . . . . . . . . . . BLL=00002 000000060 DS 1C Display
475 2 PRINT-WORK-PHONE. . . . . . . . . . . . . . BLL=00002 000000061 DS 14C Display
476 2 FILLER. . . . . . . . . . . . . . . . . . . BLL=00002 000000075 DS 1C Display
477 2 PRINT-WORK-JUNCTION . . . . . . . . . . . . BLL=00002 000000076 DS 25C Display
478 2 FILLER. . . . . . . . . . . . . . . . . . . BLL=00002 000000101 DS 20C Display
(1)
Data Definition Attribute codes (rightmost column) have the following meanings:
D = Object of OCCURS DEPENDING G = GLOBAL S = Spanned file
E = EXTERNAL O = Has OCCURS clause U = Undefined format file
F = Fixed-length file OG= Group has own length definition V = Variable-length file
FB= Fixed-length blocked file R = REDEFINES VB= Variable-length blocked file
X = Unallocated
(2) (3) (4) (5) (6) (7) (8) (9)
Source Hierarchy and Base Displacement Asmblr Data Data Def
LineID Data Name Locator Structure Definition Data Type Attributes
4 PROGRAM-ID MSGXIT----------------------------------------------------------------------------------------------------
*
F 1 EC. . . . . . . . . . . . . . . . . . . . . . 000000000 DS 2P Packed-Dec
10 1 JUNK. . . . . . . . . . . . . . . . . . . . . 000000000 DS 2C Display
(1)
Explanations of the data definition attribute codes.
(2)
Source line number where the data item was defined .
(3)
Level definition or number. The compiler generates this number in the following way:
• First level of any hierarchy is always 01. Increase 1 for each level (any item you coded as level 02
through 49).
• Level-numbers 66, 77, and 88, and the indicators FD and SD, are not changed.
(4)
Data-name that is used in the source module in source order.
(5)
Base locator used for this data item.
(6)
Hexadecimal displacement from the beginning of the containing structure if the MAP(HEX) option is in
effect. If the MAP(DEC) option is in effect, decimal displacement is shown.
(7)
Pseudoassembler code showing how the data is defined. When a structure contains variable-length
fields, the maximum length of the structure is shown.
(8)
Data type and usage.
(9)
Data definition attribute codes. The definitions are explained at the top of the DATA DIVISION map.
(10)
DETAILX-LINE was not referenced in the PROCEDURE DIVISION. Because STGOPT was specified,
DETAILX-LINE was deleted, resulting in the base locator being set to XXXXX.
Related references
“Terms used in MAP output” on page 462
“Symbols used in LIST and MAP output” on page 463
460 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Example: embedded map summary
The following example shows an embedded map summary from specifying the MAP option. The summary
appears in the right margin of the listing for lines in the DATA DIVISION that contain data declarations.
(1)
Base locator used for this data item
(2)
Decimal displacement from the beginning of the containing structure. It indicates that the MAP(DEC)
option is in effect. If you specified the MAP(HEX) option or MAP with no suboption, hexadecimal
displacement is shown.
(3)
Pseudoassembler code showing how the data is defined
462 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 61. Terms used in MAP output (continued)
Term Definition Description
POINTER DS nC Pointer data item (USAGE POINTER)
PROCEDURE-PTR DS nC Procedure pointer (USAGE PROCEDURE-POINTER)
SD Sort file definition
VSAM, QSAM, File processing method
LINESEQ
1-49, 77 Level-numbers for data descriptions
66 Level-number for RENAMES
88 Level-number for condition-names
1. n is the size in bytes for fixed-length groups and the maximum size in bytes for variable-length groups.
2. If the SYNCHRONIZED clause appears, these fields are used.
1. n is the number of the entry. For base locators, it can also be XXXXX, indicating a data item that was deleted
by STGOPT processing.
(1)
Explanations of the program attribute codes
(2)
Source line number where the program was defined
(3)
Depth of program nesting
(4)
Program-name
(5)
Program attribute codes
464 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
• An assembler listing of the initialization code for the program (program signature information bytes)
from which you can verify program characteristics such as:
– Compiler options in effect
– Types of data items present
– Statements used in the PROCEDURE DIVISION
• An assembler listing of the source code for the program
From the address in storage of the instruction that was executing when an abend occurred, you can
find the COBOL statement that corresponds to that instruction. After you find the address of the failing
instruction, go to the assembler listing and find the statement for which that instruction was generated.
The line number is in the 3rd column of the assembler listing for your program. Using the line number,
you can locate the STATEMENT by looking at the corresponding line in the Source Output section of the
listing.
• Information about WORKING-STORAGE. This information is contained in the Data Division Map and
in the Initial Heap Storage Map.
• A description of the storage is found in the Initial Heap Storage Map. The symbols in
WORKING-STORAGE area of the source are mapped into the storage that is shown in the Initial
Heap Storage Map.
You can use the Data Division Map along with the Initial Heap Storage Map section to find
the location of data items defined in WORKING-STORAGE. These data items reside in the storage . The
Initial Heap Storage Map gives the offset of each level-1 data item relative to the beginning of
the storage. The Data Division Map section gives the offset of the level-n data items relative to
their respective level-1 member. By using both pieces of information, you can determine the offset of
any data member within the storage.
If you compile with the DATA24 option, data items mapped below the line will appear in the Below the
Line Storage. You can follow the same process to determine their locations.
• Information about the constants and the literals used in the program. The Constant Area contains
information about the constants and literals in the program, as well as those created by the compiler.
This section contains the offset of each constant or literal within the Constant Area.
• Program prolog areas (PPA1, PPA2, PPA3, PPA4) contain information about the characteristics of the
compiled program.
• Externals symbols dictionary contains the list of external symbols defined by or referred to, in your
program.
• Map of the dynamic save area (DSA)
The map of the DSA (also known as the stack frame) contains information about the contents of the
storage acquired each time a separately compiled procedure is entered.
You do not need to be able to program in assembler language to understand the LIST output. The
comments that accompany most of the assembler code provide you with a conceptual understanding of
the functions performed by the code.
The INFO BYTE section of the listing also provides the following values:
• The number of DATA DIVISION statements
• The number of PROCEDURE DIVISION statements
In the following table, different signature bytes represent different information:
• Signature bytes 1-5, and 26-35 refer to compiler options
• Signature bytes 6-7 refer to DATA DIVISION items
• Signature byte 8 refers to ENVIRONMENT DIVISION items
• Signature bytes 9-25 refer to PROCEDURE DIVISION statements and items
466 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 64. Signature information bytes
Offset Signatur Bit Item
in e byte
On Off
decim
al
04 28 0 SQL NOSQL
1 CICS NOCICS
2 MDECK NOMDECK
3 SQLCCSID NOSQLCCSID
4 OPTFILE NOOPTFILE
5 XMLPARSE(XMLSS) XMLPARSE(COMPAT)
6 BLOCK0 NOBLOCK0
7 DISPSIGN(SEP) DISPSIGN(COMPAT)
05 29 0 Program uses Java-based OO syntax
1 Program uses RANDOM function
2 Program uses NATIONAL data (Unicode)
3 XML PARSE with schema validation
4 STGOPT NOSTGOPT
5 AFP(VOLATILE) AFP(NOVOLATILE)
6 HGPR(PRESERVE) HGPR(NOPRESERVE)
7 NOTEST(DWARF) Not NOTEST(DWARF)
06 30 0 QUALIFY(EXTEND) QUALIFY(COMPAT)
1 VLR(COMPAT) VLR(STANDARD)
2 COPYRIGHT string specified COPYRIGHT string not specified
3 SERVICE string specified SERVICE string not specified
4 INVDATA(FNC,x) Not INVDATA(FNC,x)
Note: When bits 4 and 5 are both off,
NOINVDATA is in effect.
468 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 64. Signature information bytes (continued)
Offset Signatur Bit Item
in e byte
On Off
decim
al
10 3 0 NUMPROC(PFD) NUMPROC(NOPFD)
1 RENT NORENT
2 RESIDENT (always on)
3 SEQUENCE NOSEQUENCE
4 Reserved
5 SOURCE NOSOURCE
6 Not NOSSRANGE NOSSRANGE
7 TERM NOTERM
11 4 0 TEST NOTEST
1 TRUNC(STD) Not TRUNC(STD)
2 WORD NOWORD
3 VBREF NOVBREF
4 XREF NOXREF
5 ZWB NOZWB
6 NAME NONAME
7 NOCMPR2 (always off)
12 5 0 Reserved
1 NUMCLS=ALT NUMCLS=PRIM
2 DBCS NODBCS
3 AWO NOAWO
4 TRUNC(BIN) Not TRUNC(BIN)
5 ADATA NOADATA
6 CURRENCY NOCURRENCY
7 Compilation unit is a class Compilation unit is a program
13 6 0 QSAM file descriptor
1 VSAM sequential file descriptor
2 VSAM indexed file descriptor
3 VSAM relative file descriptor
4 CODE-SET clause (ASCII files) in file descriptor
5 Spanned records
6 PIC G or PIC N (DBCS data item)
7 OCCURS DEPENDING ON clause in data description entry
0=NUMCHECK(BIN(TRUNCBIN))
16 9 0 ACCEPT
1 ADD
2 ALTER
3 CALL
4 CANCEL
6 CLOSE
17 10 0 COMPUTE
2 DELETE
4 DISPLAY
5 DIVIDE
470 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 64. Signature information bytes (continued)
Offset Signatur Bit Item
in e byte
On Off
decim
al
18 11 1 END-PERFORM
2 ENTER
3 ENTRY
4 EXIT
5 EXEC
6 GO TO
7 IF
19 12 0 INITIALIZE
1 INVOKE
2 INSPECT
3 MERGE
4 MOVE
5 MULTIPLY
6 OPEN
7 PERFORM
20 13 0 READ
2 RELEASE
3 RETURN
4 REWRITE
5 SEARCH
7 SET
21 14 0 SORT
1 START
2 STOP
3 STRING
4 SUBTRACT
7 UNSTRING
472 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 64. Signature information bytes (continued)
Offset Signatur Bit Item
in e byte
On Off
decim
al
27 20 0-7 Reserved
28 21 0 Hexadecimal literal
1 Altered GO TO
2 I-O ERROR declarative
3 DECIMAL-POINT IS COMMA clause
4 DEBUGGING declarative
5 Program segmentation
6 OPEN . . . EXTEND
7 EXIT PROGRAM
29 22 0 CALL literal
1 CALL identifier
2 CALL . . . ON OVERFLOW
3 CALL . . . LENGTH OF
4 CALL . . . ADDRESS OF
5 CLOSE . . . REEL/UNIT
6 Exponentiation used
7 Floating-point items used
30 23 0 COPY
1 BASIS
2 DBCS name in program
3 Shift-out and Shift-in in program
4 SUPPRESS|NOSUPPRESS
5 SSRANGE(ZLEN) (if bit 6 in byte 3 is on) SSRANGE(NOZLEN) (if bit 6 in byte 3 is
on)
6 SSRANGE(ABD) (if bit 6 in byte 3 is on) SSRANGE(MSG) (if bit 6 in byte 3 is on)
7 INLINE|NOINLINE
474 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 64. Signature information bytes (continued)
Offset Signatur Bit Item
in e byte
On Off
decim
al
52 32 0 LP(64) LP(32)
1 Reserved
2 SOURCE(HEX) SOURCE(DEC)
3 SMARTBIN NOSMARTBIN
4 Compilation unit is a function. Compilation unit is not a function.
5 Reserved
6 Program contains at least one JAVA- Program does not contain a JAVA-
SHAREABLE directive. SHAREABLE directive.
7 Program contains one or more calls to Program does not contain a call to Java
Java using a CALL statement. using a CALL statement.
53 33 0 JAVAIOP(JAVA64) JAVAIOP(NOJAVA64)
1-7 Reserved
54 34 0-7 Reserved
55 35 0-7 TUNE architecture level
Check return code: A return code greater than 4 from the compiler could mean that some of the
statements shown in the information bytes might have been discarded from the program.
Related references
“LIST” on page 382
z/OS Language Environment Vendor Interfaces (COBOL-specific vendor interfaces)
(1)
Offset from the start of the COBOL program
(2)
Hexadecimal representation of assembler instructions
(3)
Source line number
(4)
Pseudo-assembler representation of the code generated for the COBOL program
(5)
Comments that explain the pseudo-assembler code
Related references
“Signature information bytes” on page 466
Note: The MD5 signature is shown only if the TEST option is specified or if -g is specified with cob2 under
z/OS UNIX.
The presence or absence of the MD5 signature is indicated by a compilation flag bit of the PPA2. If the
bit is set to 1, the MD5 signature is present; if the bit is set to 0, the MD5 signature is absent. For details
about PPA2, see z/OS Language Environment Vendor Interfaces.
Related references
“Example: Program prolog areas” on page 478
476 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Timestamp and Version End
DATA VALIDATION AND UPDATE PROGRAM IGYTCARA Date 05/31/2022 Time 10:48:16
0029DC 0030 =X'0030' Size of Compiler Options and Prog Info Section
0029DE (+00) 0474 =X'0474' UNSIGNED BINARY CODE PAGE CCSID VALUE
0029E0 (+02) 06 =X'06' ARCHITECTURE LEVEL
0029E1 (+03) 00 =X'00' OPTIMIZATION LEVEL
0029E2 (+04) 1406 =X'1406' INFO. BYTES 28-29
0029E4 (+06) 0000 =X'0000' RESERVED
0029E6 (+08) A04875CC2001 =X'A04875CC2001' INFO. BYTES 1-6
0029EC (+14) 100010884909 =X'100010884909' INFO. BYTES 7-12
0029F2 (+20) 002008800C00 =X'002008800C00' INFO. BYTES 13-18
0029F8 (+26) 000001A000 =X'000001A000' INFO. BYTES 19-23
0029FD (+31) 00 =X'00' COBOL SIGNATURE LEVEL
0029FE (+32) 0000002F =X'0000002F' # DATA DIVISION STATEMENTS
002A02 (+36) 0000005B =X'0000005B' # PROCEDURE DIVISION STATEMENTS
002A06 (+40) 18808008 =X'18808008' INFO. BYTES 24-27
002A0A (+44) E2F1F6F0F1F1F540 =C'PXXXXXX' BUILD LEVEL INFO
(1)
Offset in the program object
(2)
Offset in decimal
(3)
Contents of the bytes in hexadecimal format
(4)
Assembler representation of the bytes
(5)
Explanation of the bytes in the section
(1)
Source code interspersed with the pseudo-assembler instructions
(2)
Relative location of the object code instruction in the module, in hexadecimal notation
Related references
“Symbols used in LIST and MAP output” on page 463
DATA VALIDATION AND UPDATE PROGRAM IGYTCARA Date 05/31/2022 Time 10:48:16
There is one PPA2 for each program. The offset to the PPA2 is recorded in each PPA1. The PPA2 contains
offsets to the Timestamp and Version Information section of the listing as well as to the PPA4
section.
If the TEST option is not in effect, the PPA2 section looks like this:
PPA2: Entry Point Constants
000800 04002203 =F'67117571' Flags
000804 FFFFF800 =A(CEESTART-PPA2)
000808 00000058 =F'88' A(PPA4-PPA2)
00080C FFFFFFB0 =A(TIMESTMP-PPA2)
000810 FFFFF800 =A(PrimaryEntryPoint-PPA2)
000814 02200000 =F'35651584' Flags
PPA2 End
If the TEST option is in effect, the PPA2 section looks like this:
PPA2: Entry Point Constants
000830 04002203 =F'67117571' Flags
000834 FFFFF7D0 =A(CEESTART-PPA2)
000838 00000058 =F'88' A(PPA4-PPA2)
00083C FFFFFFB0 =A(TIMESTMP-PPA2)
000840 FFFFF7D0 =A(PrimaryEntryPoint-PPA2)
000844 02600000 =F'39845888' Flags
PPA2 End
478 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
There is one PPA3 for each program (including each nested program) in a COBOL source file. Each entry
contains offsets, relative to the PPA3 itself, to the base locator table and to the special register table. The
PPA3 also contains an offset from the start of the program to the first COBOL statement.
There is one PPA4 for each program. It has offsets to various compiler generated tables, such as the
storage (the Initial Heap Storage Map and Below The Line Storage Map sections). The offset
to the PPA4 is recorded in a field of the PPA2.
(1)
Relative location, in hexadecimal format, of the PPA field in the object module
(2)
The contents of the field, in hexadecimal
(3)
An assembler-like syntax defining the field
(4)
A description of the contents of the field.
Related references
WORKING-STORAGE SECTION changes
(Enterprise COBOL for z/OS Migration Guide)
z/OS Language Environment Vendor Interfaces
* * * * * I N I T I A L H E A P S T O R A G E M A P * * * * *
0 4 BLL_Ptrs
4 C BLT_Ptrs
10 60 GPCB
70 4 WS-BASE-ADDRESS
74 8 TS2=6
If the RENT and DATA(31) compiler options are in effect, the WORKING-STORAGE data items are shown
under the WORKING-STORAGE MAP. If the RENT and DATA(24) options are in effect, the WORKING-
STORAGE data items are shown under the BELOW THE LINE STORAGE MAP. An INITIAL HEAP
STORAGE MAP section is also shown where compiler generated internal data items and locators are
mapped.
* * * * * B E L O W T H E L I N E S T O R A G E M A P * * * * *
0 4 JNIENVPTR
8 2 RETURN-CODE
10 2 SORT-RETURN
18 8 SORT-CONTROL
20 4 SORT-CORE-SIZE
28 4 SORT-FILE-SIZE
30 4 SORT-MODE-SIZE
38 8 SORT-MESSAGE
40 4 TALLY
48 1 SHIFT-OUT
50 1 SHIFT-IN
58 4 XML-CODE
60 1E XML-EVENT
80 4 XML-INFORMATION
88 50 COMMUTER-FILE
D8 50 COMMUTER-FILE-MST
128 7A PRINT-FILE
1A8 1 WORKING-STORAGE-FOR-IGYCARA
1B0 2 COMP-CODE
1B8 3 WS-TYPE
1C0 2 I-F-STATUS-AREA
1C8 8 STATUS-AREA
1D0 2 UPDATE-FILE-STATUS
CONSTANT AREA:
(1) (2) (3) (4)
006A98 (+0) 00CCDDFF 00000000 C9C7E8E3 C3C1D9C1 00000000 00000000 C9C7E9E2 D9E3C3C4
|........IGYTCARA........IGZSRTCD|
006AB8 (+32) 40000A00 40000000 00000008 00000000 E2E8E2D6 E4E34040 00100000 00000000
| ... ...........SYSOUT ........|
006AD8 (+64) 0E000000 00000001 0F000000 0000001E 00000000 40000000 00000003 0064003C
|.................... ...........|
006AF8 (+96) 000FE800 9F0F0000 00000011 00000000 E3D9C1D5 E2C1C3E3 4B40C3D6 C4C50000 |..Y.............TRANSACT.
CODE..|
006B18 (+128) 0000000E 00000000 E2C8C9C6 E340C3D6 C4C54040 40400000 C8D6D4C5 40D3D6C3 |........SHIFT CODE ..HOME
LOC|
006B38 (+160) 4B40C3D6 C4C50000 E6D6D9D2 40D3D6C3 4B40C3D6 C4C50000 D3C1E2E3 40D5C1D4 |. CODE..WORK LOC. CODE..LAST
NAM|
006B58 (+192) C5404040 40400000 C9D5C9E3 C9C1D3E2 40404040 40400000 C4E4D7D3 C9C3C1E3 |
E ..INITIALS ..DUPLICAT|
006B78 (+224) C540D9C5 C34B0000 D9C5C34B 40D5D6E3 40C6D6E4 D5C40000 C1C4C4D9 C5E2E240 |E REC...REC. NOT
FOUND..ADDRESS |
006B98 (+256) 40404040 40400000 C3C9E3E8 40404040 40404040 40400000 E2E3C1E3 C540C3D6 | ..CITY ..STATE
CO|
006BB8 (+288) C4C54040 40400000 E9C9D7C3 D6C4C540 40404040 40400000 C8D6D4C5 40D7C8D6 |DE ..ZIPCODE ..HOME
PHO|
006BD8 (+320) D5C54040 40400000 E6D6D9D2 40D7C8D6 D5C54040 40400000 C8D6D4C5 40D1E4D5 |NE ..WORK PHONE ..HOME
JUN|
006BF8 (+352) C3E3C9D6 D5400000 E6D6D9D2 40D1E4D5 C3E3C9D6 D5400000 C4D9C9E5 C9D5C740 |CTION ..WORK
JUNCTION ..DRIVING |
006C18 (+384) E2E3C1E3 E4E20000 40D9C5D7 D6D9E340 407B7A40 C9C7E8E3 C3C1D9C1 40404040 |STATUS.. REPORT #:
IGYTCARA |
006C38 (+416) 40404040 40404040 40404040 40404040 40404040 40404040 40404000 00000033
480 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
| .....|
006C58 (+448) C3D6D4D4 E4E3C5D9 40C6C9D3 C540E4D7 C4C1E3C5 40D3C9E2 E3404040 40404040 |COMMUTER FILE UPDATE
LIST |
006C78 (+480) 40404040 40404040 40404040 40404040 40400000 00000032 40404040 40404040
| ...... |
006C98 (+512) D7C1C7C5 407B7A40 00000000 00000010 40D7D9D6 C7D9C1D4 407B7A40 C9C7E8E3 |PAGE #: ........ PROGRAM #:
IGYT|
006CB8 (+544) C3C1D9C1 40404040 404040D9 E4D540E3 C9D4C57A 40000000 00000025 7A000000 |CARA RUN
TIME: .......:...|
006CD8 (+576) 00000030 00000000 D9E4D540 C4C1E3C5 7A400000 0000000A 61000000 0000000B |........RUN
DATE: ....../.......|
(1)
Offset in csect.
(2)
Offset in base 10.
(3)
8 columns containing the bytes in the Constant Area
(4)
Character representation. A dot (.) is used for non-printable characters.
For more information about the base locator table, see z/OS Language Environment Vendor Interfaces.
Related references
z/OS Language Environment Vendor Interfaces (Base locator table)
Each entry in the special register table consists of the following items:
• A byte which represents the following information:
– Special register ID number (bits 0 - 4). ID = 1 represents the RETURN-CODE register
– Access mode (bits 5 - 8)
- MODE = 0; Base Address = Top of Stack
- MODE = 1; Base Addr = NORENT Static
E X T E R N A L S Y M B O L D I C T I O N A R Y
* * * * * S T A C K S T O R A G E M A P * * * * *
1 2 3
OFFSET (HEX) LENGTH (HEX) NAME
80 4 _@CAA
C8 3 _BEtemp200
CC 3 _BEtemp204
D0 3 _BEtemp208
D4 3 _BEtemp212
482 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
D8 3 _BEtemp216
DC 3 _BEtemp220
E0 3 _BEtemp224
E4 3 _BEtemp228
E8 10 _BEtemp232
F8 20 _BEtemp248
118 20 _BEtemp280
138 4 _BEtemp312
13C 4 _BEtemp316
140 4 _BEtemp320
144 4 _BEtemp324
148 4 _BEtemp328
14C 4 _BEtemp332
150 4 _BEtemp336
154 4 _BEtemp340
158 4 _BEtemp344
15C 4 _BEtemp348
160 4 _BEtemp352
164 4 _BEtemp356
168 4 _BEtemp360
16C 4 _BEtemp364
170 4 _BEtemp368
174 4 _BEtemp372
178 4 _BEtemp376
(1)
Hexadecimal offset of the DSA field from the start of the DSA
(2)
Length (in hexidecimal) of the DSA field
(3)
Symbol name
Example 1
The following example shows the XREF output when SOURCE(DEC) is in effect.
265 ABEND-ITEM1
266 ABEND-ITEM2
347 ADD-CODE . . . . . . . . . . . 1102 1162
381 ADDRESS-ERROR. . . . . . . . . M1126
280 AREA-CODE. . . . . . . . . . . 1236 1261 1324 1345
382 CITY-ERROR . . . . . . . . . . M1129
1C A. . . . . . . . . . . . . . . 1D
39 A. . . . . . . . . . . . . . . 3A
38 AG
(4)
Context usage is indicated by the letter preceding a procedure-name
reference. These letters and their meanings are:
A = ALTER (procedure-name)
D = GO TO (procedure-name) DEPENDING ON
E = End of range of (PERFORM) through (procedure-name)
G = GO TO (procedure-name)
P = PERFORM (procedure-name)
T = (ALTER) TO PROCEED TO (procedure-name)
U = USE FOR DEBUGGING (procedure-name)
877 000-DO-MAIN-LOGIC
930 050-CREATE-STL-MAIN-FILE . . P879
982 100-INITIALIZE-PARAGRAPH . . . P880
Example 2
The following example shows the XREF output when SOURCE(HEX) is in effect.
1C A. . . . . . . . . . . . . . . 1D
39 A. . . . . . . . . . . . . . . 3A
38 AG
Cross-reference of data-names:
(1)
Line number where the name was defined.
(2)
Data-name.
(3)
Line numbers where the name was used. If M precedes the line number, the data item was explicitly
modified at the location.
Cross-reference of procedure references:
(4)
Explanations of the context usage codes for procedure references.
(5)
Line number where the procedure-name is defined.
(6)
Procedure-name.
(7)
Line numbers where the procedure is referenced, and the context usage code for the procedure.
484 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Defined Cross-reference of programs References
EXTERNAL EXTERNAL1. . . . . . . . . . . 25
2 X. . . . . . . . . . . . . . . 41
12 X1 . . . . . . . . . . . . . . 33 7
20 X11. . . . . . . . . . . . . . 25 16
27 X12. . . . . . . . . . . . . . 32 17
35 X2 . . . . . . . . . . . . . . 40 8
(1)
Line number where the program-name was defined. If the program is external, the word EXTERNAL is
displayed instead of a definition line number.
(2)
Program-name.
(3)
Line numbers where the program is referenced.
(1)
Text-name and library (an abbreviation for library-name) are from the statement COPY text-name
OF library-name in the source, for example, Copy ACTIONS Of OTHERLIB.
(2)
The name of the data set from which the COPY member was copied.
(3)
Abbreviation for concatenation level. Indicates how many levels deep a given data set is from the first
data set in the concatenation for a given ddname.
For example, four data sets in the example above are concatenated to ddname SYSLIB:
SYSLIB DD DSN=USERID.COBOL.COPY, 0
DD DSN=USERID.COBOL.LIB2PDSE, 1
DD DSN=USERID.COBOL.LIB3, 2
DD DSN=USERID.COBOL.LIB4X 3
Thus for example member NSMAP shown in the listing above was found in data set
USERID.COBOL.LIB3, which is two levels down from the first data set in the SYSLIB concatenation.
(4)
Creation date is shown if the PDSE was edited with STATS ON in ISPF.
Note: Some names were truncated. > = truncated on right < = truncated on left
(5)
From the COPY statement in the source; for example the COPY statement corresponding to the third
item in the cross-reference above would be:
(6)
The fully qualified path of the file from which the COPY member was copied
(7)
Truncation of a long text-name or library-name on the right is marked by a greater-than sign (>).
(8)
Truncation of a long file name on the left is marked by a less-than sign (<).
Related references
“XREF” on page 426
486 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
000993 i-o commuter-file 181
000994 output print-file 217
. . .
001442 1100-print-i-f-headings.
001443
001444 open output print-file. 217
001445
001446 move function when-compiled to when-comp. IFN 698 (2)
001447 move when-comp (5:2) to compile-month. 698 640
001448 move when-comp (7:2) to compile-day. 698 642
001449 move when-comp (3:2) to compile-year. 698 644
001450
001451 move function current-date (5:2) to current-month. IFN 649
001452 move function current-date (7:2) to current-day. IFN 651
001453 move function current-date (3:2) to current-year. IFN 653
001454
001455 write print-record from i-f-header-line-1 222 635
001456 after new-page. 138
. . .
(1)
Line number of the definition of the data-name or procedure-name in the program
(2)
Special definition symbols:
UND
The user name is undefined.
DUP
The user name is defined more than once.
IMP
Implicitly defined name, such as special registers and figurative constants.
IFN
Intrinsic function reference.
EXT
External reference.
*
The program-name is unresolved because the NOCOMPILE option is in effect.
DATA VALIDATION AND UPDATE PROGRAM IGYTCARA Date 05/31/2022 Time 10:48:16
. . .
(1) (2) (3)
LINEID HEXLOC VERBCODE LINEID HEXLOC VERBCODE LINEID HEXLOC VERBCODE
000011 0001B8 DISPLAY 000012 0001CC PERFORM 000021 0001D0 IF
000022 0001E2 MOVE 000024 0001EA MOVE 000012 000204 PERFORM
000013 000214 DISPLAY 000014 000228 PERFORM 000021 00022C IF
000022 00023E MOVE 000024 000246 MOVE 000014 00024A PERFORM
000015 00025A DISPLAY 000021 000272 IF 000022 000284 MOVE
000024 00028C MOVE 000016 000290 PERFORM 000017 0002A0 DISPLAY
000018 0002B8 STOP
(1)
Line number. Your line numbers or compiler-generated line numbers are listed.
(2)
Offset, from the start of the program, of the code generated for this verb (in hexadecimal notation).
The verbs are listed in the order in which they occur and are listed every time an instruction is
generated for a different line/statement pair than the previous instruction.
(3)
Statement used.
Related references
“OFFSET” on page 393
(1)
Number of times the statement is used in the program
(2)
statement
(3)
Line numbers where the statement is used
Example 1
This example shows the default conditional compilation output. The note numbers in the listing
correspond to numbered explanations that follow the listing.
488 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
000007 MainProgram.
000008 >>define var as 12
000009 >>evaluate var
000010 >>when 10
000011 * display 'var is 10' (1)
000012 >>when 11 thru 13
000013 display 'var is 11, 12 or 13' (2)
000014 >>when other
000015 * display 'invalid value' (1)
000016 >>end-evaluate
000017 goback.
000018 end program prog.
(1)
Those branches of the EVALUATE directive were false at compile time, so the code in those branches
was omitted from the resultant program.
(2)
That branch of the EVALUATE directive evaluated to true at compile time, so the code in that branch
was included in the resultant program.
Example 2
This example shows the conditional compilation output when CONDCOMP(SKIPSRC) is in effect. Notice
that the false branches labeled with (1) in the previous example are omitted.
LineID PL SL ----+-A-1-B--+----2----+----3----+----4----+----5----+----6----+----7-|--+----8
Map and Cross Reference
Related references
EVALUATE directive (Enterprise COBOL for z/OS Language Reference)
Conditional compilation (Enterprise COBOL for z/OS Language Reference)
Related references
“TEST” on page 414
//IGZPROUT DD SYSOUT=*
or
//IGZPROUT DD DSN=dynamic.call.report.dsname,DISP=SHR
or
//IGZPROUT DD DSN=dynamic.call.report.dsname,
// UNIT=SYSDA,SPACE=(TRK,(5,10),RLSE),
490 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
// DCB=(DSORG=PS,LRECL=80,RECFM=FB,BLKSIZE=0),
// DISP=(NEW,CATLG,DELETE)
+++++++++++++ BEG OF COBOL 5 AND LATER RELEASES PROGRAM REPORT V02 +++++++++++++
================================================================================
= COBOL ACTIVE PROGRAMS =
================================================================================
ID NAME VERSION DATE/TIME COMPILED SERVICE
------ -------- ------- ------------------- ----------
000001 PROG1 060400 2024/03/20 10:56:40
000002 PROG2 060200 2024/03/20 10:56:40 SERVICE 1
000003 PROG3 060400 2024/03/20 10:56:42 *SERVICE ST
000004 *PROG4LON 060300 2024/03/20 10:56:42
000005 *PROG5THI 060400 2024/03/20 10:56:42 *LONG SERVI
M000006 PROG8 060200 2024/03/20 10:56:42
================================================================================
= CANCELLED PROGRAMS =
================================================================================
ID NAME VERSION DATE/TIME COMPILED SERVICE
------ -------- ------- ------------------- ----------
000007 PROG6 060300 2024/03/20 10:56:40
000008 PROG9 060400 2024/03/20 10:56:40 *SERVICE ST
================================================================================
= LONG PROGRAM NAME LIST =
================================================================================
ID PROGRAM NAME
------ ----------------------------------------------------------------------
000004 PROG4LONGPROGRAMNAME1
000005 PROG5THISISALONGPROGRAMNAMETHISISALONGPROGRAMNAMETHISISALONGPROGRAMNAM
ETHISISALONGPROGRAMNAMETHISISALONGPROGRAMNAMETHISISALONGPROGRAMNAMETHI
SISALONGPROGRAMNAMET
================================================================================
= LONG SERVICE STRING LIST =
================================================================================
ID SERVICE STRING
------ ----------------------------------------------------------------
000003 SERVICE STRING LONG 1
000005 LONG SERVICE STRING CAN HAVE A MAXIMUM LENGTH OF 64 CHARACTERS!
000008 SERVICE STRING LONG 2
Note: For dynamic calls, the program-name in the PROGRAM-ID paragraph or ENTRY statement must
be identical to the corresponding program object name or program object alias of the program object
that contains the program. If the PROGRAM-ID paragraph or the ENTRY statement is not identical to the
corresponding program object (PDSE member) name or program object alias of the program object that
contains the program, then the report will list the program-name in the PROGRAM-ID paragraph or the
ENTRY statement, as opposed to listing the program object (PDSE member) name or the program object
alias name.
Related references
“Making dynamic calls” on page 548
COBOL programs that are written for CICS can run under CICS Transaction Server. CICS COBOL
application programs that use CICS services must use the CICS command-level interface.
When you use the CICS compiler option, the Enterprise COBOL compiler handles both native COBOL
statements and embedded CICS statements in the source program. You can still use the separate CICS
translator to translate CICS statements to COBOL code, but use of the integrated CICS translator is
recommended instead.
After you compile and bind your program, you need to do some other steps such as updating CICS tables
before you can run the COBOL program under CICS. However, these CICS topics are beyond the scope of
COBOL information. For further information, see the Related tasks.
You can determine how runtime errors are handled by setting the CBLPSHPOP runtime option. For
information about CICS HANDLE and CBLPSHPOP, see the Related tasks.
Related concepts
“Integrated CICS translator” on page 500
Related tasks
“Coding COBOL programs to run under CICS” on page 495
“Compiling with the CICS option” on page 499
“Using the separate CICS translator” on page 501
“Handling errors by using CICS HANDLE” on page 503
Language Environment Programming Guide (Condition handling under CICS:
using the CBLPSHPOP runtime option)
Developing CICS Applications
Related references
“CICS” on page 352
CICS commands have the basic format shown above. Within EXEC commands, use the space as a word
separator; do not use a comma or a semicolon. Do not code COBOL statements within EXEC CICS
commands.
Restriction: You cannot run COBOL programs that have object-oriented syntax for Java interoperability in
CICS. In addition, if you write programs to run under CICS, do not use the following code:
• FILE-CONTROL entry in the ENVIRONMENT DIVISION, unless the FILE-CONTROL entry is used for a
SORT statement
• FILE SECTION of the DATA DIVISION, unless the FILE SECTION is used for a SORT statement
• User-specified parameters to the main program
• USE declaratives (except USE FOR DEBUGGING)
• These COBOL language statements:
– ACCEPT format 1: data transfer (you can use format-2 ACCEPT to retrieve the system date and time)
– CLOSE
Related concepts
“Integrated CICS translator” on page 500
Related tasks
“Sorting under CICS” on page 238
“Getting the system date under CICS” on page 497
“Calling to or from COBOL programs” on page 497
“Determining the success of ECI calls” on page 498
“Using the separate CICS translator” on page 501
Related references
“CICS SORT application
restrictions” on page 238
“DISPSIGN” on page 362
496 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Getting the system date under CICS
To retrieve the system date in a CICS program, use a format-2 ACCEPT statement or the CURRENT-DATE
intrinsic function.
You can use any of these format-2 ACCEPT statements in CICS to get the system date:
• ACCEPT identifier-2 FROM DATE (two-digit year)
• ACCEPT identifier-2 FROM DATE YYYYMMDD
• ACCEPT identifier-2 FROM DAY (two-digit year)
• ACCEPT identifier-2 FROM DAY YYYYDDD
• ACCEPT identifier-2 FROM DAY-OF-WEEK (one-digit integer, where 1 represents Monday)
You can use this format-2 ACCEPT statement in CICS to get the system time:
• ACCEPT identifier-2 FROM TIME
Alternatively, you can use the CURRENT-DATE intrinsic function, which can also provide the time.
These methods work in both CICS and non-CICS environments.
Do not use a format-1 ACCEPT statement in a CICS program.
Related tasks
“Assigning input from a screen or file (ACCEPT)” on page 35
Related references
CURRENT-DATE (Enterprise COBOL for z/OS Language Reference)
Nested programs:
When you compile with the integrated CICS translator, the translator generates the DFHEIBLK and
DFHCOMMAREA control blocks with the GLOBAL clause in the outermost program. Therefore if you code
nested programs, you do not have to pass these control blocks as arguments on calls to the nested
programs.
If you code nested programs and you plan to use the separate CICS translator, pass DFHEIBLK and
DFHCOMMAREA as parameters to the nested programs that contain EXEC commands or references to the
EXEC interface block (EIB). You must pass the same parameters also to any program that forms part of
the control hierarchy between such a program and its top-level program.
For detailed information and examples on calling COBOL programs under CICS, see Calling subprograms
from COBOL programs in Developing CICS Applications.
Related concepts
“Integrated CICS translator” on page 500
Related tasks
“Using the separate CICS translator” on page 501
“Choosing the DYNAM or NODYNAM compiler option” on page 515
“Handling errors when calling programs” on page 251
ILC under CICS (Language Environment Writing Interlanguage Communication Applications)
The external CICS interface (CICS Transaction Server for z/OS External Interfaces Guide)
Related references
“DYNAM” on page 366
Related tasks
Using EXCI with CICS
498 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Compiling with the CICS option
Use the CICS compiler option to enable the integrated CICS translator and to specify CICS suboptions.
If you specify the NOCICS option, the compiler diagnoses and discards any CICS statements that it finds
in your source program. If you have already used the separate CICS translator, you must use NOCICS.
You can specify the CICS option in any of the compiler option sources: compiler invocation, PROCESS or
CBL statements, or installation default. If the CICS option is the COBOL installation default, you cannot
specify CICS suboptions. However, making the CICS option the installation default is not recommended,
because the changes that are made by the integrated CICS translator are not appropriate for non-CICS
applications.
All CBL or PROCESS statements must precede any comment lines, in accordance with the rules for
Enterprise COBOL.
The COBOL compiler passes to the integrated CICS translator the CICS suboption string that you provide
in the CICS compiler option. The compiler does not analyze the suboption string.
When you use the integrated CICS translator, you must compile with the following options:
Table 66. Compiler options required for the integrated CICS translator
Compiler option Comment
CICS If you specify DYNAM or NORENT, the compiler forces NODYNAM and RENT
on.
NODYNAM Must be in effect with CICS
RENT Must be in effect with CICS
In addition, IBM recommends that you use the compiler option WORD(CICS) to cause the compiler to flag
language elements that are not supported under CICS.
To compile your program with the integrated CICS translator, you can use the standard JCL procedural
statements that are supplied with COBOL. In addition to specifying the above compiler options, you must
change your JCL in two ways:
• Specify the STEPLIB override for the COBOL step.
• Add the data set that contains the integrated CICS translator services, unless these services are in the
linklist.
The default name of the data set for CICS Transaction Server 6.1 is CICSTS61.CICS.SDFHLOAD, but
your installation might have changed the name. For example, you might have the following line in your
JCL:
//STEPLIB DD DSN=CICSTS61.CICS.SDFHLOAD,DISP=SHR
The COBOL compiler listing includes the error diagnostics (such as syntax errors in the CICS statements)
that the integrated CICS translator generates. The listing reflects the input source; it does not include the
COBOL statements that the integrated CICS translator generates.
Compiling a sequence of programs: When you use the CICS option to compile a source file that contains
a sequence of COBOL programs, the order of precedence of the options from highest to lowest is:
• Options that are specified in the CBL or PROCESS card that initiates the unit of compilation
• Options that are specified when the compiler is started
• CICS default options
Related concepts
“Integrated CICS translator” on page 500
Related references
“CICS” on page 352
“Conflicting compiler options” on page 344
During compilation, the compiler passes the following CICS suboption string to the integrated CICS
translator:
The concatenated strings are delimited with single spaces and with a pair of quotation marks (" ") or a
pair of apostrophes (' ') around the group. When the compiler finds multiple instances of the same CICS
suboption, the last specification of the suboption in the concatenated string takes effect. The compiler
limits the length of the concatenated CICS suboption string to 4 KB.
Related references
“CICS” on page 352
500 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
as arguments on calls to nested programs or specify them in the USING phrase of the PROCEDURE
DIVISION header of nested programs.
• You can keep nested programs that contain EXEC CICS statements in separate files, and include those
nested programs by using COPY statements.
• REPLACE statements can affect EXEC CICS statements.
• You can compile programs that contain CICS statements in a batch compilation (compilation of a
sequence of programs).
• Because the compiler generates binary fields in CICS control blocks with format COMP-5 instead of
BINARY, there is no dependency on the setting of the TRUNC compiler option. You can use any setting of
the TRUNC option in CICS programs, subject only to the requirements of the application logic and use of
user-defined binary fields.
Note: The CICS documentation states that the EXCI translator option is not supported for programs
compiled with the integrated CICS translator, but CICS has reversed this position. You can now compile
with the EXCI translator option and ignore the warning message DFH7006I.
Related concepts
Developing CICS Applications (The integrated CICS translator)
Related tasks
“Coding COBOL programs to run under CICS” on page 495
“Compiling with the CICS option” on page 499
Related references
“CICS” on page 352
“TRUNC” on page 419
CBL RENT,NODYNAM,
You can suppress the insertion of a CBL statement by using the CICS translator option NOCBLCARD.
After you use the separate CICS translator, use the following compiler options when you compile the
program:
Table 67. Compiler options required for the separate CICS translator
Required compiler option Condition
RENT
NODYNAM The program is translated by the CICS translator.
In addition, IBM recommends that you use the compiler option WORD(CICS) to cause the compiler to flag
language elements that are not supported under CICS.
The following TRUNC compiler option recommendations are based on expected values for binary data
items:
For example, if you use the separate CICS translator and have a data item defined as PIC S9(8)
BINARY that might receive a value greater than eight digits, use the TRUNC(BIN) compiler option, change
the item to USAGE COMP-5, or change the PICTURE clause.
You might also want to avoid using these options, which have no effect:
• ADV
• FASTSRT
• OUTDD
The input data set for the compiler is the data set that you received as a result of translation, which is
SYSPUNCH by default.
Related concepts
“Integrated CICS translator” on page 500
Related tasks
“Compiling with the CICS option” on page 499
502 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
• SD1, 2
• SELF
• START
• SUPER
• WRITE
Notes:
1. If you intend to use the SORT statement under CICS (COBOL supports an interface for the SORT
statement under CICS), you must change the CICS reserved-word table to remove the words from the
list of words marked as restricted.
2. The SORT keyword is not restricted, but the SD keyword is. This allows you to use the format 2 (table)
sort statement but not the format 1 (file) sort statement.
3. If you restrict the DELETE keyword, you may still use the DELETE function of BASIS processing.
Related tasks
“Compiling with the CICS option” on page 499
“Sorting under CICS” on page 238
Related references
“WORD” on page 425
Related tasks
“Running efficiently with CICS, IMS, or VSAM” on page 783
***********************************************************
* Program A *
***********************************************************
ID DIVISION.
PROGRAM-ID. A.
. . .
PROCEDURE DIVISION.
EXEC CICS HANDLE CONDITION
ERROR(ERR-1)
END-EXEC.
CALL 'B' USING DFHEIBLK DFHCOMMAREA.
CALL 'A1'.
. . .
THE-END.
EXEC CICS RETURN END-EXEC.
ERR-1.
. . .
* Nested program A1.
ID DIVISION.
PROGRAM-ID. A1.
PROCEDURE DIVISION.
EXEC CICS READ (3)
FILE('LEDGER')
INTO(RECORD)
RIDFLD(ACCTNO)
END-EXEC.
END PROGRAM A1.
END PROGRAM A.
*
***********************************************************
* Program B *
***********************************************************
ID DIVISION.
PROGRAM-ID. B.
. . .
PROCEDURE DIVISION.
EXEC CICS READ (1) (2)
FILE('MAINFILE')
INTO(RECORD)
RIDFLD(ACCTNO)
END-EXEC.
. . .
END PROGRAM B.
504 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Chapter 23. Programming for a Db2 environment
In general, the coding for a COBOL program will be the same if you want the program to access a Db2
database. However, to retrieve, update, insert, and delete Db2 data and use other Db2 services, you must
use SQL statements.
To communicate with Db2, do these steps:
• Code any SQL statements that you need, delimiting them with EXEC SQL and END-EXEC statements.
• Either use the Db2 stand-alone precompiler, or compile with the SQL compiler option and use the Db2
coprocessor.
Related concepts
“Db2 coprocessor” on page 505
“COBOL and Db2 CCSID
determination” on page 510
Related tasks
“Using the separate Db2 precompiler” on page 506
“Coding SQL statements” on page 506
“Compiling with the SQL option” on page 509
“Choosing the DYNAM or NODYNAM compiler option” on page 515
Related references
“Differences in how the Db2
precompiler and coprocessor behave” on page 513
Db2 coprocessor
When you use the Db2 coprocessor (called SQL statement coprocessor by Db2), the compiler handles
your source programs that contain embedded SQL statements without your having to use a separate
precompile step.
To use the Db2 coprocessor, specify the SQL compiler option.
When the compiler encounters SQL statements in the source program, it interfaces with the Db2
coprocessor. All text between EXEC SQL and END-EXEC statements is passed to the coprocessor. The
coprocessor takes appropriate actions for the SQL statements and indicates to the compiler which native
COBOL statements to generate for them.
Although the use of a separate precompile step continues to be supported, it is recommended that you
use the coprocessor instead:
• Interactive debugging with Debug Tool is enhanced when you use the coprocessor because you see the
SQL statements (not the generated COBOL source) in the listing.
• The COBOL compiler listing includes the error diagnostics (such as syntax errors in the SQL statements)
that the Db2 coprocessor generates.
• Certain restrictions on the use of COBOL language that apply when you use the precompile step do not
apply when you use the Db2 coprocessor. With the coprocessor:
– You can use SQL statements in any nested program. (With the precompiler, SQL statements are
restricted to the outermost program.)
– You can use SQL statements in copybooks.
– REPLACE statements work in SQL statements.
Compiling with the Db2 coprocessor generates a Db2 database request module (DBRM) along with the
usual COBOL compiler outputs such as object module and listing. The DBRM writes to the data set that
you specified in the DBRMLIB DD statement in the JCL for the COBOL compile step. As input to the Db2
Related concepts
“COBOL and Db2 CCSID
determination” on page 510
Related tasks
“Using the separate Db2 precompiler” on page 506
“Compiling with the SQL option” on page 509
Related references
“Differences in how the Db2
precompiler and coprocessor behave” on page 513
“SQL” on page 408
Related concepts
“Db2 coprocessor” on page 505
Related references
“Differences in how the Db2
precompiler and coprocessor behave” on page 513
Related tasks
“Using SQL INCLUDE with the Db2 coprocessor” on page 507
“Using character data in SQL statements” on page 507
“Using national decimal data in SQL statements” on page 508
“Using national group items in SQL statements” on page 508
“Using binary items in SQL statements” on page 509
506 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
“Determining the success of SQL statements” on page 509
DB2 Application Programming and SQL Guide (Coding SQL statements in a
COBOL application)
Related references
“Code-page determination for string host variables in SQL statements” on page 511
DB2 SQL Reference
The processing of the name in an SQL INCLUDE statement follows the same rules as those of the literal in
a COPY literal-1 statement that does not have a REPLACING phrase.
The library search order for SQL INCLUDE statements is the same SYSLIB concatenation as the compiler
uses to resolve COBOL COPY statements that do not specify a library-name.
Related references
Chapter 20, “Compiler-directing statements,” on page 439
“Differences in how the Db2
precompiler and coprocessor behave” on page 513
COPY statement (Enterprise COBOL for z/OS Language Reference)
01 C1208.
49 C1208-LEN PIC S9(4) USAGE COMP.
49 C1208-TEXT PIC X(50).
EXEC SQL DECLARE :C1208 VARIABLE CCSID 1208 END-EXEC.
The NSYMBOL compiler option has no effect on a character literal inside an EXEC SQL statement.
Character literals in an EXEC SQL statement follow the SQL rules for character constants.
Related concepts
“COBOL and Db2 CCSID
determination” on page 510
Related tasks
“Using the separate Db2 precompiler” on page 506
DB2 Application Programming and SQL Guide (Coding SQL statements in a
COBOL application)
Related references
“Differences in how the Db2
precompiler and coprocessor behave” on page 513
“CODEPAGE” on page 353
DB2 SQL Reference
Any national decimal host variable that you specify in an EXEC SQL statement must have the following
characteristics:
• It must be signed.
• It must be specified with the SIGN LEADING SEPARATE clause.
• USAGE NATIONAL must be in effect implicitly or explicitly.
Related concepts
“Formats for numeric data” on page 47
Related tasks
“Defining national numeric data items” on page 132
Related references
“Differences in how the Db2
precompiler and coprocessor behave” on page 513
Because all subordinate items in a national group must have USAGE NATIONAL, a national group item
cannot describe a variable-length string.
508 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Related tasks
“Using national groups” on page 137
Related concepts
“Formats for numeric data” on page 47
Related references
“TRUNC” on page 419
Related tasks
DB2 Application Programming and SQL Guide (Coding SQL statements in a
COBOL application)
//DBRMLIB DD DSN=PAYROLL.MONTHLY.DBRMLIB.DATA(MAINFILE),DISP=SHR
//STEPLIB DD DSN=DSN910.SDSNLOAD,DISP=SHR
Compiling a batch of programs: If you use the SQL option when compiling a source file that contains
a sequence of COBOL programs (a batch compile sequence), SQL must be in effect for only the first
program of the sequence. Although you can specify SQL upon compiler invocation, the option will be in
effect for only the first program. If you specify SQL in a CBL or PROCESS statement for a program other
than the first program in the batch, you will receive a compiler diagnostic message.
Related concepts
“Db2 coprocessor” on page 505
“COBOL and Db2 CCSID
determination” on page 510
Related tasks
“Separating Db2 suboptions” on page 510
“Choosing the DYNAM or NODYNAM compiler option” on page 515
Related references
“DYNAM” on page 366
“SQL” on page 408
DB2 Command Reference
During compilation, the compiler passes the following suboption string to the Db2 coprocessor:
The concatenated strings are delimited with single spaces. If the compiler finds multiple instances of the
same SQL suboption, the last specification of that suboption in the concatenated string takes effect. The
compiler limits the length of the concatenated Db2 suboption string to 4 KB.
When you use the integrated Db2 coprocessor, the determination of the code page CCSID that will be
associated with the string host variables used in SQL statement processing depends on the setting of
510 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
the COBOL SQLCCSID option, on the programming techniques used, and on various Db2 configuration
options.
IBM recommends that you set the COBOL CCSID value the same as the Db2 DSNHDECP value and/or the
value for precompiler CCSID option.
When you use the SQL and SQLCCSID COBOL compiler options, the CCSID value nnnnn that is specified
in the CODEPAGE compiler option, or that is determined from the COBOL data type of a host variable, is
communicated automatically from COBOL to Db2. Db2 associates the COBOL CCSID with host variables,
overriding the CCSID that would otherwise be implied by Db2 external mechanisms and defaults. This
associated CCSID is used for the processing of the SQL statements that reference host variables.
When you use the SQL and NOSQLCCSID compiler options, the CCSID value nnnnn that is specified in
the CODEPAGE compiler option is used only for processing COBOL statements within the COBOL program;
that CCSID is not used for the processing of SQL statements. Instead, Db2 assumes in processing
SQL statements that host variable data values are encoded according to the CCSID or CCSIDs that are
specified through Db2 external mechanisms and defaults.
Related concepts
“Db2 coprocessor” on page 505
Related tasks
“Programming with the SQLCCSID or NOSQLCCSID option” on page 512
Related references
“Code-page determination for string host variables in SQL statements” on page 511
“CODEPAGE” on page 353
“SQL” on page 408
“SQLCCSID” on page 409
• A host variable that has USAGE NATIONAL is always processed by Db2 using CCSID 1200 (Unicode
UTF-16). For example:
• A host variable that has USAGE UTF-8 is always processed by Db2 using CCSID 1208 (Unicode UTF-8).
For example:
• An alphanumeric host variable that has an explicit FOR BIT DATA declaration is set by Db2 to CCSID
66535, which indicates that the variable does not represent encoded characters. For example:
• A BLOB, BINARY, or VARBINARY host variable has no CCSID association. These string types do not
represent encoded characters.
• A host variable for which you specify an explicit CCSID override in the SQLDA is processed with that
CCSID.
• A host variable that you specify in a declaration with an explicit CCSID is processed with that CCSID. For
example:
Related references
“CODEPAGE” on page 353
“SQLCCSID” on page 409
The SQLCCSID option is recommended for COBOL-Db2 applications that have any of these
characteristics:
• Use COBOL Unicode support
• Use other COBOL syntax that is indirectly sensitive to CCSID encoding, such as XML support or object-
oriented syntax for Java interoperability
• Process character data that is encoded in a CCSID that is different from the default CCSID assumed by
Db2
The NOSQLCCSID option is recommended for applications that require the highest compatibility with the
behavior of the Db2 precompiler.
For applications that use COBOL alphanumeric data items as host variables interacting with Db2 string
data that is defined with the FOR BIT DATA subtype, you must either:
• Use the NOSQLCCSID compiler option
• Specify explicit FOR BIT DATA declarations for those host variables, for example:
Usage notes
• If you use the Db2 DCLGEN command to generate COBOL declarations for a table, you can optionally
create FOR BIT DATA declarations automatically. To do so, specify the DCLBIT(YES) option of the
DCLGEN command.
• Performance consideration: Using the SQLCCSID compiler option could result in some performance
overhead in SQL processing, because with SQLCCSID in effect the default Db2 CCSID association
mechanism is overridden with a mechanism that works on a per-host-variable basis.
Related concepts
“Db2 coprocessor” on page 505
Related tasks
“Using the separate Db2 precompiler” on page 506
Related references
“SQLCCSID” on page 409
512 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Differences in how the Db2 precompiler and coprocessor behave
The sections that follow enumerate the differences in behavior between the stand-alone COBOL Db2
precompiler and the integrated COBOL Db2 coprocessor.
For details about the CCSID determination under the Db2 precompiler and coprocessor, see “COBOL and
Db2 CCSID determination” on page 510.
IF A = B THEN
EXEC SQL INCLUDE some_code_here END-EXEC.
ELSE
. . .
END-IF
With the precompiler, the reference to G.ABC will appear as ABC of G in the expanded source and
will be replaced with XYZ of G. With the coprocessor, replacement will not occur, because ABC is not
delimited by separators in the original source string G.ABC.
As an alternative to adding EXEC SQL DECLARE . . . FOR BIT DATA statements, you can use
the NOSQLCCSID compiler option. For details, see the related reference about code-page determination
below.
SQL-INIT-FLAG
Precompiler: With the Db2 precompiler, if you pass host variables that might be located at different
addresses when the program is called more than once, the called program must reset SQL-INIT-FLAG.
Resetting this flag indicates to Db2 that storage must be initialized when the next SQL statement runs. To
reset the flag, insert the statement MOVE ZERO TO SQL-INIT-FLAG in the PROCEDURE DIVISION of
the called program ahead of any executable SQL statements that use those host variables.
Coprocessor: With the Db2 coprocessor, the called program does not need to reset SQL-INIT-FLAG. An
SQL-INIT-FLAG is automatically defined in the program to aid program portability. However, statements
that modify SQL-INIT-FLAG, such as MOVE ZERO TO SQL-INIT-FLAG, have no effect on the SQL
processing in the program.
IGYPS0294-S SQL host variable reference "data-item" was defined with a contained "FILLER"
data item, which is not valid for an SQL host variable. The statement was discarded.
For reference, see Host structures in COBOL in Programming for Db2 for z/OS.
Related concepts
“Db2 coprocessor” on page 505
“COBOL and Db2 CCSID
determination” on page 510
Related tasks
“Using the separate Db2 precompiler” on page 506
Related references
“Code-page determination for string host variables in SQL statements” on page 511
“SQLCCSID” on page 409
514 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Choosing the DYNAM or NODYNAM compiler option
For COBOL programs that have EXEC SQL statements, your choice of the compiler option DYNAM or
NODYNAM depends on the operating environment.
Related tasks
“Compiling with the SQL option” on page 509
DB2 Application Programming and SQL Guide (Programming for the call
attachment facility)
Related references
“DYNAM” on page 366
Related tasks
“Coding SQLIMS statements” on page 518
“Compiling with the SQLIMS option” on page 519
“Compiling and linking COBOL programs for running under IMS” on page 520
“Using object-oriented COBOL and Java under IMS” on page 521
“Calling a COBOL method from a Java application
under IMS” on page 521
“Building a mixed COBOL-Java application
that starts with COBOL” on page 522
“Writing mixed-language IMS applications” on page 522
Related references
“SQLIMS” on page 410
Related tasks
“Using SQLIMS INCLUDE with the IMS SQL coprocessor” on page 518
“Using character data in SQLIMS statements” on page 518
“Using binary items in SQLIMS statements” on page 519
“Determining the success of SQLIMS statements” on page 519
The processing of the name in an SQLIMS INCLUDE statement follows the same rules as the literal in a
COPY literal-1 statement that does not have a REPLACING phrase.
The library search order for SQLIMS INCLUDE statements is the same SYSLIB concatenation as the
compiler uses to resolve COBOL COPY statements that do not specify a library-name.
Related references
Chapter 20, “Compiler-directing statements,” on page 439
COPY statement (Enterprise COBOL for z/OS Language Reference)
Related concepts
“IMS SQL
coprocessor” on page 517
Related references
“CODEPAGE” on page 353
518 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Using binary items in SQLIMS statements
For binary data items that you specify in an EXEC SQLIMS statement, you can define the data items as
either USAGE COMP-5 or as USAGE BINARY, COMP, or COMP-4.
If you define the binary data items as USAGE BINARY, COMP, or COMP-4, use the TRUNC(BIN) compiler
option. Using this option might have a larger effect on performance than using USAGE COMP-5 on
individual data items. If instead you use the TRUNC(OPT) or TRUNC(STD) compiler options, the compiler
accepts the items but the data might not be valid because of the decimal truncation rules. You must
ensure that truncation does not affect the validity of the data.
Related concepts
“Formats for numeric data” on page 47
Related references
“TRUNC” on page 419
Related tasks
IMS Application Programming Guide
//STEPLIB DD DSN=IMS.SDFSRESL,DISP=SHR
Related tasks
“Separating IMS suboptions” on page 520
Related references
“SQL” on page 408
During compilation, the compiler passes the following suboption string to the IMS SQL coprocessor:
The concatenated strings are delimited with single spaces. If the compiler finds multiple instances of the
same SQLIMS suboption, the last specification of that suboption in the concatenated string takes effect.
The compiler limits the length of the concatenated IMS suboption string to 4 KB.
Related concepts
“IMS SQL
coprocessor” on page 517
Related tasks
“Compiling with the SQLIMS option” on page 519
520 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
To run above the 16 MB line, an application program must be compiled with RENT. The data for IMS
application programs can reside above the 16 MB line, and you can use DATA(31) RENT for programs
that use IMS services.
For proper execution of COBOL programs under IMS, observe the following guidelines for the link-edit
attributes:
• To link program objects that contain only COBOL programs compiled with the RENT compiler option, link
as RENT.
• To link program objects that contain a mixture of COBOL RENT programs and other programs, use the
link-edit attributes recommended for the other programs.
Related concepts
“Storage and its addressability” on page 39
Related tasks
“Choosing the DYNAM or NODYNAM compiler option” on page 515
Language Environment Programming Guide (Condition handling under IMS)
Related references
“DATA” on page 359
“RENT” on page 401
Enterprise COBOL for z/OS Migration Guide (IMS considerations)
Related tasks
“Defining a factory section” on page 707
Chapter 39, “Writing object-oriented programs,” on page 679
Chapter 40, “Communicating with Java methods,” on page 719
Chapter 16, “Compiling, linking, and running OO applications,” on page 291
IMS Application Programming Guide
Related tasks
Chapter 16, “Compiling, linking, and running OO applications,” on page 291
“Structuring OO applications” on page 715
“Wrapping procedure-oriented COBOL programs” on page 715
IMS Application Programming Guide
Related tasks
“Structuring OO applications” on page 715
IMS Application Programming Guide
IBM SDK for Java - Tools Documentation
Related tasks
“Using the STOP RUN statement” on page 522
“Processing messages and synchronizing transactions” on page 523
“Accessing databases” on page 523
“Using the application interface block” on page 523
522 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Processing messages and synchronizing transactions
IMS message-processing applications must do all message processing and transaction synchronization
either in COBOL or Java, rather than distributing this logic between application components written in
both languages.
COBOL components use CALL statements to DL/I services to process messages (GU and GN) and
synchronize transactions (CHKP). Java components use Java classes for IMS to do these functions.
You can use object instances of classes derived from IMSFieldMessage to communicate entire IMS
messages between the COBOL and Java components of the application.
Related tasks
IMS Application Programming Guide
Related references
IMS Application Programming API Reference
Accessing databases
You can use either Java, COBOL, or a mixture of the two languages to access IMS databases.
Limitation: EXEC SQL statements for Db2 database access are not supported in COBOL routines that run
in a Java dependent region.
Recommendation: Do not access the same database program communication block (PCB) from both
Java and COBOL. The Java and COBOL parts of the application share the same database position.
Changes in database position from calls in one part of the application affect the database position in
another part of the application. (This problem occurs whether the affected parts of an application are
written in the same language or in different languages.)
Suppose that a Java component of a mixed application builds an SQL SELECT clause and uses Java
Database Connectivity (JDBC) to query and retrieve results from an IMS database. The Java class libraries
for IMS construct the appropriate request to IMS to establish the correct position in the database. If you
then invoke a COBOL method that builds a segment search argument (SSA) and issues a GU (Get Unique)
request to IMS against the same database PCB, the request probably altered the position in the database
for that PCB. If so, subsequent JDBC requests to retrieve more records by using the initial SQL SELECT
clause are incorrect because the database position changed. If you must access the same PCB from
multiple languages, reestablish the database position after an interlanguage call before you access more
records in the database.
Related tasks
IMS Application Programming Guide
Local-storage section.
copy AIB.
. . .
Linkage section.
01 IOPCB.
05 logtterm pic x(08).
05 pic x(02).
05 tpstat pic x(02).
05 iodate pic s9(7) comp-3.
05 iotime pic s9(7) comp-3.
05 pic x(02).
05 seqnum pic x(02).
05 mod pic x(08).
Procedure division.
Move spaces to input-area
Move spaces to AIB
Move "DFSAIB" to AIBRID
Move length of AIB to AIBRLEN
Move "IOPCB" to AIBRSNM1
Move length of input-area to AIBOALEN
Call "CEETDLI" using GU, AIB, input-area
Set address of IOPCB to AIBRESA1
If tpstat = spaces
* . . process input message
524 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Chapter 25. Running COBOL programs under z/OS
UNIX
To run COBOL programs in the z/OS UNIX environment, compile them using Enterprise COBOL or COBOL
for OS/390 & VM. The programs must be reentrant, so use the compiler and linker option RENT.
If you are going to run the programs from the z/OS UNIX file system, use the linker option AMODE 31. Any
AMODE 24 program that you call from within a z/OS UNIX application must reside in an MVS PDSE.
Restrictions: The following restrictions apply to running under z/OS UNIX:
• SORT and MERGE statements are not supported.
• You cannot use the old COBOL interfaces for preinitialization (runtime option RTEREUS) to establish a
reusable environment.
• You cannot run a COBOL program compiled with the NOTHREAD option in more than one thread. If you
start a COBOL application in a second thread, you get a software condition from the COBOL run time.
You can run NOTHREAD COBOL programs in the initial process thread (IPT) or in one non-IPT that you
create from a C or PL/I routine.
You can run a COBOL program in more than one thread if you compile all the COBOL programs in the
application with the THREAD option.
You can use Debug Tool to debug z/OS UNIX programs in remote debug mode, for example, by using the
Debug Perspective of IBM Developer for z/OS, or in full-screen mode (MFI) using a VTAM® terminal.
Related tasks
Chapter 15, “Compiling under z/OS UNIX,” on page 283
“Running OO applications under z/OS UNIX” on page 293
“Running in z/OS UNIX environments” on page 525
“Setting and accessing environment variables” on page 526
“Calling UNIX/POSIX APIs” on page 528
“Accessing main program parameters under z/OS UNIX” on page 530
Language Environment Programming Guide
Related references
“RENT” on page 401
The ISPF shell can direct stdout and stderr only to a z/OS UNIX file, not to your terminal.
• From outside a shell, you can run programs either under TSO/E or in batch.
Related tasks
“Running OO applications under z/OS UNIX” on page 293
“Setting and accessing environment variables” on page 526
“Calling UNIX/POSIX APIs” on page 528
“Accessing main program parameters under z/OS UNIX” on page 530
“Defining and allocating QSAM files” on page 180
“Allocating line-sequential files” on page 216
“Allocating VSAM files” on page 208
“Displaying values on a screen or in a file (DISPLAY)” on page 35
Language Environment Programming Guide (Running POSIX-enabled programs)
Related references
“TEST” on page 414
UNIX System Services User's Guide (The BPXBATCH utility)
Language Environment Programming Reference
Related tasks
“Running in z/OS UNIX environments” on page 525
“Setting environment variables that affect execution” on page 527
“Accessing main program parameters under z/OS UNIX” on page 530
“Running OO applications under z/OS UNIX” on page 293
“Setting environment variables under z/OS UNIX” on page 283
Related references
“Runtime environment variables” on page 527
Language Environment Programming Reference
MVS Program Management: User's Guide and Reference
526 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Setting environment variables that affect execution
To set environment variables for z/OS UNIX COBOL programs from a shell, use the export or set
command. To set environment variables from within the program, call POSIX functions setenv() or
putenv().
For example, to set the environment variable MYFILE:
export MYFILE=/usr/mystuff/notes.txt
Related tasks
“Calling UNIX/POSIX APIs” on page 528
“Setting environment variables under z/OS UNIX” on page 283
Related references
“Runtime environment variables” on page 527
Related tasks
“Displaying data on the system logical output device” on page 36
Related references
XL C/C++ Programming Guide (_CEE_ENVFILE)
Language Environment Programming Reference
CBL pgmname(longmixed),nodynam
Identification division.
Program-id. "envdemo".
Data division.
Working-storage section.
01 P pointer.
01 PATH pic x(5) value Z"PATH".
01 var-ptr pointer.
01 var-len pic 9(4) binary.
01 putenv-arg pic x(14) value Z"MYVAR=ABCDEFG".
01 rc pic 9(9) binary.
Linkage section.
01 var pic x(5000).
Procedure division.
* Retrieve and display the PATH environment variable
Set P to address of PATH
Call "getenv" using by value P returning var-ptr
If var-ptr = null then
Display "PATH not set"
Else
Set address of var to var-ptr
Move 0 to var-len
Inspect var tallying var-len
for characters before initial X"00"
Display "PATH = " var(1:var-len)
End-if
* Set environment variable MYVAR to ABCDEFG
Set P to address of putenv-arg
Call "putenv" using by value P returning rc
If rc not = 0 then
Display "putenv failed"
Stop run
End-if
Goback.
528 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
– The process has ever run a VS COBOL II program.
• With one exception, DD allocations are not inherited from a parent process to a child process. The
exception is the local spawn, which creates a child process in the same address space as the parent
process. You request a local spawn by setting the environment variable _BPX_ SHAREAS=YES before
you invoke the spawn() function.
The exec() and spawn() functions start a new Language Environment enclave in the new UNIX process.
Therefore the target program of the exec() or spawn() function is a main program, and all COBOL
programs in the process start in initial state with all files closed.
Sample code for calling some of the POSIX routines is provided in the SIGYSAMP data set.
Related tasks
“Running in z/OS UNIX environments” on page 525
“Setting and accessing environment variables” on page 526
“Accessing main program parameters under z/OS UNIX” on page 530
Language Environment Programming Guide
Related tasks
“Running in z/OS UNIX environments” on page 525
“Setting and accessing environment variables” on page 526
“Calling UNIX/POSIX APIs” on page 528
“Accessing main program parameters under z/OS” on page 576
Identification division.
Program-id. "EXECED".
****************************************************************
* This sample program displays arguments received via exec() *
* function of z/OS UNIX *
****************************************************************
Data division.
Working-storage section.
01 curr-arg-count pic 9(9) binary value zero.
Linkage section.
01 arg-count pic 9(9) binary. (1)
01 arg-length-list. (2)
05 arg-length-addr pointer occurs 1 to 99999
depending on curr-arg-count.
01 arg-list. (3)
05 arg-addr pointer occurs 1 to 99999
depending on curr-arg-count.
01 arg-length pic 9(9) binary.
01 arg pic X(65536).
Procedure division using arg-count arg-length-list arg-list.
*****************************************************************
* Display number of arguments received *
*****************************************************************
Display "Number of arguments received: " arg-count
*****************************************************************
* Display each argument passed to this program *
*****************************************************************
Perform arg-count times
Add 1 to curr-arg-count
* *******************************************************
530 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
* * Set address of arg-length to address of current *
* * argument length and display *
* *******************************************************
Set Address of arg-length
to arg-length-addr(curr-arg-count)
Display
"Length of Arg " curr-arg-count " = " arg-length
* *******************************************************
* * Set address of arg to address of current argument *
* * and display *
* *******************************************************
Set Address of arg to arg-addr(curr-arg-count)
Display "Arg " curr-arg-count " = " arg (1:arg-length - 1)
End-Perform
Display "Display of arguments complete."
Goback.
(1)
This count contains the number of elements in the arrays that are passed in the second and third
parameters.
(2)
This array contains a pointer to the length of the nth entry in the argument list.
(3)
This array contains a pointer to the nth character string passed as an argument in the spawn() or
exec() function or in the command invocation.
Related tasks
“Pointer data items with AMODE 64 programs” on page 533
“Compiler limits with AMODE 64 support” on page 534
“CALL statement with AMODE 64 support” on page 534
“Using compiler options to compile AMODE 64 programs” on page 534
“Other AMODE 64 considerations” on page 535
This can affect the size of group items that contain these data items. If the group item is defined in a
COBOL copybook, and if the copybook is used in both LP(64) and LP(32) compilations, you should be
aware that the difference in size might affect the program logic.
USAGE POINTER-32 data item
A new data item with USASGE POINTER-32 is added to the compiler when introducing AMODE 64
support. This can be used with the LP(64) or LP(32) compiler option, and can be used to define the
pointer data item that contains below the bar address regardless of whether the data item is used in an
AMODE 64 or AMODE 31 program. The same copybook can then be shared between LP(64) and LP(32)
programs.
Related tasks
“LP” on page 383
FUNCTION-POINTER phrase (Enterprise COBOL for z/OS Language Reference)
INDEX phrase (Enterprise COBOL for z/OS Language Reference)
LENGTH OF (Enterprise COBOL for z/OS Language Reference)
POINTER phrase (Enterprise COBOL for z/OS Language Reference)
POINTER-32 phrase (Enterprise COBOL for z/OS Language Reference)
PROCEDURE-POINTER phrase (Enterprise COBOL for z/OS Language Reference)
Related tasks
“LP” on page 383
Related tasks
CALL statement (Enterprise COBOL for z/OS Language Reference)
“LP” on page 383
534 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
The DATA(24) option is discarded when LP(64) is in effect. Data items in WORKING-STORAGE SECTION
are allocated above the bar. Data items in LOCAL section are allocated on the Language Environment
stack, which is also above the bar.
AFP and HGPR
These two options control the compiler’s register usage and are discarded by the compiler when LP(64)
is in effect. The generated code is guaranteed to work in the Language Environment, and can call or be
called by other Language Environment AMODE 64 high-level languages. User application cannot control
register usage of the COBOL compiler.
“CICS” on page 352, “SQL” on page 408, SQLIMS, “SQLCCSID” on page 409, “THREAD” on
page 418
These options are discarded in LP(64). In addition, the output of the SQL precompiler is not compatible
with AMODE 64.
Runtime options
The following COBOL only runtime options are supported in LP(64):
• AIXBLD
• CBLQDA
• DEBUG
• SIMVRD
• UPSI
The following runtime options are not supported:
• ALL31
This option is meaningful only in AMODE 31.
• CBLOPTS
• CBLPSHPOP
This option applies only for OS VS program under CICS.
• MSGFILE
This option is not supported by the Language Environment in AMODE 64.
• RTEREUS
This option supports COBOL runtime reuse environment using a legacy design, and is not supported in
LP(64). To establish a reusable runtime environment, use the LE preinitialization environment feature.
Related references
Related references
“LP” on page 383
Summary of changes (Enterprise COBOL for z/OS Language Reference)
536 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Chapter 27. Developing COBOL programs in the
mixed AMODE Language Environment
This chapter describes developing programs in the mixed AMODE Language Environment.
For example:
export STEPLIB=CEE.SCEERUN2:CEE.SCEERUN
For example:
export LIBPATH={$JAVAHOME}/lib/s390x/j9vm:./
export CLASSPATH=./
• COBJVMINITOPTIONS: Set this environment variable to Java JDK initialization options. The JVM option
-XX:+Enable3164Interoperability is needed to initialize the mixed AMODE environment.
For example:
538 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Examples for mixed AMODE COBOL/Java interoperability application
This section provides examples for mixed AMODE COBOL/Java interoperability application.
Below is an example of a COBOL program starting in AMODE 31 and calling the main method in Java in
AMODE 64.
COBOL program example:
Compile and link the program below with cob2, where the program text is in source file prog.cbl.
IDENTIFICATION DIVISION.
PROGRAM-ID. "PROG" recursive.
*
ENVIRONMENT DIVISION.
*
DATA DIVISION.
WORKING-STORAGE SECTION.
COPY JNI.
PROCEDURE DIVISION.
0010-MAIN.
* ***********************************************
* FIND CLASS
* ***********************************************
CALL FindClass USING BY VALUE
JNIEnvPtr
ADDRESS OF WS-CLASS-NAME
RETURNING WS-CLASS-ID .
IF WS-CLASS-ID = ZERO
DISPLAY "CANT LOAD CLASS " WS-CLASS-NAME
GOBACK
END-IF.
* ***********************************************
* FIND METHOD (main)
* ***********************************************
* ***********************************************
Chapter 27. Developing COBOL programs in the mixed AMODE Language Environment 539
* CALL METHOD (main)
* ***********************************************
GOBACK.
0100-INIT.
EXIT.
Parameter Passing
Both CALL ... USING BY REFERENCE and CALL ... USING BY CONTENT are supported.
CALL ... USING BY VALUE parameter is not supported.
If the CALL ... RETURNING phrase is used, the returning data item must not be larger then 24 bytes.
The RETURNING phrase supports for the following data items:
• alphanumeric
540 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
• zoned decimal
• COMP-3 (packed-decimal)
• COMP-4
• COMP-5
• COMP (BINARY)
Note: There is an extra copying required to return a data item across two AMODE settings. You can avoid
the requirement by passing the data item with CALL ... USING BY REFERENCE. This method has better
performance, especially for large data items.
External file
The same external file can not be accessed by programs with different AMODE settings.
Related tasks
“Making dynamic calls” on page 548
Related references
DATA (Enterprise COBOL for z/OS Language Reference)
CALL statement (Enterprise COBOL for z/OS Language Reference)
//IGZOPTS DD *
AMODE3164
/*
When running under z/OS UNIX, specify the option using the _IGZ_RUNOPTS environment variable. For
example:
export _IGZ_RUNOPTS=”AMODE3164”
Chapter 27. Developing COBOL programs in the mixed AMODE Language Environment 541
For more information about how to specify COBOL runtime options, see “Specifying COBOL runtime
options” on page 432.
Related tasks
“Dynamic call between AMODE 31 and AMODE 64 programs” on page 540
Performance
There is an extra overhead to transition between AMODE 31 and 64. Avoid crossing AMODE in
performance sensitive areas and group programs that need to call each other frequently into the same
AMODE.
In the CALL statement, use CALL ... BY REFERENCE whenever possible. This requires less processing
when the parameters are accessed in the other AMODE. Instead of using the RETURNING phrase, return
the data item as a BY REFERENCE parameter. This avoids additional copying when the call is returned.
CALL ...BY VALUE is not supported.
Multi-threading
It is an existing limitation that the THREAD compiler option is not supported for COBOL programs
compiled with LP(64) (running in AMODE 64). This limitation is extended to COBOL programs compiled
with LP(32) (running in AMODE 31) when the mixed AMODE 31/64 feature is used. This means that when
the LE runtime environment contains both AMODE 31 and AMODE 64 programs within any LE enclave,
only one thread can contain COBOL programs.
Note: AMODE 31 and AMODE 64 programs are running in different LE enclaves in the mixed LE
environment.
Condition handling
The condition handling support does not extend across AMODE 31/64 boundary. When processing a
condition, Language Environment does not traverses stack frames to find a condition handler until an
AMODE 31 and AMODE 64 boundary is reached. If a handler is not found at this point, the condition is
treated as unhandled. Applications that rely on condition handling might need to be modified.
Additional information
For more information about AMODE 31/64 inter operation, see Introduction to AMODE 31 and AMODE
64 programs interoperability on Language Environment Vendor Interface for AMODE 31 and AMODE 64
Interoperability.
Related tasks
“Dynamic call between AMODE 31 and AMODE 64 programs” on page 540
542 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Part 4. Structuring complex applications
Related concepts
“Main programs, subprograms, and calls” on page 545
Related tasks
“Identifying a program” on page 3
“Ending and reentering main programs or subprograms” on page 546
“Transferring control to another program” on page 547
“Making recursive calls” on page 557
“Calling to and from object-oriented programs” on page 557
“Using procedure and function pointers” on page 557
“Making programs reentrant” on page 560
“Handling COBOL limitations with multithreading” on page 594
Language Environment Writing ILC Communication Applications
Related references
Language Environment Programming Guide (Register conventions)
Related tasks
“Ending and reentering main programs or subprograms” on page 546
“Transferring control to another program” on page 547
“Making recursive calls” on page 557
Related references
Language Environment Programming Guide
STOP RUN Return to calling program.1 (Might be the Return directly to the program that called
operating system, and application will the main program.1 (Might be the operating
end.) system, and application will end.)
STOP RUN terminates the run unit STOP RUN terminates the run unit, and
(also called an enclave in Language deletes all dynamically called programs in
Environment terms), and deletes all the run unit and all programs link-edited with
dynamically called programs in the run them. (It does not delete the main program.)
unit and all programs link-edited with
In a threaded environment, the entire
them. (It does not delete the main
Language Environment enclave is terminated,
program.)
including all threads running within the
In a threaded environment, the entire enclave.
Language Environment enclave is
In a CICS environment, the entire transaction
terminated, including all threads running
is terminated, including all programs running
within the enclave.
within the transaction.
In a CICS environment, the entire
transaction is terminated, including all
programs running within the transaction.
1. If the main program is called by a program written in another language that does not follow Language
Environment linkage conventions, return is to this calling program.
2. If the thread is the initial thread of execution in an enclave, the enclave is terminated.
546 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
A subprogram is usually left in its last-used state when it terminates with EXIT PROGRAM or GOBACK. The
next time the subprogram is called in the run unit, its internal values are as they were left, except that
return points for PERFORMed paragraphs and sections are reset to their initial values. (In contrast, a main
program is initialized each time it is called.)
There are some cases in which programs will be in their initial state:
• A subprogram that is dynamically called and then canceled will be in the initial state the next time it is
called.
• A program that has the INITIAL clause in the PROGRAM-ID paragraph, or is compiled with the
INITIAL compiler option, will be in the initial state each time it is called.
• Data items defined in the LOCAL-STORAGE SECTION will be reset to the initial state specified by their
VALUE clauses each time the program is called.
Related concepts
“Comparison of WORKING-STORAGE and LOCAL-STORAGE” on page 14
Language Environment Programming Guide (What happens during termination:
thread termination)
Related tasks
“Calling nested COBOL programs” on page 554
“Making recursive calls” on page 557
Related concepts
“AMODE switching” on page 550
“Performance considerations of static and dynamic calls” on page 552
“Nested programs” on page 555
Related tasks
“Making static calls” on page 548
“Making dynamic calls” on page 548
“Making both static and dynamic calls” on page 552
“Calling nested COBOL programs” on page 554
Related references
Enterprise COBOL for z/OS Migration Guide
(Interoperability with older levels of IBM COBOL programs)
Related concepts
“Performance considerations of static and dynamic calls” on page 552
Related tasks
“Making dynamic calls” on page 548
“Making both static and dynamic calls” on page 552
“Calling to and from object-oriented programs” on page 557
Related references
“DLL” on page 363
“DYNAM” on page 366
CALL statement (Enterprise COBOL for z/OS Language Reference)
548 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
• COBOL DLL programs
• COBOL programs compiled with the PGMNAME(LONGMIXED) option, unless the program-name is less
than or equal to eight characters in length and is all uppercase
• COBOL programs compiled with the PGMNAME(LONGUPPER) option, unless the program-name is less
than or equal to eight characters in length
• More than one entry point in the same COBOL program (unless an intervening CANCEL statement was
executed)
“Examples: static and dynamic CALL statements” on page 553
Related concepts
“When to use a dynamic call with subprograms” on page 549
“Performance considerations of static and dynamic calls” on page 552
Related tasks
“Canceling a subprogram” on page 549
“Making static calls” on page 548
“Making both static and dynamic calls” on page 552
Related references
“DLL” on page 363
“DYNAM” on page 366
ENTRY statement (Enterprise COBOL for z/OS Language Reference)
CALL statement (Enterprise COBOL for z/OS Language Reference)
Language Environment Programming Reference
Canceling a subprogram
When you issue a CANCEL statement for a subprogram, the storage that is occupied by the subprogram
is freed. A subsequent call to the subprogram functions as though it were the first call. You can cancel a
subprogram from a program other than the original caller.
If the called subprogram has more than one entry point, ensure that an intervening CANCEL statement is
executed before you specify different entry points in a dynamic CALL statement to that subprogram.
After a CANCEL statement is processed for a dynamically called contained program, the program will be in
its first-used state. However, the program is not loaded with the initial call, and storage is not freed after
the program is canceled.
“Examples: static and dynamic CALL statements” on page 553
Related concepts
“Performance considerations of static and dynamic calls” on page 552
Related concepts
“AMODE switching” on page 550
“Performance considerations of static and dynamic calls” on page 552
Related tasks
“Making dynamic calls” on page 548
Related references
“DYNAM” on page 366
CALL statement (Enterprise COBOL for z/OS Language Reference)
Language Environment Programming Reference
AMODE switching
When you have an application that has COBOL subprograms, some of the COBOL subprograms can be
AMODE 31 and some can be AMODE 24. To have this mixed AMODE support, the calls must be dynamic
and the Language Environment runtime options ALL31(OFF) and STACK(,,BELOW) must be in effect.
If your application consists of only COBOL programs, and you are using dynamic calls, each COBOL
subprogram will always be entered in the proper AMODE. For example, if you are using a dynamic call from
an AMODE 31 COBOL program to an AMODE 24 COBOL program, the AMODE is automatically switched.
However, if you are using procedure pointers, function pointers, or other languages that call COBOL
subprograms, you must ensure that when a COBOL program is called more than once in an enclave, it is
entered in the same AMODE each time that it is called. The AMODE is not automatically switched in this
case.
The following scenario shows that AMODE problems can arise when procedure pointers are used to call
COBOL subprograms. This scenario is not supported because the COBOL program COBOLY is not entered
in the same AMODE each time that it is called.
550 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
1. COBOLX is AMODE 31. It uses the SET statement to set a procedure pointer to COBOLZ. COBOLZ is a
reentrant program object and is AMODE 31 and RMODE 24. COBOLX calls COBOLZ using the procedure
pointer. COBOLZ is entered in AMODE 31.
2. COBOLZ returns to COBOLX.
3. COBOLX dynamically calls COBOLY, passing the procedure pointer for COBOLZ. COBOLY is a reentrant
program object, and is AMODE 24 and RMODE 24. COBOLY is entered in AMODE 24.
4. COBOLY calls COBOLZ using the procedure pointer. This call causes COBOLZ to be entered in AMODE
24, which is not the same AMODE in which COBOLZ was entered when it was called the first time.
The following scenario uses a mix of COBOL and assembler language. This scenario is not supported
because the COBOL program COBOLB is not entered in the same AMODE each time that it is called.
1. COBOLA is AMODE 31. COBOLA dynamically calls COBOLB. COBOLB is a reentrant program object and
is AMODE 31 and RMODE 24. COBOLB is entered in AMODE 31.
2. COBOLB returns to COBOLA.
3. COBOLA dynamically calls ASSEM10, which is in assembler language. ASSEM10 is a reentrant program
object, and is AMODE 24 and RMODE 24. ASSEM10 is entered in AMODE 24.
4. ASSEM10 loads COBOLB. ASSEM10 does a BALR instruction to COBOLB. COBOLB is entered in AMODE
24, which is not the same AMODE in which COBOLB was entered when it was called the first time.
Related tasks
“Making dynamic calls” on page 548
Related references
Language Environment Programming Reference (ALL31)
Related concepts
“When to use a dynamic call with subprograms” on page 549
Related tasks
“Making static calls” on page 548
“Making dynamic calls” on page 548
Related references
“DYNAM” on page 366
552 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Examples: static and dynamic CALL statements
This example shows how you can code static and dynamic calls.
The example has three parts:
• Code that uses a static call to call a subprogram
• Code that uses a dynamic call to call the same subprogram
• The subprogram that is called by the two types of calls
The following example shows how you would code static calls:
The following example shows how you would code dynamic calls:
DATA DIVISION.
WORKING-STORAGE SECTION.
77 PGM-NAME PICTURE X(8).
01 RECORD-2 PIC x. (6)
01 RECORD-1. (2)
05 PAY PICTURE S9(5)V99.
05 HOURLY-RATE PICTURE S9V99.
05 HOURS PICTURE S99V9.
. . .
PROCEDURE DIVISION.
. . .
MOVE "SUBPROG" TO PGM-NAME.
CALL PGM-NAME USING RECORD-1. (1)
CANCEL PGM-NAME.
MOVE "PAYMASTR" TO PGM-NAME. (4)
CALL PGM-NAME USING RECORD-1 RECORD-2. (5)
STOP RUN.
The following example shows a called subprogram that is called by each of the two preceding calling
programs:
IDENTIFICATION DIVISION.
PROGRAM-ID. SUBPROG.
DATA DIVISION.
LINKAGE SECTION.
01 PAYREC. (2)
10 PAY PICTURE S9(5)V99.
10 HOURLY-RATE PICTURE S9V99.
10 HOURS PICTURE S99V9.
77 PAY-CODE PICTURE 9. (6)
PROCEDURE DIVISION USING PAYREC. (1)
. . .
EXIT PROGRAM. (3)
ENTRY "PAYMASTR" USING PAYREC PAY-CODE. (5)
. . .
GOBACK. (7)
(1)
Processing begins in the calling program. When the first CALL statement is executed, control is
transferred to the first statement of the PROCEDURE DIVISION in SUBPROG, which is the called
program.
554 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
• Include each contained program in the containing program immediately before the END PROGRAM
marker of the containing program.
• Use an END PROGRAM marker to terminate contained and containing programs.
You cannot use the THREAD option when compiling programs that contain nested programs.
Related concepts
“Nested programs” on page 555
Related references
“Scope of names” on page 556
Nested programs
A COBOL program can nest, or contain, other COBOL programs. The nested programs can themselves
contain other programs. A nested program can be directly or indirectly contained in a program.
There are four main advantages to nesting called programs:
• Nested programs provide a method for creating modular functions and maintaining structured
programming techniques. They can be used analogously to perform procedures (using the PERFORM
statement), but with more structured control flow and with the ability to protect local data items.
• Nested programs let you debug a program before including it in an application.
• Nested programs enable you to compile an application with a single invocation of the compiler.
• Calls to nested programs have the best performance of all the forms of COBOL CALL statements.
The following example describes a nested structure that has directly and indirectly contained programs:
Related references
“Scope of names” on page 556
The following table describes the calling hierarchy for the structure that is shown in the example above.
Programs A12, A2, and A3 are identified as COMMON, and the calls associated with them differ.
This program Can call these programs And can be called by these
programs
A A1, A2, A3 None
A1 A11, A12, A2, A3 A
A11 A111, A12, A2, A3 A1
A111 A12, A2, A3 A11
A12 A2, A3 A1, A11, A111
A2 A3 A, A1, A11, A111, A12, A3
A3 A2 A, A1, A11, A111, A12, A2
Scope of names
Names in nested structures are divided into two classes: local and global. The class determines whether a
name is known beyond the scope of the program that declares it. A specific search sequence locates the
declaration of a name after it is referenced in a program.
Local names
Names (except the program-name) are local unless declared to be otherwise. Local names are visible
or accessible only within the program in which they are declared. They are not visible or accessible to
contained and containing programs.
556 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Global names
A name that is global (indicated by using the GLOBAL clause) is visible and accessible to the program in
which it is declared and to all the programs that are directly and indirectly contained in that program.
Therefore, the contained programs can share common data and files from the containing program simply
by referencing the names of the items.
Any item that is subordinate to a global item (including condition-names and indexes) is automatically
global.
You can declare the same name with the GLOBAL clause more than one time, provided that each
declaration occurs in a different program. Be aware that you can mask, or hide, a name in a nested
structure by having the same name occur in different programs in the same containing structure.
However, such masking could cause problems during a search for a name declaration.
Related tasks
“Identifying a program as recursive” on page 4
Related references
PROGRAM-ID paragraph (Enterprise COBOL for z/OS Language Reference)
558 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
77 DATA-PTR USAGE POINTER.
with the data-only module revised to return the address of the data, and below is the LP(32) example:
DATAONLY CSECT
USING *,15
LA 15,DATA
BR 14
*
DATA DC ...
...
END
Related tasks
“Deciding which type of pointer to use” on page 559
“Calling alternate entry points” on page 560
“Using procedure or function pointers with DLLs” on page 585
Related references
“DLL” on page 363
“DYNAM” on page 366
CANCEL statement (Enterprise COBOL for z/OS Language Reference)
Format 6: SET for procedure-pointer and function-pointer data items
(Enterprise COBOL for z/OS Language Reference)
ENTRY statement (Enterprise COBOL for z/OS Language Reference)
MVS Program Management: User's Guide and Reference
Many callable services written in C return function pointers. You can call such a C function pointer from
your COBOL program by using COBOL function pointers as shown below.
IDENTIFICATION DIVISION.
PROGRAM-ID. DEMO.
ENVIRONMENT DIVISION.
DATA DIVISION.
*
WORKING-STORAGE SECTION.
01 FP USAGE FUNCTION-POINTER.
*
PROCEDURE DIVISION.
CALL "c-function" RETURNING FP.
CALL FP.
Related references
“NAME” on page 387
CANCEL statement (Enterprise COBOL for z/OS Language Reference)
ENTRY statement (Enterprise COBOL for z/OS Language Reference)
MVS Program Management: User's Guide and Reference
Related concepts
“Storage and its addressability” on page 39
Related tasks
“Compiling programs to create
560 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
DLLs” on page 580
Chapter 16, “Compiling, linking, and running OO applications,” on page 291
Related references
“RENT” on page 401
“DATA” on page 359
Language Environment Programming Reference (ALL31, HEAP)
Related tasks
“Using data from another
program” on page 16
“Sharing data with Java” on page 723
“Passing data” on page 563
“Coding the LINKAGE SECTION” on page 567
“Coding the PROCEDURE DIVISION
for passing arguments” on page 568
“Passing return-code information” on page 571
“Sharing data by using the EXTERNAL clause” on page 572
“Sharing files between programs (external files)” on page 573
“Accessing main program parameters under z/OS” on page 576
Passing data
You can choose among three ways of passing data between programs: BY REFERENCE, BY CONTENT, or
BY VALUE.
BY REFERENCE
The subprogram refers to and processes the data items in the storage of the calling program rather
than working on a copy of the data. BY REFERENCE is the assumed passing mechanism for a
parameter if none of the three ways is specified or implied for the parameter.
BY CONTENT
The calling program passes only the contents of the literal or identifier. The called program cannot
change the value of the literal or identifier in the calling program, even if it modifies the data item in
which it received the literal or identifier.
BY VALUE
The calling program or method passes the value of the literal or identifier, not a reference to the
sending data item. The called program or invoked method can change the parameter. However,
because the subprogram or method has access only to a temporary copy of the sending data item, any
change does not affect the argument in the calling program.
The following figure shows the differences in values passed BY REFERENCE, BY CONTENT, and BY
VALUE:
564 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 71. Methods for passing data in the CALL statement (continued)
Code Purpose Comments
A combination of BY To pass both a data item and a copy
REFERENCE and BY CONTENT of its length to a subprogram
such as:
CALL 'ERRPROC'
USING BY REFERENCE A
BY CONTENT LENGTH OF A.
CALL . . . BY VALUE To pass data to a program, such as a A copy of the identifier is passed
identifier C/C++ program, that uses BY VALUE directly in the parameter list.
parameter linkage conventions
CALL . . . BY VALUE literal To pass data to a program, such as a A copy of the literal is passed directly
C/C++ program, that uses BY VALUE in the parameter list.
parameter linkage conventions
CALL . . . BY VALUE To pass the address of identifier Any changes to the copy of the
ADDRESS OF identifier to a called program. This is the address will not affect the address
recommended way to pass data to a of identifier, but changes to identifier
C/C++ program that expects a pointer using the copy of the address will
to the data. cause changes to identifier.
CALL . . . RETURNING To call a C/C++ function with a
function return value
1. File-names as CALL operands are allowed as an IBM extension to COBOL. Any use of the extension
generally depends on the specific internal implementation of the compiler. Control block field settings might
change in future releases. Any changes made to the control block are the user's responsibility and are not
supported by IBM.
Related concepts
“Storage and its addressability” on page 39
Related tasks
“Describing arguments in the calling program” on page 565
“Describing parameters in the called program” on page 566
“Testing for OMITTED arguments” on page 567
“Specifying CALL . . . RETURNING” on page 572
“Sharing data by using the EXTERNAL clause” on page 572
“Sharing files between programs (external files)” on page 573
“Sharing data with Java” on page 723
Related references
CALL statement (Enterprise COBOL for z/OS Language Reference)
The USING phrase (Enterprise COBOL for z/OS Language Reference)
INVOKE statement (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Coding the LINKAGE SECTION” on page 567
“Coding the PROCEDURE DIVISION
for passing arguments” on page 568
Related references
The USING phrase (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Coding the LINKAGE SECTION” on page 567
Related references
The USING phrase (Enterprise COBOL for z/OS Language Reference)
566 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Testing for OMITTED arguments
You can specify that one or more BY REFERENCE arguments are not to be passed to a called program by
coding the OMITTED keyword in place of those arguments in the CALL statement.
For example, to omit the second argument when calling program sub1, code this statement:
The arguments in the USING phrase of the CALL statement must match the parameters of the called
program in number and position.
In a called program, you can test whether an argument was passed as OMITTED by comparing the
address of the corresponding parameter to NULL. For example:
Program-ID. sub1.
. . .
Procedure Division Using RPARM1, RPARM2, RPARM3.
If Address Of RPARM2 = Null Then
Display 'No 2nd argument was passed this time'
Else
Perform Process-Parm-2
End-If
Related references
CALL statement (Enterprise COBOL for z/OS Language Reference)
The USING phrase (Enterprise COBOL for z/OS Language Reference)
In the calling program, the code for parts (PARTCODE) and the part number (PARTNO) are distinct data
items. In the called program, by contrast, the code for parts and the part number are combined into one
data item (PART-ID). In the called program, a reference to PART-ID is the only valid reference to these
items.
The first header above indicates that the data items are passed BY VALUE; the second or third headers
indicate that the items are passed BY REFERENCE or BY CONTENT.
Related references
The procedure division header (Enterprise COBOL for z/OS Language Reference)
The USING phrase (Enterprise COBOL for z/OS Language Reference)
CALL statement (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Coding the LINKAGE SECTION” on page 567
Related references
CALL statement (Enterprise COBOL for z/OS Language Reference)
To determine the length of a null-terminated string, and display the value of the string and its length,
code:
568 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
To move a null-terminated string to an alphanumeric string, but delete the null, code:
Related tasks
“Manipulating null-terminated strings” on page 108
Related references
Null-terminated alphanumeric literals
(Enterprise COBOL for z/OS Language Reference)
IF PTR-NEXT-REC = NULL
. . .
(logic for end of chain)
If the program has not reached the end of the list, the program can process the record and move on to the
next record.
The data passed from a calling program might contain header information that you want to ignore.
Because pointer data items are not numeric, you cannot directly perform arithmetic on them. However, to
bypass header information, you can use the SET statement to increment the passed address.
“Example: using pointers to process a chained list” on page 570
Related tasks
“Coding the LINKAGE SECTION” on page 567
“Coding the PROCEDURE DIVISION
for passing arguments” on page 568
Related references
SET statement (Enterprise COBOL for z/OS Language Reference)
The high-level pseudocode for an application that processes these records might be:
The following code contains an outline of the calling program, LISTS, used in this example of processing
a chained list.
IDENTIFICATION DIVISION.
PROGRAM-ID. LISTS.
ENVIRONMENT DIVISION.
DATA DIVISION.
******
WORKING-STORAGE SECTION.
77 PTR-FIRST POINTER VALUE IS NULL. (1)
77 DEPT-TOTAL PIC 9(4) VALUE IS 0.
******
LINKAGE SECTION.
01 SALARY-REC.
02 PTR-NEXT-REC POINTER. (2)
02 NAME PIC X(20).
02 DEPT PIC 9(4).
02 SALARY PIC 9(6).
01 DEPT-X PIC 9(4).
******
PROCEDURE DIVISION USING DEPT-X.
******
* FOR EVERYONE IN THE DEPARTMENT RECEIVED AS DEPT-X,
* GO THROUGH ALL THE RECORDS IN THE CHAINED LIST BASED ON THE
* ADDRESS OBTAINED FROM THE PROGRAM CHAIN-ANCH
* AND ACCUMULATE THE SALARIES.
* IN EACH RECORD, PTR-NEXT-REC IS A POINTER TO THE NEXT RECORD
* IN THE LIST; IN THE LAST RECORD, PTR-NEXT-REC IS NULL.
* DISPLAY THE TOTAL.
******
CALL "CHAIN-ANCH" USING PTR-FIRST (3)
SET ADDRESS OF SALARY-REC TO PTR-FIRST (4)
******
PERFORM WITH TEST BEFORE UNTIL ADDRESS OF SALARY-REC = NULL (5)
IF DEPT = DEPT-X
THEN ADD SALARY TO DEPT-TOTAL
ELSE CONTINUE
END-IF
SET ADDRESS OF SALARY-REC TO PTR-NEXT-REC (6)
END-PERFORM
******
DISPLAY DEPT-TOTAL
GOBACK.
570 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
(1)
PTR-FIRST is defined as a pointer data item with an initial value of NULL. On a successful return from
the call to CHAIN-ANCH, PTR-FIRST contains the address of the first record in the chained list. If
something goes wrong with the call, and PTR-FIRST never receives the value of the address of the
first record in the chain, a null value remains in PTR-FIRST and, according to the logic of the program,
the records will not be processed.
(2)
The LINKAGE SECTION of the calling program contains the description of the records in the chained
list. It also contains the description of the department code that is passed in the USING clause of the
CALL statement.
(3)
To obtain the address of the first SALARY-REC record area, the LISTS program calls the program
CHAIN-ANCH.
(4)
The SET statement bases the record description SALARY-REC on the address contained in PTR-
FIRST.
(5)
The chained list in this example is set up so that the last record contains an address that is not valid.
This check for the end of the chained list is accomplished with a do-while structure where the value
NULL is assigned to the pointer data item in the last record.
(6)
The address of the record in the LINKAGE-SECTION is set equal to the address of the next record by
means of the pointer data item sent as the first field in SALARY-REC. The record-processing routine
repeats, processing the next record in the chained list.
To increment addresses received from another program, you could set up the LINKAGE SECTION and
PROCEDURE DIVISION like this:
LINKAGE SECTION.
01 RECORD-A.
02 HEADER PIC X(12).
02 REAL-SALARY-REC PIC X(30).
. . .
01 SALARY-REC.
02 PTR-NEXT-REC POINTER.
02 NAME PIC X(20).
02 DEPT PIC 9(4).
02 SALARY PIC 9(6).
. . .
PROCEDURE DIVISION USING DEPT-X.
. . .
SET ADDRESS OF SALARY-REC TO ADDRESS OF REAL-SALARY-REC
The address of SALARY-REC is now based on the address of REAL-SALARY-REC, or RECORD-A + 12.
Related tasks
“Using pointers to process a chained list” on page 569
When the called program in the example above successfully returns to its caller, the value in dataname2
is stored into the identifier that was specified in the RETURNING phrase of the CALL statement:
CEEPIPI: The results of specifying PROCEDURE DIVISION RETURNING in programs that are called with
the Language Environment preinitialization service (CEEPIPI) are undefined.
The return value of the called program is stored into dataname2. You must define dataname2 in the DATA
DIVISION of the calling program. The data type of the return value that is declared in the target function
must be identical to the data type of dataname2.
572 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
• You cannot use the name of an EXTERNAL data item as the name for another EXTERNAL item in the
same program.
• You cannot code the VALUE clause for any group item or subordinate item that is EXTERNAL.
In the run unit, any COBOL program or method that has the same data description for the item as the
program that contains the item can access and process that item. For example, suppose program A has
the following data description:
Program B can access that data item if B has the identical data description in its WORKING-STORAGE
SECTION.
Any program that has access to an EXTERNAL data item can change the value of that item. Therefore do
not use this clause for data items that you need to protect.
Related tasks
“Using data in input and output operations” on page 11
Related references
EXTERNAL clause (Enterprise COBOL for z/OS Language Reference)
Name Function
ef1 The main program, which calls all the subprograms and then verifies the contents of a
record area
ef1openo Opens the external file for output and checks the file status code
ef1write Writes a record to the external file and checks the file status code
ef1openi Opens the external file for input and checks the file status code
ef1read Reads a record from the external file and checks the file status code
Select ef1
Assign To ef1
File Status Is efs1
Organization Is Sequential.
Fd ef1 Is External
Record Contains 80 Characters
Recording Mode F.
01 ef-record-1.
02 ef-item-1 Pic X(80).
IDENTIFICATION DIVISION.
Program-Id.
ef1.
*
* This main program controls external file processing.
*
ENVIRONMENT DIVISION.
Input-Output Section.
File-Control.
Copy efselect.
DATA DIVISION.
FILE SECTION.
Copy effile.
WORKING-STORAGE SECTION.
Copy efwrkstg.
PROCEDURE DIVISION.
Call "ef1openo"
Call "ef1write"
Call "ef1close"
Call "ef1openi"
Call "ef1read"
If ef-record-1 = "First record" Then
Display "First record correct"
Else
Display "First record incorrect"
Display "Expected: " "First record"
Display "Found : " ef-record-1
End-If
Call "ef1close"
Goback.
End Program ef1.
IDENTIFICATION DIVISION.
Program-Id.
ef1openo.
*
* This program opens the external file for output.
*
ENVIRONMENT DIVISION.
Input-Output Section.
File-Control.
Copy efselect.
DATA DIVISION.
FILE SECTION.
Copy effile.
574 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
WORKING-STORAGE SECTION.
Copy efwrkstg.
PROCEDURE DIVISION.
Open Output ef1
If efs1 Not = 0
Display "file status " efs1 " on open output"
Stop Run
End-If
Goback.
End Program ef1openo.
IDENTIFICATION DIVISION.
Program-Id.
ef1write.
*
* This program writes a record to the external file.
*
ENVIRONMENT DIVISION.
Input-Output Section.
File-Control.
Copy efselect.
DATA DIVISION.
FILE SECTION.
Copy effile.
WORKING-STORAGE SECTION.
Copy efwrkstg.
PROCEDURE DIVISION.
Move "First record" to ef-record-1
Write ef-record-1
If efs1 Not = 0
Display "file status " efs1 " on write"
Stop Run
End-If
Goback.
End Program ef1write.
Identification Division.
Program-Id.
ef1openi.
*
* This program opens the external file for input.
*
ENVIRONMENT DIVISION.
Input-Output Section.
File-Control.
Copy efselect.
DATA DIVISION.
FILE SECTION.
Copy effile.
WORKING-STORAGE SECTION.
Copy efwrkstg.
PROCEDURE DIVISION.
Open Input ef1
If efs1 Not = 0
Display "file status " efs1 " on open input"
Stop Run
End-If
Goback.
End Program ef1openi.
Identification Division.
Program-Id.
ef1read.
*
* This program reads a record from the external file.
*
ENVIRONMENT DIVISION.
Input-Output Section.
File-Control.
Copy efselect.
DATA DIVISION.
FILE SECTION.
Copy effile.
WORKING-STORAGE SECTION.
Copy efwrkstg.
PROCEDURE DIVISION.
Read ef1
If efs1 Not = 0
Display "file status " efs1 " on read"
Stop Run
End-If
Goback.
End Program ef1read.
Identification Division.
Program-Id.
program_arguments/runtime_options
Related tasks
“Coding the LINKAGE SECTION” on page 567
“Accessing main program parameters under z/OS UNIX” on page 530
Appendix I, “Accessing JCL parameters,” on page 969
Language Environment Programming Guide (Specifying runtime options and
program arguments, Preparing your main routine to receive parameters)
Related references
Language Environment Customization (CBLOPTS (COBOL only))
Language Environment Programming Reference (CEE3PRM, CEE3PR2)
IDENTIFICATION DIVISION.
576 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
PROGRAM-ID. "testarg".
*
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
*
DATA DIVISION.
WORKING-STORAGE SECTION.
*
linkage section.
01 os-parm.
05 parm-len pic s999 comp.
05 parm-string.
10 parm-char pic x occurs 0 to 100 times
depending on parm-len.
*
PROCEDURE DIVISION using os-parm.
display "parm-len=" parm-len
display "parm-string='" parm-string "'"
evaluate parm-string
when "01" display "case one"
when "02" display "case two"
when "95" display "case ninety-five"
when other display "case unknown"
end-evaluate
GOBACK.
Suppose that the CBLOPTS(ON) runtime option is in effect, and that you pass the following argument in
the JCL or TSO command that you use to run the program:
'95/'
parm-len=002
parm-string='95'
case ninety-five
Related concepts
“Dynamic link libraries (DLLs)” on page 579
Related tasks
“Creating a DLL under z/OS UNIX” on page 286
“Compiling programs to create
DLLs” on page 580
“Linking DLLs” on page 581
“Using CALL identifier with DLLs” on page 583
“Using DLL linkage and dynamic calls together” on page 584
“Using COBOL DLLs with C/C++ programs” on page 587
“Using DLLs in OO COBOL
applications” on page 588
“Using procedure or function pointers with DLLs” on page 585
Related references
“PGMNAME” on page 398
MVS Program Management: User's Guide and Reference (Binder support for DLLs)
If a DLL program object includes some programs that are used only from within the DLL module, you can
hide these routines by compiling them with NOEXPORTALL.
“Example: sample JCL for a procedural DLL application” on page 581
Related tasks
“Creating a DLL under z/OS UNIX” on page 286
“Linking DLLs” on page 581
Chapter 30, “Creating a DLL or a DLL
application,” on page 579
Related references
“DLL” on page 363
580 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
“EXPORTALL” on page 369
“LP” on page 383
“RENT” on page 401
Linking DLLs
You can link DLL-enabled object modules into separate DLL program objects, or you can link them
together statically. You can decide whether to package the application as one module or as several DLL
modules at link time.
The DLL support in the z/OS binder is recommended for linking DLL applications. The binder can directly
receive the output of COBOL compilers.
A binder-based DLL must reside in a PDSE or in a z/OS UNIX file.
When using the binder to link a DLL application, use the following options:
You must specify a SYSDEFSD DD statement to indicate the data set in which the binder should create
a DLL definition side file. This side file contains IMPORT control statements for each symbol exported by
a DLL. The binder SYSLIN input (the binding code that references the DLL code) must include the DLL
definition side files for DLLs that are to be referenced from the module being linked.
If there are programs in the module that you do not want to make available with DLL linkage, you can edit
the definition side file to remove these programs.
“Example: sample JCL for a procedural DLL application” on page 581
Related tasks
“Creating a DLL under z/OS UNIX” on page 286
Chapter 30, “Creating a DLL or a DLL
application,” on page 579
“Compiling programs to create
DLLs” on page 580
Related references
MVS Program Management: User's Guide and Reference (Binder support for DLLs)
//DLLSAMP JOB ,
// TIME=(1),MSGLEVEL=(1,1),MSGCLASS=H,CLASS=A,
// NOTIFY=&SYSUID,USER=&SYSUID
// SET LEPFX='SYS1'
//*---------------------------------------------------------------------
//* Compile COBOL subprogram, bind to form a DLL.
//*---------------------------------------------------------------------
//STEP1 EXEC IGYWCL,REGION=80M,GOPGM=DEMODLL,
// PARM.COBOL='RENT,PGMN(LM),DLL,EXPORTALL',
// PARM.LKED='RENT,LIST,XREF,LET,MAP,DYNAM(DLL),CASE(MIXED)'
//COBOL.SYSIN DD *
Identification division.
Program-id. "DemoDLLSubprogram".
Procedure division.
Display "Hello from DemoDLLSubprogram!".
End program "DemoDLLSubprogram".
Identification division.
Program-id. "DemoDLLSub2".
Procedure division.
Display "Hello from DemoDLLSub2!!".
End program "DemoDLLSub2".
/*
//LKED.SYSDEFSD DD DSN=&&SIDEDECK,UNIT=SYSDA,DISP=(NEW,PASS),
// SPACE=(TRK,(1,1))
//LKED.SYSLMOD DD DSN=&&GOSET(&GOPGM),DSNTYPE=LIBRARY,DISP=(MOD,PASS)
//LKED.SYSIN DD DUMMY
//*---------------------------------------------------------------------
//* Compile and bind COBOL main program
//*---------------------------------------------------------------------
//STEP2 EXEC IGYWCL,REGION=80M,GOPGM=MAINPGM,
// PARM.COBOL='RENT,PGMNAME(LM),DLL',
// PARM.LKED='RENT,LIST,XREF,LET,MAP,DYNAM(DLL),CASE(MIXED)'
//COBOL.SYSIN DD *
Identification division.
Program-id. "MainProgram".
Procedure division.
Call "DemoDLLSubprogram"
Call "DemoDLLSub2"
Stop Run.
End program "MainProgram".
/*
//LKED.SYSIN DD DSN=&&SIDEDECK,DISP=(OLD,DELETE)
//*---------------------------------------------------------------------
//* Execute the main program, calling the subprogram DLL.
//*---------------------------------------------------------------------
//STEP3 EXEC PGM=MAINPGM,REGION=80M
//STEPLIB DD DSN=&&GOSET,DISP=(OLD,DELETE)
// DD DSN=&LEPFX..SCEERUN,DISP=SHR
// DD DSN=&LEPFX..SCEERUN2,DISP=SHR
//SYSOUT DD SYSOUT=*
//CEEDUMP DD SYSOUT=*
//DLLSAMP JOB ,
// TIME=(1),MSGLEVEL=(1,1),MSGCLASS=H,CLASS=A,
// NOTIFY=&SYSUID,USER=&SYSUID
// SET LEPFX='SYS1'
//*
// JCLLIB ORDER=(CBC.SCCNPRC) TO FIND EDCCL
//*---------------------------------------------------------------------
//* Compile C subprogram, bind to form a DLL.
//*---------------------------------------------------------------------
//STEP1 EXEC EDCCL,REGION=200M,GOPGM=DEMODLL,
582 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
// PARM.COMPILE='DLL,EXPORTALL,LIST',
// PARM.LKED='RENT,LIST,XREF,LET,MAP,DYNAM(DLL),CASE(MIXED)'
//COMPILE.SYSIN DD *
#include<stdio.h>
void DemoDLLSubprogram(){
printf("Hello from DemoDLLSubprogram!\n");
}
void DemoDLLSub2(){
printf("Hello from DemoDLLSub2!!\n");
}
/*
//LKED.SYSDEFSD DD DSN=&&SIDEDECK,UNIT=SYSDA,DISP=(NEW,PASS),
// SPACE=(TRK,(1,1))
//LKED.SYSLMOD DD DSN=&&GOSET(&GOPGM),DSNTYPE=LIBRARY,DISP=(MOD,PASS)
//LKED.SYSIN DD DUMMY
//*---------------------------------------------------------------------
//* Compile and bind COBOL main program
//*---------------------------------------------------------------------
//STEP2 EXEC IGYWCL,REGION=80M,GOPGM=MAINPGM,
// PARM.COBOL='RENT,PGMNAME(LM),DLL',
// PARM.LKED='RENT,LIST,XREF,LET,MAP,DYNAM(DLL),CASE(MIXED)'
//COBOL.SYSIN DD *
Identification division.
Program-id. "MainProgram".
Procedure division.
Call "DemoDLLSubprogram"
Call "DemoDLLSub2"
Stop Run.
End program "MainProgram".
/*
//LKED.SYSIN DD DSN=&&SIDEDECK,DISP=(OLD,DELETE)
//*---------------------------------------------------------------------
//* Execute the main program, calling the subprogram DLL.
//*---------------------------------------------------------------------
//STEP3 EXEC PGM=MAINPGM,REGION=80M
//STEPLIB DD DSN=&&GOSET,DISP=(OLD,DELETE)
// DD DSN=&LEPFX..SCEERUN,DISP=SHR
// DD DSN=&LEPFX..SCEERUN2,DISP=SHR
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//CEEDUMP DD SYSOUT=*
Related tasks
“Using DLL linkage and dynamic calls together” on page 584
Related references
“DLL” on page 363
“PGMNAME” on page 398
CALL statement (Enterprise COBOL for z/OS Language Reference)
“Search order for DLLs in the z/OS UNIX file system” on page 584
Related tasks
“Using CALL identifier with DLLs” on page 583
Related references
Language Environment Programming Reference (POSIX)
584 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Related concepts
“Dynamic link libraries (DLLs)” on page 579
Related tasks
“Compiling programs to create
DLLs” on page 580
“Linking DLLs” on page 581
“Using procedure or function pointers with DLLs” on page 585
“Calling DLLs from non-DLLs” on page 585
Related references
“DLL” on page 363
“EXPORTALL” on page 369
CALLINTERFACE (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Using CALL identifier with DLLs” on page 583
“Using procedure and function pointers” on page 557
“Compiling programs to create
DLLs” on page 580
“Linking DLLs” on page 581
Related references
“DLL” on page 363
“EXPORTALL” on page 369
CALLINTERFACE (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Using procedure and function pointers” on page 557
CBL NODYNAM
IDENTIFICATION DIVISION.
PROGRAM-ID. 'COBOL1'.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
01 DLL-INFO.
03 DLL-LOADMOD-NAME PIC X(12).
03 DLL-PROGRAM-NAME PIC X(160).
03 DLL-PROGRAM-HANDLE FUNCTION-POINTER.
77 DLL-RC PIC S9(9) BINARY.
77 DLL-STATUS PIC X(1) VALUE 'N'.
88 DLL-LOADED VALUE 'Y'.
88 DLL-NOT-LOADED VALUE 'N'.
PROCEDURE DIVISION.
IF DLL-NOT-LOADED
THEN
* Move the names in. They must be null terminated.
MOVE Z'OOC05R' TO DLL-LOADMOD-NAME
MOVE Z'ooc05r' TO DLL-PROGRAM-NAME
GOBACK.
#include <stdio.h>
#include <dll.h>
#pragma linkage (A1CCDLGT,COBOL)
586 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
typedef struct dll_lm {
char dll_loadmod_name[(12]);
char dll_func_name[(160]);
void (*fptr) (void); /* function pointer */
} dll_lm;
Identification Division.
Program-id. Demo.
Data Division.
Working-Storage section.
01 fp usage function-pointer.
Procedure Division.
Call "c-function" returning fp.
Call fp.
Related tasks
“Compiling programs to create
DLLs” on page 580
“Linking DLLs” on page 581
Related references
“DLL” on page 363
“EXPORTALL” on page 369
“RENT” on page 401
Related tasks
Chapter 16, “Compiling, linking, and running OO applications,” on page 291
“Compiling programs to create
DLLs” on page 580
“Linking DLLs” on page 581
Related references
“DLL” on page 363
“THREAD” on page 418
“RENT” on page 401
“DBCS” on page 360
588 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Chapter 31. Preparing COBOL programs for
multithreading
You can run COBOL programs in multiple threads within a process under batch, TSO, IMS, or z/OS UNIX.
There is no explicit COBOL language to use for multithreaded execution; rather, you compile with the
THREAD compiler option.
COBOL does not directly support managing program threads. However, you can run COBOL programs
that you compile with the THREAD compiler option in multithreaded application servers, in applications
that use a C/C++ driver program to create the threads, in programs that interoperate with Java and
use Java threads, and in applications that use PL/I tasking. In other words, other programs can call
COBOL programs in such a way that the COBOL programs run in multiple threads within a process or as
multiple program invocation instances within a thread. Your threaded application must run within a single
Language Environment enclave.
Choosing LOCAL-STORAGE or WORKING-STORAGE: Because you must code your multithreaded programs
as recursive, the persistence of data is that of any recursive program:
• Data items in the LOCAL-STORAGE SECTION are automatically allocated for each instance of a
program invocation. When a program runs in multiple threads simultaneously, each invocation has a
separate copy of LOCAL-STORAGE data.
• Data items in the WORKING-STORAGE SECTION are allocated once for each program and are thus
available in their last-used state to all invocations of the program.
For the data that you want to isolate to an individual program invocation instance, define the data in the
LOCAL-STORAGE SECTION. In general, this choice is appropriate for working data in threaded programs.
If you define data in WORKING-STORAGE and your program changes the contents of the data, you must
take one of the following actions:
• Structure your application so that you do not access data in WORKING-STORAGE simultaneously from
multiple threads.
• If you do access data simultaneously from separate threads, write appropriate serialization code.
Related concepts
“Multithreading” on page 589
Related tasks
“Choosing THREAD to support multithreading” on page 590
“Transferring control to multithreaded programs” on page 591
“Ending multithreaded programs” on page 591
“Processing files with multithreading” on page 592
“Handling COBOL limitations with multithreading” on page 594
Related references
“THREAD” on page 418
PROGRAM-ID paragraph (Enterprise COBOL for z/OS Language Reference)
Multithreading
To use COBOL support for multithreading, you need to understand how processes, threads, run units, and
program invocation instances relate to each other.
The operating system and multithreaded applications can handle execution flow within a process, which
is the course of events when all or part of a program runs. Programs that run within a process can share
resources. Processes can be manipulated. For example, they can have a high or low priority in terms of
the amount of time that the system devotes to running the process.
Related concepts
Language Environment Programming Guide (Program management model,
Understanding the basics: threads)
Related tasks
“Choosing THREAD to support multithreading” on page 590
“Transferring control to multithreaded programs” on page 591
“Ending multithreaded programs” on page 591
“Processing files with multithreading” on page 592
“Handling COBOL limitations with multithreading” on page 594
Related references
“THREAD” on page 418
590 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Use the THREAD option when you compile object-oriented (OO) clients and classes.
Language restrictions: When you use the THREAD option, you cannot use certain language elements. For
details, see the related reference below.
Recursion: Before you compile a program using the THREAD compiler option, you must specify the
RECURSIVE phrase in the PROGRAM-ID paragraph. If you do not do so, an error will occur.
Related tasks
“Sharing data in recursive
or multithreaded programs” on page 16
“Compiling OO applications under z/OS UNIX” on page 291
Related references
“THREAD” on page 418
Related concepts
Language Environment Programming Guide (What happens during termination:
enclave termination)
Related tasks
“Ending multithreaded programs” on page 591
“Ending and reentering main programs or subprograms” on page 546
Related concepts
Language Environment Programming Guide (What happens during termination:
enclave termination)
Related tasks
“Ending and reentering main programs or subprograms” on page 546
Automatic serialization is not applied to any statements specified within the following conditional
phrases:
• AT END
• NOT AT END
• INVALID KEY
• NOT INVALID KEY
• AT END-OF-PAGE
• NOT AT END-OF-PAGE
Related concepts
“File-definition (FD) storage” on page 592
Related tasks
“Closing QSAM files” on page 179
“Closing VSAM files” on page 203
“Coding ERROR declaratives” on page 246
“Serializing file access with multithreading” on page 593
All threads of execution share this storage. You can depend on automatic serialization for this storage
during the execution of the OPEN, CLOSE, READ, WRITE, REWRITE, START, and DELETE statements, but
not between uses of these statements.
Related tasks
“Serializing file access with multithreading” on page 593
592 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Serializing file access with multithreading
To take full advantage of automatic serialization and to avoid explicitly writing your own serialization logic,
use one of the recommended file organizations and usage patterns when you access files in threaded
programs.
OPEN INPUT fn
. . .
READ fn INTO local-storage-item
. . .
* Process the record from the local-storage item
. . .
CLOSE fn
OPEN OUTPUT fn
. . .
* Construct output record in local-storage item
. . .
WRITE rec FROM local-storage-item
. . .
CLOSE fn
With other usage patterns, you must take one of the following actions:
• Verify the safety of your application logic. Ensure that two instances of the program are never
simultaneously active on different threads.
• Code explicit serialization logic by using calls to POSIX services.
To avoid serialization problems when you access a file from multiple threads, define the data items that
are associated with the file (such as file-status data items and key arguments) in the LOCAL-STORAGE
SECTION.
“Example: usage patterns of file input and output with multithreading” on page 593
Related tasks
“Calling UNIX/POSIX APIs” on page 528
READ F1
. . .
REWRITE R1
In the example above, the second thread might execute the READ statement after the READ statement
is executed on the first thread but before the REWRITE statement is executed on the first thread. The
READ F1
. . .
* Process the data in the FD record description entry for F1
. . .
In the example above, the second thread might execute the READ statement while the first thread is still
processing a record in the FD record description entry. The second READ statement would overlay the
record that the first thread is processing. To avoid this problem, use the recommended technique:
Other cases: You must give similar consideration to other usage patterns that involve a sequence of
related input and output operations, such as START followed by READ NEXT, or READ followed by
DELETE. Take appropriate steps to ensure the correct processing of file input and output.
594 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
AMODE: You must run your multithreaded applications with AMODE 31. You can run a COBOL program
that has been compiled with the THREAD option with AMODE 24 as part of an application that does not
have multiple threads or PL/I tasks.
Asynchronous signals: In a threaded application your COBOL program might be interrupted by an
asynchronous signal or interrupt. If your program contains logic that cannot tolerate such an interrupt,
you must disable the interrupts for the duration of that logic. Call a C/C++ function to set the signal mask
appropriately.
Older COBOL programs: To run your COBOL programs on multiple threads of a multithreaded application,
you must compile them with Enterprise COBOL and use the THREAD option. Run applications that contain
programs compiled by older compilers only on one thread.
IGZETUN and IGZEOPT: Do not use the modules IGZETUN (for storage tuning) or IGZEOPT (for runtime
options) for applications in which the main program has been compiled with the THREAD option; these
CSECTs are ignored.
UPSI switches: All programs and all threads in an application share a single copy of UPSI switches. If you
modify switches in a threaded application, you must code appropriate serialization logic.
Related tasks
“Making recursive calls” on page 557
“Serializing file access with multithreading” on page 593
XL C/C++ Programming Guide (Using threads in z/OS UNIX System Services
applications)
Language Environment Writing ILC Communication Applications
program definition
Note: Currently, the SQL, CICS, and JAVAIOP facilities cannot be used with user-defined functions due to
the need to include the user-defined function definition ahead of the program using them.
Identification division.
Function-id. docalc.
Data division.
Linkage section.
1 kind pic x(3).
Related references
FUNCTION-ID paragraph (Enterprise COBOL for z/OS Language Reference)
Identification division.
Function-id. docalc.
Data division.
Linkage section.
1 kind pic x(3).
1 argA pic 999.
1 argB pic v999.
1 res pic 999v999.
Procedure division
using by reference kind argA argB
returning res.
if kind equal "add" then
compute res = argA + argB
end-if
goback.
End function docalc.
Identification division.
Program-id. 'mainprog'.
Environment division.
Configuration section.
Repository.
function docalc.
Data division.
Working-storage section.
1 result pic 999v999 usage display.
Procedure division.
compute result = docalc("add" 10 0.23)
display "hello from mainprog, result=" result
goback.
End program 'mainprog'.
598 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
hello from mainprog, result=010230
Identification division.
Function-id. docalc as 'XYZCALC'.
Data division.
Linkage section.
1 kind pic x(3).
1 argA pic 999.
1 argB pic v999.
1 res pic 999v999.
Procedure division
using by reference kind argA argB
returning res.
if kind equal "add" then
compute res = argA + argB
end-if
goback.
End function docalc.
Identification division.
Function-id. docalc.
The CONTENT-OF intrinsic function produces a temporary copy of the input argument. The temporary
copy is then provided BY REFERENCE to the user-defined function and any modifications to the formal
parameter within the user-defined function definition are effectively made to the temporary copy.
Related references
CONTENT-OF intrinsic function (Enterprise COBOL for z/OS Language Reference)
600 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Chapter 33. Using function prototypes
Function prototypes enable you to invoke COBOL user-defined functions in the following ways.
• Enable you to invoke COBOL user-defined functions or non-COBOL external functions such as C
functions using the FUNCTION keyword.
• Enable you to invoke user-defined functions whose definitions are written in other files such as
compilation groups.
• Enable you to invoke user-defined functions with a linkage interface (such as STATIC, DYNAMIC, or
DLL) that was specified on the prototype using the ENTRY-INTERFACE phrase of the FUNCTION-ID
paragraph.
The function prototype definition is a stand-alone compilation unit that, when compiled, produces no
object code but rather informs the compiler about a function prototype. When the compiler subsequently
encounters an invocation to the function, the compiler is able to perform conformance checking as well as
generate the correct calling code for the specified linkage interface. Function prototype definitions must
appear within the compilation group before any invocations to the function. Therefore it is recommended
that all function prototypes appear first, before program and user-defined function definitions.
Identification division.
Function-id. myfunc is prototype.
Data division.
Linkage section.
1 retval pic 9(9).
Procedure division returning retval.
End function myfunc.
**********************************
Identification division.
Program-id. myprog.
Data division.
Working-storage section.
1 a pic 9(9).
Procedure division.
compute a = function myfunc
goback.
End program myprog.
**********************************
Identification division.
Function-id. myfunc.
Data division.
Linkage section.
1 parm1 pic x(10).
1 retval pic 9(9).
Procedure division returning retval.
compute retval = 0
goback.
End function myfunc.
Identification division.
Function-id. GetRecord as 'QQGETREC' is prototype.
Data division.
Linkage section.
1 retval pic x(100).
Procedure division returning retval.
End function GetRecord.
**********************************
Identification division.
Program-id. myprog.
Data division.
Working-storage section.
1 a pic x(100).
Procedure division.
move function GetRecord to a
goback.
End program myprog.
"GetRecord" might then be defined in another batch compilation as the following user-defined function:
Identification division.
Function-id. GetRecord as 'QQGETREC'.
Data division.
Linkage section.
1 retval pic x(100).
Procedure division returning retval.
move "data" to retval
goback.
End function GetRecord.
Suppose instead of "QQGETREC", you choose "abc123Get_Customer_Record". To use this external name,
you need to use either the PGMNAME compiler option or the ENTRY-NAME phrase of the FUNCTION-ID
paragraph as in the following example:
Identification division.
Function-id. GetRecord as 'abc123Get_Customer_Record' is prototype
entry-name is longmixed.
Data division.
Linkage section.
1 retval pic x(100).
Procedure division returning retval.
End function GetRecord.
**********************************
Identification division.
Program-id. myprog.
Data division.
Working-storage section.
1 a pic x(100).
Procedure division.
move function GetRecord to a
goback.
End program myprog.
Identification division.
Function-id. GetRecord is prototype.
Data division.
Linkage section.
1 retval pic x(100).
602 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Procedure division returning retval.
End function GetRecord.
This copybook is included along with the user-defined function definition in another compilation group.
Copy GETREC.
Identification division.
Function-id. GetRecord.
Data division.
Linkage section.
1 retval pic x(100).
Procedure division returning retval.
move "data" to retval
goback.
End function GetRecord.
The copybook is also included in any compilation group where "GetRecord" is invoked.
Copy GETREC.
Identification division.
Program-id. myprog.
Data division.
Working-storage section.
1 a pic x(100).
Procedure division.
move function GetRecord to a
goback.
End program myprog.
Related tasks
Chapter 35, “Processing JSON input ,” on page 609
Chapter 36, “Producing JSON output ,” on page 619
Chapter 37, “Processing XML input,” on page 623
Chapter 38, “Producing XML output,” on page 663
Identification division.
Program-id. jparse1.
Data division.
Working-storage section.
1 msg.
4 ver usage comp-1.
4 uid pic 9999 usage display.
4 txt pic x(32).
Linkage section.
1 json-text pic x(128).
Procedure division using json-text.
Json parse json-text into msg
end-json.
If ver equal to 5 then
display "Message ID is " uid
display "Message text is '" txt "'".
Goback.
End program jparse1.
The JSON PARSE statement above identifies data item json-text as the UTF-8 encoded source of JSON
text, and data item msg-data as the receiver of the JSON values.
Assuming that data item json-text contains:
{"msg":{"ver":5,"uid":1000,"txt":"Hello World!"}}
How to match JSON names that are not valid COBOL data names to
data items
JSON allows many more characters and types of characters to appear in JSON names than COBOL allows
in data names. To facilitate the match of JSON names with COBOL data names, you can use the NAME
phrase on the JSON PARSE statement. Consider the following JSON text.
{"abc+":100}
The JSON name abc+ is not a valid COBOL data name but you can use the NAME phrase to match it to
a valid COBOL data name. The following COBOL program illustrates how to parse that JSON text into a
COBOL data item.
Identification division.
Program-id. name1.
Data division.
Working-storage section.
1 mydata pic 999.
Linkage section.
1 json-text pic x(128).
Procedure division using json-text.
Json parse json-text into mydata
name of mydata is "abc+"
end-json.
Display "mydata is " mydata.
Goback.
End program name1.
Notice the use of the NAME phrase. Executing the program produces the following output:
mydata is 100
There are several important details to consider from the above example:
• Characters appearing in literal-1 on the NAME phrase are assumed to be encoded using the CCSID of
the CODEPAGE compiler option in effect.
• Characters appearing in literal-1 will be matched to the JSON names in a case-sensitive manner, unlike
COBOL data names which are matched in a case-insensitive manner.
• The NAME phrase, in aggregate, must not result in an ambiguous name specification1.
1. For more details about ambiguous name specifications, see the "NAME phrase" of the JSON PARSE
statement in the Enterprise COBOL Language Reference.
Identification division.
Program-id. supp1.
Data division.
Working-storage section.
1 msg.
4 ver usage comp-1.
4 uid pic 9999 usage display.
4 txt pic x(32).
Linkage section.
1 json-text pic x(128).
610 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Procedure division using json-text.
Move 2 to uid.
Json parse json-text INTO msg
SUPPRESS uid
end-json.
If ver equal to 5 then
display "Message ID is " uid
display "Message text is '" txt "'".
Goback.
End program supp1.
Notice that the data item uid has been set in the program to the value 2 and we wish to suppress its
assignment in the JSON PARSE statement using the SUPPRESS phrase. Assuming the incoming JSON text
in data item json-text contains:
{"msg":{"ver":5,"uid":10,"txt":"Hello"}}
Message ID is 0002
Message text is 'Hello'
The data item uid retained the value 2 instead of being populated with the value 10.
{"some-data":{"msg":[{"ver":5,"uid":10,"txt":"Hello"},
{"ver":5,"uid":11,"txt":"World"},{"ver":5,"uid":12,"txt":"!"}]}}
Following is a COBOL program that parses this JSON text using a fixed occurrence table with the OCCURS
clause.
Identification division.
Program-id. occ1.
Data division.
Working-storage section.
1 some-data.
2 msg occurs 3.
4 ver usage comp-1.
4 uid pic 9999 usage display.
4 txt pic x(32).
Linkage section.
1 json-text pic x(128).
Procedure division using json-text.
Json parse json-text into some-data
end-json.
If ver(1) equal to 5 then
Display "Message ID is " uid(1)
Display "Message text is '" txt(1) "'".
If ver(2) equal to 5 then
Display "Message ID is " uid(2)
Display "Message text is '" txt(2) "'".
If ver(3) equal to 5 then
Display "Message ID is " uid(3)
Display "Message text is '" txt(3) "'".
Goback.
End program occ1.
Message ID is 0010
Message text is 'Hello '
Message ID is 0011
Message text is 'World '
Message ID is 0012
Message text is '! '
Identification division.
Program-id. odo1.
Data division.
Working-storage section.
1 i pic 9.
1 n pic 9.
1 t pic x(128).
1 msg_count pic 9.
1 some-data.
2 msg occurs 0 to 5 depending on n.
4 ver usage comp-1.
4 uid pic 9999 usage display.
4 txt pic x(32).
Linkage section.
1 json-text pic x(128).
Procedure division using json-text.
Main section.
Move 4 to n.
Move 0 to ver(1).
Move 0 to ver(2).
Move 0 to ver(3).
Move 0 to ver(4).
Json parse json-text into some-data
end-json.
Perform disp_msg varying i from 1 by 1 until i > n.
Display "Message count: " msg_count.
Goback.
Disp_msg section.
If ver(i) equal to 5 then
display "Message ID is " uid(I)
display "Message text is '" txt(I) "'"
add 1 to msg_count
else
display "Invalid Message Version, ID is " uid(I).
End program odo1.
Message ID is 0010
Message text is 'Hello '
Message ID is 0011
Message text is 'World '
Message ID is 0012
Message text is '! '
Invalid Message Version, ID is 0001
Message count: 3
Note that subordinate data items of table element msg(4) are not assigned by the JSON PARSE statement
because the JSON text does not contain a fourth table entry for the msg table. Also the OCCURS
DEPENDING ON object, defined in this example as n must not be subordinate to data item some-data
and needs to be given a value before the JSON PARSE statement receives program control. The value
of the OCCURS DEPENDING ON object is the maximum number of table elements that the JSON PARSE
statement may populate. If, in the JSON text, there are more table elements than the value of the
OCCURS DEPENDING ON object, then those table elements are ignored and the condition is indicated in
the JSON-STATUS special register. The OCCURS DEPENDING ON object is not set or updated by the JSON
PARSE statement.
Identification division.
Program-id. myprog.
Data division.
Working-storage section.
1 ACT.
2 B1 occurs 2.
3 C1.
612 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
4 M1 pic 9.
4 D1 occurs 2.
5 N1 pic 9.
1 json-text pic u dynamic.
Procedure division.
move spaces to ACT
move '[{"C1":{"M1":1,"D1":[{"N1":3},{"N1":4}]}},
- '{"C1":{"M1":2,"D1":[{"N1":5},{"N1":6}]}}]"'
to json-text
json parse json-text into b1
name b1 is omitted
end-json
display M1(1)
display M1(2)
display N1(1 1)
display N1(1 2)
display N1(2 1)
display N1(2 2)
goback
.
End program myprog.
1
2
3
4
5
6
Note that the JSON PARSE receiver b1 was not subscripted in order to refer to all occurrences of b1.
Consider the next example where the table b1 has two dimensions and is nested within another table like
below:
Identification division.
Program-id. myprog.
Data division.
Working-storage section.
1 ACT.
2 TOPTABLE occurs 3.
3 B1 occurs 2.
4 C1.
5 M1 pic 9.
5 D1 occurs 2.
6 N1 pic 9.
1 json-text pic u dynamic.
Procedure division.
move spaces to ACT
move '[{"C1":{"M1":1,"D1":[{"N1":3},{"N1":4}]}},
- '{"C1":{"M1":2,"D1":[{"N1":5},{"N1":6}]}}]"'
to json-text
json parse json-text into b1(2)
name b1 is omitted
end-json
display M1(2 1)
display M1(2 2)
display N1(2 1 1)
display N1(2 1 2)
display N1(2 2 1)
display N1(2 2 2)
goback
.
End program myprog.
1
2
3
4
5
6
Note that b1(2) was specified with a single index subscript on the JSON PARSE statement. The value of
the subscript 2 indicates that the second occurrence of table TOPTABLE shall be populated. The omission
`Identification division.`
Program-id. myprog.
Data division.
Working-storage section.
1 json-text pic u dynamic.
1 A.
2 B-data PIC X(10).
Procedure division.
move all 'z' to B-data
move u'{"A":{"B-data":null}}' to json-text
json parse json-text into A
converting B-data from json null using space
display "B-data: '" B-data "'"
goback.
End program myprog.
When compiled and run, the JSON PARSE statement encounters "B-data":null so SPACE is effectively
moved into B-data, and indeed the output of this program is as follows:
Note that not all items can be used on the CONVERTING phrase due to the MOVE compatibility rules.
`Identification division.`
Program-id. myprog.
Data division.
Working-storage section.
1 json-text pic u dynamic.
1 A.
2 B-data pic x(10).
2 B-indicator pic x.
Procedure division.
614 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
move all 'z' to A.
move u'{"A":{"B-data":null}}' to json-text
json parse json-text into A
indicating B-data is json null
using 'Y' and 'N' in B-indicator
display "B-data: '" B-data "'"
display "B-indicator: " B-indicator
goback.
End program myprog.
When compiled and run, the JSON PARSE statement encounters "B-data":null and hence populates
B-indicator with 'Y', as can be seen in the program output:
B-data: 'zzzzzzzzzz'
B-indicator: Y
Identification division.
Program-id. jp_ex.
Data division.
Working-storage section.
1 jtxt-1047-client-data.
3 pic x(16) value '{"client-data":{'.
3 pic x(28) value ' "account-num":123456789012,'.
3 pic x(19) value ' "balance":-125.53,'.
3 pic x(17) value ' "billing-info":{'.
3 pic x(22) value ' "name-first":"John",'.
3 pic x(22) value ' "name-last":"Smith",'.
3 pic x(37) value ' "addr-street":"12345 First Avenue",'.
3 pic x(25) value ' "addr-city":"New York",'.
3 pic x(27) value ' "addr-region":"New York",'.
3 pic x(21) value ' "addr-code":"10203"'.
3 pic x(3) value ' }'.
3 pic x(2) value ' }'.
3 pic x(1) value '}'.
1 jtxt-1047-transactions.
3 pic x(16) value '{"transactions":'.
3 pic x(14) value ' {"tx-record":'.
3 pic x(3) value ' ['.
3 pic x(4) value ' {'.
3 pic x(19) value ' "tx-uid":107,'.
3 pic x(34) value ' "tx-item-desc":"prod a ver 1",'.
3 pic x(30) value ' "tx-item-uid":"ab142424",'.
3 pic x(26) value ' "tx-priceinUS$":12.34,'.
3 pic x(35) value ' "tx-comment":"express shipping"'.
3 pic x(5) value ' },'.
3 pic x(4) value ' {'.
3 pic x(19) value ' "tx-uid":1904,'.
3 pic x(35) value ' "tx-item-desc":"prod g ver 2",'.
3 pic x(30) value ' "tx-item-uid":"gb051533",'.
3 pic x(27) value ' "tx-priceinUS$":833.22,'.
3 pic x(35) value ' "tx-comment":"digital download"'.
3 pic x(5) value ' } '.
3 pic x(3) value ' ]'.
3 pic x(2) value ' }'.
3 pic x(1) value '}'.
1 jtxt-1208 pic x(1000) value is all x'20'.
77 txnum pic 999999 usage display value zero.
1 client-data.
3 account-num pic 999,999,999,999.
3 balance pic $$$9.99CR.
3 billing-info.
5 name-first pic n(20).
5 name-last pic n(20).
5 addr-street pic n(20).
5 addr-city pic n(20).
5 addr-region pic n(20).
5 addr-code pic n(10).
3 transactions.
Move 2 to txnum.
Initialize jtxt-1208 all value.
Move function display-of(
function national-of(
jtxt-1047-transactions) 1208)
to jtxt-1208(1:function length(jtxt-1047-transactions)).
Display "Transactions:"
Display " Record 1:"
Display " TXID: " tx-uid(1)
Display " Description: " tx-item-desc(1)
Display " Item ID: " tx-item-uid(1)
Display " Price: " tx-price(1)
Display " Comment: "
function display-of(tx-comment(1))
Display " Record 2:"
Display " TXID: " tx-uid(2)
Display " Description: " tx-item-desc(2)
Display " Item ID: " tx-item-uid(2)
Display " Price: " tx-price(2)
Display " Comment: "
function display-of(tx-comment(2))
Goback.
End program jp_ex.
616 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
$125.53CR
Client Information:
Name:
Smith
John
Address:
12345 First Avenue
New York
New York
10203
Successful JSON Parse
Transactions:
Record 1:
TXID: 00107
Description: prod a ver 1
Item ID: ab/1424 24
Price: $12.34
Comment: express shipping
Record 2:
TXID: 01904
Description: prod g ver 2
Item ID: gb/0515 33
Price: $833.22
Comment: digital download
Related references
JSON PARSE statement (Enterprise COBOL for z/OS Language Reference)
01 Greeting.
02 Msg pic x(80) value 'Hello, World!'.
01 Jtext national pic n(80).
01 i binary pic 99.
...
JSON generate Jtext from Greeting count in i
on exception
display 'JSON generation error: ' json-code
not on exception
display function display-of(Jtext(1:i))
End-JSON
{"Greeting":{"msg":"Hello, World!"}}
The following example is more complex which illustrates optional phrases that:
• Provide alternative JSON names for the included data items (NAME)
• Allow you to exclude sensitive or unwanted information from the output (SUPPRESS)
01 GRP.
05 Ac-No PIC AA9999 value 'SX1234'.
05 More.
10 Stuff PIC S99V9 OCCURS 2.
05 SSN PIC 999/99/9999 value '987-65-4321'.
01 d pic x(80).
01 i binary pic 99.
...
move 7.8 to stuff(1), move -9 to stuff(2)
JSON generate d from grp count i
NAME of stuff is 'Value' SUPPRESS ssn
display function display-of(function national-of(
d(1:i) 1208))
{"GRP":{"Ac-No":"SX1234","More":{"Value":[7.8,-9.0]}}}
Running the program will produce the following JSON text in the item json-text:
[{"C1":{"M1":1,"D1":[{"N1":3},{"N1":4}]}},{"C1":{"M1":2,"D1":[{"N1":5},{"N1":6}]}}]
Note that the JSON GENERATE sender b1 was not subscripted in order to refer to all occurrences of b1.
Consider the next example where the table b1 has two dimensions and is nested within another table like
below:
Identification division.
Program-id. myprog.
Data division.
Working-storage section.
1 ACT.
2 TOPTABLE occurs 3.
3 B1 occurs 2.
4 C1.
5 M1 pic 9.
5 D1 occurs 2.
6 N1 pic 9.
1 json-text pic u dynamic.
Procedure division.
move 1 to M1(1 1)
move 2 to M1(1 2)
move 3 to N1(1 1 1)
move 4 to N1(1 1 2)
move 5 to N1(1 2 1)
move 6 to N1(1 2 2)
move spaces to json-text
json generate json-text from b1(1)
name b1 is omitted
end-json
goback
.
End program myprog.
Running the program will produce the following JSON text in the item json-text:
[{"C1":{"M1":1,"D1":[{"N1":3},{"N1":4}]}},{"C1":{"M1":2,"D1":[{"N1":5},{"N1":6}]}}]
Note that b1(1) was specified with a single index subscript on the JSON GENERATE statement. The value
of the subscript 1 indicates that the first occurrence of table TOPTABLE shall be generated. The omission
of a second index indicates to the JSON GENERATE statement that the statement shall operate on the
entire table b1 (rather than operating on a single occurrence of b1, which is what would have occurred if a
second index subscript was specified). This pattern applies generally to multiple nested tables, that is, an
anonymous array can be generated by the combination of the NAME IS OMITTED phrase and specifying
the sending item with one less subscript than its dimension.
620 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Generating JSON null values
This section describes the ways to generate JSON null values using the JSON GENERATE statement.
You can use either of the following ways to generate JSON null values:
• Using the CONVERTING phrase to convert certain values of COBOL data items to JSON null.
• Using the INDICATING phrase to assign a satellite data item as a null indicator.
Details of each way are as follows.
CBL CODEPAGE(1047)
Identification division.
Program-id. myprog.
Data division.
Working-storage section.
1 json-text pic u dynamic.
1 A.
2 B-data PIC X(10).
Procedure division.
move space to B-data
set length of json-text to 0
json generate json-text from A
converting B-data to json null using space
display function display-of(json-text 1047)
goback.
End program myprog.
When compiled and run, the JSON GENERATE statement converts B-data to a JSON null when B-data
contains spaces. The output of the program is as follows:
{"A":{"B-data":null}}
Note that not all items can be specified on the CONVERTING phrase due to the MOVE compatibility rules.
`CBL CODEPAGE(1047)`
Identification division.
Program-id. myprog.
Data division.
Working-storage section.
1 json-text pic u dynamic.
1 A.
2 B-data pic x(10).
2 B-indicator pic x.
Procedure division.
move "Y" to B-indicator
json generate json-text from A
indicating B-data is json null
using 'Y' in B-indicator
display function display-of(json-text 1047)
goback.
End program myprog.
When compiled and run, the JSON GENERATE statement generates a JSON null if B-indicator contains
'Y', as specified on the INDICATING phrase. The output of the program is as follows:
{"A":{"B-data":null}}
Related concepts
“XML parser in COBOL” on page 624
Related tasks
“Accessing XML documents” on page 625
Related references
“XMLPARSE” on page 425 (compiler option)
Normally, parsing continues until the entire XML document has been parsed.
624 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
The XML parser checks XML documents for most aspects of well formedness. A document is well formed if
it adheres to the XML syntax in the XML specification and follows some additional rules such as proper use
of end tags and uniqueness of attribute names.
When you parse an XML document with validation against an XML schema, the z/OS XML System Services
parser additionally verifies that the XML document adheres to the content and structure prescribed in
the schema. For example, the parser checks that there are no unexpected elements or attributes, that no
required elements or attributes are missing, and that any values of elements or attributes are legal.
Related concepts
“XML schemas” on page 636
“XML input document encoding” on page 641
Related tasks
“Parsing XML documents” on page 625
“Parsing XML documents with validation” on page 634
“Handling XML PARSE exceptions” on page 645
“Terminating XML parsing” on page 649
Related references
“The encoding of XML documents” on page 640
XML specification
Related tasks
“Coding COBOL programs to run under CICS” on page 495
Chapter 24, “Developing COBOL programs for IMS,” on page 517
“Parsing XML documents one segment at a time” on page 637
Related references
“XMLPARSE” on page 425 (compiler option)
In the XML PARSE statement, you first identify the parse data item (xml-document in the example
above) that contains the XML document character stream. In the DATA DIVISION, define the parse data
item as an elementary data item of category national or as a national group item if the encoding of the
document is Unicode UTF-16; otherwise, define the parse data item as an elementary alphanumeric data
item or an alphanumeric group item:
• If the parse data item is national, the XML document must be encoded in UTF-16, CCSID 1200.
• If the parse data item is alphanumeric, its content must be encoded in one of the supported code pages
described in the related reference about the encoding of XML documents.
Next, specify the name of the processing procedure (xml-event-handler in the example above) that is
to handle the XML events that occur during parsing of the document.
If the XMLPARSE(XMLSS) compiler option is in effect, you can also use any of these optional phrases of
the XML PARSE statement:
• ENCODING, to specify the CCSID of the document
• RETURNING NATIONAL, to cause the parser to automatically convert UTF-8 or single-byte characters
to national characters for return to the processing procedure
• VALIDATING, to cause the parser to validate the document against an XML schema
In addition, you can specify either or both of the following optional phrases (as shown in the fragment
above) to indicate the action to be taken after parsing finishes:
• ON EXCEPTION, to receive control if an unhandled exception occurs during parsing
• NOT ON EXCEPTION, to receive control otherwise
You can end the XML PARSE statement with the explicit scope terminator END-XML. Use END-XML to nest
an XML PARSE statement that uses the ON EXCEPTION or NOT ON EXCEPTION phrase in a conditional
statement.
The parser passes control to the processing procedure for each XML event. Control returns to the parser
at the end of the processing procedure. This exchange of control between the XML parser and the
processing procedure continues until one of the following events occurs:
• The entire XML document was parsed, as indicated by the END-OF-DOCUMENT event.
• If XMLPARSE(XMLSS) is in effect, either:
– The parser detects an error in the document and signals an EXCEPTION event (regardless of the kind
of exception).
– The parser signals an END-OF-INPUT event, and the processing procedure returns to the parser with
special register XML-CODE still set to zero, which indicates that no further XML data will be provided
to the parser.
• If XMLPARSE(COMPAT) is in effect, either:
– The parser signals an encoding conflict EXCEPTION event, and the processing procedure does not
reset special register XML-CODE to zero or to the correct CCSID before returning to the parser.
– The parser detects an error in the document and signals an EXCEPTION event (other than an
encoding conflict), and the processing procedure does not reset special register XML-CODE to zero
before returning to the parser.
• The parsing process is terminated deliberately by the user's code in the processing procedure that sets
the XML-CODE special register to -1 before it returns to the parser.
626 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Related concepts
“XML events” on page 629
“XML-CODE” on page 630
“XML schemas” on page 636
“XML-INFORMATION” on page 632
Related tasks
“Writing procedures to process XML” on page 627
“Parsing XML documents with validation” on page 634
“Parsing XML documents one segment at a time” on page 637
“Parsing XML documents encoded in UTF-8” on page 644
Related references
“XMLPARSE” on page 425 (compiler option)
“The encoding of XML documents” on page 640
“XML PARSE exceptions with XMLPARSE(XMLSS) in
effect” on page 809
“XML PARSE exceptions with
XMLPARSE(COMPAT) in effect” on page 811
XML PARSE statement (Enterprise COBOL for z/OS Language Reference)
XML-TEXT1 Variable-length elementary category Text (corresponding to the event that the parser
alphanumeric item encountered) from the XML document if you specify an
alphanumeric item for the XML PARSE identifier3
XML-NTEXT1 Variable-length elementary category national Text (corresponding to the event that the parser
item encountered) from the XML document if you specify a
national item for the XML PARSE identifier3
XML-NNAMESPACE1, 4 Variable-length elementary category national The namespace identifier for a NAMESPACE-
item DECLARATION XML event or for an element or attribute
name that is in a namespace, if the XML document is in a
national data item or the RETURNING NATIONAL phrase
is specified in the XML PARSE statement
XML-NAMESPACE-PREFIX1, Variable-length elementary category national The prefix, if any, for a NAMESPACE-DECLARATION XML
4 item event or for an element or attribute name that is in a
nondefault namespace, if the XML document is in an
alphanumeric data item3
XML-NNAMESPACE- Variable-length elementary category national The prefix, if any, for a NAMESPACE-DECLARATION XML
PREFIX1, 4 item event or for an element or attribute name that is in
a nondefault namespace, if the XML document is in a
national data item or the RETURNING NATIONAL phrase
is specified in the XML PARSE statement
Restrictions:
• A processing procedure must not directly execute an XML PARSE statement. However, if a processing
procedure passes control to a method or outermost program by using an INVOKE or CALL statement,
the target method or program can execute the same or a different XML PARSE statement. You can also
execute the same XML statement or different XML statements simultaneously from a program that is
running on multiple threads.
• The range of the processing procedure must not cause the execution of any GOBACK or EXIT PROGRAM
statement, except to return control from a method or program to which control was passed by an
INVOKE or CALL statement, respectively, that is executed in the range of the processing procedure.
You can code a STOP RUN statement in a processing procedure to end the run unit.
The compiler inserts a return mechanism after the last statement in each processing procedure.
“Example: program for processing XML” on page 650
Related concepts
“XML events” on page 629
“XML-CODE” on page 630
“XML-TEXT and XML-NTEXT” on page 632
“XML-NAMESPACE and XML-NNAMESPACE” on page 633
“XML-NAMESPACE-PREFIX and XML-NNAMESPACE-PREFIX” on page 633
Related tasks
“Parsing XML documents one segment at a time” on page 637
“Parsing XML documents with validation” on page 634
“Terminating XML parsing” on page 649
628 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Related references
“XMLPARSE” on page 425 (compiler option)
XML-EVENT (Enterprise COBOL for z/OS Language Reference)
XML events
An XML event results when the XML parser detects various conditions (such as END-OF-INPUT or
EXCEPTION) or encounters document fragments (such as CONTENT-CHARACTERS or START-OF-CDATA-
SECTION) while processing an XML document.
For each event that occurs during XML parsing, the parser sets the associated event name in the
XML-EVENT special register, and passes the XML-EVENT special register to the processing procedure.
Depending on the event, the parser sets other special registers to contain additional information about
the event.
In most cases, the parser sets the XML-TEXT or XML-NTEXT special register to the XML fragment that
caused the event:
• If the XMLPARSE(COMPAT) compiler option is in effect, the parser sets XML-NTEXT if the XML
document is in a national data item, or if the parser finds a character reference; otherwise, the parser
sets XML-TEXT.
• If XMLPARSE(XMLSS) is in effect, the parser sets XML-NTEXT if the RETURNING NATIONAL phrase is
specified in the XML PARSE statement, or if the XML document is in a national data item; otherwise, the
parser sets XML-TEXT.
If XMLPARSE(XMLSS) is in effect, the parser sets the namespace special registers for a NAMESPACE-
DECLARATION event, or if it encounters a name that is in a namespace.
When the parser detects an encoding conflict or a well-formedness or validation error in the document,
it sets XML-EVENT to 'EXCEPTION' and provides additional information about the exception in the
XML-CODE special register. You can parse with validation only if XMLPARSE(XMLSS) is in effect. For
further details, see the related task about parsing with validation.
For a detailed description of the set of XML events, see the related reference about XML-EVENT.
“Example: parsing a simple document” on page 649
Related concepts
“XML parser in COBOL” on page 624
“XML-CODE” on page 630
“XML-INFORMATION” on page 632
“XML-TEXT and XML-NTEXT” on page 632
“XML-NAMESPACE and XML-NNAMESPACE” on page 633
“XML-NAMESPACE-PREFIX and XML-NNAMESPACE-PREFIX” on page 633
Related tasks
“Writing procedures to process XML” on page 627
“Parsing XML documents with validation” on page 634
Related references
“XMLPARSE” on page 425 (compiler option)
630 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 76. Results of processing-procedure changes to XML-CODE with XMLPARSE(COMPAT) in effect
XML event type -1 0 Other nonzero
value
XML-CODE-100,000
1. See the exception codes in the related reference about XML PARSE exceptions with XMLPARSE(COMPAT) in
effect.
2. See the related task about handling encoding conflicts.
3. See the related task about handling XML PARSE exceptions.
4. See the related task about terminating XML parsing.
XML generation also uses the XML-CODE special register. For details, see the related task about handling
XML GENERATE exceptions.
Related concepts
“How the XML parser handles errors” on page 647
Related tasks
“Writing procedures to process XML” on page 627
“Parsing XML documents one segment at a time” on page 637
“Handling XML PARSE exceptions” on page 645
Related references
“XML PARSE exceptions with XMLPARSE(XMLSS) in
effect” on page 809
“XML PARSE exceptions with
XMLPARSE(COMPAT) in effect” on page 811
“XML GENERATE exceptions” on page 817
XML-CODE (Enterprise COBOL for z/OS Language Reference)
XML-EVENT (Enterprise COBOL for z/OS Language Reference)
Related concepts
“XML events” on page 629
“XML-CODE” on page 630
Related tasks
“Writing procedures to process XML” on page 627
Related references
XML-TEXT (Enterprise COBOL for z/OS Language Reference)
XML-NTEXT (Enterprise COBOL for z/OS Language Reference)
Related concepts
“XML events” on page 629
“XML-CODE” on page 630
Related tasks
“Writing procedures to process XML” on page 627
Related references
“XMLPARSE” on page 425 (compiler option)
XML-TEXT (Enterprise COBOL for z/OS Language Reference)
XML-NTEXT (Enterprise COBOL for z/OS Language Reference)
632 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
XML-NAMESPACE and XML-NNAMESPACE
If the XMLPARSE(XMLSS) option is in effect, the XML parser sets the XML-NAMESPACE or XML-
NNAMESPACE special register to the namespace identifier for a NAMESPACE-DECLARATION XML event,
or if it encounters an element name or attribute name that is in a namespace.
The parser sets XML-NNAMESPACE if the XML document is in a national data item, or if the RETURNING
NATIONAL phrase is specified in the XML PARSE statement. Otherwise, the parser sets XML-NAMESPACE.
The special registers XML-NAMESPACE and XML-NNAMESPACE are mutually exclusive: If the parser sets
XML-NAMESPACE, XML-NNAMESPACE is empty with length zero. If the parser sets XML-NNAMESPACE,
XML-NAMESPACE is empty with length zero.
To determine the number of character encoding units in XML-NNAMESPACE, use the LENGTH intrinsic
function; for example: FUNCTION LENGTH(XML-NNAMESPACE). To determine the number of bytes
in XML-NNAMESPACE, use special register LENGTH OF XML-NNAMESPACE. The number of character
encoding units differs from the number of bytes.
To determine the number of bytes in XML-NAMESPACE, use either special register LENGTH OF XML-
NAMESPACE or the LENGTH intrinsic function; each returns the number of bytes.
The XML namespace special registers are undefined outside the processing procedure.
Related concepts
“XML events” on page 629
“XML-CODE” on page 630
“XML-NAMESPACE-PREFIX and XML-NNAMESPACE-PREFIX” on page 633
“XML-TEXT and XML-NTEXT” on page 632
Related tasks
“Writing procedures to process XML” on page 627
Related references
“XMLPARSE” on page 425 (compiler option)
Related concepts
“XML events” on page 629
“XML-NAMESPACE and XML-NNAMESPACE” on page 633
Related tasks
“Writing procedures to process XML” on page 627
Related tasks
“Converting to numbers (NUMVAL, NUMVAL-C, NUMVAL-F)” on page 115
“Using national data (Unicode) in COBOL” on page 125
“Writing procedures to process XML” on page 627
Use one of two forms of the VALIDATING phrase, depending on the location of the preprocessed schema:
• In one form, you use the FILE keyword and specify an XML schema name. In this case, the schema
must be in an MVS data set or a z/OS UNIX file.
• In the other form, you specify the identifier of a data item that contains the schema.
634 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
If you use the FILE keyword and specify an XML schema name, the COBOL runtime library automatically
retrieves the schema during execution of the XML PARSE statement. The following code fragment shows
this method of specifying validation:
To associate an XML schema name with the external file that contains the schema, code the XML-SCHEMA
clause in the SPECIAL-NAMES paragraph, specifying either a literal or a user-defined word to identify the
file.
For example, you can associate the XML schema name schema-name shown in the fragment above with
the ddname DDSCHEMA by coding the ddname as a literal in the XML-SCHEMA clause as follows:
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
XML-SCHEMA schema-name IS 'DDSCHEMA'.
For running the program, you can associate ddname DDSCHEMA with the z/OS UNIX file item.osr by
coding a DD statement as follows:
//GO.DDSCHEMA DD PATH='/u/HLQ/xml/item.osr'
Read the preprocessed schema into the data item, for example by using normal COBOL statements.
For more information about this form of the VALIDATING phrase, see the related reference about the XML
PARSE statement.
Related concepts
“XML-CODE” on page 630
“XML schemas” on page 636
Related tasks
“Handling XML PARSE exceptions” on page 645
Related references
“XMLPARSE” on page 425 (compiler option)
XML schemas
An XML schema is a mechanism, defined by the W3C, for describing and constraining the structure and
content of XML documents. An XML schema, which is itself expressed in XML, effectively defines a class
of XML documents of a given type, for example, purchase orders.
For Enterprise COBOL, XML schemas used for validating XML documents must be in a preprocessed
format known as Optimized Schema Representation (OSR). For information about this format, see the
related reference about z/OS XML System Services.
Consider an XML document that describes an item for stock-keeping purposes:
<stockItem itemNumber="453-SR">
<itemName>Stainless steel rope thimbles</itemName>
<quantityOnHand>23</quantityOnHand>
</stockItem>
The example document above is both well formed and valid according to the following schema. (The
numbers that precede each line are not part of the schema, but are used in the explanations after the
schema.)
1. <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
2.
3. <xsd:element name="stockItem" type="stockItemType"/>
4.
5. <xsd:complexType name="stockItemType">
6. <xsd:sequence>
7. <xsd:element name="itemName" type="xsd:string" minOccurs="0"/>
8. <xsd:element name="quantityOnHand">
9. <xsd:simpleType>
10. <xsd:restriction base="xsd:nonNegativeInteger">
11. <xsd:maxExclusive value="100"/>
12. </xsd:restriction>
13. </xsd:simpleType>
14. </xsd:element>
15. </xsd:sequence>
16. <xsd:attribute name="itemNumber" type="SKU" use="required"/>
17. </xsd:complexType>
18.
636 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
19. <xsd:simpleType name="SKU">
20. <xsd:restriction base="xsd:string">
21. <xsd:pattern value="\d{3}-[A-Z]{2}"/>
22. </xsd:restriction>
23. </xsd:simpleType>
24.
25. </xsd:schema>
The schema declares (line 3) that the root element is stockItem, which has a mandatory itemNumber
attribute (line 16) of type SKU, and includes a sequence (lines 6 - 15) of other elements:
• An optional itemName element of type string (line 7)
• A required quantityOnHand element that has a constrained range of 1 - 99 based on the type
nonNegativeInteger (lines 8 - 14)
Type declarations can be inline and unnamed, as in lines 9 - 13, which include the maxExclusive facet
to specify the legal values for the quantityOnHand element.
For the itemNumber attribute, by contrast, the named type SKU is declared separately in lines 19 - 23,
which include a pattern facet that uses regular expression syntax to specify that the legal values for that
type consist of (in order): 3 digits, a hyphen-minus, then two uppercase letters.
The example referenced below shows a program that parses documents against this schema.
“Example: parsing XML documents with validation” on page 660
Related tasks
“Parsing XML documents with validation” on page 634
Related references
z/OS XML System Services User's Guide and Reference
<Tagline>
638 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
COBOL is the language of the future!
</Tagline> <
!--First comment--
> <?pi data?> <!-
-This comment ends this segment-->
<!-- This segment is not included in the parse-->
Related tasks
“Parsing XML documents one segment at a time” on page 637
“XML-CODE” on page 630
Related references
“XMLPARSE” on page 425 (compiler option)
Related concepts
“XML events” on page 629
“XML-CODE” on page 630
1. Supported for the XML PARSE statement in the ENCODING phrase if XMLPARSE(XMLSS) is in effect
Related concepts
“XML input document encoding” on page 641
Related tasks
“Specifying the encoding” on page 642
640 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
“Parsing XML documents encoded in UTF-8” on page 644
Chapter 38, “Producing XML output,” on page 663
Related references
“CODEPAGE” on page 353
Related tasks
“Converting to or from national (Unicode) representation” on page 134
“Specifying the encoding” on page 642
“Parsing XML documents encoded in UTF-8” on page 644
“Handling XML PARSE exceptions” on page 645
Related references
“XMLPARSE” on page 425 (compiler option)
642 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Omitting the encoding declaration makes it possible to more easily transmit an XML document between
heterogeneous systems. (If you included an encoding declaration, you would need to update it to reflect
any code-page translation imposed by the transmission process.)
For XMLPARSE(COMPAT):
You can instead specify an encoding declaration in the XML declaration with which most XML documents
begin. For example:
Note that the XML parser generates an exception if it encounters an XML declaration that does not begin
in the first byte of an XML document.
If you specify an encoding declaration, do so in one of the following ways:
• Specify the CCSID number (with or without any number of leading zeros) prefixed by one of the
following strings in any mixture of uppercase and lowercase letters:
– IBM-
– IBM_
– CCSID-
– CCSID_
• Use one of the aliases listed in the following table. You can code the aliases in any mixture of uppercase
and lowercase letters.
For more information about the CCSIDs that are supported for XML parsing, see the related reference
about the encoding of XML documents.
Related concepts
“XML input document encoding” on page 641
Related tasks
“Parsing XML documents encoded in UTF-8” on page 644
“Handling encoding conflicts” on page 648
Related references
“The encoding of XML documents” on page 640
You define xml-document as an alphanumeric data item or alphanumeric group item in WORKING-
STORAGE or LOCAL-STORAGE.
If you do not code the RETURNING NATIONAL phrase in the XML PARSE statement, the parser returns
the XML document fragments in the alphanumeric special registers XML-TEXT, XML-NAMESPACE, and
XML-NAMESPACE-PREFIX.
UTF-8 characters are encoded using a variable number of bytes per character. Most COBOL operations on
alphanumeric data assume a single-byte encoding, in which each character is encoded in 1 byte. When
you operate on UTF-8 characters as alphanumeric data, you must ensure that the data is processed
correctly. Avoid operations (such as reference modification and moves that involve truncation) that can
split a multibyte character between bytes. You cannot reliably use statements such as INSPECT to
process multibyte characters in alphanumeric data.
You can more reliably process UTF-8 document fragments by specifying the RETURNING NATIONAL
phrase in the XML PARSE statement. If you use the RETURNING NATIONAL phrase, XML document
fragments are efficiently converted to UTF-16 encoding and are returned to the application in the national
special registers XML-NTEXT, XML-NNAMESPACE, and XMLNNAMESPACE-PREFIX. Then you can process
the XML text fragments in national data items. (The UTF-16 encoding in national data items greatly
facilitates Unicode processing in COBOL.)
The following code fragment illustrates the use of both the ENCODING phrase and the RETURNING
NATIONAL phrase for parsing a UTF-8 XML document:
Related concepts
“XML-TEXT and XML-NTEXT” on page 632
644 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
“XML-NAMESPACE and XML-NNAMESPACE” on page 633
“XML-NAMESPACE-PREFIX and XML-NNAMESPACE-PREFIX” on page 633
Related tasks
“Processing UTF-8 data using UTF-16 (national) data types” on page 153
“Parsing XML documents” on page 625
“Specifying the encoding” on page 642
Related references
“XMLPARSE” on page 425 (compiler option)
“The encoding of XML documents” on page 640
XML PARSE statement (Enterprise COBOL for z/OS Language Reference)
<msg>Hello</mmsg>
The return code is hexadecimal 000C (XRC_NOT_WELL_FORMED), and the reason code is hexadecimal
3035 (XRSN_ENDTAG_NAME_MISMATCH), if you parse the document without validation. The
concatenation of these two values, hexadecimal 000C3035, is returned to the processing procedure in
the XML-CODE special register.
If you parse a document with validation, the values returned in XML-CODE for any well-formedness errors
differ from the values returned for the same errors when you parse without validation. The return code
generated by the z/OS XML System Services parser for any validation error is 24 (hexadecimal 0018).
For more information about the return codes and reason codes that can be generated, see the related
reference about exceptions with XMLPARSE(XMLSS) in effect.
If XMLPARSE(XMLSS) is in effect, processing procedures cannot handle exception events and cannot
cause parsing to resume. When a processing procedure returns to the parser from an exception event, the
parser does not signal any further events. The parser transfers control to the statement that is specified in
the ON EXCEPTION phrase of the XML PARSE statement. If you did not code an ON EXCEPTION phrase,
control is passed to the end of the XML PARSE statement. XML-CODE contains the original exception code
set by the parser.
If no exception occurs during parsing, control is passed to the statement specified in the NOT ON
EXCEPTION phrase. If you did not code a NOT ON EXCEPTION phrase, control is passed to the end of the
XML PARSE statement. XML-CODE contains zero.
For XMLPARSE(COMPAT):
If the exception code is within a certain range, you might be able to handle the exception event within
your processing procedure, and resume parsing.
To handle an exception in the processing procedure, follow these steps:
1. Check the contents of XML-CODE.
2. Handle the exception appropriately.
Related concepts
“XML-CODE” on page 630
“XML input document encoding” on page 641
“How the XML parser handles errors” on page 647
Related tasks
“Writing procedures to process XML” on page 627
“Parsing XML documents with validation” on page 634
“Handling encoding conflicts” on page 648
Related references
“XMLPARSE” on page 425 (compiler option)
“The encoding of XML documents” on page 640
“XML PARSE exceptions with XMLPARSE(XMLSS) in
effect” on page 809
“XML PARSE exceptions with
XMLPARSE(COMPAT) in effect” on page 811
z/OS XML System Services User's Guide and Reference
646 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
How the XML parser handles errors
When the XML parser detects an error in an XML document, it generates an XML exception event and
passes control to your processing procedure.
The parser passes the following information in special registers to the processing procedure:
• XML-EVENT contains 'EXCEPTION'.
• XML-CODE contains a numeric exception code.
The exception codes are described in the related references about XML PARSE exceptions.
• For fatal exceptions, XML-TEXT or XML-NTEXT contains the document text up to and including the point
where the exception was detected.
• For the warning exceptions issued for using an undeclared prefix, XML-TEXT or XML-NTEXT contains
the fully qualified attribute name or element name. That is, the name includes the undeclared prefix and
the separator colon (:).
• If XMLPARSE(COMPAT) is in effect, XML-TEXT or XML-NTEXT contains the document text up to and
including the point where the exception was detected.
• If XMLPARSE(XMLSS) is in effect, XML-TEXT or XML-NTEXT contains the document text up to the point
where the error or anomaly was detected. If you process the XML document one segment at a time, the
applicable special register contains only the current segment.
All other XML special registers are empty with length zero.
For XMLPARSE(XMLSS):
Parsing cannot continue after a fatal exception even if you set XML-CODE to zero in the processing
procedure. Upon return to the parser from the processing procedure, the parser transfers control to the
ON EXCEPTION phrase, if specified; otherwise the parser transfers control to the end of the XML PARSE
statement. XML-CODE contains the original exception code set by the parser.
For XMLPARSE(COMPAT):
The processing procedure might be able to handle an exception so that parsing continues if the exception
code is within one of the following ranges:
• 1 - 99
• 100,001 - 165,535
If the exception code has any other nonzero value, parsing cannot continue.
Encoding conflicts: The exceptions for encoding conflicts (50 - 99 and 300 - 399) are signaled before the
parsing of the document begins. For these exceptions, XML-TEXT or XML-NTEXT is either length zero or
contains only the encoding declaration value from the document.
Exception codes 1 - 49: An exception for which the exception code is in the range 1 - 49 is a fatal
error according to the XML specification. Therefore, the parser does not continue normal parsing even if
the processing procedure handles the exception. However, the parser does continue scanning for further
errors until it reaches the end of the document, or until the existing XML EVENT token array is exhausted.
For these exceptions, the parser does not signal any further normal events except the END-OF-DOCUMENT
event.
Related concepts
“XML events” on page 629
“XML-CODE” on page 630
“XML input document encoding” on page 641
Related tasks
“Parsing XML documents one segment at a time” on page 637
“Handling XML PARSE exceptions” on page 645
“Handling encoding conflicts” on page 648
Related references
“XMLPARSE” on page 425 (compiler option)
“The encoding of XML documents” on page 640
“XML PARSE exceptions with XMLPARSE(XMLSS) in
effect” on page 809
“XML PARSE exceptions with
XMLPARSE(COMPAT) in effect” on page 811
z/OS XML System Services User's Guide and Reference
XML specification
Related concepts
“XML-CODE” on page 630
“XML input document encoding” on page 641
“How the XML parser handles errors” on page 647
Related tasks
“Handling XML PARSE exceptions” on page 645
Related references
“XMLPARSE” on page 425 (compiler option)
“The encoding of XML documents” on page 640
648 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
“XML PARSE exceptions with XMLPARSE(XMLSS) in
effect” on page 809
“XML PARSE exceptions with
XMLPARSE(COMPAT) in effect” on page 811
z/OS XML System Services User's Guide and Reference
Related concepts
“XML-CODE” on page 630
“How the XML parser handles errors” on page 647
Related tasks
“Writing procedures to process XML” on page 627
“Handling XML PARSE exceptions” on page 645
The processing procedure displays the content of XML-EVENT and XML-TEXT for each event that the
parser signals during parsing. The following table shows the events and the text.
Related concepts
“XML events” on page 629
“XML-TEXT and XML-NTEXT” on page 632
Process codepage(1047)
Identification division.
Program-id. XMLSAMPL.
Data division.
Working-storage section.
******************************************************************
* XML document data, encoded as initial values of data items. *
******************************************************************
1 xml-document-data.
2 pic x(39) value '<?xml version="1.0" encoding="IBM-1047"'.
2 pic x(19) value ' standalone="yes"?>'.
2 pic x(39) value '<!--This document is just an example-->'.
2 pic x(10) value '<sandwich>'.
2 pic x(33) value '<bread type="baker's best"/>'.
2 pic x(36) value '<?spread We'll use real mayonnaise?>'.
2 pic x(29) value '<meat>Ham & turkey</meat>'.
2 pic x(34) value '<filling>Cheese, lettuce, tomato, '.
2 pic x(32) value 'and that's all, Folks!</filling>'.
2 pic x(25) value '<![CDATA[We should add a '.
2 pic x(20) value '<relish> element!]]>'.
2 pic x(28) value '<listprice>$4.99</listprice>'.
2 pic x(25) value '<discount>0.10</discount>'.
2 pic x(31) value '</sandwich>'.
650 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
******************************************************************
* XML document, represented as fixed-length records. *
******************************************************************
1 xml-document redefines xml-document-data.
2 xml-segment pic x(40) occurs 10 times.
1 xml-segment-no comp pic s9(4).
1 content-buffer pic x(100).
1 current-element-stack.
2 current-element pic x(30) occurs 10 times.
******************************************************************
* Sample data definitions for processing numeric XML content. *
******************************************************************
1 element-depth comp pic s9(4).
1 discount computational pic 9v99 value 0.
1 display-price pic $$9.99.
1 filling pic x(4095).
1 list-price computational pic 9v99 value 0.
1 ofr-ed pic x(9) justified.
1 ofr-ed-1 redefines ofr-ed pic 999999.99.
Procedure division.
Mainline section.
Move 1 to xml-segment-no
Display 'Initial segment {' xml-segment(xml-segment-no) '}'
Display ' '
XML parse xml-segment(xml-segment-no)
processing procedure XML-handler
On exception
Display 'XML processing error, XML-Code=' XML-Code '.'
Move 16 to return-code
Goback
Not on exception
Display 'XML document successfully parsed.'
End-XML
******************************************************************
* Process the transformed content and calculate promo price. *
******************************************************************
Display ' '
Display '-----+++++***** Using information from XML '
'*****+++++-----'
Display ' '
Move list-price to Display-price
Display ' Sandwich list price: ' Display-price
Compute Display-price = list-price * (1 - discount)
Display ' Promotional price: ' Display-price
Display ' Get one today!'
Goback.
XML-handler section.
Evaluate XML-Event
* ==> Order XML events most frequent first
When 'START-OF-ELEMENT'
Display 'Start element tag: {' XML-Text '}'
Add 1 to element-depth
Move XML-Text to current-element(element-depth)
When 'CONTENT-CHARACTERS'
Display 'Content characters: {' XML-Text '}'
* ==> In general, a split can occur for any element or attribute
* ==> data, but in this sample, it only occurs for "filling"...
If xml-information = 2 and
current-element(element-depth) not = 'filling'
Display 'Unexpected split in content for element '
current-element(element-depth)
Move -1 to xml-code
End-if
* ==> Transform XML content to operational COBOL data item...
Evaluate current-element(element-depth)
When 'filling'
* ==> After reassembling separate pieces of character content...
String xml-text delimited by size into
content-buffer with pointer tally
On overflow
Display 'content buffer ('
length of content-buffer
' bytes) is too small'
Move -1 to xml-code
End-string
Evaluate xml-information
When 2
Display ' Character data for element "filling" '
'is incomplete.'
Display ' The partial data was buffered for '
'content assembly.'
When 1
Start of document
End of input
Next segment: {standalone="yes"?><!--This document is j}
Version: {1.0}
Encoding: {ibm-1047}
Standalone: {yes}
652 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Comment: {This document is j}
End of input
Next segment: {ust an example--><sandwich><bread type="}
PI target: {spread}
PI data: {eal mayonnaise}
Start element tag: {meat}
Content characters: {Ham & turkey}
End of input
Next segment: {meat><filling>Cheese, lettuce, tomato, a}
Start of document
Version: {1.0}
Encoding: {IBM-1047}
Standalone: {yes}
Comment: {This document is just an example}
Start element tag: {sandwich}
Content characters: { }
Start element tag: {bread}
Related concepts
“XML events” on page 629
Related tasks
“Handling splits using the XML-INFORMATION special register” on page 639
Related references
“XMLPARSE” on page 425 (compiler option)
XML-EVENT (Enterprise COBOL for z/OS Language Reference)
<section
xmlns="http://www.ibm.com/events"
654 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
xmlns:bk="urn:loc.gov:books"
xmlns:pi="urn:personalInformation"
xmlns:isbn='urn:ISBN:0-395-36341-6'>
<title>Book-Signing Event</title>
<signing>
<bk:author pi:title="Mr" pi:name="Jim Ross"/>
<book bk:title="Writing COBOL for Fun and Profit" isbn:number="0426070806"/>
<comment xmlns=''>What a great issue!</comment>
</signing>
</section>
Identification division.
Program-id. XMLup.
Data division.
Working-storage section.
1 d.
2 pic x(40) value '<pfx0:root xmlns:pfx1="http://whatever">'.
2 pic x(19) value '<pfx1:localElName1>'.
2 pic x(20) value '<pfx2:localElName2/>'.
2 pic x(40) value '<pfx3:localElName3 pfx4:localAtName4="">'.
2 pic x(02) value 'c1'.
2 pic x(41) value '<pfx5:localElName5 pfx6:localAtName6=""/>'.
2 pic x(24) value 'c2</pfx3:localElName3>c3'.
2 pic x(32) value '</pfx1:localElName1></pfx0:root>'.
Procedure division.
main.
display 'XML document: ' d
display ' '
xml parse d processing procedure h
goback.
h.
if xml-event = 'EXCEPTION'
display ' '
end-if
display xml-event xml-code '|' xml-text '|'
xml-namespace-prefix '|'
xml-namespace '|'
if xml-event = 'EXCEPTION' and xml-code = 264192 or 264193
move 0 to xml-code
end-if
.
End program XMLup.
656 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Results from parsing XML document with an undeclared namespace prefix
The following table lists the sequence of events that the processing procedure receives from the parser,
and shows the content of the associated XML special registers.
Table 83. XML events and special registers from parsing XML document with an undeclared namespace prefix
XML-EVENT XML-CODE XML-TEXT XML-NAMESPACE- XML-NAMESPACE
PREFIX
START-OF- 000000000
DOCUMENT
EXCEPTION 000264193 pfx0:root
START-OF- 000000000 root pfx0
ELEMENT
NAMESPACE- 000000000 pfx1 http://
DECLARATION whatever
START-OF- 000000000 localElName1 pfx1 http://
ELEMENT whatever
EXCEPTION 000264193 pfx2:localElName2
START-OF- 000000000 localElName2 pfx2
ELEMENT
END-OF-ELEMENT 000000000 localElName2 pfx2
EXCEPTION 000264193 pfx3:localElName3
START-OF- 000000000 localElName3 pfx3
ELEMENT
EXCEPTION 000264192 pfx4:localAtName4
ATTRIBUTE-NAME 000000000 localAtName4 pfx4
ATTRIBUTE- 000000000
CHARACTERS
CONTENT- 000000000 c1
CHARACTERS
EXCEPTION 000264193 pfx5:localElName5
START-OF- 000000000 localElName5 pfx5
ELEMENT
EXCEPTION 000264192 pfx6:localAtName6
ATTRIBUTE-NAME 000000000 localAtName6 pfx6
ATTRIBUTE- 000000000
CHARACTERS
END-OF-ELEMENT 000000000 localElName5 pfx5
CONTENT- 000000000 c2
CHARACTERS
END-OF-ELEMENT 000000000 localElName3 pfx3
CONTENT- 000000000 c3
CHARACTERS
For a detailed description of the set of XML events, see the related reference about XML-EVENT.
Related concepts
“XML events” on page 629
“XML-TEXT and XML-NTEXT” on page 632
“XML-NAMESPACE and XML-NNAMESPACE” on page 633
“XML-NAMESPACE-PREFIX and XML-NNAMESPACE-PREFIX” on page 633
Related references
“XMLPARSE” on page 425 (compiler option)
XML-EVENT (Enterprise COBOL for z/OS Language Reference)
Content of infile
The XML document that will be parsed a segment at a time is contained in file infile, shown below.
<?xml version='1.0'?>
<Tagline>
COBOL is the language of the future!
</Tagline>
Program PARSESEG
Program PARSESEG reads a segment (a record) of the XML document from file infile, then passes the
record to the parser using the XML PARSE statement. The parser processes the XML text and transfers
control to the processing procedure for each XML event. The processing procedure handles each event
and returns to the parser.
At the end of the segment, the parser sets XML-EVENT to END-OF-INPUT, sets XML-CODE to zero, and
transfers control to the processing procedure. The processing procedure reads the next XML record into
the parse data item, sets XML-CODE to one, and returns to the parser.
The exchange between the processing procedure and the parser continues until the READ statement
returns the end-of-file status code. The processing procedure returns to the parser with XML-CODE still
set to zero to indicate the end of segment processing.
Identification division.
Program-id. PARSESEG.
Environment division.
Input-output section.
File-control.
Select Input-XML
658 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Assign to infile
File status is Input-XML-status.
Data division.
File section.
FD Input-XML
Record is varying from 1 to 255 depending on Rec-length
Recording mode V.
1 fdrec.
2 pic X occurs 1 to 255 depending on Rec-length .
Working-storage section.
1 Event-number comp pic 99.
1 Rec-length comp-5 pic 9(4).
1 Input-XML-status pic 99.
Procedure division.
Open input Input-XML
If Input-XML-status not = 0
Display 'Open failed, file status: ' Input-XML-status
Goback
End-if
Read Input-XML
If Input-XML-status not = 0
Display 'Read failed, file status: ' Input-XML-status
Goback
End-if
Move 0 to Event-number
Display 'Starting with: ' fdrec
Display 'Event number and name Content of XML-text'
XML parse fdrec processing procedure Handle-parse-events
Close Input-XML
Goback
.
Handle-parse-events.
Add 1 to Event-number
Display ' ' Event-number ': ' XML-event '{' XML-text '}'
Evaluate XML-event
When 'END-OF-INPUT'
Read Input-XML
Evaluate Input-XML-status
When 0
Move 1 to XML-code
Display 'Continuing with: ' fdrec
When 10
Display 'At EOF; no more input.'
When other
Display 'Read failed, file status:' Input-XML-status
Goback
End-evaluate
When other
Continue
End-evaluate
.
End program PARSESEG.
For a detailed description of the XML events that were detected, see the related reference about XML-
EVENT.
Related references
“XMLPARSE” on page 425 (compiler option)
XML-EVENT (Enterprise COBOL for z/OS Language Reference)
The example uses the XML-SCHEMA clause to associate the XML schema name schema with the ddname
ddschema. The following DD statement associates the ddname with the external z/OS UNIX file that
contains the schema:
//GO.DDSCHEMA DD PATH='/u/HLQ/xml/item.osr'
Program ValidCk
Identification division.
Program-id. ValidCk.
Environment division.
Configuration section.
Special-names.
xml-schema schema is 'ddschema'.
Data division.
Working-storage section.
1 xml-decode.
2 rtn comp Pic 9(2).
2 rsn comp-5 Pic 9(4).
1 hv pic x(16) value '0123456789ABCDEF'.
1 T Pic 999 COMP.
1 xml-document-1.
2 pic x(52) value
'<!--Valid: the "itemName" element can be omitted-->'.
2 pic x(31) value '<stockItem itemNumber="123-AB">'.
2 pic x(36) value ' <quantityOnHand>1</quantityOnHand>'.
2 pic x(12) value '</stockItem>'.
1 xml-document-2.
2 pic x(44)
value '<!--Invalid: missing attribute itemNumber-->'.
2 pic x(11) value '<stockItem>'.
2 pic x(30) value ' <itemName>No name</itemName>'.
2 pic x(36) value ' <quantityOnHand>1</quantityOnHand>'.
2 pic x(12) value '</stockItem>'.
1 xml-document-3.
2 pic x(47)
value '<!--Invalid: unexpected attribute warehouse-->'.
2 pic x(46) value
'<stockItem itemNumber="074-UN" warehouse="NJ">'.
2 pic x(37) value ' <quantityOnHand>10</quantityOnHand>'.
2 pic x(32) value ' <itemName>Not here!</itemName>'.
2 pic x(12) value '</stockItem>'.
1 xml-document-4.
2 pic x(46)
660 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
value '<!--Invalid: illegal attribute value 123-Ab-->'.
2 pic x(31) value '<stockItem itemNumber="123-Ab">'.
2 pic x(33) value ' <itemName>Paintbrush</itemName>'.
2 pic x(37) value ' <quantityOnHand>10</quantityOnHand>'.
2 pic x(12) value '</stockItem>'.
1 xml-document-5.
2 pic x(46)
value '<!--Invalid: missing element quantityOnHand-->'.
2 pic x(31) value '<stockItem itemNumber="074-UN">'.
2 pic x(32) value ' <itemName>Not here!</itemName>'.
2 pic x(12) value '</stockItem>'.
1 xml-document-6.
2 pic x(42)
value '<!--Invalid: unexpected element comment-->'.
2 pic x(31) value '<stockItem itemNumber="123-AB">'.
2 pic x(33) value ' <itemName>Paintbrush</itemName>'.
2 pic x(36) value ' <quantityOnHand>1</quantityOnHand>'.
2 pic x(35) value ' <comment>Nylon bristles</comment>'.
2 pic x(12) value '</stockItem>'.
1 xml-document-7.
2 pic x(46) value
'<!--Invalid: out-of-range element value 100-->'.
2 pic x(31) value '<stockItem itemNumber="123-AB">'.
2 pic x(33) value ' <itemName>Paintbrush</itemName>'.
2 pic x(38) value ' <quantityOnHand>100</quantityOnHand>'.
2 pic x(12) value '</stockItem>'.
Procedure division.
m.
xml parse xml-document-1 validating with file schema
processing procedure p
xml parse xml-document-2 validating with file schema
processing procedure p
xml parse xml-document-3 validating with file schema
processing procedure p
xml parse xml-document-4 validating with file schema
processing procedure p
xml parse xml-document-5 validating with file schema
processing procedure p
xml parse xml-document-6 validating with file schema
processing procedure p
xml parse xml-document-7 validating with file schema
processing procedure p
goback
.
p.
evaluate xml-event
when 'COMMENT'
display ' '
display xml-text
when 'END-OF-DOCUMENT'
display ' Document successfully parsed.'
when 'EXCEPTION'
move xml-code to xml-decode
Divide rsn by 16 giving tally remainder T
display ' RC=' rtn ', reason=x'''
hv(function mod(rsn / 4096 16) + 1:1)
hv(function mod(rsn / 256 16) + 1:1)
hv(function mod(rsn / 16 16) + 1:1)
hv(T + 1:1) ''''
end-evaluate
.
End program ValidCk.
Related concepts
“XML-CODE” on page 630
“XML schemas” on page 636
Related tasks
“Parsing XML documents with validation” on page 634
“Handling XML PARSE exceptions” on page 645
Related references
“XML PARSE exceptions with XMLPARSE(XMLSS) in
effect” on page 809
662 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Chapter 38. Producing XML output
You can produce XML output from a COBOL program by using the XML GENERATE statement.
In the XML GENERATE statement, you identify the source and the output data items. You can optionally
also identify:
• A field to receive a count of the XML characters generated
• A code page in which the generated XML document is to be encoded
• A namespace for the generated document
• A namespace prefix to qualify the start and end tag of each element, if you specify a namespace
• A user-defined element or attribute name in the generated XML document
• Attributes or elements to be suppressed according to some specified conditions
• Particular items to be specified as attributes, elements or content in the generated XML output.
• A statement to receive control if an exception occurs
Optionally, you can generate an XML declaration for the document, and can cause eligible source data
items to be expressed as attributes in the output rather than as elements.
You can use the XML-CODE special register to determine the status of XML generation.
After you transform COBOL data items to XML, you can use the resulting XML output in various ways,
such as deploying it in a web service, passing it as a message to WebSphere MQ, or transmitting it for
subsequent conversion to a CICS communication area.
Link-edit considerations: COBOL programs that contain the XML GENERATE statement must be link-
edited with AMODE 31.
Related tasks
“Generating XML output” on page 663
“Controlling the encoding of generated XML output” on page 668
“Handling XML GENERATE exceptions” on page 668
“Enhancing XML output” on page 673
Related references
Extensible Markup Language (XML)
XML GENERATE statement (Enterprise COBOL for z/OS Language Reference)
In the XML GENERATE statement, you first identify the data item (XML-OUTPUT in the example above)
that is to receive the XML output. Define the data item to be large enough to contain the generated
XML output, typically five to 10 times the size of the COBOL source data depending on the length of its
data-name or data-names.
In the DATA DIVISION, you can define the receiving identifier as alphanumeric (either an alphanumeric
group item or an elementary item of category alphanumeric) or as national (either a national group item or
an elementary item of category national).
The code above generates the following XML document, in which A, B, and E are expressed as child
elements of element G, and C and D become child elements of element B:
<G><A>aaa</A><B><C>ccc</C><D>ddd</D></B><E>eee</E></G>
Alternatively, you can specify the ATTRIBUTES phrase of the XML GENERATE statement. The
ATTRIBUTES phrase causes every eligible data item included in the generated XML document to
be expressed as an attribute of the containing XML element, rather than as a child element of the
containing XML element. To be eligible, the data item must be elementary, must have a name other than
FILLER, and must not have an OCCURS clause in its data description entry. The containing XML element
corresponds to the group data item that is immediately superordinate to the elementary data item.
Optionally, you can specify more precise control of which data items should be expressed as attributes or
elements by using the TYPE OF phrase.
For example, suppose that the XML GENERATE statement in the program excerpt above had instead been
coded as follows:
The code would then generate the following XML document, in which A and E are expressed as attributes
of element G, and C and D become attributes of element B:
Optionally, you can code the ENCODING phrase of the XML GENERATE statement to specify the CCSID
of the generated XML document. If you do not use the ENCODING phrase, the document encoding is
664 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
determined by the category of the receiving data item and by the CODEPAGE compiler option. For further
details, see the related task below about controlling the encoding of generated XML output.
Optionally, you can code the XML-DECLARATION phrase to cause the generated XML document to have
an XML declaration that includes version information and an encoding declaration. If the receiving data
item is of category:
• National: The encoding declaration has the value UTF-16 (encoding="UTF-16").
• Alphanumeric: The encoding declaration is derived from the ENCODING phrase, if specified, or from the
CODEPAGE compiler option in effect for the program if the ENCODING phrase is not specified.
For example, the program excerpt below specifies the XML-DECLARATION phrase of XML GENERATE, and
specifies encoding with CCSID 1208 (UTF-8):
01 Greeting.
05 msg pic x(80) value 'Hello, world!'.
. . .
XML Generate Doc from Greeting
with Encoding 1208
with XML-declaration
End-XML
If you do not code the XML-DECLARATION phrase, an XML declaration is not generated.
Optionally, you can code the NAMESPACE phrase to specify a namespace for the generated XML
document. The namespace value must be a valid Uniform Resource Identifier (URI), for example, a URL
(Uniform Resource Locator); for further details, see the related concept about URI syntax below.
Specify the namespace in an identifier or literal of either category national or alphanumeric.
If you specify a namespace, but do not specify a namespace prefix (described below), the namespace
becomes the default namespace for the document. That is, the namespace define on the root element
applies by default to each element name in the document, including the root element.
For example, consider the following data definitions and XML GENERATE statement:
01 Greeting.
05 msg pic x(80) value 'Hello, world!'.
01 NS pic x(20) value 'http://example'.
. . .
XML Generate Doc from Greeting
namespace is NS
If you do not specify a namespace, the element names in the generated XML document are not in any
namespace.
Optionally, you can code the NAMESPACE-PREFIX phrase to specify a prefix to be applied to the start and
end tag of each element in the generated document. You can specify a prefix only if you have specified a
namespace as described above.
When the XML GENERATE statement is executed, the prefix value must be a valid XML name, but without
the colon (:); see the related reference below about namespaces for details. The value can have trailing
spaces, which are removed before the prefix is used.
Specify the namespace prefix in an identifier or literal of either category national or alphanumeric.
It is recommended that the prefix be short, because it qualifies the start and end tag of each element.
01 Greeting.
05 msg pic x(80) value 'Hello, world!'.
01 NS pic x(20) value 'http://example'.
01 NP pic x(5) value 'pre'.
. . .
XML Generate Doc from Greeting
namespace is NS
namespace-prefix is NP
The resulting XML document has an explicit namespace (http://example), and the prefix pre is
applied to the start and end tag of the elements Greeting and msg, as follows:
Optionally, you can code the NAME phrase to specify attribute and element names in the generated XML
document. The attribute and element names must be alphanumeric or national literals and must be legal
names according to the XML 1.0 standard.
For example, consider the following data structure and XML GENERATE statement:
01 Msg.
02 Msg-Severity pic 9 value 1.
02 Msg-Date pic 9999/99/99 value "2012/04/12".
02 Msg-Text pic X(50) value "Sell everything!".
01 Doc pic X(500).
Optionally, you can code the SUPPRESS phrase to specify whether individual data items are generated
based on whether or not they meet certain criteria.
For example, consider the following data structure and XML GENERATE statement to suppress spaces
and zeros:
01 G.
02 SensitiveInfo.
03 SSN pic x(11) value '123-45-6789'.
03 HomeAddress pic x(50) value '123 Main St, Anytown, USA'.
02 Aarray value spaces.
03 A pic AAA occurs 5.
02 Barray value spaces.
03 B pic XXX occurs 5.
02 Carray value zeros.
03 C pic 999 occurs 5.
Move 'abc' to A(1)
Move 123 to C(3)
XML Generate Doc from G
Suppress SensitiveInfo
every nonnumeric element when space
every numeric element when zero
End-XML
<G>
<Aarray><A>abc</A></Aarray>
666 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
<Carray><C>123</C></Carray>
</G>
Optionally, you can use the TYPE OF phrase to specify whether individual data items are expressed as
attributes, elements or content.
For example, consider the following data structure and XML GENERATE statement:
01 Msg.
02 Msg-Severity pic 9 value 1.
02 Msg-Date pic 9999/99/99 value "2012/04/12".
02 Msg-Text pic X(50) value "Sell everything!".
01 Doc pic X(500).
XML Generate Doc from Msg
With attributes
Type of Msg-Severity is attribute
Msg-Date is attribute
Msg-Text is element
End-XML
In addition, you can specify either or both of the following phrases to receive control after generation of
the XML document:
• ON EXCEPTION, to receive control if an error occurs during XML generation
• NOT ON EXCEPTION, to receive control if no error occurs
You can end the XML GENERATE statement with the explicit scope terminator END-XML. Code END-XML
to nest an XML GENERATE statement that has the ON EXCEPTION or NOT ON EXCEPTION phrase in a
conditional statement.
XML generation continues until either the COBOL source record has been transformed to XML or an error
occurs. If an error occurs, the results are as follows:
• The XML-CODE special register contains a nonzero exception code.
• Control is passed to the ON EXCEPTION phrase, if specified, otherwise to the end of the XML
GENERATE statement.
If no error occurs during XML generation, the XML-CODE special register contains zero, and control is
passed to the NOT ON EXCEPTION phrase if specified or to the end of the XML GENERATE statement
otherwise.
“Example: generating XML” on page 669
Related concepts
Uniform Resource Identifier (URI): Generic Syntax
Related tasks
“Controlling the encoding of generated XML output” on page 668
“Handling XML GENERATE exceptions” on page 668
“Processing UTF-8 data using UTF-16 (national) data types” on page 153
Related references
XML GENERATE statement (Enterprise COBOL for z/OS Language Reference)
Extensible Markup Language (XML)
Namespaces in XML 1.0
Related references
“CODEPAGE” on page 353
“The encoding of XML documents” on page 640
XML GENERATE statement (Enterprise COBOL for z/OS Language Reference)
Operation of XML GENERATE (Enterprise COBOL for z/OS Language Reference)
668 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
1. Code the COUNT IN phrase in the XML GENERATE statement.
The count field that you specify holds a count of the XML character encoding units that are filled during
XML generation. If you define the XML output as national, the count is in UTF-16 character encoding
units; for all other encodings (including for UTF-8), the count is in bytes.
2. Use the count field as a reference modification length to refer to the substring of the receiving data
item that contains the XML characters that were generated until the point when the error occurred.
For example, if XML-OUTPUT is the data item that receives the XML output, and XML-CHAR-COUNT is
the count field, then XML-OUTPUT(1:XML-CHAR-COUNT) references the XML output.
Use the contents of XML-CODE to determine what corrective action to take. For a list of the exceptions
that can occur during XML generation, see the related reference below.
Related tasks
“Referring to substrings of data items” on page 109
Related references
“XML GENERATE exceptions” on page 817
XML-CODE (Enterprise COBOL for z/OS Language Reference)
Program XGFX
Identification division.
Program-id. XGFX.
Data division.
Working-storage section.
01 numItems pic 99 global.
01 purchaseOrder global.
05 orderDate pic x(10).
05 shipTo.
10 country pic xx value 'US'.
10 name pic x(30).
10 street pic x(30).
10 city pic x(30).
10 state pic xx.
10 zip pic x(10).
05 billTo.
10 country pic xx value 'US'.
10 name pic x(30).
10 street pic x(30).
10 city pic x(30).
10 state pic xx.
10 zip pic x(10).
05 orderComment pic x(80).
05 items occurs 0 to 20 times depending on numItems.
10 item.
15 partNum pic x(6).
15 productName pic x(50).
15 quantity pic 99.
15 USPrice pic 999v99.
15 shipDate pic x(10).
15 itemComment pic x(40).
01 numChars comp pic 999.
01 xmlPO pic x(999).
Procedure division.
Move 0 to numItems
Call 'addFirstItem'
Call 'addSecondItem'
Move space to xmlPO
Xml generate xmlPO from purchaseOrder count in numChars
with xml-declaration with attributes
namespace 'http://www.example.com' namespace-prefix 'po'
Call 'pretty' using xmlPO value numChars
Goback
.
Identification division.
Program-id. 'addFirstItem'.
Procedure division.
Add 1 to numItems
Move '872-AA' to partNum(numItems)
Move 'Lawnmower' to productName(numItems)
Move 1 to quantity(numItems)
Move 148.95 to USPrice(numItems)
Move 'Confirm this is electric' to itemComment(numItems)
Goback.
End program 'addFirstItem'.
Identification division.
Program-id. 'addSecondItem'.
Procedure division.
Add 1 to numItems
Move '926-AA' to partNum(numItems)
Move 'Baby Monitor' to productName(numItems)
Move 1 to quantity(numItems)
Move 39.98 to USPrice(numItems)
Move '1999-05-21' to shipDate(numItems)
Goback.
End program 'addSecondItem'.
Program Pretty
670 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
88 charcontent value 4.
Linkage section.
1 doc.
2 pic x occurs 16384 times depending on len.
1 len comp-5 pic 9(9).
Procedure division using doc value len.
m.
Move space to prettyPrint
Move 0 to depth
Move 1 to posd pose
Xml parse doc processing procedure p
Goback
.
p.
Evaluate xml-event
When 'VERSION-INFORMATION'
String '<?xml version="' xml-text '"' delimited by size
into buffer with pointer posd
Set xml-declaration to true
When 'ENCODING-DECLARATION'
String ' encoding="' xml-text '"' delimited by size
into buffer with pointer posd
When 'STANDALONE-DECLARATION'
String ' standalone="' xml-text '"' delimited by size
into buffer with pointer posd
When 'START-OF-ELEMENT'
Evaluate true
When xml-declaration
String '?>' delimited by size into buffer
with pointer posd
Set unknown to true
Perform printline
Move 1 to posd
When element
String '>' delimited by size into buffer
with pointer posd
When attribute
String '">' delimited by size into buffer
with pointer posd
End-evaluate
If elementName not = space
Perform printline
End-if
Move xml-text to elementName
Add 1 to depth
Move 1 to pose
Set element to true
If xml-namespace-prefix = space
String '<' xml-text delimited by size
into buffer with pointer pose
Else
String '<' xml-namespace-prefix ':' xml-text
delimited by size into buffer with pointer pose
End-if
Move pose to posd
When 'ATTRIBUTE-NAME'
If element
String ' ' delimited by size into buffer
with pointer posd
Else
String '" ' delimited by size into buffer
with pointer posd
End-if
If xml-namespace-prefix = space
String xml-text '="' delimited by size into buffer
with pointer posd
Else
String xml-namespace-prefix ':' xml-text '="'
delimited by size into buffer with pointer posd
End-if
Set attribute to true
When 'NAMESPACE-DECLARATION'
If element
String ' ' delimited by size into buffer
with pointer posd
Else
String '" ' delimited by size into buffer
with pointer posd
End-if
If xml-namespace-prefix = space
String 'xmlns="' xml-namespace delimited by size
into buffer with pointer posd
672 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Output from program XGFX
Related tasks
Chapter 37, “Processing XML input,” on page 623
Related references
“XMLPARSE” on page 425 (compiler option)
Operation of XML GENERATE (Enterprise COBOL for z/OS Language Reference)
Related references
Operation of XML GENERATE (Enterprise COBOL for z/OS Language Reference)
01 CDR-LIFE-BASE-VALUES-BOX.
15 CDR-LIFE-BASE-VAL-DATE PIC X(08).
15 CDR-LIFE-BASE-VALUE-LINE OCCURS 2 TIMES.
20 CDR-LIFE-BASE-DESC.
25 CDR-LIFE-BASE-DESC1 PIC X(15).
25 FILLER PIC X(01).
25 CDR-LIFE-BASE-LIT PIC X(08).
25 CDR-LIFE-BASE-DTE PIC X(08).
20 CDR-LIFE-BASE-PRICE.
25 CDR-LIFE-BP-SPACE PIC 9(08).
25 CDR-LIFE-BP-DASH PIC X.
25 CDR-LIFE-BP-SPACE1 PIC X(02).
20 CDR-LIFE-BASE-PRICE-ED REDEFINES
CDR-LIFE-BASE-PRICE PIC $$$.$$.
20 CDR-LIFE-BASE-QTY.
25 CDR-LIFE-QTY-SPACE PIC X(08).
25 CDR-LIFE-QTY-DASH PIC X.
25 CDR-LIFE-QTY-SPACE1 PIC X(03).
25 FILLER PIC X(02).
20 CDR-LIFE-BASE-VALUE PIC $$$9.99
BLANK WHEN ZERO.
15 CDR-LIFE-BASE-TOT-VALUE PIC X(15)
When this data structure is populated with some sample values, and XML is generated directly from it and
then formatted using program Pretty (shown in “Example: generating XML” on page 669), the result is
as follows:
<CDR-LIFE-BASE-VALUES-BOX>
<CDR-LIFE-BASE-VAL-DATE>01/02/03</CDR-LIFE-BASE-VAL-DATE>
<CDR-LIFE-BASE-VALUE-LINE>
<CDR-LIFE-BASE-DESC>
<CDR-LIFE-BASE-DESC1>First</CDR-LIFE-BASE-DESC1>
<CDR-LIFE-BASE-LIT> </CDR-LIFE-BASE-LIT>
<CDR-LIFE-BASE-DTE>01/01/01</CDR-LIFE-BASE-DTE>
</CDR-LIFE-BASE-DESC>
<CDR-LIFE-BASE-PRICE>
<CDR-LIFE-BP-SPACE>23</CDR-LIFE-BP-SPACE>
<CDR-LIFE-BP-DASH>.</CDR-LIFE-BP-DASH>
<CDR-LIFE-BP-SPACE1>00</CDR-LIFE-BP-SPACE1>
</CDR-LIFE-BASE-PRICE>
<CDR-LIFE-BASE-QTY>
<CDR-LIFE-QTY-SPACE>123</CDR-LIFE-QTY-SPACE>
<CDR-LIFE-QTY-DASH>.</CDR-LIFE-QTY-DASH>
<CDR-LIFE-QTY-SPACE1>000</CDR-LIFE-QTY-SPACE1>
</CDR-LIFE-BASE-QTY>
<CDR-LIFE-BASE-VALUE>$765.00</CDR-LIFE-BASE-VALUE>
</CDR-LIFE-BASE-VALUE-LINE>
<CDR-LIFE-BASE-VALUE-LINE>
<CDR-LIFE-BASE-DESC>
<CDR-LIFE-BASE-DESC1>Second</CDR-LIFE-BASE-DESC1>
<CDR-LIFE-BASE-LIT> </CDR-LIFE-BASE-LIT>
<CDR-LIFE-BASE-DTE>02/02/02</CDR-LIFE-BASE-DTE>
</CDR-LIFE-BASE-DESC>
<CDR-LIFE-BASE-PRICE>
<CDR-LIFE-BP-SPACE>34</CDR-LIFE-BP-SPACE>
<CDR-LIFE-BP-DASH>.</CDR-LIFE-BP-DASH>
<CDR-LIFE-BP-SPACE1>00</CDR-LIFE-BP-SPACE1>
</CDR-LIFE-BASE-PRICE>
<CDR-LIFE-BASE-QTY>
<CDR-LIFE-QTY-SPACE>234</CDR-LIFE-QTY-SPACE>
<CDR-LIFE-QTY-DASH>.</CDR-LIFE-QTY-DASH>
<CDR-LIFE-QTY-SPACE1>000</CDR-LIFE-QTY-SPACE1>
</CDR-LIFE-BASE-QTY>
<CDR-LIFE-BASE-VALUE>$654.00</CDR-LIFE-BASE-VALUE>
</CDR-LIFE-BASE-VALUE-LINE>
<CDR-LIFE-BASE-TOT-VALUE>Very high!</CDR-LIFE-BASE-TOT-VALUE>
</CDR-LIFE-BASE-VALUES-BOX>
674 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
This generated XML suffers from several problems:
• The element names are long and not very meaningful. There may also be an XML schema that specifies
required tag names.
• The XML schema may require some tag names that are COBOL reserved words such as DATE/TIME
• Some fields that are elements should be attributes such as, CDR-LIFE-BASE-VAL-DATE and CDR-
LIFE-BASE-DESC1.
• There is unwanted data, for example, CDR-LIFE-BASE-LIT and CDR-LIFE-BASE-DTE.
• Other required fields are split into too many subcomponents. For example, CDR-LIFE-BASE-PRICE
has three subcomponents for one amount.
These and other characteristics of the XML output can be remedied by using additional phrases of the XML
GENERATE statement as follows:
• Use the NAME OF phrase to provide appropriate tag or attribute names.
• Use the TYPE OF … IS ATTRIBUTE phrase to select the fields which should be XML attributes rather
than elements.
• Use the TYPE OF … IS CONTENT phrase to suppress tags for excessive subcomponents.
• Use the SUPPRESS … WHEN phrase to exclude fields that contain uninteresting values.
Here is an example of the XML GENERATE statement to address those problems:
The result of generating and formatting XML from the statement shown above is more usable:
<Base_Values Date="01/02/03">
<BaseValueLine Description="First">
<Date>01/01/01</Date>
<BasePrice>23.00</BasePrice>
<BaseQuantity>123.000</BaseQuantity>
<BaseValue>$765.00</BaseValue>
</BaseValueLine>
<BaseValueLine Description="Second">
<Date>02/02/02</Date>
<BasePrice>34.00</BasePrice>
<BaseQuantity>234.000</BaseQuantity>
<BaseValue>$654.00</BaseValue>
Note that the COBOL reserved word DATE can now be used as an XML tag name in the output. Characters
such as accented letters and period . that are illegal in single-byte data names can also be used.
Related references
Operation of XML GENERATE (Enterprise COBOL for z/OS Language Reference)
REPLACE statement (Enterprise COBOL for z/OS Language Reference)
676 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Part 6. Developing object-oriented programs
Related tasks
“Defining a class” on page 682
“Defining a class instance method” on page 686
“Defining a client” on page 694
“Defining a subclass” on page 704
“Defining a factory section” on page 707
Chapter 16, “Compiling, linking, and running OO applications,” on page 291
Upgrading IBM COBOL source programs
(Enterprise COBOL for z/OS Migration Guide)
Related references
The Java Language Specification
The words in parentheses in the diagrams are the names of the instance data, and the words that follow a
number and colon are the names of the instance methods.
The structure below shows how the classes relate to each other, and is known as the inheritance
hierarchy. The Account class inherits directly from the class java.lang.Object.
680 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Subclasses
In the account example, Account is a general-purpose class. However, a bank could have many different
types of accounts: checking accounts, savings accounts, mortgage loans, and so forth, all of which have
all the general characteristics of accounts but could have additional characteristics not shared by all types
of accounts.
For example, a CheckingAccount class could have, in addition to the account number and account balance
that all accounts have, a check fee that applies to each check written on the account. A CheckingAccount
class also needs a method to process checks (that is, to read the amount, debit the payer, credit the
payee, and so forth). So it makes sense to define CheckingAccount as a subclass of Account, and to define
in the subclass the additional instance data and instance methods that the subclass needs.
As you design the CheckingAccount class, you discover the need for a class that models checks. An
instance of class Check needs, at a minimum, instance data for payer, payee, and the check amount.
Many additional classes (and database and transaction-processing logic) would need to be designed
in a real-world OO account system, but have been omitted to keep the example simple. The updated
inheritance diagram is shown below.
A number and colon with no method-name following them indicate that the method with that number is
inherited from the superclass.
Related tasks
“Defining a class” on page 682
“Defining a class instance method” on page 686
“Defining a subclass” on page 704
Defining a class
A COBOL class definition consists of an IDENTIFICATION DIVISION and ENVIRONMENT DIVISION,
followed by an optional factory definition and optional object definition, followed by an END CLASS
marker.
682 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
A class CONFIGURATION SECTION can consist of the same entries as a program CONFIGURATION
SECTION, except that a class CONFIGURATION SECTION cannot contain an INPUT-OUTPUT SECTION.
You define an INPUT-OUTPUT SECTION only in the individual methods that require it rather than defining
it at the class level.
As shown above, you define instance data and methods in the DATA DIVISION and PROCEDURE
DIVISION, respectively, within the OBJECT paragraph of the class definition. In classes that require data
and methods that are to be associated with the class itself rather than with individual object instances,
define a separate DATA DIVISION and PROCEDURE DIVISION within the FACTORY paragraph of the
class definition.
Each COBOL class definition must be in a separate source file.
“Example: defining a class” on page 686
Related tasks
“WORKING-STORAGE SECTION for defining class instance data” on page 685
“Defining a class instance method” on page 686
“Defining a subclass” on page 704
“Defining a factory section” on page 707
“Describing the computing environment” on page 5
Chapter 16, “Compiling, linking, and running OO applications,” on page 291
Related references
COBOL class definition structure (Enterprise COBOL for z/OS Language Reference)
Related tasks
“REPOSITORY paragraph for defining a class” on page 684
Related references
CLASS-ID paragraph (Enterprise COBOL for z/OS Language Reference)
User-defined words (Enterprise COBOL for z/OS Language Reference)
The REPOSITORY paragraph entries indicate that the external class-names of the classes referred to as
Base and Account within the class definition are java.lang.Object and Account, respectively.
In the REPOSITORY paragraph, you must code an entry for each class-name that you explicitly reference
in the class definition. For example:
• Base
• A superclass from which the class that you are defining inherits
• The classes that you reference in methods within the class definition
In a REPOSITORY paragraph entry, you must specify the external class-name if the name contains
non-COBOL characters. You must also specify the external class-name for any referenced class that is
part of a Java package. For such a class, specify the external class-name as the fully qualified name of the
package, followed by period (.), followed by the simple name of the Java class. For example, the Object
class is part of the java.lang package, so specify its external name as java.lang.Object as shown above.
An external class-name that you specify in the REPOSITORY paragraph must be an alphanumeric literal
that conforms to the rules of formation for a fully qualified Java class-name.
If you do not include the external class-name in a REPOSITORY paragraph entry, the external class-name
is formed from the class-name in the following manner:
• The class-name is converted to uppercase.
• Each hyphen is changed to zero.
• The first character, if a digit, is changed:
– 1-9 are changed to A-I.
– 0 is changed to J.
• Underscores are not changed.
In the example above, class Account is known externally as Account (in mixed case) because the external
name is spelled using mixed case.
You can optionally include in the REPOSITORY paragraph an entry for the class that you are defining
(Account in this example). You must include an entry for the class that you are defining if the external
class-name contains non-COBOL characters, or to specify a fully package-qualified class-name if the
class is to be part of a Java package.
“Example: external class-names and Java packages” on page 685
Related tasks
“Declaring arrays and strings for Java” on page 724
Related references
REPOSITORY paragraph (Enterprise COBOL for z/OS Language Reference)
The Java Language Specification (Identifiers)
The Java Language Specification (Packages)
684 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Example: external class-names and Java packages
The following example shows how external class-names are determined from entries in a REPOSITORY
paragraph.
Environment division.
Configuration section.
Repository.
Class Employee is "com.acme.Employee"
Class JavaException is "java.lang.Exception"
Class Orders.
The local class-names (the class-names as used within the class definition), the Java packages that
contain the classes, and the associated external class-names are as shown in the table below.
The external class-name (the name after the class-name and optional IS in the REPOSITORY paragraph
entry) is composed of the fully qualified name of the package (if any) followed by a period, followed by the
simple name of the class.
Related tasks
“REPOSITORY paragraph for defining a class” on page 684
Related references
REPOSITORY paragraph (Enterprise COBOL for z/OS Language Reference)
IDENTIFICATION DIVISION.
Object.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 AccountNumber pic 9(6).
01 AccountBalance pic S9(9) value zero.
. . .
End Object.
The instance data is allocated when an object instance is created, and exists until garbage collection of
the instance by the Java run time.
You can initialize simple instance data by using VALUE clauses as shown above. You can initialize more
complex instance data by coding customized methods to create and initialize instances of classes.
COBOL instance data is equivalent to Java private nonstatic member data. No other class or subclass
(nor factory method in the same class, if any) can reference COBOL instance data directly. Instance data
is global to all instance methods that the OBJECT paragraph defines. If you want to make instance data
accessible from outside the OBJECT paragraph, define attribute (get or set) instance methods for doing
so.
Related tasks
“Creating and initializing instances of classes” on page 701
“Freeing instances of classes” on page 703
“Defining a factory method” on page 709
“Coding attribute (get and set) methods” on page 691
cbl dll,thread,pgmname(longmixed)
IDENTIFICATION DIVISION.
Class-id. Account inherits Base.
ENVIRONMENT DIVISION.
Configuration section.
Repository.
Class Base is "java.lang.Object"
Class Account is "Account".
*
IDENTIFICATION DIVISION.
Object.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 AccountNumber pic 9(6).
01 AccountBalance pic S9(9) value zero.
*
PROCEDURE DIVISION.
*
* (Instance method definitions here)
*
End Object.
*
End class Account.
Related tasks
Chapter 16, “Compiling, linking, and running OO applications,” on page 291
“Defining a client” on page 694
686 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 86. Structure of instance method definitions (continued)
Division Purpose Syntax
ENVIRONMENT Relate the file-names used “INPUT-OUTPUT SECTION for defining a class
(optional) in a method to the instance method” on page 688 (optional)
corresponding file-names
known to the operating
system.
DATA (optional) Define external files. Allocate “DATA DIVISION for defining a class instance
a copy of the data. method” on page 688 (optional)
PROCEDURE Code the executable “PROCEDURE DIVISION for defining a class
(optional) statements to complete the instance method” on page 689 (optional)
service provided by the
method.
Definition: The signature of a method consists of the name of the method and the number and type of
its formal parameters. (You define the formal parameters of a COBOL method in the USING phrase of the
method's PROCEDURE DIVISION header.)
Within a class definition, you do not need to make each method-name unique, but you do need to give
each method a unique signature. (You overload methods by giving them the same name but a different
signature.)
COBOL instance methods are equivalent to Java public nonstatic methods.
“Example: defining a method” on page 692
Related tasks
“PROCEDURE DIVISION for defining a class instance method” on page 689
“Overloading an instance method” on page 690
“Overriding an instance method” on page 690
“Invoking methods (INVOKE)” on page 697
“Defining a subclass instance
method” on page 706
“Defining a factory method” on page 709
Identification Division.
Method-id. "credit".
Other Java or COBOL methods or programs (that is, clients) use the method-name to invoke a method.
Related tasks
“Invoking methods (INVOKE)” on page 697
“Using national data (Unicode) in COBOL” on page 125
Related references
The Java Language Specification (Meaning of method names)
Environment Division.
Input-Output Section.
File-Control.
Select account-file Assign AcctFile.
The syntax for the INPUT-OUTPUT SECTION of a method is the same as the syntax for the INPUT-
OUTPUT SECTION of a program.
Related tasks
“Describing the computing environment” on page 5
Related references
INPUT-OUTPUT section (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Describing the data” on page 11
“Sharing data by using the EXTERNAL clause” on page 572
688 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Related references
DATA DIVISION overview (Enterprise COBOL for z/OS Language Reference)
You can code the EXIT METHOD or GOBACK statement in an instance method to return control to the
invoking client. Both statements have the same effect. If you specify the RETURNING phrase upon
invocation of the method, the EXIT METHOD or GOBACK statement returns the value of the data item to
the invoking client.
An implicit EXIT METHOD is generated as the last statement in the PROCEDURE DIVISION of each
method.
You can specify STOP RUN in a method; doing so terminates the entire run unit including all threads
executing within it.
You must terminate a method definition with an END METHOD marker. For example, the following
statement marks the end of the credit method:
USING phrase for obtaining passed arguments: Specify the formal parameters to a method, if any, in
the USING phrase of the method's PROCEDURE DIVISION header. You must specify that the arguments
are passed BY VALUE. Define each parameter as a level-01 or level-77 item in the method's LINKAGE
SECTION. The data type of each parameter must be one of the types that are interoperable with Java.
RETURNING phrase for returning a value: Specify the data item to be returned as the method result, if
any, in the RETURNING phrase of the method's PROCEDURE DIVISION header. Define the data item as a
level-01 or level-77 item in the method's LINKAGE SECTION. The data type of the return value must be
one of the types that are interoperable with Java.
Related tasks
“Coding interoperable data types in OO COBOL and Java” on page 723
“Overriding an instance method” on page 690
“Overloading an instance method” on page 690
“Comparing and setting object references” on page 696
“Invoking methods (INVOKE)” on page 697
Chapter 16, “Compiling, linking, and running OO applications,” on page 291
Linkage section.
01 inDebit pic S9(9) binary.
Procedure Division using by value inDebit.
If you define a CheckingAccount subclass and want it to have a debit method that overrides the
debit method defined in the Account superclass, define the subclass method with exactly one input
parameter also specified as pic S9(9) binary. If a client invokes debit using an object reference to
a CheckingAccount instance, the CheckingAccount debit method (rather than the debit method in the
Account superclass) is invoked.
The presence or absence of a method return value and the data type of the return value used in the
PROCEDURE DIVISION RETURNING phrase (if any) must be identical in the subclass instance method
and the overridden superclass instance method.
An instance method must not override a factory method in a COBOL superclass nor a static method in a
Java superclass.
“Example: defining a method” on page 692
Related tasks
“PROCEDURE DIVISION for defining a class instance method” on page 689
“Coding interoperable data types in OO COBOL and Java” on page 723
“Invoking methods (INVOKE)” on page 697
“Invoking overridden superclass
methods” on page 701
“Defining a subclass” on page 704
“Hiding a factory or static method” on page 710
Related references
The Java Language Specification (Inheritance, overriding, and hiding)
690 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
parameter. The LINKAGE SECTION and PROCEDURE DIVISION header of the init method look like
this:
Linkage section.
01 inAccountNumber pic S9(9) binary.
Procedure Division using by value inAccountNumber.
Clients invoke this method to initialize an Account instance with a given account number (and a
default account balance of zero) by passing exactly one argument that matches the data type of
inAccountNumber.
But the Account class could define, for example, a second instance method init that has an additional
formal parameter that allows the opening account balance to also be specified. The LINKAGE SECTION
and PROCEDURE DIVISION header of this init method could look like this:
Linkage section.
01 inAccountNumber pic S9(9) binary.
01 inBalance pic S9(9) binary.
Procedure Division using by value inAccountNumber
inBalance.
Clients could invoke either init method by passing arguments that match the signature of the required
method.
The presence or absence of a method return value does not have to be consistent in overloaded methods,
and the data type of the return value given in the PROCEDURE DIVISION RETURNING phrase (if any)
does not have to be identical in overloaded methods.
You can overload factory methods in exactly the same way that you overload instance methods.
The rules for overloaded method definition and resolution of overloaded method invocations are based on
the corresponding rules for Java.
Related tasks
“Invoking methods (INVOKE)” on page 697
“Defining a factory method” on page 709
Related references
The Java Language Specification (Overloading)
Identification Division.
Class-id. Account inherits Base.
* (ENVIRONMENT DIVISION not shown)
* (FACTORY paragraph not shown)
*
Identification division.
Object.
Data division.
WORKING-STORAGE SECTION.
01 AccountBalance pic S9(9) value zero.
* (Other instance data not shown)
*
Procedure Division.
*
Identification Division.
Method-id. "getBalance".
Data division.
Linkage section.
01 outBalance pic S9(9) binary.
*
Procedure Division returning outBalance.
Move AccountBalance to outBalance.
End method "getBalance".
*
* (Other instance methods not shown)
End Object.
*
End class Account.
Account class
cbl dll,thread,pgmname(longmixed)
Identification Division.
Class-id. Account inherits Base.
Environment Division.
Configuration section.
Repository.
Class Base is "java.lang.Object"
Class Account is "Account".
*
* (FACTORY paragraph not shown)
*
Identification division.
Object.
Data division.
Working-storage section.
01 AccountNumber pic 9(6).
01 AccountBalance pic S9(9) value zero.
*
Procedure Division.
*
* init method to initialize the account:
Identification Division.
Method-id. "init".
Data division.
Linkage section.
01 inAccountNumber pic S9(9) binary.
Procedure Division using by value inAccountNumber.
Move inAccountNumber to AccountNumber.
692 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
End method "init".
*
* getBalance method to return the account balance:
Identification Division.
Method-id. "getBalance".
Data division.
Linkage section.
01 outBalance pic S9(9) binary.
Procedure Division returning outBalance.
Move AccountBalance to outBalance.
End method "getBalance".
*
* credit method to deposit to the account:
Identification Division.
Method-id. "credit".
Data division.
Linkage section.
01 inCredit pic S9(9) binary.
Procedure Division using by value inCredit.
Add inCredit to AccountBalance.
End method "credit".
*
* debit method to withdraw from the account:
Identification Division.
Method-id. "debit".
Data division.
Linkage section.
01 inDebit pic S9(9) binary.
Procedure Division using by value inDebit.
Subtract inDebit from AccountBalance.
End method "debit".
*
* print method to display formatted account number and balance:
Identification Division.
Method-id. "print".
Data division.
Local-storage section.
01 PrintableAccountNumber pic ZZZZZZ999999.
01 PrintableAccountBalance pic $$$$,$$$,$$9CR.
Procedure Division.
Move AccountNumber to PrintableAccountNumber
Move AccountBalance to PrintableAccountBalance
Display " Account: " PrintableAccountNumber
Display " Balance: " PrintableAccountBalance.
End method "print".
*
End Object.
*
End class Account.
Check class
/**
* A Java class for check information
*/
public class Check {
private CheckingAccount payer;
private Account payee;
private int amount;
Related tasks
Chapter 16, “Compiling, linking, and running OO applications,” on page 291
Because you must compile all COBOL programs that contain object-oriented syntax or that interoperate
with Java with the THREAD compiler option, you cannot use the following language elements in a COBOL
client:
• SORT or MERGE statements
• Nested programs
Any programs that you compile with the THREAD compiler option must be recursive. You must specify the
RECURSIVE clause in the PROGRAM-ID paragraph of each OO COBOL client program.
Related tasks
Chapter 16, “Compiling, linking, and running OO applications,” on page 291
Chapter 31, “Preparing COBOL programs for multithreading,” on page 589
Chapter 40, “Communicating with Java methods,” on page 719
“Coding interoperable data types in OO COBOL and Java” on page 723
“Creating and initializing instances of classes” on page 701
694 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
“Comparing and setting object references” on page 696
“Invoking methods (INVOKE)” on page 697
“Invoking factory or static methods” on page 710
Related references
“THREAD” on page 418
The REPOSITORY paragraph entries indicate that the external class-names of the classes referred to as
Account and Check within the client are Account and Check, respectively.
In the REPOSITORY paragraph, you must code an entry for each class-name that you explicitly reference
in the client. In a REPOSITORY paragraph entry, you must specify the external class-name if the name
contains non-COBOL characters.
You must specify the external class-name for any referenced class that is part of a Java package. For such
a class, specify the external class-name as the fully qualified name of the package, followed by period (.),
followed by the simple name of the Java class.
An external class-name that you specify in the REPOSITORY paragraph must be an alphanumeric literal
that conforms to the rules of formation for a fully qualified Java class-name.
If you do not include the external class-name in a REPOSITORY paragraph entry, the external class-name
is formed from the class-name in the same manner as it is when an external class-name is not included in
a REPOSITORY paragraph entry in a class definition. In the example above, class Account and class Check
are known externally as Account and Check (in mixed case), respectively, because the external names are
spelled using mixed case.
The SOURCE-COMPUTER, OBJECT-COMPUTER, and SPECIAL-NAMES paragraphs of the CONFIGURATION
SECTION are optional.
Related tasks
“REPOSITORY paragraph for defining a class” on page 684
Related references
REPOSITORY paragraph (Enterprise COBOL for z/OS Language Reference)
The Java Language Specification (Identifiers)
The Java Language Specification (Packages)
Data Division.
Local-storage section.
01 anAccount usage object reference Account.
01 aCheckingAccount usage object reference CheckingAccount.
01 aCheck usage object reference Check.
Because a client references classes, it needs one or more special data items called object references,
that is, references to instances of those classes. All requests to instance methods require an object
reference to an instance of a class in which the method is supported (that is, either defined or available
by inheritance). You code object references to refer to instances of Java classes using the same syntax
as you use to refer to instances of COBOL classes. In the example above, the phrase usage object
reference indicates an object reference data item.
All four object references in the code above are called typed object references because a class-name
appears after the OBJECT REFERENCE phrase. A typed object reference can refer only to an instance of
the class named in the OBJECT REFERENCE phrase or to one of its subclasses. Thus anAccount can refer
to instances of the Account class or one of its subclasses, but cannot refer to instances of any other class.
Similarly, aCheck can refer only to instances of the Check class or any subclasses that it might have.
Another type of object reference, not shown above, does not have a class-name after the OBJECT
REFERENCE phrase. Such a reference is called a universal object reference, which means that it can
refer to instances of any class. Avoid coding universal object references, because they are interoperable
with Java in only very limited circumstances (when used in the RETURNING phrase of the INVOKE
class-name NEW . . . statement).
You must define, in the REPOSITORY paragraph of the CONFIGURATION SECTION, class-names that you
use in the OBJECT REFERENCE phrase.
Related tasks
“Choosing LOCAL-STORAGE
or WORKING-STORAGE” on page 696
“Coding interoperable data types in OO COBOL and Java” on page 723
“Invoking methods (INVOKE)” on page 697
“REPOSITORY paragraph for defining a client” on page 695
Related references
RETURNING phrase (Enterprise COBOL for z/OS Language Reference)
Related tasks
Chapter 31, “Preparing COBOL programs for multithreading,” on page 589
If anAccount = Null . . .
If anAccount = Nulls . . .
You can code a call to IsSameObject to check whether two object references, object1 and object2, refer
to the same object instance or whether each refers to no object instance. To ensure that the arguments
696 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
and return value are interoperable with Java and to establish addressability to the callable service, code
the following data definitions and statements before the call to IsSameObject:
Local-storage Section.
. . .
01 is-same Pic X.
88 is-same-false Value X'00'.
88 is-same-true Value X'01' Through X'FF'.
Linkage Section.
Copy JNI.
Procedure Division.
Set Address Of JNIEnv To JNIEnvPtr
Set Address Of JNINativeInterface To JNIEnv
Call IsSameObject Using By Value JNIEnvPtr object1 object2
Returning is-same
If is-same-true . . .
Within a method you can check whether an object reference refers to the object instance on which the
method was invoked by coding a call to IsSameObject that compares the object reference and SELF.
You can instead invoke the Java equals method (inherited from java.lang.Object) to determine whether
two object references refer to the same object instance.
You can make an object reference refer to no object instance by using the SET statement. For example:
You can also make one object reference refer to the same instance as another object reference does by
using the SET statement. For example:
This SET statement causes anotherAccount to refer to the same object instance as anAccount does. If
the receiver (anotherAccount) is a universal object reference, the sender (anAccount) can be either a
universal or a typed object reference. If the receiver is a typed object reference, the sender must be a
typed object reference bound to the same class as the receiver or to one of its subclasses.
Within a method you can make an object reference refer to the object instance on which the method was
invoked by setting it to SELF. For example:
Related tasks
“Coding interoperable data types in OO COBOL and Java” on page 723
“Accessing JNI services” on page 719
Related references
The Java Native Interface (IsSameObject)
When the method-name is an identifier, you must define the object reference (objRef) as USAGE OBJECT
REFERENCE with no specified type, that is, as a universal object reference.
If an invoked method is not supported in the class to which the object reference refers, a severity-3
Language Environment condition is raised at run time unless you code the ON EXCEPTION phrase in the
INVOKE statement.
You can use the optional scope terminator END-INVOKE with the INVOKE statement.
The INVOKE statement does not set the RETURN-CODE special register.
Related tasks
“USING phrase for passing arguments” on page 698
“RETURNING phrase for obtaining a returned value” on page 700
“PROCEDURE DIVISION for defining a class instance method” on page 689
“Coding interoperable data types in OO COBOL and Java” on page 723
“Invoking overridden superclass
methods” on page 701
“Invoking factory or static methods” on page 710
Related references
INVOKE statement (Enterprise COBOL for z/OS Language Reference)
698 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 88. Conformance of arguments in a COBOL client
Programming Is the argument Then code the DATA Restriction
language of the an object DIVISION definition of the
target method reference? argument as:
COBOL No The same as the definition
of the corresponding formal
parameter
Java No Interoperable with the
corresponding Java
parameter
COBOL or Java Yes An object reference that is In a COBOL client (unlike
typed to the same class as in a Java client), the class
the corresponding parameter of an argument cannot be a
in the target method subclass of the class of the
corresponding parameter.
See the example referenced below for a way to make an object-reference argument conform to the type
of a corresponding formal parameter by using the SET statement or the REDEFINES clause.
“Example: passing conforming object-reference arguments from a COBOL client” on page 699
If the target method is overloaded, the data types of the arguments are used to select from among the
methods that have the same name.
You must specify that the arguments are passed BY VALUE. In other words, the arguments are not
affected by any change to the corresponding formal parameters in the invoked method.
The data type of each argument must be one of the types that are interoperable with Java.
Related tasks
“PROCEDURE DIVISION for defining a class instance method” on page 689
“Overloading an instance method” on page 690
“Coding interoperable data types in OO COBOL and Java” on page 723
“Passing data” on page 563
Related references
INVOKE statement (Enterprise COBOL for z/OS Language Reference)
SET statement (Enterprise COBOL for z/OS Language Reference)
REDEFINES clause (Enterprise COBOL for z/OS Language Reference)
. . .
Class-id. C inherits Base.
. . .
Repository.
Class Base is "java.lang.Object"
Class JavaObject is "java.lang.Object".
Identification division.
Factory.
. . .
Procedure Division.
Identification Division.
Method-id. "M".
Data division.
To invoke method M, a COBOL client must pass an argument that is a reference to an object of class
java.lang.Object. The client below defines a data item aString, which cannot be passed as an argument
to M because aString is a reference to an object of class java.lang.String. The client first uses a SET
statement to assign aString to a data item, anObj, that is a reference to an object of class java.lang.Object.
(This SET statement is legal because java.lang.String is a subclass of java.lang.Object.) The client then
passes anObj as the argument to M.
. . .
Repository.
Class jstring is "java.lang.String"
Class JavaObject is "java.lang.Object".
Data division.
Local-storage section.
01 aString object reference jstring.
01 anObj object reference JavaObject.
*
Procedure division.
. . . (statements here assign a value to aString)
Set anObj to aString
Invoke C "M"
using by value anObj
Instead of using a SET statement to obtain anObj as a reference to an object of class java.lang.Object, the
client could define aString and anObj with the REDEFINES clause as follows:
. . .
01 aString object reference jstring.
01 anObj redefines aString object reference JavaObject.
After the client assigns a value to data item aString (that is, a valid reference to an object of class
java.lang.String), anObj can be passed as the argument to M. For an example of the use of the REDEFINES
clause to obtain argument conformance, see the example referenced below.
“Example: J2EE client written in COBOL” on page 731
Related tasks
“Coding interoperable data types in OO COBOL and Java” on page 723
“PROCEDURE DIVISION for defining a class instance method” on page 689
Related references
INVOKE statement (Enterprise COBOL for z/OS Language Reference)
SET statement (Enterprise COBOL for z/OS Language Reference)
REDEFINES clause (Enterprise COBOL for z/OS Language Reference)
700 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 89. Conformance of the returned data item in a COBOL client (continued)
Programming language Is the returned item an Then code the DATA DIVISION definition of the
of the target method object reference? returned item as:
Java No Interoperable with the returned Java data item
COBOL or Java Yes An object reference that is typed to the same class
as the object reference that is returned by the
target method
In all cases, the data type of the returned value must be one of the types that are interoperable with Java.
Related tasks
“Coding interoperable data types in OO COBOL and Java” on page 723
Related references
INVOKE statement (Enterprise COBOL for z/OS Language Reference)
You would define amount as PIC S9(9) BINARY to match the signature of the debit methods.
The CheckingAccount class overrides the print method that is defined in the Account class. Because
the print method has no formal parameters, a method in the CheckingAccount class could invoke the
superclass print method with this statement:
The keyword SUPER indicates that you want to invoke a superclass method rather than a method in
the current class. (SUPER is an implicit reference to the object used in the invocation of the currently
executing method.)
“Example: accounts” on page 680
Related tasks
“Overriding an instance method” on page 690
Related references
INVOKE statement (Enterprise COBOL for z/OS Language Reference)
If you do not call NewGlobalRef, the returned object reference is only a local reference, which means that
it is automatically freed after the method returns.
Related tasks
“Instantiating Java classes” on page 702
“Instantiating COBOL classes” on page 702
“Accessing JNI services” on page 719
“Managing local and global references” on page 721
“DATA DIVISION for defining a client” on page 695
“Invoking methods (INVOKE)” on page 697
“Coding interoperable data types in OO COBOL and Java” on page 723
Related references
INVOKE statement (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Invoking methods (INVOKE)” on page 697
“Coding interoperable data types in OO COBOL and Java” on page 723
Related references
VALUE clause (Enterprise COBOL for z/OS Language Reference)
INVOKE statement (Enterprise COBOL for z/OS Language Reference)
702 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
To make it possible to initialize COBOL instance data that cannot be initialized using VALUE clauses
alone, when designing a COBOL class you must define a parameterized creation method in the FACTORY
paragraph and a parameterized initialization method in the OBJECT paragraph:
1. In the parameterized factory creation method, do these steps:
a) Code INVOKE class-name NEW RETURNING objectRef to create an instance of class-name and to
give initial values to the instance data items that have VALUE clauses.
b) Invoke the parameterized initialization method on the instance (objectRef), passing BY VALUE the
arguments that were supplied to the factory method.
2. In the initialization method, code logic to complete the instance data initialization using the values
supplied through the formal parameters.
To create an instance of the COBOL class and properly initialize it, the client invokes the parameterized
factory method, passing BY VALUE the required arguments. The object reference returned to the client
is a local reference. If the client code is within a method, and the use of the returned object reference is
not limited to the duration of that method, the client code must convert the returned object reference to a
global reference by calling the JNI service NewGlobalRef.
“Example: defining a factory (with methods)” on page 711
Related tasks
“Accessing JNI services” on page 719
“Managing local and global references” on page 721
“Invoking methods (INVOKE)” on page 697
“Defining a factory section” on page 707
Related references
VALUE clause (Enterprise COBOL for z/OS Language Reference)
INVOKE statement (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Managing local and global references” on page 721
cbl dll,thread,pgmname(longmixed)
Identification division.
Program-id. "TestAccounts" recursive.
Environment division.
Configuration section.
Repository.
Class Account is "Account".
Data Division.
* Working data is declared in LOCAL-STORAGE instead of
Defining a subclass
You can make a class (called a subclass, derived class, or child class) a specialization of another class
(called a superclass, base class, or parent class).
A subclass inherits the methods and instance data of its superclasses, and is related to its superclasses
by an is-a relationship. For example, if subclass P inherits from superclass Q, and subclass Q inherits
from superclass S, then an instance of P is an instance of Q and also (by transitivity) an instance of S. An
instance of P inherits the methods and data of Q and S.
Using subclasses has several advantages:
• Reuse of code: Through inheritance, a subclass can reuse methods that already exist in a superclass.
• Specialization: In a subclass you can add new methods to handle cases that the superclass does not
handle. You can also add new data items that the superclass does not need.
• Change in action: A subclass can override a method that it inherits from a superclass by defining a
method of the same signature as that in the superclass. When you override a method, you might make
only a few minor changes or completely change what the method does.
Restriction: You cannot use multiple inheritance in your COBOL programs. Each COBOL class that you
define must have exactly one immediate superclass that is implemented in Java or COBOL, and each
class must be derived directly or indirectly from java.lang.Object. The semantics of inheritance are as
defined by Java.
The structure and syntax of a subclass definition are identical to those of a class definition: Define
instance data and methods in the DATA DIVISION and PROCEDURE DIVISION, respectively, within the
OBJECT paragraph of the subclass definition. In subclasses that require data and methods that are to be
associated with the subclass itself rather than with individual object instances, define a separate DATA
DIVISION and PROCEDURE DIVISION within the FACTORY paragraph of the subclass definition.
COBOL instance data is private. A subclass can access the instance data of a COBOL superclass only if the
superclass defines attribute (get or set) instance methods for doing so.
Related tasks
“Defining a class” on page 682
“Overriding an instance method” on page 690
704 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
“Coding attribute (get and set) methods” on page 691
“Defining a subclass instance
method” on page 706
“Defining a factory section” on page 707
Related references
The Java Language Specification (Inheritance, overriding, and hiding)
COBOL class definition structure (Enterprise COBOL for z/OS Language Reference)
In the example above, CheckingAccount is the subclass being defined. CheckingAccount inherits all the
methods of the class known within the subclass definition as Account. CheckingAccount methods can
access Account instance data only if the Account class provides attribute (get or set) methods for doing
so.
You must specify the name of the immediate superclass in the REPOSITORY paragraph in the
CONFIGURATION SECTION of the ENVIRONMENT DIVISION. You can optionally associate the
superclass name with the name of the class as it is known externally. You can also specify the name of
the subclass that you are defining (here, CheckingAccount) in the REPOSITORY paragraph and associate it
with its corresponding external class-name.
Related tasks
“CLASS-ID paragraph for defining a class” on page 683
“Coding attribute (get and set) methods” on page 691
“REPOSITORY paragraph for
defining a subclass” on page 705
In the REPOSITORY paragraph, you must code an entry for each class-name that you explicitly reference
in the subclass definition. For example:
• A user-defined superclass from which the subclass that you are defining inherits
• The classes that you reference in methods within the subclass definition
The rules for coding REPOSITORY paragraph entries in a subclass are identical to those for coding
REPOSITORY paragraph entries in a class.
Related references
REPOSITORY paragraph (Enterprise COBOL for z/OS Language Reference)
IDENTIFICATION DIVISION.
Object.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 CheckFee pic S9(9) value 1.
. . .
End Object.
Related tasks
“WORKING-STORAGE SECTION for defining class instance data” on page 685
Related tasks
“Defining a class instance method” on page 686
“Overriding an instance method” on page 690
“Overloading an instance method” on page 690
cbl dll,thread,pgmname(longmixed)
Identification Division.
Class-id. CheckingAccount inherits Account.
706 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Environment Division.
Configuration section.
Repository.
Class CheckingAccount is "CheckingAccount"
Class Check is "Check"
Class Account is "Account".
*
* (FACTORY paragraph not shown)
*
Identification division.
Object.
Data division.
Working-storage section.
01 CheckFee pic S9(9) value 1.
Procedure Division.
*
* processCheck method to get the check amount and payee,
* add the check fee, and invoke inherited methods debit
* to debit the payer and credit to credit the payee:
Identification Division.
Method-id. "processCheck".
Data division.
Local-storage section.
01 amount pic S9(9) binary.
01 payee usage object reference Account.
Linkage section.
01 aCheck usage object reference Check.
*
Procedure Division using by value aCheck.
Invoke aCheck "getAmount" returning amount
Invoke aCheck "getPayee" returning payee
Invoke payee "credit" using by value amount
Add checkFee to amount
Invoke self "debit" using by value amount.
End method "processCheck".
*
* print method override to display account status:
Identification Division.
Method-id. "print".
Data division.
Local-storage section.
01 printableFee pic $$,$$$,$$9.
Procedure Division.
Invoke super "print"
Move CheckFee to printableFee
Display " Check fee: " printableFee.
End method "print".
*
End Object.
*
End class CheckingAccount.
Related tasks
Chapter 16, “Compiling, linking, and running OO applications,” on page 291
“Invoking methods (INVOKE)” on page 697
“Overriding an instance method” on page 690
“Invoking overridden superclass
methods” on page 701
COBOL factory data is equivalent to Java private static data. A single copy of the data is instantiated for
the class and is shared by all object instances of the class. You most commonly use factory data when you
want to gather data from all the instances of a class. For example, you could define a factory data item to
keep a running total of the number of instances of the class that are created.
COBOL factory methods are equivalent to Java public static methods. The methods are supported by the
class independently of any object instance. You most commonly use factory methods to customize object
creation when you cannot use VALUE clauses alone to initialize instance data.
IDENTIFICATION DIVISION.
Factory.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 NumberOfAccounts pic 9(6) value zero.
. . .
End Factory.
You can initialize simple factory data by using VALUE clauses as shown above.
COBOL factory data is equivalent to Java private static data. No other class or subclass (nor instance
method in the same class, if any) can reference COBOL factory data directly. Factory data is global to all
factory methods that the FACTORY paragraph defines. If you want to make factory data accessible from
outside the FACTORY paragraph, define factory attribute (get or set) methods for doing so.
Related tasks
“Coding attribute (get and set) methods” on page 691
“Instantiating COBOL classes” on page 702
708 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Defining a factory method
Define COBOL factory methods in the PROCEDURE DIVISION of the FACTORY paragraph of a class
definition. A factory method defines an operation that is supported by a class independently of any object
instance of the class. COBOL factory methods are equivalent to Java public static methods.
You typically define factory methods for classes whose instances require complex initialization, that is,
to values that you cannot assign by using VALUE clauses alone. Within a factory method you can invoke
instance methods to initialize the instance data. A factory method cannot directly access instance data.
You can code factory attribute (get and set) methods to make factory data accessible from outside
the FACTORY paragraph, for example, to make the data accessible from instance methods in the
same class or from a client program. For example, the Account class could define a factory method
getNumberOfAccounts to return the current tally of the number of accounts.
You can use factory methods to wrap procedure-oriented COBOL programs so that they are accessible
from Java programs. You can code a factory method called main to enable you to run an OO application
by using the java command, and to structure your applications in keeping with standard Java practice.
See the Related tasks for details.
In defining factory methods, you use the same syntax that you use to define instance methods. A COBOL
factory method definition consists of four divisions (like a COBOL program), followed by an END METHOD
marker:
Within a class definition, you do not need to make each factory method-name unique, but you do need
to give each factory method a unique signature. You can overload factory methods in exactly the same
way that you overload instance methods. For example, the CheckingAccount subclass provides two
versions of the factory method createCheckingAccount: one that initializes the account to have a default
balance of zero, and one that allows the opening balance to be passed in. Clients can invoke either
createCheckingAccount method by passing arguments that match the signature of the intended method.
If you define a data item with the same name in both the DATA DIVISION of a factory method and the
DATA DIVISION of the FACTORY paragraph, a reference in the method to that data-name refers only to
the method data item. The method DATA DIVISION takes precedence.
“Example: defining a factory (with methods)” on page 711
Related tasks
“Structuring OO applications” on page 715
“Wrapping procedure-oriented COBOL programs” on page 715
“Instantiating COBOL classes” on page 702
“Defining a class instance method” on page 686
“Coding attribute (get and set) methods” on page 691
“Overloading an instance method” on page 690
“Hiding a factory or static method” on page 710
“Invoking factory or static methods” on page 710
“Using object-oriented COBOL and Java under IMS” on page 521
The presence or absence of a method return value and the data type of the return value used in the
PROCEDURE DIVISION RETURNING phrase (if any) must be identical in the subclass factory method and
the hidden superclass method.
A factory method must not hide an instance method in a Java or COBOL superclass.
“Example: defining a factory (with methods)” on page 711
Related tasks
“Coding interoperable data types in OO COBOL and Java” on page 723
“Overriding an instance method” on page 690
“Invoking methods (INVOKE)” on page 697
Related references
The Java Language Specification (Inheritance, overriding, and hiding)
The procedure division header (Enterprise COBOL for z/OS Language Reference)
For example, a client program could invoke one of the overloaded CheckingAccount factory methods
called createCheckingAccount to create a checking account with account number 777777 and an opening
balance of $300 by coding this statement:
To invoke a factory method from within the same class in which you define the factory method, you also
use the class-name as the first operand in the INVOKE statement.
Code the name of the method to be invoked either as a literal or as an identifier whose value at run
time is the method-name. The method-name must be an alphanumeric or national literal or a category
alphabetic, alphanumeric, or national data item, and is interpreted in a case-sensitive manner.
If an invoked method is not supported in the class that you name in the INVOKE statement, a severity-3
Language Environment condition is raised at run time unless you code the ON EXCEPTION phrase in the
INVOKE statement.
The conformance requirements for passing arguments to a COBOL factory method or Java static method
in the USING phrase, and receiving a return value in the RETURNING phrase, are the same as those for
invoking instance methods.
“Example: defining a factory (with methods)” on page 711
Related tasks
“Invoking methods (INVOKE)” on page 697
“Using national data (Unicode) in COBOL” on page 125
“Coding interoperable data types in OO COBOL and Java” on page 723
710 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Related references
INVOKE statement (Enterprise COBOL for z/OS Language Reference)
Account class
cbl dll,thread,pgmname(longmixed)
Identification Division.
Class-id. Account inherits Base.
Environment Division.
Configuration section.
Repository.
Class Base is "java.lang.Object"
Class Account is "Account".
*
Identification division.
Factory.
Data division.
Working-storage section.
01 NumberOfAccounts pic 9(6) value zero.
*
Procedure Division.
*
* createAccount method to create a new Account
* instance, then invoke the OBJECT paragraph's init
* method on the instance to initialize its instance data:
Identification Division.
Method-id. "createAccount".
Data division.
Linkage section.
01 inAccountNumber pic S9(6) binary.
01 outAccount object reference Account.
* Facilitate access to JNI services:
Copy JNI.
Procedure Division using by value inAccountNumber
returning outAccount.
* Establish addressability to JNI environment structure:
Set address of JNIEnv to JNIEnvPtr
Set address of JNINativeInterface to JNIEnv
Invoke Account New returning outAccount
Invoke outAccount "init" using by value inAccountNumber
Add 1 to NumberOfAccounts.
End method "createAccount".
*
End Factory.
*
Identification division.
Object.
Data division.
cbl dll,thread,pgmname(longmixed)
Identification Division.
Class-id. CheckingAccount inherits Account.
Environment Division.
Configuration section.
Repository.
Class CheckingAccount is "CheckingAccount"
Class Check is "Check"
Class Account is "Account".
*
Identification division.
Factory.
Data division.
712 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Working-storage section.
01 NumberOfCheckingAccounts pic 9(6) value zero.
*
Procedure Division.
*
* createCheckingAccount overloaded method to create a new
* CheckingAccount instance with a default balance, invoke
* inherited instance method init to initialize the account
* number, and increment factory data tally of checking accounts:
Identification Division.
Method-id. "createCheckingAccount".
Data division.
Linkage section.
01 inAccountNumber pic S9(6) binary.
01 outCheckingAccount object reference CheckingAccount.
* Facilitate access to JNI services:
Copy JNI.
Procedure Division using by value inAccountNumber
returning outCheckingAccount.
* Establish addressability to JNI environment structure:
Set address of JNIEnv to JNIEnvPtr
Set address of JNINativeInterface to JNIEnv
Invoke CheckingAccount New returning outCheckingAccount
Invoke outCheckingAccount "init"
using by value inAccountNumber
Add 1 to NumberOfCheckingAccounts.
End method "createCheckingAccount".
*
* createCheckingAccount overloaded method to create a new
* CheckingAccount instance, invoke inherited instance methods
* init to initialize the account number and credit to set the
* balance, and increment factory data tally of checking accounts:
Identification Division.
Method-id. "createCheckingAccount".
Data division.
Linkage section.
01 inAccountNumber pic S9(6) binary.
01 inInitialBalance pic S9(9) binary.
01 outCheckingAccount object reference CheckingAccount.
Copy JNI.
Procedure Division using by value inAccountNumber
inInitialBalance
returning outCheckingAccount.
Set address of JNIEnv to JNIEnvPtr
Set address of JNINativeInterface to JNIEnv
Invoke CheckingAccount New returning outCheckingAccount
Invoke outCheckingAccount "init"
using by value inAccountNumber
Invoke outCheckingAccount "credit"
using by value inInitialBalance
Add 1 to NumberOfCheckingAccounts.
End method "createCheckingAccount".
*
End Factory.
*
Identification division.
Object.
Data division.
Working-storage section.
01 CheckFee pic S9(9) value 1.
Procedure Division.
*
* processCheck method to get the check amount and payee,
* add the check fee, and invoke inherited methods debit
* to debit the payer and credit to credit the payee:
Identification Division.
Method-id. "processCheck".
Data division.
Local-storage section.
01 amount pic S9(9) binary.
01 payee usage object reference Account.
Linkage section.
01 aCheck usage object reference Check.
Procedure Division using by value aCheck.
Invoke aCheck "getAmount" returning amount
Invoke aCheck "getPayee" returning payee
Invoke payee "credit" using by value amount
Add checkFee to amount
Invoke self "debit" using by value amount.
End method "processCheck".
*
* print method override to display account status:
Check class
/**
* A Java class for check information
*/
public class Check {
private CheckingAccount payer;
private Account payee;
private int amount;
cbl dll,thread,pgmname(longmixed)
Identification division.
Program-id. "TestAccounts" recursive.
Environment division.
Configuration section.
Repository.
Class Account is "Account"
Class CheckingAccount is "CheckingAccount"
Class Check is "Check".
Data Division.
* Working data is declared in Local-storage
* so that each thread has its own copy:
Local-storage section.
01 anAccount usage object reference Account.
01 aCheckingAccount usage object reference CheckingAccount.
01 aCheck usage object reference Check.
01 payee usage object reference Account.
*
Procedure division.
Test-Account-section.
Display "Test Account class"
* Create account 123456 with 0 balance:
Invoke Account "createAccount"
using by value 123456
returning anAccount
* Deposit 500 to the account:
Invoke anAccount "credit" using by value 500
Invoke anAccount "print"
Display space
*
Display "Test CheckingAccount class"
* Create checking account 777777 with balance of 300:
Invoke CheckingAccount "createCheckingAccount"
using by value 777777 300
714 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
returning aCheckingAccount
* Set account 123456 as the payee:
Set payee to anAccount
* Initialize check for 125 to be paid by account 777777 to payee:
Invoke Check New
using by value aCheckingAccount, payee, 125
returning aCheck
* Debit the payer, and credit the payee:
Invoke aCheckingAccount "processCheck"
using by value aCheck
Invoke aCheckingAccount "print"
Invoke anAccount "print"
*
Stop Run.
End program "TestAccounts".
Related tasks
“Creating and initializing instances of classes” on page 701
“Defining a factory method” on page 709
“Invoking factory or static methods” on page 710
Chapter 16, “Compiling, linking, and running OO applications,” on page 291
Related tasks
“Defining a class” on page 682
“Defining a factory section” on page 707
“Defining a factory method” on page 709
Structuring OO applications
You can structure applications that use object-oriented COBOL syntax in one of three ways.
An OO application can begin with:
• A COBOL program, which can have any name.
Under z/OS UNIX, you can run the application by specifying the name of the linked module (which
should match the program name) at the command prompt. You can also bind the program as a module
in a PDSE and run it in JCL using the EXEC PGM statement.
Related tasks
Chapter 16, “Compiling, linking, and running OO applications,” on page 291
“Defining a factory method” on page 709
“Declaring arrays and strings for Java” on page 724
Chapter 24, “Developing COBOL programs for IMS,” on page 517
In each case, main has no RETURNING phrase and has a single USING parameter, an object reference to
a class that is an array with elements of type java.lang.String. You can run these applications by using the
java command.
Displaying a message
cbl dll,thread
Identification Division.
Class-id. CBLmain inherits Base.
Environment Division.
Configuration section.
Repository.
Class Base is "java.lang.Object"
Class stringArray is "jobjectArray:java.lang.String"
Class CBLmain is "CBLmain".
*
Identification Division.
Factory.
Procedure division.
*
Identification Division.
Method-id. "main".
Data division.
Linkage section.
01 SA usage object reference stringArray.
Procedure division using by value SA.
Display " >> COBOL main method entered"
.
End method "main".
End factory.
End class CBLmain.
716 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
cbl dll,thread,pgmname(longmixed),ssrange
Identification Division.
Class-id. Echo inherits Base.
Environment Division.
Configuration section.
Repository.
Class Base is "java.lang.Object"
Class stringArray is "jobjectArray:java.lang.String"
Class jstring is "java.lang.String"
Class Echo is "Echo".
*
Identification Division.
Factory.
Procedure division.
*
Identification Division.
Method-id. "main".
Data division.
Local-storage section.
01 SAlen pic s9(9) binary.
01 I pic s9(9) binary.
01 SAelement object reference jstring.
01 SAelementlen pic s9(9) binary.
01 Sbuffer pic X(65535).
01 P pointer.
Linkage section.
01 SA object reference stringArray.
Copy "JNI.cpy" suppress.
Procedure division using by value SA.
Set address of JNIEnv to JNIEnvPtr
Set address of JNINativeInterface to JNIEnv
Call GetArrayLength using by value JNIEnvPtr SA
returning SAlen
Display "Input string array length: " SAlen
Display "Input strings:"
Perform varying I from 0 by 1 until I = SAlen
Call GetObjectArrayElement
using by value JNIEnvPtr SA I
returning SAelement
Call "GetStringPlatformLength"
using by value JNIEnvPtr
SAelement
address of SAelementlen
0
Call "GetStringPlatform"
using by value JNIEnvPtr
SAelement
address of Sbuffer
length of Sbuffer
0
Display Sbuffer(1:SAelementlen)
End-perform
.
End method "main".
End factory.
End class Echo.
Related tasks
Chapter 16, “Compiling, linking, and running OO applications,” on page 291
“Defining a factory method” on page 709
Chapter 40, “Communicating with Java methods,” on page 719
Related tasks
Chapter 16, “Compiling, linking, and running OO applications,” on page 291
“Accessing JNI services” on page 719
“Sharing data with Java” on page 723
Chapter 39, “Writing object-oriented programs,” on page 679
Chapter 31, “Preparing COBOL programs for multithreading,” on page 589
Related references
JDK 5.0 Documentation
Use the special register JNIEnvPtr to reference the JNI environment pointer to obtain the address for
the JNI environment structure. JNIEnvPtr is implicitly defined as USAGE POINTER; do not use it as a
receiving data item. Before you reference the contents of the JNI environment structure, you must code
the following statements to establish its addressability:
Linkage section.
COPY JNI
. . .
Related tasks
“Managing local and global references” on page 721
“Handling Java exceptions” on page 720
“Coding interoperable data types in OO COBOL and Java” on page 723
“Defining a client” on page 694
Related references
Appendix F, “JNI.cpy copybook,” on page 847
The Java Native Interface
Throwing an exception: Use one of the following services to throw a Java exception from a COBOL
method:
• Throw
• ThrowNew
You must make the thrown object an instance of a subclass of java.lang.Throwable.
The Java virtual machine (JVM) does not recognize and process the thrown exception until the method
that contains the call has completed and returned to the JVM.
Catching an exception: After you invoke a method that might have thrown a Java exception, you can do
these steps:
1. Test whether an exception occurred.
2. If an exception occurred, process the exception.
3. Clear the exception, if clearing is appropriate.
720 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Use the following JNI services:
• ExceptionOccurred
• ExceptionCheck
• ExceptionDescribe
• ExceptionClear
To do error analysis, use the methods supported by the exception object that is returned. This object is an
instance of the java.lang.Throwable class.
“Example: handling Java exceptions” on page 721
Repository.
Class JavaException is "java.lang.Exception".
. . .
Local-storage section.
01 ex usage object reference JavaException.
Linkage section.
COPY "JNI.cpy".
. . .
Procedure division.
Set address of JNIEnv to JNIEnvPtr
Set address of JNINativeInterface to JNIEnv
. . .
Invoke anObj "someMethod"
Perform ErrorCheck
. . .
ErrorCheck.
Call ExceptionOccurred
using by value JNIEnvPtr
returning ex
If ex not = null then
Call ExceptionClear using by value JNIEnvPtr
Display "Caught an unexpected exception"
Invoke ex "printStackTrace"
Stop run
End-if
Local references
Local references are valid only while the method that you invoke runs. Automatic freeing of the local
references occurs after the native method returns.
Global references
Global references remain valid until you explicitly delete them. You can create global references from
local references by using the JNI service NewGlobalRef.
The following object references are always local:
• Object references that are received as method parameters
• Object references that are returned as the method RETURNING value from a method invocation
• Object references that are returned by a call to a JNI function
• Object references that you create by using the INVOKE . . . NEW statement
Related tasks
“Accessing JNI services” on page 719
“Deleting, saving, and freeing local references” on page 722
Use a SET statement to convert a local reference to a global reference if you want to save a reference in
any of these data items:
• An object instance variable
• A factory variable
• A data item in the WORKING-STORAGE SECTION of a method
Otherwise, an error occurs. These storage areas persist when a method returns; therefore a local
reference is no longer valid.
In most cases you can rely on the automatic freeing of local references that occurs when a method
returns. However, in some cases you should explicitly free a local reference within a method by using the
JNI service DeleteLocalRef. Here are two situations where explicit freeing is appropriate:
• In a method you access a large object, thereby creating a local reference to the object. After extensive
computations, the method returns. Free the large object if you do not need it for the additional
computations, because the local reference prevents the object from being released during garbage
collection.
• You create a large number of local references in a method, but do not use all of them at the same time.
Because the Java virtual machine requires space to keep track of each local reference, you should free
those that you no longer need. Freeing the local references helps prevent the system from running out
of memory.
For example, in a COBOL method you loop through a large array of objects, retrieve the elements as
local references, and operate on one element at each iteration. You can free the local reference to the
array element after each iteration.
Use the following callable services to manage local references and global references.
722 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 92. JNI services for local and global references (continued)
Service Input arguments Return value Purpose
DeleteGlobalRef • The JNI environment None To delete a global
pointer reference to the object
that the input object
• A global object reference refers to
reference
Related tasks
“Accessing JNI services” on page 719
Related tasks
“Coding interoperable data types in OO COBOL and Java” on page 723
“Declaring arrays and strings for Java” on page 724
“Manipulating Java arrays” on page 726
“Manipulating Java strings” on page 728
“Invoking methods (INVOKE)” on page 697
Chapter 29, “Sharing data,” on page 563
1. You must distinguish boolean from byte, because they each correspond to PIC X. PIC X is
interpreted as boolean only if you define an argument or a parameter with the two condition-names
as shown. Otherwise, a PIC X data item is interpreted as the Java byte type.
2. Java floating-point data is formatted according to the IEEE Standard for Binary Floating Point
Arithmetic. Enterprise COBOL, however, uses hexadecimal floating-point representation. When you
pass floating-point arguments by using an INVOKE statement, or you receive floating-point data from
a Java method, the arguments and data are automatically converted as needed.
Related tasks
“Using national data (Unicode) in COBOL” on page 125
724 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 94. Interoperable arrays and strings in COBOL and Java (continued)
Java data type Corresponding COBOL data type
Object[ ] object reference jobjectArray
String object reference jstring
To use one of these classes for interoperability with Java, you must code an entry in the REPOSITORY
paragraph. For example:
Configuration section.
Repository.
Class jbooleanArray is "jbooleanArray".
The REPOSITORY paragraph entry for an object array type must specify an external class-name in one of
these forms:
"jobjectArray"
"jobjectArray:external-classname-2"
In the first case, the REPOSITORY entry specifies an array class in which the elements of the array are
objects of type java.lang.Object. In the second case, the REPOSITORY entry specifies an array class in
which the elements of the array are objects of type external-classname-2. Code a colon as the separator
between the specification of the jobjectArray type and the external class-name of the array elements.
The following example shows both cases. In the example, oa defines an array of elements that are
objects of type java.lang.Object. aDepartment defines an array of elements that are objects of type
com.acme.Employee.
Environment Division.
Configuration Section.
Repository.
Class jobjectArray is "jobjectArray"
Class Employee is "com.acme.Employee"
Class Department is "jobjectArray:com.acme.Employee".
. . .
Linkage section.
01 oa usage object reference jobjectArray.
01 aDepartment usage object reference Department.
. . .
Procedure division using by value aDepartment.
. . .
“Examples: COBOL applications that run using the java command” on page 716
The following Java array types are currently not supported for interoperation with COBOL programs.
Related tasks
“REPOSITORY paragraph for defining a class” on page 684
01 longArray.
02 X pic S9(10) comp-5 occurs 1 to 500 times depending on N.
To operate on objects of the special Java-array classes, call the services that the JNI provides. You can
use services to access and set individual elements of an array and for the following purposes, using the
services cited:
GetBooleanArrayElements, • The JNI environment pointer A pointer to the To extract the array
GetByteArrayElements, storage buffer elements from a Java
• The array object reference
GetCharArrayElements, array into a storage
GetShortArrayElements, • A pointer to a boolean item. buffer. The services
GetIntArrayElements, If the pointer is not null, return a pointer to
GetLongArrayElements the boolean item is set to the storage buffer,
true if a copy of the array which you can use
elements was made. If a copy as the address of a
was made, the corresponding COBOL group data
ReleasexxxArrayElements item defined in the
service must be called if LINKAGE SECTION.
changes are to be written back
to the array object.
ReleaseBooleanArrayElements • The JNI environment pointer None; the storage To release the
, ReleaseByteArrayElements, for the array is storage buffer that
• The array object reference
ReleaseCharArrayElements, released. contains elements
ReleaseShortArrayElements, • A pointer to the storage buffer that have been
ReleaseIntArrayElements, • The release mode, as a binary extracted from a
ReleaseLongArrayElements fullword integer. See Java Java array, and
JNI documentation for details. conditionally map the
(Recommendation: Specify 0 to updated array values
copy back the array content and back into the array
free the storage buffer.) object
726 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 96. JNI array services (continued)
Service Input arguments Return value Purpose
NewObjectArray • The JNI environment pointer The array object To create a new Java
reference, or NULL object array
• The number of elements in if the array cannot
the array, as a binary fullword be constructed1
integer
• An object reference for the array
element class
• An object reference for the
initial element value. All array
elements are set to this value.
“Examples: COBOL applications that run using the java command” on page 716
“Example: processing a Java integer
array” on page 727
Related tasks
“Coding interoperable data types in OO COBOL and Java” on page 723
“Declaring arrays and strings for Java” on page 724
“Accessing JNI services” on page 719
cbl thread,dll
Identification division.
Class-id. OOARRAY inherits Base.
Environment division.
Configuration section.
Repository.
Class Base is "java.lang.Object"
Class jintArray is "jintArray".
Call GetArrayLength
using by value JNIEnvPtr inIntArrayObj
returning intArrayLen
Call GetIntArrayElements
using by value JNIEnvPtr inIntArrayObj 0
returning IntArrayPtr
Set address of intArrayGroup to intArrayPtr
Call ReleaseIntArrayElements
using by value JNIEnvPtr inIntArrayObj intArrayPtr 0.
End method "ProcessArray".
End Object.
End class OOARRAY.
Table 97. Services that convert between jstring references and national data
Service Input arguments Return value
NewString1 • The JNI environment pointer jstring object reference
• A pointer to a Unicode string, such
as a COBOL national data item
• The number of characters in the
string; binary fullword
GetStringLength • The JNI environment pointer The number of Unicode characters in the jstring
object reference; binary fullword
• A jstring object reference
728 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 97. Services that convert between jstring references and national data (continued)
Service Input arguments Return value
GetStringChars1 • The JNI environment pointer • A pointer to the array of Unicode characters
• A jstring object reference extracted from the jstring object, or NULL if the
operation fails. The pointer is valid until it is
• A pointer to a boolean data item, or released with ReleaseStringChars.
NULL
• If the pointer to the boolean data item is not
null, the boolean value is set to true if a copy
is made of the string and to false if no copy is
made.
ReleaseStringChars • The JNI environment pointer None; the storage for the array is released.
• A jstring object reference
• A pointer to the array of Unicode
characters that was returned from
GetStringChars
Services for EBCDIC: Use the following z/OS services, an extension of the JNI, to convert between jstring
object references and COBOL alphanumeric data (PIC X(n)).
Table 98. Services that convert between jstring references and alphanumeric data
Service Input arguments Return value
NewStringPlatform • The JNI environment pointer Return code as a binary fullword
integer:
• Pointer to the null-terminated EBCDIC
character string that you want to convert 0
to a jstring object Success.
• Pointer to the jstring object reference in -1
which you want the result Malformed input or illegal input
character.
• Pointer to the Java encoding name
for the string, represented as a null- -2
terminated EBCDIC character string1 Unsupported encoding; the jstring
object reference pointer is set to
NULL.
1. If the pointer is NULL, the encoding from the Java file.encoding property is used.
These EBCDIC services are packaged as a DLL that is part of your IBM Java Software Development Kit. For
details about the services, see jni_convert.h in the IBM Java Software Development Kit.
Use CALL literal statements to call the services. The calls are resolved through the libjvm.x DLL side
file, which you must include in the link step of any COBOL program that uses object-oriented language.
For example, the following code creates a Java String object from the EBCDIC string 'MyConverter'. (This
code fragment is from the J2EE client program, which is shown in full in “Example: J2EE client written in
COBOL” on page 731.)
730 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
If the EBCDIC services are the only JNI services that you call from a COBOL program, you do not need to
copy the JNI.cpy copybook. You also do not need to establish addressability with the JNI environment
pointer.
Services for UTF-8: The Java Native Interface also provides services for conversion between jstring
object references and UTF-8 strings. These services are not recommended for use in COBOL programs
due to the difficulty in handling UTF-8 character strings on the z/OS platform.
Related tasks
“Accessing JNI services” on page 719
“Coding interoperable data types in OO COBOL and Java” on page 723
“Declaring arrays and strings for Java” on page 724
“Using national data (Unicode) in COBOL” on page 125
Chapter 16, “Compiling, linking, and running OO applications,” on page 291
Process pgmname(longmixed),dll,thread
*****************************************************************
* Demo J2EE client written in COBOL. *
* *
* Based on the sample J2EE client written in Java, which is *
* given in the "Getting Started" chapter of "The Java(TM) 2 *
* Enterprise Edition Developer's Guide." *
* *
* The client: *
* - Locates the home interface of a session enterprise bean *
* (a simple currency converter bean) *
* - Creates an enterprise bean instance *
* - Invokes a business method (currency conversion) *
*****************************************************************
Identification division.
Program-id. "ConverterClient" is recursive.
Environment Division.
Configuration section.
Repository.
Class InitialContext is "javax.naming.InitialContext"
Class PortableRemoteObject
is "javax.rmi.PortableRemoteObject"
Class JavaObject is "java.lang.Object"
Class JavaClass is "java.lang.Class"
Class JavaException is "java.lang.Exception"
Class jstring is "jstring"
Class Converter is "Converter"
Class ConverterHome is "ConverterHome".
Data division.
Working-storage section.
01 initialCtx object reference InitialContext.
01 obj object reference JavaObject.
01 classObj object reference JavaClass.
01 ex object reference JavaException.
01 currencyConverter object reference Converter.
01 home object reference ConverterHome.
01 homeObject redefines home object reference JavaObject.
01 jstring1 object reference jstring.
01 stringBuf pic X(500) usage display.
01 len pic s9(9) comp-5.
*****************************************************************
* Create JNDI naming context. *
*****************************************************************
Invoke InitialContext New returning initialCtx
Perform JavaExceptionCheck
*****************************************************************
* Create a jstring object for the string "MyConverter" for use *
* as argument to the lookup method. *
*****************************************************************
Move z"MyConverter" to stringBuf
Call "NewStringPlatform"
using by value JNIEnvPtr
address of stringBuf
address of jstring1
0
returning rc
If rc not = zero then
Display "Error occurred creating jstring object"
Stop run
End-if
*****************************************************************
* Use the lookup method to obtain a reference to the home *
* object bound to the name "MyConverter". (This is the JNDI *
* name specified when deploying the J2EE application.) *
*****************************************************************
Invoke initialCtx "lookup" using by value jstring1
returning obj
Perform JavaExceptionCheck
*****************************************************************
* Narrow the home object to be of type ConverterHome. *
* First obtain class object for the ConverterHome class, by *
* passing the null-terminated ASCII string "ConverterHome" to *
* the FindClass API. Then use this class object as the *
* argument to the static method "narrow". *
*****************************************************************
Move z"ConverterHome" to stringBuf
Call "__etoa"
using by value address of stringBuf
returning len
If len = -1 then
Display "Error occurred on ASCII conversion"
Stop run
End-if
Call FindClass
using by value JNIEnvPtr
address of stringBuf
returning classObj
If classObj = null
Display "Error occurred locating ConverterHome class"
Stop run
End-if
Invoke PortableRemoteObject "narrow"
using by value obj
classObj
returning homeObject
Perform JavaExceptionCheck
*****************************************************************
* Create the ConverterEJB instance and obtain local object *
* reference for its remote interface *
*****************************************************************
Invoke home "create" returning currencyConverter
Perform JavaExceptionCheck
*****************************************************************
* Invoke business methods *
*****************************************************************
Invoke currencyConverter "dollarToYen"
using by value +100.00E+0
returning amount
Perform JavaExceptionCheck
732 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Display amount
Display amount
*****************************************************************
* Remove the object and return. *
*****************************************************************
Invoke currencyConverter "remove"
Perform JavaExceptionCheck
Goback
.
*****************************************************************
* Check for thrown Java exceptions *
*****************************************************************
JavaExceptionCheck.
Call ExceptionOccurred using by value JNIEnvPtr
returning ex
If ex not = null then
Call ExceptionClear using by value JNIEnvPtr
Display "Caught an unexpected exception"
Invoke ex "printStackTrace"
Stop run
End-if
.
End program "ConverterClient".
/*
*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the proprietary information of Sun Microsystems, Inc.
* Use is subject to license terms.
*
*/
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import Converter;
import ConverterHome;
ConverterHome home =
(ConverterHome)PortableRemoteObject.narrow(objref,
ConverterHome.class);
currencyConverter.remove();
Related tasks
Chapter 16, “Compiling, linking, and running OO applications,” on page 291
WebSphere for z/OS: Applications
Java 2 Enterprise Edition Developer's Guide (Getting Started)
The Java EE 5 Tutorial (Getting Started with Enterprise Beans)
Data Division.
734 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Working-storage section.
01 args object reference stringArray.
01 argsLen pic s9(9) binary value 0.
01 jstring1 object reference JavaString.
01 stringClass object reference JavaClass.
01 ex object reference JavaException.
01 stringBuf pic X(256) usage display.
Linkage section.
COPY "JNI" SUPPRESS.
Procedure division.
Display "COBOL program TSTHELLO entered"
Set address of JNIEnv to JNIEnvPtr
Set address of JNINativeInterface to JNIENV
*
* This static JZOS method will redirect Java stdout/stderr
* to DD:STDOUT and DD:STDERR, which may be spool files or data sets
*
Invoke ZUtil "redirectStandardStreams" (3)
Perform ErrorCheck
Display "Returned from ZUtil.redirectStandardStreams"
*
* We invoke com.ibm.jzos.sample.HelloWorld,
* but this could be any arbitrary Java code
*
Perform BuildEmptyArgsArray.
Invoke HelloWorld "main" (4)
using by value args
Perform ErrorCheck
Display "Returned from HelloWorld.main"
Goback.
ErrorCheck.
Call ExceptionOccurred
using by value JNIEnvPtr
returning ex
If ex not = null then
Call ExceptionClear using by value JNIEnvPtr
Display "Caught a Java exception"
Invoke ex "printStackTrace"
Stop run
End-if.
BuildEmptyArgsArray.
* Create a new empty string
Call NewString
using by value JNIEnvPtr
address of stringBuf
0
returning jstring1
If jstring1 not = null then
Display "NewString returned OK"
Else
Display "NewString returned null!"
Stop run
End-if
(1)
Set the JCL symbols to match your environment.
(2)
The JNI.cpy file is shipped with the compiler and is available as member JNI in data set SIGYLIB.
(3)
The ZUtil redirectStandardStreams method will redirect Java System.out and System.err
to DD:STDOUT and DD:STDERR respectively.
(4)
The com.ibm.jzos.sample.HelloWorld class prints “Hello World! (stdout)” to
System.out and “Hello World! (stderr)” to System.err. You can download the
com.ibm.jzos.sample.HelloWorld class with the JZOS samples.
(5)
Set the INCLUDEs to point to the locations where your Java and COBOL are installed.
(6)
Set the Language Environment ENVARs to point to your Java home directories. Note that individual
environment variable settings wrap at column 72.
736 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
(7)
You can add the COBJVMINITOPTIONS environment variable as shown to set Java system properties
for the JVM. The jzos.merge.sysout=true property can be used to merge both System.out and
System.err to go to DD:SYSOUT.
(8)
The JAVAOUT DD and JAVAERR DD statements are not used if
ZUtil.redirectStandardStreams() works properly, so you can point these to DD DUMMY.
About JZOS
Java Batch Launcher and Toolkit for z/OS (JZOS) is a set of tools that helps you develop z/OS Java
applications that run in a traditional batch environment, and that access z/OS system services. For details,
see the JZOS Installation and User's Guide.
Related references
Example: COBPROD application
JAVA-CALLABLE (Enterprise COBOL for z/OS Language Reference)
JAVA-SHAREABLE (Enterprise COBOL for z/OS Language Reference)
identification division.
program-id. COBPROG.
data division.
working-storage section.
linkage-section.
01 arg1 pic s9(9) comp-5.
01 arg2.
03 pic s9(18) comp-5 occurs 10 times.
01 retval pic x(20).
>>JAVA-CALLABLE
procedure division using arg1 arg2 arg3
returning retval
* COBOL code follows
:
In this example, the JAVA-CALLABLE directive makes this program automatically callable by Java.
Note:
• If a COBOL program with the JAVA-CALLABLE directive has parameters that are not one of the Java-
compatible types, an error will be generated.
• If a general COBOL group item is specified as a parameter and is not a legal Java-compatible array type,
then it will be mapped to a byte array in Java (byte[]). In this case, you need to fill the byte array with
data that matches the layout of the COBOL group that will be used to map those bytes.
COBPROG_java_native.cbl
When running the cjbuild utility to build the DLL for this application, you can specify a package name (-p
option) that will indicate the Java package with which the COBOL native methods are to be associated in
your Java application. The default is enterprise.COBOL.
For an application that consists of just one COBOL native method called COBPROG and the stub files
generated by the compiler are located in the current directory which does not contain stub files for any
other applications, and you accept the current directory for all the output paths for cjbuild (which is the
default and which we do here for simplicity but is not recommended in production), then cjbuild can be
invoked as follows:
cjbuild -v app1
which tells cjbuild to include all the stub files in the current directory into the DLL it builds. The string
"app1" is used to construct the name of the resulting DLL. For a DLL written to a z/OS UNIX path, the DLL
will be called libapp1.so. If the DLL is output to an MVS data set, the DLL will appear as a member in that
data set with the name LIBAPP1. See the -d option of cjbuild utility for details.
Alternatively, if you are mixing stub files for multiple interoperable applications in the same directory you
can create a file in your current z/OS UNIX directory called "programs" that contains the name COBPROG,
which is the only program that is part of this current application, and then you can invoke cjbuild as
follows:
As a further alternative, if you are mixing stub files for multiple interoperable applications in the same
directory, you can use the `-i/--progid` option of cjbuild to indicate that COBPROG is the only COBOL
program in the current application, and then you can invoke cjbuild as:
The -i/--progid option can be specified once for each COBOL program in your application, just like the
program file can contain the name of each COBOL program in your application.
Programming tip: Using a program file or specifying one or more -i\--progid options is supported
so that if you want to place the stub files for all your COBOL programs in a single z/OS UNIX directory,
you can specify which subset of them you care about for a particular interoperable application you
are building. However, if you use one directory of stub files per interoperable application, which is one
possible approach to organizing your code, then you can simply omit those options and arguments, and
cjbuild will process all stub files in the artifact directory as indicated by the -c/--coboldir option, and
this can simplify your build process and is recommended.
Note: If the DLL resides on the z/OS UNIX file system, you can use the java.library.path property of
the JVM on the java command that starts the application to indicate the location of the DLL.
For example, to run a Java application that starts with the "main" method of class TestApp and calls a
COBOL program with an associated stub program DLL located in /home/myid/libs, issue the following
command:
Otherwise, if the DLL is output to a data set, ensure that data set is in your STEPLIB at run time.
742 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
The actual Java code to invoke this native method is as follows:
import enterprise.COBOL.*;
:
int arg1 = 5;
int[] arg2 = new int[10];
:
String retval = enterprise.COBOL.progs.COBPROG(arg1, arg2);
Note: If the name of your COBOL native method program is not defined using a literal, that is, the name
is not case-sensitive, then you must refer to it in Java in its form of upper case, as in the above example
with COBPROG. However, if the COBPROG program was compiled with the PGMNAME(LONGMIXED) option
in effect, then the program name should be specified as "cobprog" and the program should be referred
to in Java with the name exactly as it appears in the quotes. See the following example:
Related references
Example: COBPROD application
JAVA-CALLABLE (Enterprise COBOL for z/OS Language Reference)
'Java.java-class-name.java-static-method-name'
where java-class-name is a Java class name that is fully-qualified with its package name if it is part of
a package, and where java-static-method-name is the name of the static method being called.
If the method is part of a group of nested classes, each nested class name must be introduced with a $
character in the literal.
For example, to call a method myMethod() that exists in nested class Util in outer class TestApp as part of
package com.acme, use the following CALL statement:
Note: The 'Java.' prefix of the literal is not case-sensitive, that is, 'JAVA.' and 'jAvA.' would both be
accepted, but the remaining portion of the literal is case-sensitive and must match the names as they are
declared in Java.
Example
The following example consists of Java class TestApp with static method MyMethod having the indicated
signature:
identification division.
program-id. COBPROG.
data division.
:
package com.acme;
import java.math.*;
working-storage section.
01 f1 comp-1.
01 l1 pic s9(18) comp-5.
01 bdarr.
03 pd pic s9(9)v9(2) comp-3 occurs 3 times.
Procedure division.
:
CALL 'Java.come.acme.TestApp.myMethod' USING f1 l1 bdarr
To build the DLL for this COBOL application that calls Java, if the stub files generated by the compiler
are located in the current directory which does not contain stub files for any other application(s), and you
accept the current directory for all the output paths for cjbuild (which is the default and which we do here
for simplicity but is not recommended in production), then cjbuild can be invoked as follows:
cjbuild -v app1
As a further alternative, if you are mixing stub files for multiple interoperable applications in the same
directory, you can use the -i/--progid option of cjbuild to indicate that COBPROG is the only COBOL
program in the current application, and then you can invoke cjbuild as:
Programming tip: Using a program file or specifying one or more -i\--progid options is supported
so that if you want to place the stub files for all your COBOL programs in a single z/OS UNIX directory,
you can specify which subset of them you care about for a particular interoperable application you
are building. However, if you use one directory of stub files per interoperable application, which is one
possible approach to organizing your code, then you can simply omit those options and arguments, and
cjbuild will process all stub files in the artifact directory as indicated by the -c/--coboldir option, and
this can simplify your build process and is recommended.
Related references
Example: COBPROD application
746 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Chapter 43. Using Java-compatible array types in
COBOL
A COBOL table is compatible with a single-dimension Java array when its definition follows a well-defined
pattern.
Specifically, for a COBOL table to be considered compatible with a Java array, you should define the table
in the following way:
01 array.
03 array-data <java-compatible-elementary-type> occurs X times.
01 array-double.
03 double-data comp-2 occurs 10 times.
01 array-packed.
03 packed-data pic s9(5)v9(4) usage comp-3 occurs 20 times.
Note: USAGE DISPLAY can also be used here instead of USAGE COMP-3 or USAGE PACKED-DECIMAL,
that is, both packed decimal and zoned decimal types in COBOL map to java.math.BigDecimal in
Java. Any legal packed or zoned decimal definition is compatible with java.math.BigDecimal. All
conversions between native COBOL packed or zoned decimal formats and java.math.BigDecimal
objects are handled by conversion routines that are part of the IBM JZOS Web Development Toolkit
product.
An example of an array that corresponds to a java.lang.String object is:
01 array-string
03 string-data pic n(20) occurs 15 times.
Note: For string arrays, PIC X, PIC N, or PIC U can all be used. However, as Java strings are stored
in the UTF-16 Unicode encoding, PIC N will be the most efficient way of communicating string data
between Java and COBOL because codepage conversion is not needed.
01 g1.
03 g1-data1 pic s9(9) comp-5 value 12.
03 g1-data2 pic s9(18) comp-5 value 15.
This group will be identified by the compiler as corresponding to an array of bytes in Java. If g1 is used
as a parameter in a COBOL program with the JAVA-CALLABLE directive, then it is assumed that the
incoming data from Java is in a byte array (byte[]) and it is the Java program's responsibility to set up
the array correctly.
Meanwhile, if the COBOL program passes g1 as an argument in a CALL to a static Java method, the
corresponding Java method must receive the group as an array of bytes.
Here is an example of a static Java method that can be called from COBOL and can receive group
argument g1 as a byte array and access the two subordinate data items of g1:
import java.nio.*;
Array restrictions
At present, only fixed-length tables in COBOL can receive Java arrays (no ODO tables), and the
number of elements in the incoming Java array and the number of elements in the COBOL
table as indicated in its OCCURS clause must match exactly. Otherwise, a Java exception of class
java.lang.IllegalArgumentException is thrown. This exception can be caught in Java code with
try/catch and can be caught by a COBOL program calling a static Java method using the ON EXCEPTION
phrase of the CALL statement.
Note: In Java, array parameters of a method are always dynamic and can receive an incoming array of
any length. Therefore, calls from COBOL to static Java methods are more flexible because a mismatch in
the number of elements of array arguments is not possible. For an array returned from Java to COBOL,
however, the length must still match exactly or an exception will be thrown.
748 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Chapter 44. Accessing COBOL WORKING-STORAGE
data items from Java
This topic explains how data items in COBOL WORKING-STORAGE can be accessed from Java.
Any Java-compatible data items in a COBOL program that fall under the scope of a JAVA-SHAREABLE
ON directive are accessible from Java. The directive applies only to 01/77-level items, thus if a JAVA-
SHAREABLE ON directive appears in the middle of a group, it will apply to the next 01/77-level item that
follows. However, if an 01-level group item falls under the scope of a JAVA-SHAREABLE ON directive, all
data items subordinate to the 01-level item in the group can be accessed from Java.
When a data item is shareable with Java, the compiler generates a Java class that defines an interface to
both read and write to the memory of the data item from Java code. The interface class is instantiated at
run time and accessible through a special class called strg that belongs to the package indicated by the
-p option when cjbuild is run, where enterprise.COBOL is the default package name. The strg class
will provide an interface for each COBOL program in the application that shares WORKING-STORAGE
memory with Java, and for each program there will be an interface for each of the WORKING-STORAGE
01/77-level items that are shareable.
Note:
1. Because the mechanism for sharing data between COBOL and Java involves EXTERNAL data items in
COBOL, data items that are Java-shareable should have a unique name across the entire COBOL part
of the application; otherwise, there is a possibility for a name collision. The name of Java-shareable
data items must also be 26 characters or less.
2. Before the WORKING-STORAGE memory of a COBOL program can be accessed from Java, the
WORKING-STORAGE of the program should be initialized first. This can only happen if the program
is called directly or indirectly from Java.
3. Any data item that falls under the scope of a JAVA-SHAREABLE ON directive that is not a Java-
compatible type will be ignored.
Example
Consider the following Java-shareable group defined in Java-callable COBOL program PROGA:
JAVA-SHAREABLE ON
01 g1.
03 data1 pic s9(9) comp-5.
03 data2 pic s9(5)v9(4) comp-3.
01 fl comp-1.
JAVA-SHAREABLE OFF
And consider the following Java-shareable group that is defined in Java-callable COBOL program PROGB:
JAVA-SHAREABLE ON
01 g2.
03 data1 pic x(20).
03 data2 pic comp-2.
01 i1 pic s9(9) comp-5.
JAVA-SHAREABLE OFF
Assume the default package enterprise.COBOL was used when building the DLL for the application
that uses cjbuild. You can use the following Java code to access these data items:
import enterprise.COBOL.*;
import java.math.*;
Related references
JAVA-CALLABLE (Enterprise COBOL for z/OS Language Reference)
JAVA-SHAREABLE (Enterprise COBOL for z/OS Language Reference)
Related tasks
“Step 2: Running the cjbuild utility to build a DLL of Java stub programs” on page 304
750 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Chapter 45. Handling errors in Java-interoperable
COBOL applications
This topic provides suggestions on COBOL/Java interoperability error handing.
For cases where COBOL calls out to a static Java method using the CALL statement, exceptions can occur
on the Java side of the application or in the Java call stub program. All exceptions occurring during the call
can be handled using the ON EXCEPTION phrase of the CALL statement. If an exception occurs and the
ON EXCEPTION phrase is specified, the exception will be cleared before the code in the ON EXCEPTION
phrase is executed. If desired, user exception handling code can access the Java exception object that
caused the exception through the IGY-JAVAIOP-CALL-EXCEPTION special register. To propagate the
exception up the chain of calling programs, the JNI function Throw() can be used to re-throw the
exception object. If an exception occurs and the ON EXCEPTION phrase is not specified, the COBOL
run unit will be stopped due to the unhandled exception. An alternative method of handling exceptions
that occur on the Java side of the application when COBOL calls a static Java method is for the static Java
method to catch any exceptions and convert them to a return code that is returned to the COBOL caller.
On the COBOL side, the COBOL application can decide what to do based on the return code.
For cases where Java calls COBOL, if a Java exception occurs in the native method call stub program
when executing JNI functions, the stub program will not clear the exception and will immediately return
to the Java side of the application where the exception can be caught and handled appropriately. If the
exception is not handled, the Java application will be terminated due to the unhandled exception.
Related tasks
Chapter 17, “Compiling, linking, and running non-OO COBOL applications that interoperate with Java,” on
page 301
Related tasks
“Setting checkpoints” on page 757
“Restarting programs” on page 760
“Resubmitting jobs for restart” on page 762
z/OS DFSMS: Checkpoint/Restart
Related references
“DD statements for defining checkpoint data sets” on page 758
“Messages generated during checkpoint” on page 760
“Formats for requesting deferred restart” on page 761
Setting checkpoints
To set checkpoints, use job control statements and use the RERUN clause in the ENVIRONMENT
DIVISION. Associate each RERUN clause with a particular COBOL file.
The RERUN clause indicates that a checkpoint record is to be written to a checkpoint data set whenever a
specified number of records in the COBOL file have been processed or when END OF VOLUME is reached.
You cannot use the RERUN clause with files that are defined with the EXTERNAL attribute.
You can write checkpoint records from several COBOL files to one checkpoint data set, but you must use a
separate data set exclusively for checkpoint records. You cannot embed checkpoint records in one of your
program data sets.
Restrictions: A checkpoint data set must have sequential organization. You cannot write checkpoints in
VSAM data sets or in data sets that are allocated to extended-format QSAM data sets. Also, a checkpoint
cannot be taken if any program in the run unit has an extended-format QSAM data set that is open.
Checkpoint records are written in the checkpoint data set defined by a DD statement. In the DD statement,
you also choose the checkpoint method:
Single (store single checkpoints)
Only one checkpoint record exists at any given time. After the first checkpoint record is written, any
succeeding checkpoint record overlays the previous one.
This method is acceptable for most programs. You save space in the checkpoint data set, and you can
restart your program at the latest checkpoint.
Multiple (store multiple contiguous checkpoints)
Checkpoints are recorded and numbered sequentially. Each checkpoint is saved.
Use this method if you want to restart a program at a checkpoint other than the latest one taken.
You must use the multiple checkpoint method for complete compliance with the 85 COBOL Standard.
Related tasks
“Using checkpoint/restart with DFSORT” on page 237
“Designing checkpoints” on page 758
“Testing for a successful checkpoint” on page 758
Related references
“DD statements for defining checkpoint data sets” on page 758
Designing checkpoints
Design your checkpoints at critical points in your program so that data can be easily reconstructed. Do not
change the contents of files between the time of a checkpoint and the time of the restart.
In a program that uses disk files, design the program so that you can identify previously processed
records. For example, consider a disk file that contains loan records that are periodically updated for
interest due. If a checkpoint is taken, records are updated, and then the program is interrupted, you
would want to test that the records that are updated after the last checkpoint are not updated again when
the program is restarted. To do this, set up a date field in each record, and update the field each time the
record is processed. Then, after the restart, test the field to determine whether the record was already
processed.
For efficient repositioning of a print file, take checkpoints on the file only after printing the last line of a
page.
Related references
z/OS DFSMS: Checkpoint/Restart (Return codes)
//ddname DD DSNAME=data-set-name,
// [VOLUME=SER=volser,]UNIT=device-type,
// DISP=({NEW|MOD},PASS)
//ddname DD DSNAME=data-set-name,
// [VOLUME=(PRIVATE,RETAIN,SER=volser),]
// UNIT=device-type,SPACE=(subparms),
// DISP=({NEW|MOD},PASS,KEEP)
758 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
ddname
Provides a link to the DD statement. The same as the ddname portion of the assignment-name used in
the COBOL RERUN clause.
data-set-name
Identifies the checkpoint data set to the restart procedure. The name given to the data set used to
record checkpoint records.
volser
Identifies the volume by serial number.
device-type
Identifies the device.
subparms
Specifies the amount of track space needed for the data set.
MOD
Specifies the multiple contiguous checkpoint method.
NEW
Specifies the single checkpoint method.
PASS
Prevents deletion of the data set at successful completion of the job step, unless the job step is the
last in the job. If it is the last step, the data set is deleted.
KEEP
Keeps the data set if the job step abnormally ends.
“Examples: defining checkpoint data sets” on page 759
//CHECKPT DD DSNAME=CHECK1,VOLUME=SER=ND0003,
// UNIT=TAPE,DISP=(NEW,KEEP),LABEL=(,NL)
. . .
ENVIRONMENT DIVISION.
. . .
RERUN ON CHECKPT EVERY
5000 RECORDS OF ACCT-FILE.
//CHEK DD DSNAME=CHECK2,
// VOLUME=(PRIVATE,RETAIN,SER=DB0030),
// UNIT=3380,DISP=(NEW,KEEP),SPACE=(CYL,5)
. . .
ENVIRONMENT DIVISION.
. . .
RERUN ON CHEK EVERY
20000 RECORDS OF PAYCODE.
RERUN ON CHEK EVERY
30000 RECORDS OF IN-FILE.
//CHEKPT DD DSNAME=CHECK3,VOLUME=SER=111111,
// UNIT=TAPE,DISP=(MOD,PASS),LABEL=(,NL)
. . .
ENVIRONMENT DIVISION.
. . .
RERUN ON CHEKPT EVERY
10000 RECORDS OF PAY-FILE.
checkid C0000004
Restarting programs
The system restart routine retrieves the information recorded in a checkpoint record, restores the
contents of main storage and all registers, and restarts the program.
You can begin the restart routine in one of two ways:
• Automatically at the time an interruption stopped the program
• At a later time as a deferred restart
The RD parameter of the job control language determines the type of restart. You can use the RD
parameter on either the JOB or the EXEC statement. If coded on the JOB statement, the parameter
overrides any RD parameters on the EXEC statement.
To suppress both restart and writing checkpoints, code RD=NC.
Restriction: If you try to restart at a checkpoint taken by a COBOL program during a SORT or MERGE
operation, an error message is issued and the restart is canceled. Only checkpoints taken by DFSORT are
valid.
Data sets that have the SYSOUT parameter coded in their DD statements are handled in various ways
depending on the type of restart.
If the checkpoint data set is multivolume, include in the VOLUME parameter the sequence number of the
volume on which the checkpoint entry was written. If the checkpoint data set is on a 7-track tape with
nonstandard labels or no labels, the SYSCHK DD statement must contain DCB=(TRTCH=C,. . .).
Related tasks
“Using checkpoint/restart with DFSORT” on page 237
“Requesting automatic restart” on page 760
“Requesting deferred restart” on page 761
760 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
To restart automatically, a program must satisfy the following conditions:
• In the program you must request restart by using the RD parameter or by taking a checkpoint.
• An abend that terminated the job must return a code that allows restart.
• The operator must authorize the restart.
“Example: requesting a step restart” on page 762
Request a deferred restart by using the RESTART parameter on the JOB card and a SYSCHK DD statement
to identify the checkpoint data set. If a SYSCHK DD statement is present in a job and the JOB statement
does not contain the RESTART parameter, the SYSCHK DD statement is ignored. If a RESTART parameter
without the CHECKID subparameter is included in a job, a SYSCHK DD statement must not appear before
the first EXEC statement for the job.
“Example: restarting a job at a specific checkpoint step” on page 762
Related references
“Formats for requesting deferred restart” on page 761
762 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
// VOLUME=(PRIVATE,RETAIN,,6)
//DDCKPNT DD UNIT=TAPE,DISP=(MOD,PASS,CATLG),
// DSNAME=C91468,LABEL=(,NL)
The DDCKPNT DD statement defines a checkpoint data set. For this step, after a RERUN clause is
performed, only automatic checkpoint restart can occur unless a CHKPT cancel is issued.
764 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Chapter 48. Using zlib compression from a COBOL
program
Refer to the following example including instructions and tricks about using zlib compression from a
COBOL program.
Working-Storage Section.
**> Memory for tests. 'data' to be compressed
01 zinput pic X(65536) value x'00'.
01 zoutput pic X(65536) value x'00'.
01 z.
* next_in is a Pointer to zstring
02 next_in Pointer.
02 avail_in Pic S9(9) Comp-5.
02 total_in Pic S9(9) Comp-5.
* next_out is a Pointer to zstring
02 next_out Pointer.
02 avail_out Pic S9(9) Comp-5.
02 total_out Pic S9(9) Comp-5.
* msg is a Pointer to zstring
02 msg Pointer.
02 state Pointer.
02 zalloc Function-pointer.
02 zfree Function-pointer.
02 opaque Function-pointer.
02 data_type Pic S9(9) Comp-5.
02 adler Pic S9(9) Comp-5.
02 reserved Pic S9(9) Comp-5.
01 y.
* next_in is a Pointer to zstring
02 next_in Pointer.
02 avail_in Pic S9(9) Comp-5.
02 total_in Pic S9(9) Comp-5.
* next_out is a Pointer to zstring
02 next_out Pointer.
02 avail_out Pic S9(9) Comp-5.
02 total_out Pic S9(9) Comp-5.
* msg is a Pointer to zstring
02 msg Pointer.
02 state Pointer.
Linkage Section.
77 zstring Pic x(1000).
77 rc Pic S9(9) Comp-5.
* *>********************************************************/
* *> */
* *> Call deflateInit to initialize the deflate stream */
* *> service using a GZIP wrapper */
* *> */
* *>********************************************************/
Call 'DEIN2' Using By Value Address of z,
By Value -1, 8, 31, 8, 0,
By Content '1.2.7',
By Value Length Of z
returning rc
If rc NOT = 0 Then
Move rc to rc-disp
Display 'Error: deflateInit failed with Return Code '
rc-disp
If msg of z NOT = Null Then
Set Address of zstring to msg of z
Display 'Message = ' zstring
Else
Display 'Message pointer is NULL '
End-if
Move -1 To Return-code rc
Goback
Else
Display 'deflatinit Successful ! '
End-if
******************************************************************
* Initialize available input, output, total in for deflate
******************************************************************
Compute avail_in of z = 65536
Compute avail_out of z = 65536
Compute total_in of z = 0
******************************************************************
* Set input and output pointers
******************************************************************
Set next_out of z to Address of zoutput
Set next_in of z to Address of zinput
* *>***********************************************************/
* *> */
* *> Call deflate to compress the data. We only call it */
* *> once with a flush mode of Z_FINISH (4) which indicates */
* *> to end the stream */
* *> */
* *>***********************************************************/
Call 'deflate' Using By Value Address of z
BY Value 4 Returning rc
If rc NOT = 1 Then
Move rc to rc-disp
Display ' Error: deflate returned ' rc-disp
766 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Display "avail_in of z= " avail_in of z
Display "total_in of z= " total_in of z
Display "avail_out of z= " avail_out of z
Display "total_out of z= " total_out of z
Move -1 To Return-code rc
Goback
Else
Display 'deflate Successful ! '
End-if
* /************************************************************/
* /* */
* /* Now that we are done , call deflateEnd to cleanup the */
* /* deflate internal state. */
* /* */
* /************************************************************/
Call 'DEEND' Using By Value Address of z returning rc
If rc Not = 0 Then
Move rc to rc-disp
Display 'Error: deflateEnd returned ' rc-disp
* /************************************************************/
* /* */
* /* Inflate the data we just deflated. Call inflateInit to */
* /* initialize the inflate stream */
* /* */
* /************************************************************/
Set zalloc of y to Null
Set zfree of y to Null
If rc NOT = 0 Then
Move rc to rc-disp
Display 'Error: inflateInit failed with Return Code '
rc-disp
* /************************************************************/
* /* */
* /* Set the amount of input based on what deflate returned */
* /* and what we expect the output size to be. */
* /* */
* /************************************************************/
Compute avail_in of y = total_out of z
Compute avail_out of y = 65536
Compute total_in of y = 0
* /************************************************************/
* /* */
* /* Call inflate to decompress the data. Note that we expect */
* /* this to end with a Z_STREAM_END (1)since we provided the */
* /* full stream above. */
* /* */
* /************************************************************/
Call 'inflate' Using By Value Address of y
By Value 0 Returning rc
If rc Not = 1 Then
Move rc to rc-disp
Display ' Error: inflate returned ' rc-disp
* /************************************************************/
* /* */
* /* Now that we are done call inflateEnd to cleanup the */
* /* internal inflate state of the stream. */
* /* */
* /************************************************************/
Call 'INEND' Using By Value Address of y Returning rc
If rc Not = 0 Then
If rc Not = 0 Then
Move rc to rc-disp
Display 'Error: inflateEnd returned ' rc-disp
768 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Part 9. Improving performance and productivity
Related concepts
“Optimization” on page 776
Related tasks
“Using an optimal programming
style” on page 771
“Choosing efficient data types” on page 772
“Handling tables efficiently” on page 774
“Optimizing your code” on page 776
“Choosing compiler features to enhance performance” on page 777
“Running efficiently with CICS, IMS, or VSAM” on page 783
Language Environment Programming Guide (Specifying runtime options)
Related references
“Performance-related compiler options” on page 778
Language Environment Programming Guide (Storage performance considerations)
Related tasks
“Using structured programming” on page 772
“Factoring expressions” on page 772
“Using symbolic constants” on page 772
Factoring expressions
By factoring expressions in your programs, you can potentially eliminate a lot of unnecessary
computation.
For example, the first block of code below is more efficient than the second block of code:
The optimizer does not factor expressions across multiple statements. For details, see Factoring
expressions in the Enterprise COBOL for z/OS Performance Tuning Guide.
Related concepts
“Formats for numeric data” on page 47
Related tasks
“Choosing efficient computational data items” on page 773
“Using consistent data types” on page 773
“Making arithmetic expressions efficient” on page 773
“Making exponentiations efficient” on page 774
772 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Choosing efficient computational data items
When you use a data item mainly for arithmetic or as a subscript, code USAGE BINARY on the data
description entry for the item. The operations for manipulating binary data are faster than those for
manipulating decimal data.
However, if a fixed-point arithmetic statement has intermediate results with a large precision (number
of significant digits), the compiler uses decimal arithmetic anyway, after converting the operands to
packed-decimal, decimal floating point, or vector decimal form. For fixed-point arithmetic statements, the
compiler normally uses binary arithmetic for simple computations with binary operands if the precision
is eight or fewer digits. Above 18 digits, the compiler always uses decimal arithmetic. With a precision of
nine to 18 digits, the compiler uses either form.
To produce the most efficient code for a BINARY data item, ensure that it has:
• A sign (an S in its PICTURE clause)
• Eight or fewer digits
For a data item that is larger than eight digits or is used with DISPLAY or NATIONAL data items, use
PACKED-DECIMAL. The code generated for PACKED-DECIMAL data items can be as fast as that for
BINARY data items in some cases, especially if the statement is complicated or specifies rounding.
To produce the most efficient code for a PACKED-DECIMAL data item, ensure that it has:
• A sign (an S in its PICTURE clause)
• An odd number of digits (9s in the PICTURE clause), so that it occupies an exact number of bytes
without a half byte left over
• 15 or fewer digits in the PICTURE specification on ARCH(7) machines. If a PACKED-DECIMAL data item
has more than 31 digits, library routines are used. For a PACKED-DECIMAL data item with 16-31 digits
on ARCH(8) or higher level machines, the compiler uses instructions that are more efficient than library
calls, but not as fast as if the data item has 15 or fewer digits.
774 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
• Avoid errors in references by coding index and subscript checks into your program.
If you need to validate indexes and subscripts, it might be faster to code your own checks than to use
the SSRANGE compiler option.
You can also improve the efficiency of tables by using these guidelines:
• Use binary data items for all subscripts.
When you use subscripts to address a table, use a BINARY signed data item with eight or fewer digits. In
some cases, using four or fewer digits for the data item might also improve processing time.
• Use binary data items for variable-length table items.
For tables with variable-length items, you can improve the code for OCCURS DEPENDING ON (ODO). To
avoid unnecessary conversions each time the variable-length items are referenced, specify BINARY for
OCCURS . . . DEPENDING ON objects.
• Use fixed-length data items whenever possible.
Copying variable-length data items into a fixed-length data item before a period of high-frequency use
can reduce some of the overhead associated with using variable-length data items.
• Organize tables according to the type of search method used.
If the table is searched sequentially, put the data values most likely to satisfy the search criteria at the
beginning of the table. If the table is searched using a binary search algorithm, put the data values in
the table sorted alphabetically on the search key field.
Related concepts
“Optimization of table references” on page 775
Related tasks
“Referring to an item in
a table” on page 70
“Choosing efficient data types” on page 772
Related references
“SSRANGE” on page 411
Here comp_s1 is the value of S1 after conversion to binary, comp-s2 is the value of S2 after conversion
to binary, and so on. The strides for each dimension are d1, d2, and d3. The stride of a given dimension
is the distance in bytes between table elements whose occurrence numbers in that dimension differ by 1
and whose other occurrence numbers are equal. For example, the stride d2 of the second dimension in
the above example is the distance in bytes between ELEMENT(S1 1 S3) and ELEMENT(S1 2 S3).
Index computations are similar to subscript computations, except that no multiplication needs to be
done. Index values have the stride factored into them. They involve loading the indexes into registers, and
these data transfers can be optimized, much as the individual subscript computation terms are optimized.
SET I5 TO I
SET I5 UP BY 5
SET J3 TO J
SET J3 DOWN BY 3
SET K2 TO K
SET K2 UP BY 2
This processing makes the direct indexing less efficient than the relative indexing in ELEMENT (I + 5,
J - 3, K + 2).
Related concepts
“Optimization” on page 776
Related tasks
“Handling tables efficiently” on page 774
Related concepts
“Optimization” on page 776
Related references
“LIST” on page 382
“OPTIMIZE” on page 395
Optimization
To improve the efficiency of the generated code, you can use the OPTIMIZE(1) or OPTIMIZE(2)
compiler option.
OPTIMIZE(1) causes the COBOL optimizer to do the following optimizations:
• Eliminate unnecessary transfers of control and inefficient branches, including those generated by the
compiler that are not evident from looking at the source program.
• Simplify the compiled code for a PERFORM statement. The compiler replicates the PERFORM a number of
times to avoid linkage code.
• Eliminate duplicate computations (such as subscript computations and repeated statements) that have
no effect on the results of the program.
776 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
• Eliminate constant computations by performing them when the program is compiled.
• Eliminate constant conditional expressions.
• Aggregate moves of contiguous items (such as those that often occur with the use of MOVE
CORRESPONDING) into a single move. Both the source and target must be contiguous for the moves
to be aggregated.
• Delete from the program, and identify with a warning message, code that can never be performed
(unreachable code elimination).
• Discard unreferenced data items from the DATA DIVISION, and suppress generation of code to
initialize these data items to their VALUE clauses. (The optimizer takes this action only when you use
the STGOPT option.)
OPTIMIZE(2) causes the COBOL optimizer to do further optimizations:
• Simplify operations more aggressively and schedule instructions.
• Do interblock optimizations such as global value propagation and loop invariant code motion.
Related concepts
“PERFORM procedure integration” on page 777
Related references
“OPTIMIZE” on page 395
Program size: If the performed procedures are invoked by several PERFORM statements and replace each
such statement, the program could become large. The optimizer limits this increase, after which it no
longer integrates these procedures.
Related references
“INLINE” on page 375
INLINE directive (Enterprise COBOL for z/OS Language Reference)
Related concepts
“Optimization” on page 776
Related tasks
“Optimizing your code” on page 776
“Getting listings” on page 453
Related references
“Performance-related compiler options” on page 778
AFP(NOVOLATIL To control the AFP(NOVOLATILE) lets None Poorly behaved assembler code might
E) compiler usage of the compiler generate not adhere to the standard calling
the Additional Floating more efficient code convention and might fail to correctly
(see “AFP” on
Point (AFP) registers sequences for programs preserve values in Floating Point
page 346)
that are provided with floating point registers. With AFP(NOVOLATILE),
by IBM z/Architecture operations. COBOL programs can safely call such
processors routines.
ARCH To specify the If you specify a higher None Your application might abend if it runs
machine architecture ARCH level, the machine on a processor with an architecture
(see “ARCH” on
for which the generates code that level lower than that specified for the
page 347)
executable program uses newer and faster ARCH option.
instructions are to be instructions instead of
generated the sequences of
common instructions.
ARITH(EXTEND) To increase the None ARITH(EXTEND) The amount of degradation that you
maximum number of causes some experience depends directly on the
(see “ARITH” on
digits allowed for degradation in amount of decimal data that you use.
page 349)
decimal numbers performance for all
decimal data types
because of larger
intermediate results.
AWO To get optimum use Can result in None If you use AWO, the APPLY WRITE-
of buffer and device performance savings, ONLY clause is in effect for all QSAM
(see “AWO” on
space for QSAM files because this option files in the program that have V-mode
page 350)
results in fewer calls records.
to data management
services to handle input
and output
778 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 99. Performance-related compiler options (continued)
BLOCK0 To take advantage Can result in enhanced None If you use BLOCK0, a BLOCK CONTAINS
of system-determined processing speed and 0 clause is activated for all QSAM files in
(see “BLOCK0”
block size for QSAM minimized storage the program that specify neither BLOCK
on page 350)
output files requirements for QSAM CONTAINS nor RECORDING MODE U in
output files the file description entry.
DATA(31) To have DFSMS Because extended- None On a z/OS system with DFSMS, if your
allocate QSAM buffers format QSAM data application processes striped extended-
(see “DATA” on
above the 16 MB line sets can require many format QSAM data sets, use the RENT
page 359)
(by using the RENT and buffers, allocating the and DATA(31) compiler options to have
DATA(31) compiler buffers in unrestricted the input-output buffers for your QSAM
options) storage avoids virtual files allocated from storage above the
storage constraint 16 MB line.
problems.
DYNAM To have subprograms Subprograms are easier There is a slight To free virtual storage that is no longer
(called through the to maintain, because performance penalty, needed, issue the CANCEL statement.
(see “DYNAM” on
CALL statement) the application does not because the call must
page 366)
dynamically loaded at have to be link-edited go through a Language
run time again if a subprogram is Environment routine.
changed.
FASTSRT To specify that the IBM Eliminates the overhead None FASTSRT is recommended if direct work
DFSORT product (or of returning to Enterprise files are used for the sort work files. Not
(see “FASTSRT”
equivalent) will handle COBOL after each record all sorts are eligible for this option.
on page 369)
all of the input and is processed.
output
HGPR To control the compiler If you specify None If your program modifies and does not
usage of the 64-bit HGPR(NOPRESERVE), save the high-halves of the registers,
(see “HGPR” on
registers provided by the compiler omits but calling programs depend on the
page 372)
IBM z/Architecture preserving the high- unchanged values, the application might
processors. halves of the 64-bit give incorrect results.
GPRs that a program is
Exception: It does not apply if the
using, which improves
caller of this program is Enterprise
performance.
COBOL, Enterprise PL/I or z/OS XL C/C+
+ programs.
INLINE To control the Specifying INLINE Specifying INLINE You can use the INLINE compiler
compiler usage of allows the compiler usually increases the option to indicate that a procedure
(see “INLINE” on
inlining procedures to decide whether size of the module. For should be considered eligible for
page 375)
(paragraphs or to inline procedures commonly occurring inlining, but the decision whether
sections) referenced by referenced by PERFORM but rarely executed to inline a procedure in a specific
PERFORM statements statements. This procedures, you can PERFORM statement or not is made by
in the source program. typically improves use the >>INLINE OFF the compiler.
performance when the directive to prevent the
application contains compiler from inlining
commonly occurring that procedure and
and often-executed increasing the module
procedures. size.
INITCHECK To have the compiler None Use of the INITCHECK All of the INITCHECK analyses occur
check for uninitialized option might increase at compile time only. The INITCHECK
(see
data items and issue compile time and option has no effect on the behavior or
“INITCHECK” on
warning messages memory consumption. performance of the program after it has
page 373)
when they are been compiled.
used without being
initialized.
NUMPROC(PFD) To have invalid sign Generates significantly For most references If you use NUMPROC(PFD), the compiler
processing bypassed more efficient code for to COMP-3 and assumes and requires that all decimal
(see “NUMPROC”
for numeric operations numeric comparisons DISPLAY numeric data items contain the preferred sign values
on page 392)
items, NUMPROC(PFD) and bypasses the sign "fix-up" process.
inhibits extra code from However, because not all external
being generated to data files contain the proper signs
"fix up" signs. This for COMP-3 or DISPLAY numeric data,
extra code might also and programs might use REDEFINES,
inhibit some other group moves, or parameter passing
types of optimizations. in ways that do not ensure preferred
The extra code signs, the NUMPROC(PFD) might not be
is generated with appropriate for many programs.
NUMPROC(NOPFD).
OPTIMIZE(0|1| To optimize generated Generally results in more Longer compile OPTIMIZE(0) is generally used
2) code for better efficient runtime code time: OPTIMIZE(1| during program development when
performance 2) requires more frequent compiles are needed; it also
(see “OPTIMIZE”
processing time allows for symbolic debugging. For
on page 395)
for compiles than production runs, OPTIMIZE(1|2) is
OPTIMIZE(0). recommended.
STGOPT To optimize storage Generally results in less None STGOPT deletes unused data items,
allocation in DATA storage usage which might be undesirable in the case
(see “STGOPT”
DIVISION of time stamps or data items that are
on page 412)
used only as markers for dump reading.
780 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 99. Performance-related compiler options (continued)
SMARTBIN To instruct the compiler Enables your COBOL Use of this option None
to generate modules modules to be eligible increases compile time
(see
containing additional for ABO optimization in and module size on
“SMARTBIN” on
binary metadata that the future to maximize disk, requiring larger
page 406)
enables them to benefits of IBM Z load modules. Size
be optimized by hardware enhancements in memory is not
IBM Automatic Binary without the need to impacted as the
Optimizer (ABO) for recompile and test metadata is created in
z/OS (ABO) 2.2 a NOLOAD segment.
SSRANGE To verify that all SSRANGE generates With SSRANGE In general, if you need to verify the
table references and additional code specified, checks for table references only a few times
(see “SSRANGE”
reference modification for verifying table valid ranges do affect instead of at every reference, coding
on page 411)
expressions are in references. Using compiler performance. your own checks might be faster
proper bounds NOSSRANGE causes that than using SSRANGE. For performance-
code not to be sensitive applications, NOSSRANGE is
generated. recommended.
TEST To get full debugging None Some reduction in For production runs, using NOTEST or
capability when using optimization occurs TEST(NOEJPD) is recommended.
(see “TEST” on
Debug Tool and to get when the TEST option
page 414) If during a production run, you want
a symbolic dump of the is used. More reduction
a symbolic dump of the data items
data items in CEEDUMP. in optimization occurs
in a formatted dump if the program
You can also get a when the EJPD
abends, compile using TEST or with
symbolic dump of the suboption of TEST is
NOTEST(DWARF).
data items in CEEDUMP used.
with NOTEST(DWARF).
TRUNC(OPT) To avoid having code Does not generate extra Both TRUNC(BIN) and TRUNC(STD) conforms to the 85
generated to truncate code and generally TRUNC(STD) generate COBOL Standard, but TRUNC(BIN)
(see “TRUNC” on
the receiving fields of improves performance extra code whenever a and TRUNC(OPT) do not. With
page 419)
arithmetic operations BINARY data item is TRUNC(OPT), the compiler assumes
changed. TRUNC(BIN) that the data conforms to the PICTURE
is usually the slowest and USAGE specifications. TRUNC(OPT)
of these options. is recommended where possible.
TUNE To specify the Tunes instruction None If the specified TUNE level is lower than
architecture for selection and the specified ARCH level, the compiler
(see “TUNE” on
which the executable other implementation- adjusts the TUNE level to match the
page 421)
program will be dependent performance ARCH level.
optimized enhancements for a
specific implementation
of a hardware
architecture
Related concepts
“Optimization” on page 776
“Storage and its addressability” on page 39
Related tasks
“Generating a list of compiler
messages” on page 281
“Evaluating performance” on page 782
“Optimizing buffer and device space” on page 10
“Choosing compiler features to enhance performance” on page 777
Related references
“Sign representation of zoned and packed-decimal data” on page 53
“Allocation of buffers for QSAM files” on page 186
“COBOL compiler options” on page 339
“Conflicting compiler options” on page 344
Evaluating performance
Fill in the following worksheet to help you evaluate the performance of your program. If you answer yes to
each question, you are probably improving the performance.
In thinking about the performance tradeoff, be sure you understand the function of each option as well as
the performance advantages and disadvantages. You might prefer function over increased performance in
many instances.
782 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Related concepts
“Storage and its addressability” on page 39
Related tasks
“Choosing compiler features to enhance performance” on page 777
Related references
“Performance-related compiler options” on page 778
CICS: If your application runs under CICS, convert EXEC CICS LINK commands to COBOL CALL
statements to improve transaction response time.
IMS: If your application runs under IMS, preloading the application program and the library routines can
help reduce the overhead of loading and searching. It can also reduce the input-output activity.
For better system performance, use the RENT compiler option and preload the applications and library
routines when possible. You can also use the Language Environment library routine retention (LRR)
function to improve performance in IMS/TM regions.
VSAM: When you use VSAM files, increase the number of data buffers for sequential access or index
buffers for random access. Also, select a control interval size (CISZ) that is appropriate for the
application. A smaller CISZ results in faster retrieval for random processing at the expense of inserts.
A larger CISZ is more efficient for sequential processing.
For better performance, access the records sequentially and avoid using multiple alternate indexes when
possible. If you use alternate indexes, access method services builds them more efficiently than the
AIXBLD runtime option.
Related tasks
“Coding COBOL programs to run under CICS” on page 495
Chapter 24, “Developing COBOL programs for IMS,” on page 517
“Improving VSAM performance” on page 211
Language Environment Customization
Related references
Language Environment Programming Guide (Specifying runtime options)
Related concepts
“Performance considerations of static and dynamic calls” on page 552
You can use coding techniques to improve your productivity. By using the COPY statement, the format
2 SORT statement, COBOL intrinsic functions, Language Environment callable services, COBOL/Java
communication features, calls between AMODE 31 (31-bit) and AMODE 64 (64-bit) COBOL programs, and
user-defined functions, you can avoid repetitive coding and having to code many arithmetic calculations
or other complex tasks. In addition, compiler options including SSRANGE, NUMCHECK, PARMCHECK, and
INITCHECK can help detect invalid data issues to ease your migration efforts from COBOL 4 or earlier to
COBOL 6 or later.
COPY statement
If your program contains frequently used code sequences (such as blocks of common data items, input-
output routines, error routines, or even entire COBOL programs), write the code sequences once and put
them in a COBOL copy library. You can use the COPY statement to retrieve these code sequences and have
them included in your program at compile time. Using copybooks in this manner eliminates repetitive
coding. For details, see “Eliminating repetitive coding” on page 786.
Format 2 SORT statement
To sort a table, you can use the format 2 SORT statement to simplify coding. It provides a much simpler
way compared to the format 1 SORT statement. For details, see “Using the format 2 SORT statement to
sort a table” on page 791.
Intrinsic functions
COBOL provides various capabilities for manipulating strings and numbers. These capabilities can help
you simplify your coding. For details, see “Converting data items (intrinsic functions)” on page 113 and
“Evaluating data items (intrinsic functions)” on page 117.
Language Environment callable services
The Language Environment date and time callable services store dates as fullword binary integers and
store time stamps as long (64-bit) floating-point values. These formats let you do arithmetic calculations
on date and time values simply and efficiently. You do not need to write special subroutines that use
services outside the language library to perform such calculations. For details, see “Using Language
Environment callable services” on page 787.
COBOL/Java interoperability
COBOL programs can interoperate with Java programs without using the object-oriented programming
framework. Therefore, you can easily extend your COBOL applications with Java. For details, see Chapter
17, “Compiling, linking, and running non-OO COBOL applications that interoperate with Java,” on page
301 and Part 7, “COBOL/Java interoperability outside of the object-oriented (OO) COBOL framework,” on
page 739.
AMODE 31 (31-bit) and AMODE 64 (64-bit) COBOL programs interoperability
You can create AMODE 64 COBOL applications that can interoperate with your existing AMODE 31 COBOL
applications. AMODE 64 COBOL applications can access data items greater than the existing AMODE 31
data size limits, without changes to the program logic. For details, see “COBOL applications with mixed
AMODE 31 and AMODE 64 programs” on page 540.
User-defined functions
As with many popular programming languages, COBOL supports user-defined functions, which gives
you a familiar structure. Write your own functions using the user-defined function definition and invoke
them like intrinsic functions, improving code modularity and maintainability. For details, see Function
identification division in the Enterprise COBOL for z/OS Language Reference and Chapter 32, “Using user-
defined functions,” on page 597.
Compiler options to detect invalid data during COBOL migration
Related references
Chapter 20, “Compiler-directing statements,” on page 439
786 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
You can retrieve the text-name CFILEA by using the COPY statement in a source program as follows:
FD FILEA
COPY CFILEA.
The library entry is copied into your program, and the resulting program listing looks like this:
FD FILEA
COPY CFILEA.
C BLOCK CONTAINS 20 RECORDS
C RECORD CONTAINS 120 CHARACTERS
C LABEL RECORDS ARE STANDARD
C DATA RECORD IS FILE-OUT.
C 01 FILE-OUT PIC X(120).
In the compiler source listing, the COPY statement prints on a separate line. C precedes copied lines.
Assume that a copybook with the text-name DOWORK is stored by using the following statements:
paragraph-name.
COPY DOWORK.
The statements that are in the DOWORK procedure will follow paragraph-name.
If you use the EXIT compiler option to provide a LIBEXIT module, your results might differ from those
shown here.
Note: To save compile time, you might group related items in a copybook, but not necessarily have a
single large copybook with unrelated items in it.
Related tasks
“Eliminating repetitive coding” on page 786
Related references
Chapter 20, “Compiler-directing statements,” on page 439
Related concepts
“Sample list of Language Environment callable
services” on page 788
Related tasks
“Using numeric intrinsic functions” on page 56
“Using math-oriented callable services” on page 58
“Using date callable services” on page 59
“Calling Language Environment services” on page 789
“Using procedure and function pointers” on page 557
788 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 101. Language Environment callable services
Function type Service Purpose
Condition handling CEEHDLR To register a user condition handler
CEESGL To raise or signal a condition
CEEMRCR To indicate where the program will resume running after the
condition handler has finished
Dynamic storage CEEGTST To get storage
CEECZST To change the size of a previously allocated storage block
CEEFRST To free storage
Date and time CEECBLDY To convert a string that represents a date into COBOL integer date
format, which represents a date as the number of days since 31
December 1600
CEEQCEN, To query and set the Language Environment century window, which
CEESCEN is valuable when a program uses two digits to express a year
CEEGMTO To calculate the difference between the local system time and
Greenwich Mean Time
CEELOCT To get the current local time in your choice of three formats
Math CEESIABS To calculate the absolute value of an integer
CEESSNWN To calculate the nearest whole number for a single-precision
floating-point number
CEESSCOS To calculate the cosine of an angle
Message handling CEEMOUT To dispatch a message
CEEMGET To retrieve a message
National language CEE3LNG To change or query the current national language
support
CEE3CTY To change or query the current national country
CEE3MCS To obtain the default currency symbol for a given country
General CEE3DMP To obtain a Language Environment formatted dump
CEETEST To start a debugging tool, such as Debug Tool
Related references
Language Environment Programming Reference
77 argument comp-1.
77 feedback-code pic x(12) display.
77 result comp-1.
. . .
CALL "CEESSSQT" using argument, feedback-code, result
In the example above, Language Environment service CEESSSQT calculates the value of the square root of
the variable argument and returns this value in the variable result.
Related concepts
Language Environment Programming Guide (General callable services)
Related references
Language Environment Programming Reference (General callable services)
CALL statement (Enterprise COBOL for z/OS Language Reference)
ID DIVISION.
PROGRAM-ID. HOHOHO.
************************************************************
* FUNCTION: DISPLAY TODAY'S DATE IN THE FOLLOWING FORMAT: *
* WWWWWWWWW, MMMMMMMM DD, YYYY *
* *
* For example: TUESDAY, SEPTEMBER 15, 2009 *
* *
************************************************************
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 CHRDATE.
05 CHRDATE-LENGTH PIC S9(4) COMP VALUE 10.
05 CHRDATE-STRING PIC X(10).
01 PICSTR.
05 PICSTR-LENGTH PIC S9(4) COMP.
05 PICSTR-STRING PIC X(80).
*
77 LILIAN PIC S9(9) COMP.
77 FORMATTED-DATE PIC X(80).
*
PROCEDURE DIVISION.
***************************************************************
* USE LANGUAGE ENVIRONMENT CALLABLE SERVICES TO PRINT OUT *
* TODAY'S DATE FROM COBOL ACCEPT STATEMENT. *
***************************************************************
ACCEPT CHRDATE-STRING FROM DATE.
*
MOVE "YYMMDD" TO PICSTR-STRING.
MOVE 6 TO PICSTR-LENGTH.
CALL "CEEDAYS" USING CHRDATE , PICSTR , LILIAN , OMITTED.
*
MOVE " WWWWWWWWWZ, MMMMMMMMMZ DD, YYYY " TO PICSTR-STRING.
MOVE 50 TO PICSTR-LENGTH.
CALL "CEEDATE" USING LILIAN , PICSTR , FORMATTED-DATE ,
OMITTED.
*
DISPLAY "******************************".
DISPLAY FORMATTED-DATE.
DISPLAY "******************************".
790 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
*
STOP RUN.
Note: Do not use the format 2 SORT with large tables in an environment where storage is constrained,
because the format 2 SORT uses heap storage to do the sort.
Related references
SORT statement (Enterprise COBOL for z/OS Language Reference)
Related concepts
“Formats for numeric data” on page 47
“Fixed-point contrasted with floating-point arithmetic” on page 62
Related references
“Fixed-point data and intermediate results” on page 795
“Floating-point data and intermediate results” on page 800
“Arithmetic expressions in nonarithmetic statements” on page 801
“ARITH” on page 349
Related references
ROUNDED phrase (Enterprise COBOL for z/OS Language Reference)
COMPUTE Y = A + B * C - D / E + F ** G
794 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
1. Exponentiate F by G yielding ir1.
2. Multiply B by C yielding ir2.
3. Divide E into D yielding ir3.
4. Add A to ir2 yielding ir4.
5. Subtract ir3 from ir4 yielding ir5.
6. Add ir5 to ir1 yielding Y.
Related tasks
“Using arithmetic expressions” on page 56
Related references
“Terminology used for intermediate results” on page 794
You must define the operands of any arithmetic statements with enough decimal places to obtain the
accuracy you want in the final result.
The following table shows the number of places the compiler carries for fixed-point intermediate results
of arithmetic operations that involve addition, subtraction, multiplication, or division in compatibility mode
(that is, when the default compiler option ARITH(COMPAT) is in effect):
The following table shows the number of places the compiler carries for fixed-point intermediate results
of arithmetic operations that involve addition, subtraction, multiplication, or division in extended mode
(that is, when the compiler option ARITH(EXTEND) is in effect):
Exponentiation
Exponentiation is represented by the expression op1 ** op2. Based on the characteristics of op2, the
compiler handles exponentiation of fixed-point numbers in one of three ways:
• When op2 is expressed with decimals, floating-point instructions are used.
• When op2 is an integral literal or constant, the value d is computed as
d = d1 * |op2|
i = i1 * |op2|
– When op1 is a literal or constant, i is set equal to the number of integers in the value of op1 ** |op2|.
In compatibility mode (compilation using ARITH(COMPAT)), the compiler having calculated i and d
takes the action indicated in the table below to handle the intermediate results ir of the exponentiation.
In extended mode (compilation using ARITH(EXTEND)), the compiler having calculated i and d takes
the action indicated in the table below to handle the intermediate results ir of the exponentiation.
If op2 is negative, the value of 1 is then divided by the result produced by the preliminary computation.
The values of i and d that are used are calculated following the division rules for fixed-point data already
shown above.
796 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
• When op2 is an integral data-name or variable, dmax decimal places and 30-dmax (compatibility mode)
or 31-dmax (extended mode) integer places are used. op1 is multiplied by itself (|op2| - 1) times for
nonzero op2.
If op2 is equal to 0, the result is 1. Division-by-0 and exponentiation SIZE ERROR conditions apply.
Fixed-point exponents with more than nine significant digits are always truncated to nine digits. If
the exponent is a literal or constant, an E-level compiler diagnostic message is issued; otherwise, an
informational message is issued at run time.
“Example: exponentiation in fixed-point arithmetic” on page 797
Related references
“Terminology used for intermediate results” on page 794
“Truncated intermediate
results” on page 797
“Binary data and intermediate
results” on page 798
“Floating-point data and intermediate results” on page 800
“Intrinsic functions evaluated in fixed-point arithmetic” on page 798
“ARITH” on page 349
SIZE ERROR phrases (Enterprise COBOL for z/OS Language Reference)
COMPUTE Y = A ** B
If B is equal to 4, the result is computed as shown below. The values of i and d that are used are
calculated according to the multiplication rules for fixed-point data and intermediate results (referred to
below).
1. Multiply A by A yielding an internal intermediate result iir1.
2. Multiply iir1 by A yielding an internal intermediate result iir2.
3. Multiply iir2 by A yielding an internal intermediate result iir3.
4. Move iir3 to ir4.
ir4 has dmax decimal places. Because B is positive, ir4 is moved to Y. If B were equal to -4, however,
an additional fifth step would be performed:
5. Divide ir4 into 1 yielding ir5.
ir5 has dmax decimal places, and would then be moved to Y.
Note: The internal intermediate results (iir1, iir2, and iir3) obtained by the internal library routine
performing the exponential calculation in steps 1, 2, and 3 above do not use the same decimal precision
as ir4 and ir5 above. Instead, those intermediate results are much more precise, ensuring the most
accurate result possible in ir4 or ir5.
Related references
“Terminology used for intermediate results” on page 794
“Fixed-point data and intermediate results” on page 795
If you want to avoid the truncation of intermediate results that can occur in fixed-point calculations, use
floating-point operands (COMP-1 or COMP-2) instead.
Related concepts
“Formats for numeric data” on page 47
Related references
“Fixed-point data and intermediate results” on page 795
“ARITH” on page 349
Related references
“Fixed-point data and intermediate results” on page 795
“ARITH” on page 349
Integer functions
Integer intrinsic functions return an integer; thus their outer-dmax is always zero. For those integer
functions whose arguments must all be integers, the inner-dmax is thus also always zero.
The following table summarizes the inner-dmax and the precision of the function result.
798 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Function Inner-dmax Digit precision of function result
INTEGER For a fixed-point argument: one more digit than in the
argument. For a floating-point argument: 30 in compatibility
mode, 31 in extended mode.
INTEGER-PART For a fixed-point argument: same number of digits as in the
argument. For a floating-point argument: 30 in compatibility
mode, 31 in extended mode.
Mixed functions
A mixed intrinsic function is a function whose result type depends on the type of its arguments. A mixed
function is fixed point if all of its arguments are numeric and none of its arguments is floating point. (If any
argument of a mixed function is floating point, the function is evaluated with floating-point instructions
and returns a floating-point result.) When a mixed function is evaluated with fixed-point arithmetic, the
result is integer if all of the arguments are integer; otherwise, the result is fixed point.
For the mixed functions MAX, MIN, RANGE, REM, and SUM, the outer-dmax is always equal to the inner-
dmax (and both are thus zero if all the arguments are integer). To determine the precision of the result
returned for these functions, apply the rules for fixed-point arithmetic and intermediate results (as
referred to below) to each step in the algorithm.
MAX
1. Assign the first argument to the function result.
2. For each remaining argument, do the following steps:
a. Compare the algebraic value of the function result with the argument.
b. Assign the greater of the two to the function result.
MIN
1. Assign the first argument to the function result.
2. For each remaining argument, do the following steps:
a. Compare the algebraic value of the function result with the argument.
b. Assign the lesser of the two to the function result.
RANGE
1. Use the steps for MAX to select the maximum argument.
2. Use the steps for MIN to select the minimum argument.
3. Subtract the minimum argument from the maximum.
4. Assign the difference to the function result.
REM
1. Divide argument one by argument two.
2. Remove all noninteger digits from the result of step 1.
3. Multiply the result of step 2 by argument two.
4. Subtract the result of step 3 from argument one.
5. Assign the difference to the function result.
SUM
1. Assign the value 0 to the function result.
2. For each argument, do the following steps:
a. Add the argument to the function result.
b. Assign the sum to the function result.
Floating-point instructions are used to compute an arithmetic expression if any of the following conditions
is true of the expression:
• A receiver or operand is COMP-1, COMP-2, external floating point, or a floating-point literal.
• An exponent contains decimal places.
• An exponent is an expression that contains an exponentiation or division operator, and dmax is greater
than zero.
• An intrinsic function is a floating-point function.
In compatibility mode, if an expression is computed in floating-point arithmetic, the precision used to
evaluate the arithmetic operations is determined as follows:
• Single precision is used if all receivers and operands are COMP-1 data items and the expression
contains no multiplication or exponentiation operations.
• In all other cases, long precision is used.
Whenever long-precision floating point is used for one operation in an arithmetic expression, all
operations in the expression are computed as if long floating-point instructions were used.
In extended mode, if an expression is computed in floating-point arithmetic, the precision used to
evaluate the arithmetic operations is determined as follows:
• Single precision is used if all receivers and operands are COMP-1 data items and the expression
contains no multiplication or exponentiation operations.
• Long precision is used if all receivers and operands are COMP-1 or COMP-2 data items, at least
one receiver or operand is a COMP-2 data item, and the expression contains no multiplication or
exponentiation operations.
• In all other cases, extended precision is used.
Whenever extended-precision floating point is used for one operation in an arithmetic expression, all
operations in the expression are computed as if extended-precision floating-point instructions were used.
Alert: If a floating-point operation has an intermediate result field in which exponent overflow occurs, the
job is abnormally terminated.
800 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Intrinsic functions evaluated in floating-point arithmetic
In compatibility mode, floating-point intrinsic functions always return a long (64-bit) floating-point
value. In extended mode, floating-point intrinsic functions always return an extended-precision (128-bit)
floating-point value.
Mixed functions that have at least one floating-point argument are evaluated using floating-point
arithmetic.
Related references
“Terminology used for intermediate results” on page 794
“ARITH” on page 349
If operand-1 is a data-name defined to be COMP-2, the rules for floating-point arithmetic apply to
expression-1 even if it contains only fixed-point operands, because it is being compared to a floating-
point operand.
• When the comparison between an arithmetic expression and another data item or arithmetic expression
does not use a relational operator (that is, there is no explicit relation condition), the arithmetic
expression is evaluated without regard to the attributes of its comparand. For example:
EVALUATE expression-1
WHEN expression-2 THRU expression-3
WHEN expression-4
. . .
END-EVALUATE
Related concepts
“Fixed-point contrasted with floating-point arithmetic” on page 62
Related references
“Terminology used for intermediate results” on page 794
“Fixed-point data and intermediate results” on page 795
“Floating-point data and intermediate results” on page 800
IF statement (Enterprise COBOL for z/OS Language Reference)
802 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Appendix B. Converting double-byte character set
(DBCS) data
The Language Environment service routines IGZCA2D and IGZCD2A were intended for converting
alphanumeric data items that contain DBCS data to and from pure DBCS data items in order to reliably
perform operations such as STRING, UNSTRING, and reference modification.
These service routines continue to be provided for compatibility; however, using national data items and
the national conversion operations is now recommended instead for this purpose.
The service routines do not support a code-page argument and are not sensitive to the code page
specified by the CODEPAGE compiler option. The DBCS compiler option does not affect their operation.
Related tasks
“Converting to or from national (Unicode) representation” on page 134
“Processing alphanumeric data items that contain DBCS data” on page 160
Related references
“DBCS notation” on page 803
“Alphanumeric to DBCS
data conversion (IGZCA2D)” on page 803
“DBCS to alphanumeric
data conversion (IGZCD2A)” on page 805
“CODEPAGE” on page 353
DBCS notation
The symbols shown below are used in the DBCS data conversion examples to describe DBCS items.
Symbols Meaning
< and > Shift-out (SO) and shift-in (SI), respectively
D0, D1, D2, . . ., Dn Any DBCS character except for double-byte EBCDIC
characters that correspond to single-byte EBCDIC characters
.A, .B, .C, . . . Any double-byte EBCDIC character that corresponds to a
single-byte EBCDIC character. The period (.) represents the
value X'42'.
A single letter, such as A, B, or s Any single-byte EBCDIC character
IGZCA2D syntax
To use the IGZCA2D service routine, pass the following four parameters to the routine by using the CALL
statement:
parameter-1
The sending field for the conversion, handled as an alphanumeric data item.
parameter-2
The receiving field for the conversion, handled as a DBCS data item.
Related references
“IGZCA2D return codes” on page 804
804 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 103. IGZCA2D return codes (continued)
Return code Explanation
10 parameter-1 was converted and the results were placed in parameter-2. A single-
byte character in the range X'00' to X'3F' or X'FF' was encountered. The valid single-
byte character was converted into an out-of-range DBCS character.
The DBCS data in parameter-2 was truncated on the right.
12 An odd number of bytes was found between paired shift codes in parameter-1. No
conversion occurred.
13 Unpaired or nested shift codes were found in parameter-1. No conversion occurred.
14 parameter-1 and parameter-2 were overlapping. No conversion occurred.
15 The value provided for parameter-3 or parameter-4 was out of range. No conversion
occurred.
16 An odd number of bytes was coded in parameter-4. No conversion occurred.
Example: IGZCA2D
This example CALL statement converts the alphanumeric data in alpha-item to DBCS data. The results
of the conversion are placed in dbcs-item.
Suppose the contents of alpha-item and dbcs-item and the lengths before the conversion are:
alpha-item = AB<D1D2D3>CD
dbcs-item = D4D5D6D7D8D9D0
LENGTH OF alpha-item = 12
LENGTH OF dbcs-item = 14
alpha-item = AB<D1D2D3>CD
dbcs-item = .A.BD1D2D3.C.D
Related references
“DBCS notation” on page 803
IGZCD2A syntax
To use the IGZCD2A service routine, pass the following four parameters to the routine using the CALL
statement:
parameter-1
The sending field for the conversion, handled as a DBCS data item.
Related references
“IGZCD2A return codes” on page 806
806 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 104. IGZCD2A return codes (continued)
Return code Explanation
1. If a truncation occurs within the DBCS characters, the truncation is on an even-byte boundary and a
shift-in (SI) is inserted. If necessary, the alphanumeric data is padded with a single-byte space after
the shift-in.
Example: IGZCD2A
This example CALL statement converts the DBCS data in dbcs-item to alphanumeric data with double-
byte characters. The results of the conversion are placed in alpha-item.
Suppose the contents of dbcs-item and alpha-item and the lengths before the conversion are:
dbcs-item = .A.BD1D2D3.C.D
alpha-item = ssssssssssss
LENGTH OF dbcs-item = 14
LENGTH OF alpha-item = 12
dbcs-item = .A.BD1D2D3.C.D
alpha-item = AB<D1D2D3>CD
Related references
“DBCS notation” on page 803
Related references
“XML PARSE exceptions with XMLPARSE(XMLSS) in
effect” on page 809
“XML PARSE exceptions with
XMLPARSE(COMPAT) in effect” on page 811
“XML GENERATE exceptions” on page 817
XML specification
Table 105. Reason codes for XML PARSE exceptions that are unique to Enterprise COBOL
Reason code Description
(hexadecimal)
700 VALIDATING WITH FILE is not supported under CICS.
701 The optimized XML schema that was read in was too short, or the file was empty.
702 The file identifier for the schema was not a ddname or environment-variable name.
703 The DSN value contained a space character in a position where a space is not allowed.
704 The DSN value specified a temporary data set.
For any of the reason codes except 900, correct the error and then retry your program.
Related concepts
“XML-CODE” on page 630
“XML events” on page 629
Related tasks
“Handling XML PARSE exceptions” on page 645
Related references
“XMLPARSE” on page 425 (compiler option)
810 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
XML PARSE exceptions with XMLPARSE(COMPAT) in effect
When an exception event occurs, the XML parser that is provided with the Enterprise COBOL library sets
special register XML-CODE to a value that identifies the exception. Depending on the value in XML-CODE,
the parser might or might not be able to continue processing after the exception, as detailed in the
information referenced below.
Related references
“XML PARSE exceptions that allow continuation” on page 811
“XML PARSE exceptions that do not allow continuation” on page 814
2 The parser found an invalid The parser continues detecting errors until it
start of a processing instruction, reaches the end of the document or encounters
element, comment, or document an error that does not allow continuation. The
type declaration outside element parser does not signal any further normal events,
content. except for the END-OF-DOCUMENT event.
3 The parser found a duplicate The parser continues detecting errors until it
attribute name. reaches the end of the document or encounters
an error that does not allow continuation. The
parser does not signal any further normal events,
except for the END-OF-DOCUMENT event.
4 The parser found the markup The parser continues detecting errors until it
character '<' in an attribute value. reaches the end of the document or encounters
an error that does not allow continuation. The
parser does not signal any further normal events,
except for the END-OF-DOCUMENT event.
812 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 106. XML PARSE exceptions that allow continuation (continued)
Exception Description Parser action on continuation
code
(decimal)
14 The parser found an invalid digit in a The parser continues detecting errors until it
decimal character reference (of the reaches the end of the document or encounters
form &#dddd;). an error that does not allow continuation. The
parser does not signal any further normal events,
except for the END-OF-DOCUMENT event.
15 The encoding declaration value in The parser continues detecting errors until it
the XML declaration did not begin reaches the end of the document or encounters
with lowercase or uppercase A an error that does not allow continuation. The
through Z. parser does not signal any further normal events,
except for the END-OF-DOCUMENT event.
16 A character reference did not refer The parser continues detecting errors until it
to a legal XML character. reaches the end of the document or encounters
an error that does not allow continuation. The
parser does not signal any further normal events,
except for the END-OF-DOCUMENT event.
17 The parser found an invalid The parser continues detecting errors until it
character in an entity reference reaches the end of the document or encounters
name. an error that does not allow continuation. The
parser does not signal any further normal events,
except for the END-OF-DOCUMENT event.
18 The parser found an invalid The parser continues detecting errors until it
character in an attribute value. reaches the end of the document or encounters
an error that does not allow continuation. The
parser does not signal any further normal events,
except for the END-OF-DOCUMENT event.
70 The actual document encoding The parser uses the encoding specified by
was EBCDIC, and the CODEPAGE theCODEPAGE compiler option.
compiler option specified a
supported EBCDIC code page, but
the document encoding declaration
did not specify a supported EBCDIC
code page.
71 The actual document encoding The parser uses the encoding specified by the
was EBCDIC, and the document document encoding declaration.
encoding declaration specified a
supported EBCDIC encoding, but
the CODEPAGE compiler option did
not specify a supported EBCDIC
code page.
72 The actual document encoding was The parser uses EBCDIC code page 1140 (USA,
EBCDIC, the CODEPAGE compiler Canada, . . . Euro Country Extended Code Page).
option did not specify a supported
EBCDIC code page, and the
document did not contain an
encoding declaration.
Related concepts
“XML-CODE” on page 630
“XML input document encoding” on page 641
Related tasks
“Handling XML PARSE exceptions” on page 645
Related references
“XMLPARSE” on page 425 (compiler option)
Table 107. XML PARSE exceptions that do not allow continuation (for XMLPARSE(COMPAT))
Exception code Description
(decimal)
100 The parser reached the end of the document while scanning the start of the XML
declaration.
814 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 107. XML PARSE exceptions that do not allow continuation (for XMLPARSE(COMPAT)) (continued)
Exception code Description
(decimal)
101 The parser reached the end of the document while looking for the end of the XML
declaration.
102 The parser reached the end of the document while looking for the root element.
103 The parser reached the end of the document while looking for the version information
in the XML declaration.
104 The parser reached the end of the document while looking for the version information
value in the XML declaration.
106 The parser reached the end of the document while looking for the encoding
declaration value in the XML declaration.
108 The parser reached the end of the document while looking for the standalone
declaration value in the XML declaration.
109 The parser reached the end of the document while scanning an attribute name.
110 The parser reached the end of the document while scanning an attribute value.
111 The parser reached the end of the document while scanning a character reference or
entity reference in an attribute value.
112 The parser reached the end of the document while scanning an empty element tag.
113 The parser reached the end of the document while scanning the root element name.
114 The parser reached the end of the document while scanning an element name.
115 The parser reached the end of the document while scanning character data in element
content.
116 The parser reached the end of the document while scanning a processing instruction
in element content.
117 The parser reached the end of the document while scanning a comment or CDATA
section in element content.
118 The parser reached the end of the document while scanning a comment in element
content.
119 The parser reached the end of the document while scanning a CDATA section in
element content.
120 The parser reached the end of the document while scanning a character reference or
entity reference in element content.
121 The parser reached the end of the document while scanning after the close of the root
element.
122 The parser found a possible invalid start of a document type declaration.
123 The parser found a second document type declaration.
124 The first character of the root element name was not a letter, '_', or ':'.
125 The first character of the first attribute name of an element was not a letter, '_', or ':'.
126 The parser found an invalid character either in or following an element name.
127 The parser found a character other than '=' following an attribute name.
816 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 107. XML PARSE exceptions that do not allow continuation (for XMLPARSE(COMPAT)) (continued)
Exception code Description
(decimal)
156 The standalone declaration value in the XML declaration specified a bad character,
or the start and end delimiters did not match.
157 The parser found an invalid character following the standalone declaration value
closing delimiter in the XML declaration.
158 The XML declaration was not terminated by the proper character sequence '?>', or
contained an invalid attribute.
159 The parser found the start of a document type declaration after the end of the root
element.
160 The parser found the start of an element after the end of the root element.
315 The actual document encoding was UTF-16 little-endian, which the parser does not
support on this platform.
316 The actual document encoding was UCS4, which the parser does not support.
317 The parser cannot determine the document encoding. The document might be
damaged.
318 The actual document encoding was UTF-8, which the parser does not support.
320 The document data item was national, but the actual document encoding was
EBCDIC.
321 The document data item was national, but the actual document encoding was ASCII.
500 - 599 Internal error. Report the error to your service representative.
Related concepts
“XML-CODE” on page 630
Related tasks
“Handling XML PARSE exceptions” on page 645
Related tasks
“Handling XML GENERATE exceptions” on page 668
818 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Appendix D. JSON reference material
The following information describes the JSON exception codes that might be returned during JSON
parsing or JSON generation.
Related references
“JSON GENERATE exceptions” on page 819
“JSON PARSE conditions and associated codes and runtime messages” on page 819
“Nonexception conditions and corresponding values of JSON-STATUS” on page 820
“Exception conditions, and corresponding values of JSON-CODE” on page 820
“Nonexception condition runtime messages” on page 821
“Exception condition runtime messages” on page 822
820 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 111. Reason codes for JSON exception conditions (continued)
Reason code in the JSON-CODE register Description
102 Superfluous nonwhitespace characters were found
after the closing brace of the outermost JSON
object.
103 One or more data items had multiple matching
JSON name/value pairs with different values, and
were set to the leftmost value encountered in the
JSON text.
104 One or more JSON name/value pairs had a value
that was incompatible with the matching data item.
105 One or more matching JSON name/value pairs had
the value true or false.
106 No JSON name/value pair matched any data item.
107 One or more matching JSON name/value pairs had
the value true or false but the matching COBOL
data item was not specified on a ‘CONVERTING
BOOLEAN’ phrase.
108 JSON PARSE statement without NAME OMITTED
phrase and OCCURS clause attempted to parse
anonymous JSON array in the JSON text.
109 The CCSID of the ENCODING phrase in the JSON
PARSE statement was invalid or unsupported.
822 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
special values true or false. But, the matching COBOL data item data-name is not specified on a
'CONVERTING BOOLEAN' phrase of the JSON PARSE statement.
IGZ0343W
During execution of the JSON PARSE statement on line line-number of program program-name,
the JSON text in data-name was found to be an anonymous JSON array, but 'NAME data-name
OMITTED' phrase of the JSON PARSE statement was not specified or data-name did not contain an
OCCURS clause.
IGZ0344W
During execution of the JSON PARSE statement on line line-number of program program-name, the
CCSID ccsid-number of an ENCODING phrase was found to be invalid or unsupported.
Related tasks
“Using the user-exit work
area” on page 825
“Calling from exit modules” on page 826
Using the EXIT compiler option with CICS, SQL and
SQLIMS statements
Related references
“EXIT” on page 367
“Processing of INEXIT” on page 826
“Processing of LIBEXIT” on page 827
“Processing of PRTEXIT” on page 830
“Processing of ADEXIT” on page 832
“Processing of MSGEXIT” on page 833
“Error handling for exit modules” on page 842
Related references
“Processing of INEXIT” on page 826
“Processing of LIBEXIT” on page 827
“Processing of PRTEXIT” on page 830
“Processing of ADEXIT” on page 832
“Processing of MSGEXIT” on page 833
Related concepts
“Storage and its addressability” on page 39
Processing of INEXIT
The INEXIT exit module is used to read the primary source code instead of obtaining it directly from
SYSIN.
INEXIT parameters
The compiler uses 10 parameters, passed by reference, to communicate with the exit module. The return
code, data length, and data parameters are set by the exit module for return to the compiler; the other
items are passed from the compiler to the exit module.
826 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 114. INEXIT parameters (continued)
Parameter Parameter item Description of item
number
2 Operation code Halfword that indicates the type of operation:
• 0=OPEN
• 1=CLOSE
• 2=GET
3 Return code Fullword, set by the exit module, that indicates the success of
the requested operation:
• 0=Operation was successful
• 4=End-of-data
• 12=Operation failed
4 User-exit work area Six-fullword work area provided by the compiler for use by the
user-exit module.
First word: for use by INEXIT
5 Data length Fullword, set by the exit module, that specifies the length of the
record being returned by the GET operation (must be 80)
6 Data or str1 Fullword, set by the exit module, that contains the address of
the record in a user-owned buffer, for the GET operation.
str1 applies only to OPEN. The first halfword (on a halfword
boundary) contains the length of the string, followed by the
string.
Related tasks
“Using the user-exit work
area” on page 825
“Calling from exit modules” on page 826
Using the EXIT compiler option with CICS, SQL and
SQLIMS statements
Processing of LIBEXIT
The LIBEXIT exit module is used in place of the SYSLIB, or library-name, data set. Calls are made to the
module by the compiler to obtain copybooks whenever COPY or BASIS statements are encountered.
The following table shows how the processing of LIBEXIT changes when the compiler encounters a valid
nested COPY statement.
828 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 117. LIBEXIT processing with nested COPY statements
Action by compiler Action by exit module
If the requested library-name from Pushes its control information about the active copybook
the nested COPY statement was onto a stack. Completes the requested action (OPEN). The
not previously opened, calls the newly requested text-name (or basis-name) becomes the active
exit module with an OPEN op code copybook.
Calls the exit module with a FIND Pushes its control information about the active copybook
op code for the requested new onto a stack. Completes the requested action (FIND). The
text-name newly requested text-name (or basis-name) becomes the active
copybook.
Calls the exit module with a GET op Passes the compiler either the length and address of the record to
code be copied from the active copybook or the end-of-data indicator. At
end-of-data, pops its control information from the stack.
LIBEXIT parameters
The compiler uses 10 parameters, passed by reference, to communicate with the exit module. The return
code, data length, and data parameters are set by the exit module for return to the compiler; the other
items are passed from the compiler to the exit module.
3 Return code Fullword, set by the exit module, that indicates the success of
the requested operation:
• 0=Operation was successful
• 4=End-of-data
• 12=Operation failed
4 User-exit work area Six-fullword work area provided by the compiler for use by the
user-exit module.
Second word: for use by LIBEXIT
5 Data length Fullword, set by the exit module, that specifies the length of the
record being returned by the GET operation (must be 80)
Related tasks
“Using the user-exit work
area” on page 825
“Calling from exit modules” on page 826
Using the EXIT compiler option with CICS, SQL and
SQLIMS statements
Processing of PRTEXIT
The PRTEXIT exit module is used in place of the SYSPRINT data set.
830 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
PRTEXIT parameters
The compiler uses 10 parameters, passed by reference, to communicate with the exit module. The return
code, data length, and data buffer parameters are set by the exit module for return to the compiler; the
other items are passed from the compiler to the exit module.
3 Return code Fullword, set by the exit module, that indicates the success of
the requested operation:
• 0=Operation was successful
• 12=Operation failed
4 User-exit work area Six-fullword work area provided by the compiler for use by the
user-exit module.
Third word: for use by PRTEXIT
5 Data length Fullword that specifies the length of the record being supplied
by the PUT operation (the compiler sets this value to 133)
6 Data buffer or str3 Data buffer where the compiler has placed the record to be
printed by the PUT operation.
str3 applies only to OPEN. The first halfword (on a halfword
boundary) contains the length of the string, followed by the
string.
Related tasks
“Using the user-exit work
area” on page 825
“Calling from exit modules” on page 826
Using the EXIT compiler option with CICS, SQL and
SQLIMS statements
ADEXIT parameters
The compiler uses 10 parameters, passed by reference, to communicate with the exit module. The return
code, data length, and data buffer parameters are set by the exit module for return to the compiler; the
other items are passed from the compiler to the exit module.
3 Return code Fullword, set by the exit module, that indicates the success of
the requested operation:
• 0=Operation was successful
• 12=Operation failed
4 User-exit work area Six-fullword work area provided by the compiler for use by the
user-exit module.
Fourth word: for use by ADEXIT
5 Data length Fullword that specifies the length of the record being supplied
by the PUT operation
832 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 122. ADEXIT parameters (continued)
Parameter Parameter item Description of item
number
6 Data buffer or str4 Fullword that contains the address of the data buffer where
the compiler has placed the record to be printed by the PUT
operation.
str4 applies only to OPEN. The first halfword (on a halfword
boundary) contains the length of the string, followed by the
string.
Related tasks
“Using the user-exit work
area” on page 825
“Calling from exit modules” on page 826
Using the EXIT compiler option with CICS, SQL and
SQLIMS statements
Related references
“ADATA” on page 345
Processing of MSGEXIT
The MSGEXIT module is used to customize compiler diagnostic messages and FIPS messages. The
module can customize a message either by changing its severity or suppressing it.
If the MSGEXIT module assigns a severity to a FIPS message, the message is converted into a diagnostic
message. (The message is shown in the summary of diagnostic messages in the listing.)
A MSGEXIT summary at the end of the compiler listing shows how many messages were changed in
severity and how many messages were suppressed.
Calls the exit module with a CLOSE op Optionally frees storage and passes the status of the CLOSE
code request to the compiler
MSGEXIT parameters
The compiler uses 10 parameters, passed by reference, to communicate with the exit module. The return
code and user-requested severity parameters are set by the exit module for return to the compiler; the
other items are passed from the compiler to the exit module.
3 Return code Fullword, set by the exit module, that indicates the success of
the requested operation.
For op code MSGSEV:
• 0=Message not customized
• 4=Message found and customized
• 12=Operation failed
4 User-exit work area Six-fullword work area provided by the compiler for use by the
user-exit module.
Sixth word: for use by MSGEXIT
7 str5 First halfword (on a halfword boundary): the length of the string,
followed by the string
8 Not used (Used only by LIBEXIT)
9 Not used (Used only by LIBEXIT)
834 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 124. MSGEXIT parameters (continued)
Parameter Parameter item Description of item
number
10 Not used (Used only by LIBEXIT)
Related tasks
“Using the user-exit work
area” on page 825
“Calling from exit modules” on page 826
“Customizing compiler-message severities” on page 835
Using the EXIT compiler option with CICS, SQL and
SQLIMS statements
Related tasks
“Generating a list of compiler
messages” on page 281
Related references
“Severity codes for
compiler diagnostic messages” on page 282
“Customizable compiler-message severities” on page 836
“Effect
of message customization on compilation return code” on page 837
“Error handling for exit modules” on page 842
836 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
– Disallow complex OCCURS DEPENDING ON by changing FIPS message 8235 from a category-E FIPS
message to a severity-S compiler diagnostic message.
• Severity-E messages can be raised to severity S, but not lowered to severity I or W, because an error
condition has occurred in the program.
• Severity-S and severity-U messages cannot be changed to have a different severity.
You can request suppression of compiler messages as follows:
• I, W, and FIPS messages can be suppressed.
• E and S messages cannot be suppressed.
Related references
“Severity codes for
compiler diagnostic messages” on page 282
“FLAGSTD” on page 370
“Effect
of message customization on compilation return code” on page 837
Related tasks
“Customizing compiler-message severities” on page 835
Related references
“Severity codes for
compiler diagnostic messages” on page 282
*****************************************************************
* IGYMSGXT - Sample COBOL program for MSGEXIT *
*****************************************************************
* *
* IBM Enterprise COBOL for z/OS *
* Version 6 Release 4 Modification 0 *
* *
* LICENSED MATERIALS - PROPERTY OF IBM. *
* *
* 5655-EC6 COPYRIGHT IBM CORP. 2022 *
* ALL RIGHTS RESERVED *
* *
* US GOVERNMENT USERS RESTRICTED RIGHTS - USE, *
* DUPLICATION OR DISCLOSURE RESTRICTED BY GSA *
* ADP SCHEDULE CONTRACT WITH IBM CORP. *
* *
*****************************************************************
Working-Storage Section.
*****************************************************************
* *
* Local variables. *
* *
*****************************************************************
*****************************************************************
* *
* Definition of the User-Exit Parameter List, which is *
* passed from the COBOL compiler to the user-exit module. *
* *
*****************************************************************
Linkage Section.
01 EXIT-TYPE PIC 9(4) COMP.
01 EXIT-OPERATION PIC 9(4) COMP.
01 EXIT-RETURNCODE PIC 9(9) COMP.
01 EXIT-WORK-AREA.
02 EXIT-WORK-AREA-PTR OCCURS 6 POINTER.
01 EXIT-DUMMY POINTER.
01 EXIT-MESSAGE-PARMS.
02 EXIT-MESSAGE-NUM PIC 9(4) COMP.
02 EXIT-DEFAULT-SEV PIC 9(4) COMP.
02 EXIT-USER-SEV PIC S9(4) COMP.
01 EXIT-STRING.
02 EXIT-STR-LEN PIC 9(4) COMP.
02 EXIT-STR-TXT PIC X(64).
*****************************************************************
*****************************************************************
* *
* Begin PROCEDURE DIVISION *
* *
* Check parameters and perform the operation requested. *
838 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
* *
*****************************************************************
*****************************************************************
Compute EXIT-RETURNCODE = 0
Evaluate TRUE
*****************************************************************
* Handle a bad invocation of this exit by the compiler. *
* This could happen if this routine was used for one of the *
* other EXITs, such as INEXIT, PRTEXIT or LIBEXIT. *
*****************************************************************
When EXIT-TYPE Not = 6
Move EXIT-TYPE to EXIT-TYPEN
Display '**** Invalid exit routine identifier'
Display '**** EXIT TYPE = ' EXIT-TYPE
Compute EXIT-RETURNCODE = 16
*****************************************************************
* Handle the OPEN call to this exit by the compiler *
* Display the exit string (str5 in syntax diagram) from *
* the EXIT(MSGEXIT('str5',mod5)) option specification. *
*****************************************************************
When EXIT-OPERATION = 0
* Display 'Opening MSGEXIT'
* If EXIT-STR-LEN Not Zero Then
* Display ' str5 len = ' EXIT-STR-LEN
* Display ' str5 = ' EXIT-STR-TXT(1:EXIT-STR-LEN)
* End-If
Continue
*****************************************************************
* Handle the CLOSE call to this exit by the compiler *
*****************************************************************
When EXIT-OPERATION = 1
* Display 'Closing MSGEXIT'
Goback
*****************************************************************
* Handle the customize message severity call to this exit *
* Display information about every customized severity. *
*****************************************************************
When EXIT-OPERATION = 5
* Display 'MSGEXIT called with MSGSEV'
If EXIT-MESSAGE-NUM < 8000 Then
Perform Error-Messages-Severity
Else
Perform FIPS-Messages-Severity
End-If
* If EXIT-RETURNCODE = 4 Then
* Display '>>>> Customizing message ' EXIT=MESSAGE-NUM
* ' with new severity ' EXIT-USER-SEV ' <<<<'
* If EXIT-MESSAGE-NUM > 8000 Then
* Display 'FIPS sev =' EXIT-DEFAULT-SEV-FIPS '<<<<'
* End-If
* End-If
*****************************************************************
* Handle a bad invocation of this exit by the compiler. *
* The compiler should not invoke this exit with EXIT-TYPE = 6 *
* and an opcode other than 0, 1, or 5. This should not happen *
* and IBM service should be contacted if it does. *
*****************************************************************
When Other
Display '**** Invalid MSGEXIT routine operation '
Display '**** EXIT OPCODE = ' EXIT-OPERATION
Compute EXIT-RETURNCODE = 16
End-Evaluate
Goback.
*****************************************************************
* ERROR MESSAGE PROCESSOR *
Evaluate EXIT-MESSAGE-NUM
*****************************************************************
* Change severity of message 1154(W) to 12 ('S') *
* This is the case of redefining a large item *
* with a smaller item, IBM Req # MR0904063236 *
*****************************************************************
When(1154)
Compute EXIT-USER-SEV = 12
*****************************************************************
* Modify the severity of RULES messages to enforce coding *
* standards or highlight coding that you want to avoid. *
* Here are the message numbers and what they flag: *
* 1158 RULES(NOOMITODOMIN) Missing min idx in ODO table def*
* 1348 RULES(NOEVENPACK) Even digit packed-decimal items *
* 1353 RULES(NOSLACKBYTES) Slack bytes within records *
* 1379 RULES(NOSLACKBYTES) Slack bytes between records *
* 2159 RULES(NOENDPERIOD) Cond stmt terminated by period *
* 2262 RULES(NOUNREFALL) Unref'd items (source/copybook) *
* 2262 RULES(NOUNREFSOURCE) Unref'd items (source only) *
* 2224 RULES(NOLAXPERF) Ineff. type for PERFORM VARYING *
* 2246 RULES(NOLAXPERF) Ineff. type for subscript *
* 2247 RULES(NOLAXPERF) Compiler option NOAWO in effect *
* 2248 RULES(NOLAXPERF) Option ARITH(EXTEND) in effect *
* 2249 RULES(NOLAXPERF) Option NOBLOCK0 in effect *
* 2250 RULES(NOLAXPERF) Option NOFASTSRT in effect *
* 2251 RULES(NOLAXPERF) Option NUMPROC(NOPFD) in effect*
* 2252 RULES(NOLAXPERF) Option OPTIMIZE(0) in effect *
* 2253 RULES(NOLAXPERF) Option SSRANGE in effect *
* 2254 RULES(NOLAXPERF) Option THREAD in effect *
* 2255 RULES(NOLAXPERF) Option TRUNC(STD) in effect *
* 2256 RULES(NOLAXPERF) Option TRUNC(BIN) in effect *
* 3084 RULES(NOLAXPERF) Ineff. type for arith sender *
* 3123 RULES(NOLAXPERF) Lots of padding in alph MOVE *
* *
*****************************************************************
When(1158) *> Disallow omitting ODO table min
Compute EXIT-USER-SEV = 12
When(1348) *> Disallow even-digit Comp-3
Compute EXIT-USER-SEV = 12
When(1353) When(1379) *> Disallow slack bytes
Compute EXIT-USER-SEV = 12
When(2159) *> Disallow period-termination
Compute EXIT-USER-SEV = 12 *> of conditional stmts
When(2262) *> Disallow unref'd data items
Compute EXIT-USER-SEV = 12
* Highlight poorly performing COBOL features
When(2224) *> Ineff. type for PERFORM VARYING
When(2246) *> Ineff. type for subscript
When(2247) *> Compiler option NOAWO in effect
When(2248) *> Option ARITH(EXTEND) in effect
When(2249) *> Option NOBLOCK0 in effect
When(2250) *> Option NOFASTSRT in effect
When(2251) *> Option NUMPROC(NOPFD) in effect
When(2252) *> Option OPTIMIZE(0) in effect
When(2253) *> Option SSRANGE in effect
When(2254) *> Option THREAD in effect
When(2255) *> Option TRUNC(STD) in effect
When(2256) *> Option TRUNC(BIN) in effect
When(3084) *> Ineff. type for arith sender
When(3123) *> Lots of padding in alph MOVE
Compute EXIT-USER-SEV = 8
*****************************************************************
* Change severity of messages 3178(I) to highlight File *
* Definitions that could lead to wrong-length read conditions. *
* Message 3178 is issued when the length of the shortest *
* record description is less than the FROM integer in the *
* RECORD IS VARYING clause, and when the length of the *
* longest record description is greater than the TO integer *
* in the RECORD IS VARYING clause. *
*****************************************************************
When(3178)
Compute EXIT-USER-SEV = 8
840 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
*****************************************************************
* Change severity of messages 3188(W) and 3189(W)
* to 12 ('S'). This is to force a fix for all
* SEARCH ALL cases that might behave differently
* between COBOL compilers previous to Enterprise
* COBOL release 3.4 and later compilers such as
* Enterprise COBOL 4.2.
* Another way to handle this migration is to analyze all of
* the warnings you get and then change them to I-level when
* the analysis is complete.
*****************************************************************
When(3188) When(3189)
Compute EXIT-USER-SEV = 12
*****************************************************************
* Change severity of message 4019 to suppress this message.
* Message 4019 says 'Compiler option "OPTFILE" was specified, "
* but file SYSOPTF could not be opened. No options from a
* "SYSOPTF" file were used.
* This customization would allow users to specify OPTFILE
* as a default option and it would only have an affect
* if there is a SYSOPTF file present
*****************************************************************
When(4019)
Compute EXIT-USER-SEV = -1
*****************************************************************
* Change severity of 'optimization' messages to suppress them
* so that compilation Return Code can be zero (RC=0)
* 7300: The code from lines &2 in program '&1' can never
* be executed and was therefore discarded.
* 7301: A zero base was raised to a zero power in a numeric
* literal exponentiation. The result was set to 1.
* 7302: A zero base was raised to a negative power in a numeric
* literal exponentiation. The result was set to 0.
* 7304: An exception "&1" occured while processing numeric
* literals. The result of the operation was set to zero.
* 7307: This statement may cause a program exception at execution
* time.
* 7309: There may be a loop from the "PERFORM" statement at "
* "PERFORM (line &1)" to itself.
* 7312: Procedure starting at 'proc-name' (line 'num') was
* copied one or more times to be inlined for PERFORM
* statements. xxx total bytes were generated from
* copying that procedure.
*****************************************************************
When(7300) When(7301) When(7302) When(7304)
When(7307) When(7309) When(7312)
Compute EXIT-USER-SEV = -1 *> Suppress the messages
*****************************************************************
* Change severity of message 7311(W) to 12 ('S'). This is the *
* case of INITCHECK messages about uninitialized data items. *
*****************************************************************
When(7311)
Compute EXIT-USER-SEV = 12
*****************************************************************
* Message severity Not customized
*****************************************************************
When Other
Compute EXIT-RETURNCODE = 0
End-Evaluate
.
*****************************************************************
* FIPS MESSAGE PROCESSOR *
*****************************************************************
Fips-Messages-Severity.
EVALUATE EXIT-DEFAULT-SEV
When 81
MOVE 'D' To EXIT-DEFAULT-SEV-FIPS
When 82
MOVE 'E' To EXIT-DEFAULT-SEV-FIPS
When 83
*****************************************************************
* Example of using FIPS category to force coding
* restrictions. This is not a recommendation!
* Change severity of all OBSOLETE item FIPS
* messages to 'S'
*****************************************************************
* If EXIT-DEFAULT-SEV-FIPS = 'O' Then
* Display '>>>> Default customizing FIPS category '
* EXIT-DEFAULT-SEV-FIPS ' msg ' EXIT-MESSAGE-NUM '<<<<'
* Compute EXIT-USER-SEV = 12
* End-If
Evaluate EXIT-MESSAGE-NUM
*****************************************************************
* Change severity of message 8062(O) to 8 ('E')
* 8062 = GO TO without proc name
*****************************************************************
When(8062)
Compute EXIT-USER-SEV = 8
*****************************************************************
* Change severity of message 8193(E) to 0('I')
* 8193 = GOBACK
*****************************************************************
When(8193)
Compute EXIT-USER-SEV = 0
*****************************************************************
* Change severity of message 8235(E) to 8 (Error)
* to disallow Complex Occurs Depending On
* 8235 = Complex Occurs Depending On
*****************************************************************
When(8235)
Compute EXIT-USER-SEV = 08
*****************************************************************
* Change severity of message 8270(O) to -1 (Suppress)
* 8270 = SERVICE LABEL
*****************************************************************
When(8270)
Compute EXIT-USER-SEV = -1
*****************************************************************
* Message severity Not customized
*****************************************************************
When Other
* For the default set 'O' to 'S' case...
* If EXIT-USER-SEV = 12 Then
* Compute EXIT-RETURNCODE = 4
* Else
Compute EXIT-RETURNCODE = 0
* End-If
End-Evaluate
.
END PROGRAM IGYMSGXT.
842 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
An error occurred while attempting to load user exit exit-name.
A PUT request to the PRTEXIT user exit failed with return code nn.
The record address was not set by the exit-name user exit.
• IGYSI5205-U:
A GET request from the INEXIT user exit failed with return code nn.
• IGYSI5206-U:
The record length was not set by the exit-name user exit.
A PUT request to the ADEXIT user exit failed with return code nn.
MSGEXIT failures:
Customization failure: Message IGYPP5293-U is written to the listing if an unsupported severity change
or unsupported message suppression is attempted:
General failure: Message IGYPP5064-U is written to the listing if the MSGEXIT module sets the return
code to a nonzero value other than 4:
A call to the MSGEXIT user exit routine exit-name failed with return code nn.
In the MSGEXIT messages, the two characters PP indicate the phase of the compiler that issued the
message that resulted in a call to the MSGEXIT module.
Related tasks
“Customizing compiler-message severities” on page 835
Table 126. Actions possible in exit modules for CICS, SQL and SQLIMS statements
Compile Translated with Possible actions Comments
with integrated or
suboption separate CICS and
Db2 translators?
INEXIT Integrated Can process EXEC CICS, EXEC The INEXIT module does not get
SQL, and EXEC SQLIMS statements control of the COBOL statements
in the INEXIT module that are generated for the EXEC
statements.
Separate Can process the COBOL statements You can change the generated
that are generated for the EXEC statements in the INEXIT module,
statements in the INEXIT module but doing so is not supported by
IBM.
LIBEXIT Integrated Can process in the LIBEXIT module EXEC SQL INCLUDE and EXEC
the statements that are brought SQLIMS INCLUDE statements
in by the EXEC SQL INCLUDE are processed like COBOL COPY
and EXEC SQLIMS INCLUDE statements.
statements. Can process EXEC
CICS source statements in the
LIBEXIT module.
Separate Can process the COBOL statements You can process the input
that are generated for the EXEC statements that are brought in
CICS statements in the LIBEXIT by the EXEC SQL INCLUDE and
module SQLIMS INCLUDE statements only
by using the INEXIT suboption.
PRTEXIT Integrated Can process the EXEC CICS , EXEC The PRTEXIT module does not have
SQL, and EXEC SQLIMS source access to the COBOL statements
statements from the SOURCE listing that are generated.
in the PRTEXIT module
Separate Can process the COBOL SOURCE
listing statements that are
generated for the EXEC statements
in the PRTEXIT module
844 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 126. Actions possible in exit modules for CICS, SQL and SQLIMS statements (continued)
Compile Translated with Possible actions Comments
with integrated or
suboption separate CICS and
Db2 translators?
ADEXIT Integrated Can process the EXEC CICS, EXEC The ADEXIT module does not have
SQL, and EXEC SQLIMS source access to the COBOL statements
statements in the ADEXIT module that are generated.
Separate Can process the COBOL SYSADATA
statements that are generated for
the EXEC statements in the ADEXIT
module
MSGEXIT Integrated Can process CICS and Db2
messages in the MSGEXIT module
Separate Cannot process CICS and Db2 Messages from CICS are shown in
messages in the MSGEXIT module the separate CICS translator listing;
messages from Db2 are shown in
the Db2 precompiler listing.
Related concepts
“Integrated CICS translator” on page 500
“Db2 coprocessor” on page 505
Related tasks
“Compiling with the CICS option” on page 499
“Compiling with the SQL option” on page 509
Related references
“Processing of INEXIT” on page 826
“Processing of LIBEXIT” on page 827
“Processing of PRTEXIT” on page 830
“Processing of ADEXIT” on page 832
“Processing of MSGEXIT” on page 833
*****************************************************************
* COBOL declarations for Java native method interoperation *
* *
* To use the Java Native Interface callable services from a *
* COBOL program: *
* 1) Use a COPY statement to include this file into the *
* the Linkage Section of the program, e.g. *
* Linkage Section. *
* Copy JNI *
* 2) Code the following statements at the beginning of the *
* Procedure Division: *
* Set address of JNIEnv to JNIEnvPtr *
* Set address of JNINativeInterface to JNIEnv *
*****************************************************************
*
* Sample JNI type definitions in COBOL
*
*01 jboolean1 pic X.
* 88 jboolean1-true value X'01' through X'FF'.
* 88 jboolean1-false value X'00'.
*
*01 jbyte1 pic X.
*
*01 jchar1 pic N usage national.
*
*01 jshort1 pic s9(4) comp-5.
*01 jint1 pic s9(9) comp-5.
*01 jlong1 pic s9(18) comp-5.
*
*01 jfloat1 comp-1.
*01 jdouble1 comp-2.
*
*01 jobject1 object reference.
*01 jclass1 object reference.
*01 jstring1 object reference jstring.
*01 jarray1 object reference jarray.
*
*01 jbooleanArray1 object reference jbooleanArray.
*01 jbyteArray1 object reference jbyteArray.
*01 jcharArray1 object reference jcharArray.
*01 jshortArray1 object reference jshortArray.
*01 jintArray1 object reference jintArray.
*01 jlongArray1 object reference jlongArray.
*01 floatArray1 object reference floatArray.
*01 jdoubleArray1 object reference jdoubleArray.
*01 jobjectArray1 object reference jobjectArray.
01 JNIenv pointer.
848 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
02 CallNonvirtualVoidMethod function-pointer.
02 CallNonvirtualVoidMethodV function-pointer.
02 CallNonvirtualVoidMethodA function-pointer.
02 GetFieldID function-pointer.
02 GetObjectField function-pointer.
02 GetBooleanField function-pointer.
02 GetByteField function-pointer.
02 GetCharField function-pointer.
02 GetShortField function-pointer.
02 GetIntField function-pointer.
02 GetLongField function-pointer.
02 GetFloatField function-pointer.
02 GetDoubleField function-pointer.
02 SetObjectField function-pointer.
02 SetBooleanField function-pointer.
02 SetByteField function-pointer.
02 SetCharField function-pointer.
02 SetShortField function-pointer.
02 SetIntField function-pointer.
02 SetLongField function-pointer.
02 SetFloatField function-pointer.
02 SetDoubleField function-pointer.
02 GetStaticMethodID function-pointer.
02 CallStaticObjectMethod function-pointer.
02 CallStaticObjectMethodV function-pointer.
02 CallStaticObjectMethodA function-pointer.
02 CallStaticBooleanMethod function-pointer.
02 CallStaticBooleanMethodV function-pointer.
02 CallStaticBooleanMethodA function-pointer.
02 CallStaticByteMethod function-pointer.
02 CallStaticByteMethodV function-pointer.
02 CallStaticByteMethodA function-pointer.
02 CallStaticCharMethod function-pointer.
02 CallStaticCharMethodV function-pointer.
02 CallStaticCharMethodA function-pointer.
02 CallStaticShortMethod function-pointer.
02 CallStaticShortMethodV function-pointer.
02 CallStaticShortMethodA function-pointer.
02 CallStaticIntMethod function-pointer.
02 CallStaticIntMethodV function-pointer.
02 CallStaticIntMethodA function-pointer.
02 CallStaticLongMethod function-pointer.
02 CallStaticLongMethodV function-pointer.
02 CallStaticLongMethodA function-pointer.
02 CallStaticFloatMethod function-pointer.
02 CallStaticFloatMethodV function-pointer.
02 CallStaticFloatMethodA function-pointer.
02 CallStaticDoubleMethod function-pointer.
02 CallStaticDoubleMethodV function-pointer.
02 CallStaticDoubleMethodA function-pointer.
02 CallStaticVoidMethod function-pointer.
02 CallStaticVoidMethodV function-pointer.
02 CallStaticVoidMethodA function-pointer.
02 GetStaticFieldID function-pointer.
02 GetStaticObjectField function-pointer.
02 GetStaticBooleanField function-pointer.
02 GetStaticByteField function-pointer.
02 GetStaticCharField function-pointer.
02 GetStaticShortField function-pointer.
02 GetStaticIntField function-pointer.
02 GetStaticLongField function-pointer.
02 GetStaticFloatField function-pointer.
02 GetStaticDoubleField function-pointer.
02 SetStaticObjectField function-pointer.
02 SetStaticBooleanField function-pointer.
02 SetStaticByteField function-pointer.
02 SetStaticCharField function-pointer.
02 SetStaticShortField function-pointer.
02 SetStaticIntField function-pointer.
02 SetStaticLongField function-pointer.
02 SetStaticFloatField function-pointer.
02 SetStaticDoubleField function-pointer.
02 NewString function-pointer.
02 GetStringLength function-pointer.
02 GetStringChars function-pointer.
02 ReleaseStringChars function-pointer.
02 NewStringUTF function-pointer.
02 GetStringUTFLength function-pointer.
02 GetStringUTFChars function-pointer.
02 ReleaseStringUTFChars function-pointer.
02 GetArrayLength function-pointer.
02 NewObjectArray function-pointer.
Related tasks
“Compiling OO applications under z/OS UNIX” on page 291
“Accessing JNI services” on page 719
850 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Appendix G. COBOL SYSADATA file contents
When you use the ADATA compiler option, the compiler produces a file, the SYSADATA file, that contains
additional program data. You can use this file instead of the compiler listing to extract information about
the program. For example, you can extract information about the program for symbolic debugging tools or
cross-reference tools.
“Example: SYSADATA” on page 853
Related references
“ADATA” on page 345
“Compiler options that affect the SYSADATA file” on page 851
“SYSADATA record types” on page 852
“SYSADATA record descriptions” on page 854
The Type 0038 Source record contains two fields that relate to line numbers and record numbers:
Related references
“SYSADATA record types” on page 852
“COMPILE” on page 355
“EXIT” on page 367
“LANGUAGE” on page 381
“NUMBER” on page 388
“TEST” on page 414
852 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 127. SYSADATA record types (continued)
Record type What it does
“Symbol cross-reference record: X'0044'” on Describes references to a single symbol
page 941
“Nested program record: X'0046'” on page 943 Describes the name and nesting level of a program
“Library record: X'0060'” on page 943 Describes the library files and members used from
each library
“Statistics record: X'0090'” on page 944 Describes the statistics about the compilation
“EVENTS record: X'0120'” on page 944 EVENTS records provide compatibility with COBOL/
370. The record format is identical with that in
COBOL/370, with the addition of the standard ADATA
header at the beginning of the record and a field
indicating the length of the EVENTS record data.
Example: SYSADATA
The following sample shows part of the listing of a COBOL program. If this COBOL program were compiled
with the ADATA option, the records produced in the associated data file would be in the sequence shown
in the table below.
Type Description
X'0120' EVENTS Timestamp record
X'0120' EVENTS Processor record
X'0120' EVENTS File-ID record
X'0120' EVENTS Program record
X'0001' ADATA Identification record
X'0000' Job Identification record
X'0010' Options record
X'0038' Source record for statement 1
X'0038' Source record for statement 2
X'0038' Source record for statement 3
X'0038' Source record for statement 4
X'0038' Source record for statement 5
X'0038' Source record for statement 6
X'0038' Source record for statement 7
X'0038' Source record for statement 8
Related references
“SYSADATA record descriptions” on page 854
Related references
“Common header section” on page 855
“Job identification record: X'0000'” on page 857
“ADATA identification record: X'0001'” on page 858
“Compilation unit start | end record: X'0002'” on page 858
“Options record: X'0010'” on page 859
“External symbol record: X'0020'” on page 871
“Parse tree record: X'0024'” on page 872
“Token record: X'0030'” on page 899
“Source error record: X'0032'” on page 927
“Source record: X'0038'” on page 927
“COPY REPLACING record: X'0039'” on page 928
“Symbol record: X'0042'” on page 929
“Symbol cross-reference record: X'0044'” on page 941
“Nested program record: X'0046'” on page 943
854 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
“Library record: X'0060'” on page 943
“Statistics record: X'0090'” on page 944
“EVENTS record: X'0120'” on page 944
Associated data record XL1 Used to indicate a new format for a specific record type, usually 0
edition level
Reserved CL4 Reserved for future use
856 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 128. SYSADATA common header section (continued)
Field Size Description
Associated data field HL2 The length in bytes of the data following the header
length
1. When a batch compilation (sequence of programs) is run with the ADATA option, there will be
multiple Job Identification, Options, and Statistics records for each compilation.
The mapping of the 12-byte header does not include the area used for the variable-length record-
descriptor word required by the access method on MVS and VSE.
...Input file number HL2 The assigned sequence number of the file
...Input file name length HL2 The length of the following input file name
...Volume serial number HL2 The length of the volume serial number
length
...Member name length HL2 The length of the member name
...Input file name CL(n) The name of the input file for the compilation
...Volume serial number CL(n) The volume serial number of the (first) volume on which the input
file resides
...Member name CL(n) Where applicable, the name of the member in the input file
1. Where the number of input files would exceed the record size for the associated data file, the record
is continued on the next record. The current number of input files (for that record) is stored in the
record, and the record is written to the associated data file. The next record contains the rest of the
input files. The count of the number of input files is a count for the current record.
Code-page name length XL2 Length of the code-page name that follows
Code-page name CL(n) Name of the code page
1. The appropriate CCS flag will always be set. If the CCSID is set to nonzero, the code-page name
length will be zero. If the CCSID is set to zero, the code-page name length will be nonzero and the
code-page name will be present.
858 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Options record: X'0010'
The following table shows the contents of the options record.
860 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 132. SYSADATA options record (continued)
Field Size Description
Option byte 4 XL1 1... ....
Bit 1 = ADV, Bit 0 = NOADV
.1.. ....
Bit 1 = APOST, Bit 0 = QUOTE
..1. ....
Bit 1 = DYNAM, Bit 0 = NODYNAM
...1 ....
Bit 1 = AWO, Bit 0 = NOAWO
.... 1...
Bit 1 = RMODE specified, Bit 0 = RMODE(AUTO)
.... .1..
Bit 1 = RENT, Bit 0 = NORENT
.... ..1.
Bit 1 = RES: this flag will always be set on for COBOL.
.... ...1
Bit 1 = RMODE(24), Bit 0 = RMODE(ANY)
862 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 132. SYSADATA options record (continued)
Field Size Description
Option byte 9 XL1 1... ....
Bit 1 = DATA(24), Bit 0 = DATA(31)
.1.. ....
Bit 1 = FASTSRT, Bit 0 = NOFASTSRT
.... .1..
Bit 1 = THREAD, Bit 0 = NOTHREAD
...1 1.11
Reserved for future use
864 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 132. SYSADATA options record (continued)
Field Size Description
Option byte F XL1 1... ....
Bit = INITIAL, Bit 0 = NOINITIAL
.1.. ....
Bit 1 = COPYRIGHT, Bit 0 = NOCOPYRIGHT
..1. ....
Bit 1 = QUALIFY(EXTEND), Bit 0 = QUALIFY(COMPAT)
...1 ....
Bit 1 = SERVICE, Bit 0 = NOSERVICE
.... 1...
Bit 1 = ZONEDATA(MIG)
.... .1..
Bit 1 = ZONEDATA(NOPFD)
.... ..1.
Bit 1 = NUMCHECK(ZON|PAC|BIN|ABD|MSG), Bit 0 =
NONUMCHECK
.... ...1
Bit 1 = PARMCHECK(ABD|MSG), Bit 0 = NOPARMCHECK
866 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 132. SYSADATA options record (continued)
Field Size Description
Imbedded diagnostic XL1 X'00'
level Flag(I)
X'04'
Flag(W)
X'08'
Flag(E)
X'0C'
Flag(S)
X'10'
Flag(U)
X'FF'
Noflag
868 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 132. SYSADATA options record (continued)
Field Size Description
CALLINTERFACE XL1 1... ....
suboptions Bit 1 = CALLINTERFACE(DLL)
.1.. ....
Bit 1 = CALLINTERFACE(DYNAMIC)
..11 1111
Reserved for future use
870 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
External symbol record: X'0020'
The following table shows the contents of the external symbol record.
101
IDENTIFICATION DIVISION
102
ENVIRONMENT DIVISION
103
DATA DIVISION
104
PROCEDURE DIVISION
105
End Program/Method/Class
201
Declaratives body
202
Nondeclaratives body
301
Section
302
Procedure section
401
Paragraph
402
Procedure paragraph
872 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 134. SYSADATA parse tree record (continued)
Field Size Description
501
Sentence
502
File definition
503
Sort file definition
504
Program-name
505
Program attribute
508
ENVIRONMENT DIVISION clause
509
CLASS attribute
510
METHOD attribute
511
USE statement
601
Statement
602
Data description clause
603
Data entry
604
File description clause
605
Data entry name
606
Data entry level
607
EXEC entry
701
EVALUATE subject phrase
702
EVALUATE WHEN phrase
703
EVALUATE WHEN OTHER phrase
704
SEARCH WHEN phrase
705
INSPECT CONVERTING phrase
706
INSPECT REPLACING phrase
707
INSPECT TALLYING phrase
708
PERFORM UNTIL phrase
709
PERFORM VARYING phrase
710
PERFORM AFTER phrase
711
Statement block
712
Scope terminator
713
INITIALIZE REPLACING phrase
714
EXEC CICS Command
715
INITIALIZE WITH FILLER
716
INITIALIZE TO VALUE
717
INITIALIZE TO DEFAULT
718
ALLOCATE INITIALIZED
719
ALLOCATE LOC
720
DATA DIVISION phrase
874 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 134. SYSADATA parse tree record (continued)
Field Size Description
801
Phrase
802
ON phrase
803
NOT phrase
804
THEN phrase
805
ELSE phrase
806
Condition
807
Expression
808
Relative indexing
809
EXEC CICS Option
810
Reserved word
811
INITIALIZE REPLACING category
901
Section or paragraph name
902
Identifier
903
Alphabet-name
904
Class-name
905
Condition-name
906
File-name
907
Index-name
908
Mnemonic-name
910
Symbolic-character
911
Literal
912
Function identifier
913
Data-name
914
Special register
915
Procedure reference
916
Arithmetic operator
917
All procedures
918
INITIALIZE literal (no tokens)
919
ALL literal or figcon
920
Keyword class test name
921
Reserved word at identifier level
922
Unary operator
923
Relational operator
876 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 134. SYSADATA parse tree record (continued)
Field Size Description
1001
Subscript
1002
Reference modification
878 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 134. SYSADATA parse tree record (continued)
Field Size Description
For ENVIRONMENT DIVISION clause type:
0001
WITH DEBUGGING MODE
0002
MEMORY-SIZE
0003
SEGMENT-LIMIT
0004
CURRENCY-SIGN
0005
DECIMAL POINT
0006
PROGRAM COLLATING SEQUENCE
0007
ALPHABET
0008
SYMBOLIC-CHARACTER
0009
CLASS
0010
ENVIRONMENT NAME
0011
SELECT
0012
XML-SCHEMA
880 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 134. SYSADATA parse tree record (continued)
Field Size Description
For file description clause type:
0001
FILE STATUS
0002
ORGANIZATION
0003
ACCESS MODE
0004
RECORD KEY
0005
ASSIGN
0006
RELATIVE KEY
0007
PASSWORD
0008
PROCESSING MODE
0009
RECORD DELIMITER
0010
PADDING CHARACTER
0011
BLOCK CONTAINS
0012
RECORD CONTAINS
0013
LABEL RECORDS
0014
VALUE OF
0015
DATA RECORDS
0016
LINAGE
0017
ALTERNATE KEY
0018
LINES AT TOP
0019
LINES AT BOTTOM
0020
CODE-SET
0021
RECORDING MODE
0022
RESERVE
0023
GLOBAL
0024
EXTERNAL
0025
LOCK
882 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 134. SYSADATA parse tree record (continued)
Field Size Description
For Statement type:
0002
NEXT SENTENCE
0003
ACCEPT
0004
ADD
0005
ALTER
0006
CALL
0007
CANCEL
0008
CLOSE
0009
COMPUTE
0010
CONTINUE
0011
DELETE
0012
DISPLAY
0013
DIVIDE (INTO)
0113
DIVIDE (BY)
0014
ENTER
0015
ENTRY
0016
EVALUATE
0017
EXIT
0018
GO
0019
GOBACK
0020
IF
0021
INITIALIZE
0022
INSPECT
0023
INVOKE
0024
MERGE
0025
MOVE
0026
MULTIPLY
0027
OPEN
0028
PERFORM
0029
READ
0030
READY
0031
RELEASE
0032
RESET
0033
RETURN
0034
REWRITE
0035
SEARCH
0036
SERVICE
0037
SET
884 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 134. SYSADATA parse tree record (continued)
Field Size Description
0038
SORT
0039
START
0040
STOP
0041
STRING
0042
SUBTRACT
0043
UNSTRING
0044
EXEC SQL
0144
EXEC CICS
0045
WRITE
0046
XML
0047
ALLOCATE
0048
FREE
0049
JSON
886 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 134. SYSADATA parse tree record (continued)
Field Size Description
0019
DEBUGGING
0020
SEQUENCE
0021
Reserved for future use
0022
Reserved for future use
0023
Reserved for future use
0024
TALLYING
0025
Reserved for future use
0026
ON SIZE ERROR
0027
ON OVERFLOW
0028
ON ERROR
0029
AT END
0030
INVALID KEY
0031
END-OF-PAGE
0032
USING
0033
BEFORE
0034
AFTER
0035
EXCEPTION
0036
CORRESPONDING
0037
Reserved for future use
0038
RETURNING
0039
GIVING
0040
THROUGH
0041
KEY
0042
DELIMITER
0043
POINTER
0044
COUNT
0045
METHOD
0046
PROGRAM
0047
INPUT
0048
OUTPUT
0049
I-O
0050
EXTEND
0051
RELOAD
0052
ASCENDING
0053
DESCENDING
888 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 134. SYSADATA parse tree record (continued)
Field Size Description
0054
DUPLICATES
0055
NATIVE (USAGE)
0056
INDEXED
0057
FROM
0058
FOOTING
0059
LINES AT BOTTOM
0060
LINES AT TOP
0061
XML ENCODING
0062
XML GENERATE XML-DECLARATION
0063
XML GENERATE ATTRIBUTES
0064
XML GENERATE NAMESPACE
0065
XML PARSE PROCESSING
0066
XML PARSE VALIDATING
0067
XML GENERATE NAME
0068
XML GENERATE TYPE
0069
XML GENERATE SUPPRESS
0070
BYTE-LENGTH
0071
LIMIT
890 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 134. SYSADATA parse tree record (continued)
Field Size Description
0019
LENGTH
0020
MEDIAN
0021
NUMVAL
0022
RANDOM
0023
ANNUITY
0024
INTEGER
0025
ORD-MAX
0026
ORD-MIN
0027
REVERSE
0028
MIDRANGE
0029
NUMVAL-C
0030
VARIANCE
0031
FACTORIAL
0032
LOWER-CASE
0033
UPPER-CASE
0034
CURRENT-DATE
0035
INTEGER-PART
0036
PRESENT-VALUE
0037
WHEN-COMPILED
0038
DAY-OF-INTEGER
0039
INTEGER-OF-DAY
0040
DATE-OF-INTEGER
0041
INTEGER-OF-DATE
0042
STANDARD-DEVIATION
0043
YEAR-TO-YYYY
0044
DAY-TO-YYYYDDD
0045
DATE-TO-YYYYMMDD
0049
DISPLAY-OF
0050
NATIONAL-OF
0051
UPOS
0052
UVALID
0053
UWIDTH
0054
ULENGTH
0055
USUBSTR
892 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 134. SYSADATA parse tree record (continued)
Field Size Description
0056
USUPPLEMENTARY
0057
HEX-OF
0058
BIT-OF
0059
E
0060
TRIM
0061
PI
0062
ABS
0063
BYTE-LENGTH
0064
EXP
0065
EXP10
0066
BIT-TO-CHAR
0067
NUMVAL-F
0068
HEX-TO-CHAR
0069
SIGN
0070
TEST-NUMVAL
0071
TEST-NUMVAL-C
0072
TEST-NUMVAL-F
0073
UUID4
0074
FORMATTED-DATE
0075
FORMATTED-TIME
0076
TEST-DAY-YYYYDDD
0077
COMBINED-DATETIME
0078
FORMATTED-DATETIME
0079
TEST-DATE-YYYYMMDD
0080
SECONDS-PAST-MIDNIGHT
0081
FORMATTED-CURRENT-DATE
0082
TEST-FORMATTED-DATETIME
0083
INTEGER-OF-FORMATTED-DATE
0084
SECONDS-FROM-FORMATTED-TIME
894 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 134. SYSADATA parse tree record (continued)
Field Size Description
For Keyword Class Test Name type:
0001
ALPHABETIC
0002
ALPHABETIC-LOWER
0003
ALPHABETIC-UPPER
0004
DBCS
0005
KANJI
0006
NUMERIC
0007
NEGATIVE
0008
POSITIVE
0009
ZERO
896 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 134. SYSADATA parse tree record (continued)
Field Size Description
For Reserved word at identifier level type:
0001
ROUNDED
0002
TRUE
0003
ON
0004
OFF
0005
SIZE
0006
DATE
0007
DAY
0008
DAY-OF-WEEK
0009
TIME
0010
WHEN-COMPILED
0011
PAGE
0012
DATE YYYYMMDD
0013
DAY YYYYDDD
0014
Attribute
0015
Element
0016
Content
0017
Numeric
0018
Nonnumeric
0019
Every
0020
When
Parent node number FL4 The node number of the parent of the node
Left sibling node number FL4 The node number of the left sibling of the node, if any. If none, the
value is zero.
898 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 134. SYSADATA parse tree record (continued)
Field Size Description
Symbol ID FL4 The Symbol ID of the node, if it is a user-name of one of the
following types:
• Data entry
• Identifier
• File-name
• Index-name
• Procedure-name
• Condition-name
• Mnemonic-name
This value corresponds to the Symbol ID in a Symbol (Type 42)
record, except for procedure-names where it corresponds to the
Paragraph ID.
For all other node types this value is zero.
Section Symbol ID FL4 The Symbol ID of the section containing the node, if it is a qualified
paragraph-name reference. This value corresponds to the Section
ID in a Symbol (Type 42) record.
For all other node types this value is zero.
First token number FL4 The number of the first token associated with the node
Last token number FL4 The number of the last token associated with the node
Reserved FL4 Reserved for future use
Flags CL1 Information about the node:
X'80'
Reserved
X'40'
Generated node, no tokens
900 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 135. SYSADATA token record (continued)
Field Size Description
Token code HL2 The type of token (user-name, literal, reserved word, and so forth).
For reserved words, the compiler reserved-word table values are
used.
For PICTURE strings, the special code 0000 is used.
For each piece (other than the last) of a continued token, the
special code 3333 is used.
Otherwise, the following codes are used:
0001
ACCEPT
0002
ADD
0003
ALTER
0004
CALL
0005
CANCEL
0007
CLOSE
0009
COMPUTE
0011
DELETE
0013
DISPLAY
0014
DIVIDE
0017
READY
0018
END-PERFORM
0019
ENTER
0020
ENTRY
0021
EXIT
0022
EXEC
EXECUTE
0023
GO
0024
IF
0025
INITIALIZE
0026
INVOKE
0027
INSPECT
0028
MERGE
0029
MOVE
902 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 135. SYSADATA token record (continued)
Field Size Description
0030
MULTIPLY
0031
OPEN
0032
PERFORM
0033
READ
0035
RELEASE
0036
RETURN
0037
REWRITE
0038
SEARCH
0040
SET
0041
SORT
0042
START
0043
STOP
0044
STRING
0045
SUBTRACT
0048
UNSTRING
0049
USE
0050
WRITE
0051
CONTINUE
0052
END-ADD
0053
END-CALL
0054
END-COMPUTE
0055
END-DELETE
0056
END-DIVIDE
0057
END-EVALUATE
0058
END-IF
0059
END-MULTIPLY
0060
END-READ
0061
END-RETURN
0062
END-REWRITE
0063
END-SEARCH
0064
END-START
0065
END-STRING
0066
END-SUBTRACT
0067
END-UNSTRING
0068
END-WRITE
0069
GOBACK
904 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 135. SYSADATA token record (continued)
Field Size Description
0070
EVALUATE
0071
RESET
0072
SERVICE
0073
END-INVOKE
0074
END-EXEC
0075
XML
0076
END-XML
0077
ALLOCATE
0078
FREE
0079
JSON
0080
END-JSON
0099
FOREIGN-VERB
0101
DATA-NAME
0105
DASHED-NUM
0106
DECIMAL
0107
DIV-SIGN
0108
EQ
0109
EXPONENTIATION
0110
GT
0111
INTEGER
0112
LT
0113
LPAREN
0114
MINUS-SIGN
0115
MULT-SIGN
0116
NONUMLIT
0117
PERIOD
0118
PLUS-SIGN
0121
RPAREN
0122
SIGNED-INTEGER
0123
QUID
0124
COLON
0125
IEOF
0126
EGCS-LIT
0127
COMMA-SPACE
0128
SEMICOLON-SPACE
0129
PROCEDURE-NAME
0130
FLT-POINT-LIT
0131
Language Environment
906 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 135. SYSADATA token record (continued)
Field Size Description
0132
GE
0133
IDREF
0134
EXPREF
0136
CICS
0137
NEW
0138
NATIONAL-LIT
0200
ADDRESS
0201
ADVANCING
0202
AFTER
0203
ALL
0204
ALPHABETIC
0205
ALPHANUMERIC
0206
ANY
0207
AND
0208
ALPHANUMERIC-EDITED
0209
BEFORE
0210
BEGINNING
0211
FUNCTION
0212
CONTENT
0213
CORR
CORRESPONDING
0214
DAY
0215
DATE
0216
DEBUG-CONTENTS
0217
DEBUG-ITEM
0218
DEBUG-LINE
0219
DEBUG-NAME
0220
DEBUG-SUB-1
0221
DEBUG-SUB-2
0222
DEBUG-SUB-3
0223
DELIMITED
0224
DELIMITER
0225
DOWN
908 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 135. SYSADATA token record (continued)
Field Size Description
0226
NUMERIC-EDITED
0227
XML-EVENT
0228
END-OF-PAGE
EOP
0229
EQUAL
0230
ERROR
0231
XML-NTEXT
0232
EXCEPTION
0233
EXTEND
0234
FIRST
0235
FROM
0236
GIVING
0237
GREATER
0238
I-O
0239
IN
0240
INITIAL
0241
INTO
0242
INVALID
0243
SQL
0244
LESS
0245
LINAGE-COUNTER
0246
XML-TEXT
0247
LOCK
0248
GENERATE
0249
NEGATIVE
0250
NEXT
0251
NO
0252
NOT
0253
NUMERIC
0254
KANJI
0255
OR
0256
OTHER
0257
OVERFLOW
0258
PAGE
0259
CONVERTING
910 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 135. SYSADATA token record (continued)
Field Size Description
0260
POINTER
0261
POSITIVE
0262
DBCS
0263
PROCEDURES
0264
PROCEED
0265
REFERENCES
0266
DAY-OF-WEEK
0267
REMAINDER
0268
REMOVAL
0269
REPLACING
0270
REVERSED
0271
REWIND
0272
ROUNDED
0273
RUN
0274
SENTENCE
0275
STANDARD
0276
RETURN-CODE
SORT-CORE-SIZE
SORT-FILE-SIZE
SORT-MESSAGE
SORT-MODE-SIZE
SORT-RETURN
TALLY
XML-CODE
0277
TALLYING
0278
SUM
0279
TEST
0280
THAN
0281
UNTIL
0282
UP
0283
UPON
0284
VARYING
0285
RELOAD
0286
TRUE
912 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 135. SYSADATA token record (continued)
Field Size Description
0287
THEN
0288
RETURNING
0289
ELSE
0290
SELF
0291
SUPER
0292
WHEN-COMPILED
0293
ENDING
0294
FALSE
0295
REFERENCE
0296
NATIONAL-EDITED
0297
COM-REG
0298
ALPHABETIC-LOWER
0299
ALPHABETIC-UPPER
0301
REDEFINES
0302
OCCURS
0303
SYNC
SYNCHRONIZED
0304
MORE-LABELS
0305
JUST
JUSTIFIED
0306
SHIFT-IN
0307
BLANK
0308
VALUE
0309
COMP
COMPUTATIONAL
0310
COMP-1
COMPUTATIONAL-1
0311
COMP-3
COMPUTATIONAL-3
0312
COMP-2
COMPUTATIONAL-2
0313
COMP-4
COMPUTATIONAL-4
0314
DISPLAY-1
0315
SHIFT-OUT
914 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 135. SYSADATA token record (continued)
Field Size Description
0316
INDEX
0317
USAGE
0318
SIGN
0319
LEADING
0320
SEPARATE
0321
INDEXED
0322
LEFT
0323
RIGHT
0324
PIC
PICTURE
0325
VALUES
0326
GLOBAL
0327
EXTERNAL
0328
BINARY
0329
PACKED-DECIMAL
0330
EGCS
0331
PROCEDURE-POINTER
0332
COMP-5
COMPUTATIONAL-5
0333
FUNCTION-POINTER
0334
TYPE
0335
JNIENVPTR
0336
NATIONAL
0337
GROUP-USAGE
0342
VOLATILE
0401
HIGH-VALUE
HIGH-VALUES
0402
LOW-VALUE
LOW-VALUES
0403
QUOTE
QUOTES
0404
SPACE
SPACES
0405
ZERO
916 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 135. SYSADATA token record (continued)
Field Size Description
0406
ZEROES
ZEROS
0407
NULL
NULLS
0501
BLOCK
0502
BOTTOM
0505
CHARACTER
0506
CODE
0507
CODE-SET
0514
FILLER
0516
FOOTING
0520
LABEL
0521
LENGTH
0524
LINAGE
0526
OMITTED
0531
RENAMES
0543
TOP
0545
TRAILING
0549
RECORDING
0500
POINTER-32
0551
BYTE-LENGTH
0555
LIMIT
0601
INHERITS
0603
RECURSIVE
0701
ACCESS
0702
ALSO
0703
ALTERNATE
0704
AREA
AREAS
0705
ASSIGN
0707
COLLATING
0708
COMMA
0709
CURRENCY
0710
CLASS
0711
DECIMAL-POINT
0712
DUPLICATES
0713
DYNAMIC
0714
EVERY
918 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 135. SYSADATA token record (continued)
Field Size Description
0716
MEMORY
0717
MODE
0718
MODULES
0719
MULTIPLE
0720
NATIVE
0721
OFF
0722
OPTIONAL
0723
ORGANIZATION
0724
POSITION
0725
PROGRAM
0726
RANDOM
0727
RELATIVE
0728
RERUN
0729
RESERVE
0730
SAME
0731
SEGMENT-LIMIT
0732
SELECT
0733
SEQUENCE
0734
SEQUENTIAL
0736
SORT-MERGE
0737
STANDARD-1
0738
TAPE
0739
WORDS
0740
PROCESSING
0741
APPLY
0742
WRITE-ONLY
0743
COMMON
0744
ALPHABET
0745
PADDING
0746
SYMBOLIC
0747
STANDARD-2
0748
OVERRIDE
0750
PASSWORD
0751
XML-SCHEMA
920 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 135. SYSADATA token record (continued)
Field Size Description
0801
ARE
IS
0802
ASCENDING
0803
AT
0804
BY
0805
CHARACTERS
0806
CONTAINS
0808
COUNT
0809
DEBUGGING
0810
DEPENDING
0811
DESCENDING
0812
DIVISION
0814
FOR
0815
ORDER
0816
INPUT
0817
REPLACE
0818
KEY
0819
LINE
LINES
0820
XML-INFORMATION
0821
OF
0822
ON
0823
OUTPUT
0825
RECORD
0826
RECORDS
0827
REEL
0828
SECTION
0829
SIZE
0830
STATUS
0831
THROUGH
THRU
0832
TIME
0833
TIMES
0834
TO
0836
UNIT
922 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 135. SYSADATA token record (continued)
Field Size Description
0837
USING
0838
WHEN
0839
WITH
0840
SQLIMS
0841
DEFAULT
0901
PROCEDURE
0902
DECLARATIVES
0903
END
1001
DATA
1002
FILE
1003
FD
1004
SD
1005
WORKING-STORAGE
1006
LOCAL-STORAGE
1007
LINKAGE
1101
ENVIRONMENT
1102
CONFIGURATION
1103
SOURCE-COMPUTER
1104
OBJECT-COMPUTER
1105
SPECIAL-NAMES
1106
REPOSITORY
1107
INPUT-OUTPUT
1108
FILE-CONTROL
1109
I-O-CONTROL
1201
ID
IDENTIFICATION
1202
PROGRAM-ID
1203
AUTHOR
1204
INSTALLATION
1205
DATE-WRITTEN
1206
DATE-COMPILED
1207
SECURITY
1208
CLASS-ID
1209
METHOD-ID
1210
METHOD
1211
FACTORY
924 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 135. SYSADATA token record (continued)
Field Size Description
1212
OBJECT
2020
TRACE
2046
SUPPRESS
3000
DATADEF
3001
F-NAME
3002
UPSI-SWITCH
3003
CONDNAME
3004
CONDVAR
3005
BLOB
3006
CLOB
3007
DBCLOB
3008
BLOB-LOCATOR
3009
CLOB-LOCATOR
3010
DBCLOB-LOCATOR
3011
BLOB-FILE
3012
CLOB-FILE
3013
DBCLOB-FILE
3014
DFHRESP
5001
PARSE
5002
AUTOMATIC
5003
PREVIOUS
5004
ENCODING
5005
NAMESPACE
5006
NAMESPACE-PREFIX
5007
XML-DECLARATION
5008
ATTRIBUTES
5009
VALIDATING
5010
UNBOUNDED
5011
ATTRIBUTE
5012
ELEMENT
5013
NONNUMERIC
5014
NAME
5015
CYCLE
5016
PARAGRAPH
5020
AS
5021
INITIALIZED
9999
COBOL
926 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 135. SYSADATA token record (continued)
Field Size Description
Flags CL1 Information about the token:
X'80'
Token is continued
X'40'
Last piece of continued token
Note that for PICTURE strings, even if the source token is
continued, there will be only one Token record generated. It will
have a token code of 0000, the token column and line of the first
piece, the length of the complete string, no continuation flags set,
and the token text of the complete string.
928 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Symbol record: X'0042'
The following table shows the contents of the symbol record.
930 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 139. SYSADATA symbol record (continued)
Field Size Description
Clauses XL1 Clauses specified in symbol definition.
For symbols that have a symbol attribute of Numeric (X'01'),
Elementary character (X'02'), Group (X'03'), Pointer (X'04'),
Index data item (X'05'), or Object reference (X'18'):
1... ....
Value
.1.. ....
Indexed
..1. ....
Redefines
...1 ....
Renames
.... 1...
Occurs
.... .1..
Has Occurs keys
.... ..1.
Occurs Depending On
.... ...1
Occurs in parent
For file types:
1... ....
Select
.1.. ....
Assign
..1. ....
Rerun
...1 ....
Same area
.... 1...
Same record area
.... .1..
Recording mode
.... ..1.
Reserved
.... ...1
Record
932 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 139. SYSADATA symbol record (continued)
Field Size Description
20
SYSIN|SYSIPT
22
SYSOUT|SYSLST|SYSLIST
24
SYSPUNCH|SYSPCH
26
UPSI-0
27
UPSI-1
28
UPSI-2
29
UPSI-3
30
UPSI-4
31
UPSI-5
32
UPSI-6
33
UPSI-7
34
AFP-5A
Data flags 1 XL1 For file types, and for symbols that have a symbol attribute of
Numeric (X'01'), Elementary character (X'02'), Group (X'03'),
Pointer (X'04'), Index data item (X'05'), or Object reference
(X'18'):
1... ....
Redefined
.1.. ....
Renamed
..1. ....
Synchronized
...1 ....
Implicitly redefined
.... 1...
Volatile
.... .1..
Implicit redefines
.... ..1.
FILLER
.... ...1
Level 77
934 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 139. SYSADATA symbol record (continued)
Field Size Description
936 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 139. SYSADATA symbol record (continued)
Field Size Description
Sign clause FL1 X'00'
No SIGN clause
X'01'
SIGN IS LEADING
X'02'
SIGN IS LEADING SEPARATE CHARACTER
X'03'
SIGN IS TRAILING
X'04'
SIGN IS TRAILING SEPARATE CHARACTER
Size FL4 The size of this data item. The actual number of bytes this item
occupies in storage. If a DBCS item, the number is in bytes, not
characters. For variable-length items, this field will reflect the
maximum size of storage reserved for this item by the compiler.
Also known as the "Length attribute."
Precision FL1 The precision of a fixed or float data item
Scale FL1 The scale factor of a fixed data item. This is the number of digits to
the right of the decimal point.
938 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 139. SYSADATA symbol record (continued)
Field Size Description
Data flags 4 XL1 For symbols that have a symbol attribute of Numeric (X'01'):
1... ....
Numeric national
For symbols that have a symbol attribute of Elementary character
(X'02'):
1... ....
National
.1.. ....
National edited
For symbols that have a symbol attribute of Group (X'03'):
1... ....
Group-Usage National
.1.. ....
Unbounded length group
Structure displacement AL4 Offset of symbol within structure. This offset is set to 0 for variably
located items.
Parent displacement AL4 Byte offset from immediate parent of the item being defined.
Parent ID FL4 The symbol ID of the immediate parent of the item being defined.
Redefined ID FL4 The symbol ID of the data item that this item redefines, if
applicable.
Start-renamed ID FL4 If this item is a level-66 item, the symbol ID of the starting COBOL
data item that this item renames. If not a level-66 item, this field is
set to 0.
End-renamed ID FL4 If this item is a level-66 item, the symbol ID of the ending COBOL
data item that this item renames. If not a level-66 item, this field is
set to 0.
Program-name symbol FL4 ID of the program-name of the program or the class-name of the
ID class where this symbol is defined.
OCCURS minimum FL4 Minimum value for OCCURS
Paragraph ID Proc-name ID for a paragraph-name
Dynamic-length item FL4 The value of the LIMIT phrase of the DYNAMIC LENGTH clause for
limit dynamic-length items; zero if the item is not dynamic-length or the
LIMIT phrase was not specified.
Reserved CL4 Reserved for future use
Value pairs count HL2 Count of value pairs
Symbol name length HL2 Number of characters in the symbol name
Picture data length for HL2 Number of characters in the picture data; zero if symbol has no
data-name associated PICTURE clause. (Length of the PICTURE field.) Length
represents the field as it is found in the source input. This length
or
does not represent the expanded field for PICTURE items that
Assignment-name contain a replication factor. The maximum COBOL length for a
length for file-name PICTURE string is 50 bytes. Zero in this field indicates no PICTURE
specified.
Number of characters in the external file-name if this is a file-
name. This is the DD name part of the assignment-name. Zero if
file-name and ASSIGN USING specified.
Initial Value length for HL2 Number of characters in the symbol value; zero if symbol has no
data-name initial value
External class-name Number of characters in the external class-name for CLASS-ID
length for CLASS-ID
ODO symbol name ID for FL4 If data-name, ID of the ODO symbol name; zero if ODO not
data-name specified
ID of ASSIGN data- If file-name, Symbol-ID for ASSIGN USING data-name; zero if
name if file-name ASSIGN TO specified
940 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 139. SYSADATA symbol record (continued)
Field Size Description
Keys (n)XL8 This field contains data describing keys specified for an array. The
following three fields are repeated as many times as specified in
the 'Keys count' field.
...Key Sequence FL1 Ascending or descending indicator.
X'00'
DESCENDING
X'01'
ASCENDING
...2nd value length HL2 Length of second value, zero if not a THRU value pair
...2nd value data CL(n) 2nd value.
This field contains the literal (or figurative constant) as it is
specified in the VALUE clause in the source file. It includes any
beginning and ending delimiters, embedded quotation marks, and
SHIFT IN and SHIFT OUT characters. If the literal spans multiple
lines, the lines are concatenated into one long string. If a figurative
constant is specified, this field contains the actual reserved word,
not the value associated with that word.
Number of references1 HL2 The number of references in this record to the symbol following
Cross-reference type XL1 X'01'
Program
X'02'
Procedure
X'03'
statement
X'04'
Symbol or data-name
X'05'
Method
X'06'
Class
...Line number XL4 The line number on which the symbol or statement is referenced
942 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 140. SYSADATA symbol cross-reference record (continued)
Field Size Description
1. The reference flag field and the statement number field occur as many times as the number of
references field dictates. For example, if there is a value of 10 in the number of references field, there
will be 10 occurrences of the reference flag and statement number pair for data-name, procedure, or
program symbols, or 10 occurrences of the statement number for statements.
Where the number of references would exceed the record size for the SYSADATA file, the record
is continued on the next record. The continuation flag is set in the common header section of the
record.
1. If 10 COPY members are retrieved from a library, the "Number of members" field will contain 10 and
there will be 10 occurrences of the "COPY/BASIS member file ID" field, the "COPY/BASIS name
length" field, and the "COPY/BASIS name" field.
2. If COPY/BASIS members are retrieved from different libraries, a library record is written to the
SYSADATA file for each unique library.
EOJ severity XL1 The maximum return code for the compile job
Program-name length XL1 The length of the program-name
Program-name CL(n) Program-name
944 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Events records are of the following types:
• Time stamp
• Processor
• File end
• Program
• File ID
• Error
946 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Table 148. SYSADATA EVENTS FILE ID record layout (continued)
Field Size Description
Source file name length H2
Blank separator CL1
Source file name CL(n)
948 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Appendix H. Using sample programs
The sample programs, which are included on your product tape, demonstrate many language elements
and concepts of COBOL.
This information contains the following items:
• Overview of the programs, including program charts for two of the samples
• Format and sample of the input data
• Sample of reports produced
• Information about how to run the programs
• List of the language elements and concepts that are illustrated
Pseudocode and other comments about the programs are included in the program prolog, which you can
obtain in a program listing.
There are three sample programs:
• IGYTCARA is an example of using QSAM files and VSAM indexed files, and shows how to use many
COBOL intrinsic functions.
• IGYTCARB is an example of using IBM Interactive System Product Facility (ISPF).
• IGYTSALE is an example of using several of the features of the Language Environment callable services.
Related concepts
“IGYTCARA: batch application” on page 949
“IGYTCARB: interactive program” on page 953
“IGYTSALE: nested program
application” on page 955
Related references
“Input data for IGYTCARA” on page 950
“Report produced by IGYTCARA” on page 951
“Language elements and concepts that are illustrated” on page 963
1. Transaction code
2. Shift
3. Home code
4. Work code
5. Commuter name
950 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
6. Home address
7. Home phone
8. Work phone
9. Home location code
10. Work location code
11. Driving status code
Related concepts
“IGYTCARA: batch application” on page 949
Related tasks
“Running IGYTCARA” on page 952
Related references
“Input data for IGYTCARA” on page 950
“Report produced by IGYTCARA” on page 951
“Language elements and concepts that are illustrated” on page 963
Running IGYTCARA
The following procedure compiles, link-edits, and runs the IGYTCARA program. If you want only to
compile or only to compile and link-edit the program, you must change the IGYWCLG cataloged
procedure.
To run IGYTCARA under z/OS, use JCL to define a VSAM cluster and compile the program. Insert the
information specific to your system and installation (accounting information, volume serial number, unit
name, cluster prefix) in the fields that are shown in lowercase letters. These examples use the name
IGYTCAR.MASTFILE; you can use another name if you want to.
1. Use this JCL to create the required VSAM cluster:
To remove any existing cluster, a DELETE is issued before the VSAM cluster is created.
2. Use the following JCL to compile, link-edit, and run the IGYTCARA program:
952 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
//IGYTCARA JOB (acct-info),'IGYTCAR',MSGLEVEL=(1,1),TIME=(0,29)
//TEST EXEC IGYWCLG
//COBOL.SYSLIB DD DSN=IGY.V6R4M0.SIGYSAMP,DISP=SHR
//COBOL.SYSIN DD DSN=IGY.V6R4M0.SIGYSAMP(IGYTCARA),DISP=SHR
//GO.SYSOUT DD SYSOUT=A
//GO.COMMUTR DD DSN=your-prefix.IGYTCAR.MASTFILE,DISP=SHR
//GO.LOCCODE DD DSN=IGY.V6R4M0.SIGYSAMP(IGYTCODE),DISP=SHR
//GO.UPDTRANS DD DSN=IGY.V6R4M0.SIGYSAMP(IGYTRANX),DISP=SHR
//GO.UPDPRINT DD SYSOUT=A,DCB=BLKSIZE=133
//
Related tasks
Chapter 10, “Processing VSAM files,” on page 189
Related references
“Compile, link-edit, and run procedure (IGYWCLG)” on page 259
Related tasks
“Preparing to run IGYTCARB” on page 953
Related tasks
“Running IGYTCARB” on page 954
Related references
“Language elements and concepts that are illustrated” on page 963
Running IGYTCARB
The following procedure compiles, link-edits, and runs the IGYTCARB program. If you want only to
compile or only to compile and link-edit the program, you must change the procedure.
To run IGYTCARB under z/OS, do the following steps:
1. Using the ISPF editor, change the ISPF/PDF Primary Option Panel (ISR@PRIM) or some other panel
to include the IGYTCARB invocation. Panel ISR@PRIM is in your site's PDF panel data set (normally
ISRPLIB).
The following example shows an ISR@PRIM panel modified, in two identified locations, to include the
IGYTCARB invocation. If you add or change an option in the upper portion of the panel definition, you
must also add or change the corresponding line on the lower portion of the panel.
954 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
As indicated by (1) in this example, you add IGYTCARB to the upper portion of the panel by entering:
You add the corresponding line on the lower portion of the panel, indicated by (2), by entering:
C,'PGM(IGYTCARB)'
2. Place ISR@PRIM (or your other modified panel) and IGYTPNL in a library and make this library the first
library in the ISPPLIB concatenation.
3. Comment sequence line IB2200 and uncomment sequence line IB2210 in IGYTCARB. (The OPEN
EXTEND statement is supported under z/OS.)
4. Compile and link-edit IGYTCARB and place the resulting program object in your LOADLIB.
5. Allocate ISPLLIB by using the following command:
Here DSN1 is the library name of the LOADLIB from step 4. DSN2 is your installed ISPLLIB.
6. Allocate the input and output data sets by using the following command:
Here DSN3 is the library containing the modified panels. DSN4 is the ISPF panel library.
8. Invoke IGYTCARB by using your modified panel.
Related references
ISPF Dialog Developer's Guide and Reference
Related tasks
“Preparing to run IGYTSALE” on page 962
Related references
“Input data for IGYTSALE” on page 956
“Reports produced by IGYTSALE” on page 958
“Language elements and concepts that are illustrated” on page 963
956 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
1. Record type
2. Customer code
3. Customer name
4. Product code
5. Product description
6. Product unit price
7. Salesperson number
8. Salesperson name
9. Date of hire
10. Commission rate
The value of field 1 (C, P, or S) determines the format of the input record. The following sample shows a
section of IGYTABLE:
In addition, the distributor collected information about sales transactions. Each transaction represents an
individual salesperson's sales to a particular customer. The customer can purchase from one to five items
during each transaction. The transaction information is coded and put into an input file, called IGYTRANA.
The format of this file is as follows, with an explanation of the items below:
A00001119900227010101CNTRL VALLEY11442019900228259999
A00004119900310100530CNTRL VALLEY11441019900403150099
A00005119900418222409CNTRL VALLEY11441219900419059900
A00006119900523151010CNTRL VALLEY11442019900623250004
419990324591515SAN DIEGO 11615 60200132200110522045100
B11114419901111003301SAN DIEGO 11661519901114260200132200110522041100
A00007119901115003205CNTRL VALLEY11332019901117120023
C00125419900118101527SF BAY AREA 11331519900120160200112200250522145111
B11116419901201132013SF BAY AREA 11331519901203060200102200110522045102
B11117319901201070833SAN Diego 1165661990120333020o132200120522041100
B11118419901221191544SAN DIEGO 11661419901223160200142200130522040300
B11119419901210211544SAN DIEGO 11221219901214060200152200160522050500
B11120419901212000816SAN DIEGO 11220419901213150200052200160522040100
B11121419901201131544SAN DIEGO 11330219901203120200112200140522250100
B11122419901112073312SAN DIEGO 11221019901113100200162200260522250100
B11123919901110123314SAN DIEGO 11660919901114260200270500110522250100140010
B11124219901313510000SAN DIEGO 116611 1 0200042200120a22141100
B11125419901215012510SAN DIEGO 11661519901216110200162200130522141111
B11126119901111000034SAN DIEGO 11331619901113260022
B11127119901110154100SAN DIEGO 11221219901113122000
B11128419901110175001SAN DIEGO 11661519901113260200132200160521041104
. . .
958 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Example: IGYTSALE transaction errors
The following sample of IGYTSALE output shows transaction errors in the last column.
================================================================================================================================
==
|Product Number 04 | | | | | |
| |
|Basketballs | | | | | |
| |
| Units Sold | | | 433 | | 2604 | 5102 |
8139 |
| Unit Price | | | 22.20 | | 22.20 | 22.20
| |
| Amount of Sale | | | $9,612.60 | | $57,808.80 | $113,264.40 |
$180,685.80 |
--------------------------------------------------------------------------------------------------------------------------------
--
|Product Number 05 | | | | | |
| |
|Basketball Rim/Board| | | | | |
| |
| Units Sold | | 9900 | 2120 | 11 | 2700 | |
14731 |
| Unit Price | | 88.30 | 88.30 | 88.30 | 88.30 |
| |
| Amount of Sale | | $874,170.00 | $187,196.00 | $971.30 | $238,410.00 | |
$1,300,747.30 |
--------------------------------------------------------------------------------------------------------------------------------
--
|Product Number 10 | | | | | |
| |
|Baseball Cage | | | | | |
| |
| Units Sold | 45 | | 3450 | 16 | 200 | 3320 |
7031 |
| Unit Price | 890.00 | | 890.00 | 890.00 | 890.00 | 890.00
| |
| Amount of Sale | $40,050.00 | |$3,070,500.00 | $14,240.00 | $178,000.00 |$2,954,800.00 |
$6,257,590.00 |
--------------------------------------------------------------------------------------------------------------------------------
--
|Product Number 11 | | | | | |
| |
|Baseball Uniform | | | | | |
| |
| Units Sold | 10003 | | 3578 | | 2922 | 2746 |
19249 |
| Unit Price | 45.70 | | 45.70 | | 45.70 | 45.70
| |
| Amount of Sale | $457,137.10 | | $163,514.60 | | $133,535.40 | $125,492.20 |
$879,679.30 |
--------------------------------------------------------------------------------------------------------------------------------
--
|Product Number 12 | | | | | |
| |
|Softballs | | | | | |
| |
| Units Sold | 10 | 137 | 2564 | 13 | 2200 | 22 |
4946 |
| Unit Price | 1.40 | 1.40 | 1.40 | 1.40 | 1.40 | 1.40
| |
| Amount of Sale | $14.00 | $191.80 | $3,589.60 | $18.20 | $3,080.00 | $30.80 |
$6,924.40 |
--------------------------------------------------------------------------------------------------------------------------------
--
|Product Number 13 | | | | | |
| |
|Softball Bats | | | | | |
| |
| Units Sold | 3227 | | 3300 | 1998 | 5444 | 99 |
14068 |
| Unit Price | 12.60 | | 12.60 | 12.60 | 12.60 | 12.60
| |
| Amount of Sale | $40,660.20 | | $41,580.00 | $25,174.80 | $68,594.40 | $1,247.40 |
$177,256.80 |
--------------------------------------------------------------------------------------------------------------------------------
--
|Product Number 14 | | | | | |
| |
|Softball Gloves | | | | | |
| |
| Units Sold | 1155 | | 136 | 3119 | 3833 | 5152 |
13395 |
| Unit Price | 12.00 | | 12.00 | 12.00 | 12.00 | 12.00
| |
| Amount of Sale | $13,860.00 | | $1,632.00 | $37,428.00 | $45,996.00 | $61,824.00 |
$160,740.00 |
--------------------------------------------------------------------------------------------------------------------------------
--
|Product Number 15 | | | | | |
| |
|Softball Cage | | | | | |
| |
| Units Sold | 997 | 99 | 2000 | | 2400 | |
5496 |
| Unit Price | 890.00 | 890.00 | 890.00 | | 890.00 |
| |
| Amount of Sale | $887,330.00 | $88,110.00 |$1,780,000.00 | |$2,136,000.00 | |
$4,891,440.00 |
--------------------------------------------------------------------------------------------------------------------------------
--
|Product Number 16 | | | | | |
| |
|Softball Uniform | | | | | |
| |
| Units Sold | 44 | | 465 | 16 | 6165 | 200 |
6890 |
| Unit Price | 45.70 | | 45.70 | 45.70 | 45.70 | 45.70
| |
| Amount of Sale | $2,010.80 | | $21,250.50 | $731.20 | $281,740.50 | $9,140.00 |
$314,873.00 |
--------------------------------------------------------------------------------------------------------------------------------
--
|Product Number 25 | | | | | |
| |
|RacketBalls | | | | | |
960 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
| |
| Units Sold | 1001 | 10003 | 1108 | 8989 | 200 | 522 |
21823 |
| Unit Price | 0.60 | 0.60 | 0.60 | 0.60 | 0.60 | 0.60
| |
| Amount of Sale | $600.60 | $6,001.80 | $664.80 | $5,393.40 | $120.00 | $313.20 |
$13,093.80 |
--------------------------------------------------------------------------------------------------------------------------------
--
|Product Number 26 | | | | | |
| |
|Racketball Rackets | | | | | |
| |
| Units Sold | 21 | | 862 | 194 | 944 | 31 |
2052 |
| Unit Price | 12.70 | | 12.70 | 12.70 | 12.70 | 12.70
| |
| Amount of Sale | $266.70 | | $10,947.40 | $2,463.80 | $11,988.80 | $393.70 |
$26,060.40 |
--------------------------------------------------------------------------------------------------------------------------------
--
================================================================================================================================
==
| Total Units Sold | 16503 | 20139 | 20016 | 15346 | 29812 | 17394 *
119210 *
| Total Sales |$1,441,929.40 | $968,473.60 |$5,290,487.50 | $128,198.70 |$3,163,713.90 |$3,274,945.70 *
$14,267,748.80 *
962 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
When you run IGYTSALE, the following messages are printed to the SYSOUT data set:
Related concepts
“IGYTSALE: nested program
application” on page 955
Related tasks
“Running IGYTSALE” on page 963
Related references
“Input data for IGYTSALE” on page 956
“Reports produced by IGYTSALE” on page 958
“Language elements and concepts that are illustrated” on page 963
Running IGYTSALE
Use the following JCL to compile, link-edit, and run the IGYTSALE program. If you want only to compile or
only to compile and link-edit the program, change the IGYWCLG cataloged procedure.
Insert the accounting information for your system or installation in the fields that are shown in lowercase
letters.
The following table lists the language elements and programming concepts that the sample programs
illustrate. The language element or concept is described, and the sequence string is shown. The sequence
string is the special character string that appears in the sequence field of the source file. You can use this
string as a search argument for locating the elements in the listing.
964 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Language element or concept Sequence string
ENVIRONMENT DIVISION (optional) IS0200
Error handling, termination of program IA4620, IA5080, IA7800-7980
EVALUATE statement IA6270-6590
EVALUATE . . . ALSO IS2400
EXIT PROGRAM not only statement in paragraph IS2000
Exponentiation IS4500
EXTERNAL clause IS1200
FILE-CONTROL entry for sequential file IA1190-1300
FILE-CONTROL entry for VSAM indexed file IA1070-1180
FILE SECTION (optional) IS0200
FILE STATUS code check IA4600-4630, IA4760-4790
FILLER (optional) IS0400
Flags, level-88, definition IA1730-1800, IA2440-2480, IA2710
Flags, level-88, testing IA4430, IA5200-5250
FLOATING POINT IS4400
GLOBAL statement IS0300
INITIAL statement for nested programs IS2300
INITIALIZE IS2500
Initializing a table in the DATA DIVISION IA2920-4260
Inline PERFORM statement IA4410-4520
I-O-CONTROL paragraphs (optional) IS0200
INPUT-OUTPUT SECTION (optional) IS0200
Intrinsic functions:
1. CURRENT-DATE 1. IA9005
2. MAX 2. IA9235
3. MEAN 3. IA9215
4. MEDIAN 4. IA9220
5. MIN 5. IA9240
6. STANDARD-DEVIATION 6. IA9230
7. UPPER-CASE 7. IA9015
8. VARIANCE 8. IA9225
9. WHEN-COMPILED 9. IA9000
966 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Language element or concept Sequence string
SELECT IS1100
Sequence number can contain any character IA, IB, IS
Sequential file processing IA4480-4510, IA4840-4870
Sequential table search, using PERFORM IA7690-7770
Sequential table search, using SEARCH IA5270-5320, IA5340-5390
SET INDEX IS3200
SET . . . TO TRUE statement IA4390, IA4500, IA4860, IA4980
SOURCE-COMPUTER (optional) IS0200
SPECIAL-NAMES paragraph (optional) IS0200
STRING statement IA6950, IA7050
Support for lowercase letters IS0100
TALLY IS1650
TITLE statement for nested programs IS0100
Update commuter record IA6200-6610
Update transaction work value spaces IB0790-IB1000
USAGE BINARY IS1300
USAGE PACKED-DECIMAL IS1301
Validate elements IB0810, IB0860, IB1000
VALUE with OCCURS IS0600
VALUE SPACE (S) IS0601
VALUE ZERO (S) (ES) IS0600
Variable-length table control variable IA5100
Variable-length table definition IA2090-2210
Variable-length table loading IA4840-4990
VSAM indexed file key definition IA1170
VSAM return-code display IA7800-7900
WORKING-STORAGE SECTION IS0250
LINKAGE SECTION.
01 PARMDATA.
05 STRINGLEN PIC 9(4) USAGE COMP.
05 STRINGPARM PIC X(80).
PROCEDURE DIVISION USING PARMDATA.
IF STRINGLEN > 0 . . .
For more information, see “Coding the LINKAGE SECTION” on page 567.
Using CEE3PR2
You must define parameters to the CEE3PR2 callable service, without the need to add parameters to your
PROCEDURE DIVISION USING statement.
WORKING-STORAGE SECTION.
01 PARMLEN PIC S9(9) BINARY.
01 PARMSTR.
02 STR1-LENGTH PIC S9(4) BINARY.
02 STR1-STRING.
03 STR1-CHAR PIC X
OCCURS 0 TO 256 TIMES
DEPENDING ON STR1-LENGTH.
. . .
CALL "CEE3PR2" USING PARMLEN,PARMSTR, FC.
For more information about the CEE3PR2 callable service, see CEE3PR2 in the Language Environment
Programming Reference.
Related tasks
“Accessing main program parameters under z/OS” on page 576
Accessibility features
z/OS includes the following major accessibility features:
• Interfaces that are commonly used by screen readers and screen-magnifier software
• Keyboard-only navigation
• Ability to customize display attributes such as color, contrast, and font size
z/OS uses the latest W3C Standard, WAI-ARIA 1.0 (http://www.w3.org/TR/wai-aria/), to ensure
compliance to US Section 508 (https://www.access-board.gov/ict/) and Web Content Accessibility
Guidelines (WCAG) 2.0 (http://www.w3.org/TR/WCAG20/). To take advantage of accessibility features,
use the latest release of your screen reader in combination with the latest web browser that is supported
by this product.
The Enterprise COBOL for z/OS online product documentation in IBM Knowledge Center is enabled for
accessibility. The accessibility features of IBM Knowledge Center are described at http://www.ibm.com/
support/knowledgecenter/en/about/releasenotes.html.
Keyboard navigation
Users can access z/OS user interfaces by using TSO/E or ISPF.
Users can also access z/OS services by using IBM Developer for z/OS.
For information about accessing these interfaces, see the following publications:
• z/OS TSO/E Primer (http://publib.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/ikj4p120)
• z/OS TSO/E User's Guide (http://publib.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/ikj4c240/
APPENDIX1.3)
• z/OS ISPF User's Guide Volume I (http://publib.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/ispzug70)
These guides describe how to use TSO/E and ISPF, including the use of keyboard shortcuts or function
keys (PF keys). Each guide includes the default settings for the PF keys and explains how to modify their
functions.
Interface information
The Enterprise COBOL for z/OS online product documentation is available in IBM Knowledge Center,
which is viewable from a standard web browser.
PDF files have limited accessibility support. With PDF documentation, you can use optional font
enlargement, high-contrast display settings, and can navigate by keyboard alone.
To enable your screen reader to accurately read syntax diagrams, source code examples, and text that
contains period or comma PICTURE symbols, you must set the screen reader to speak all punctuation.
Assistive technology products work with the user interfaces that are found in z/OS. For specific guidance
information, see the documentation for the assistive technology product that you use to access z/OS
interfaces.
TTY service
800-IBM-3383 (800-426-3383)
(within North America)
972 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Notices
This information was developed for products and services offered in the U.S.A.
IBM may not offer the products, services, or features discussed in this document in other countries.
Consult your local IBM representative for information on the products and services currently available in
your area. Any reference to an IBM product, program, or service is not intended to state or imply that
only that IBM product, program, or service may be used. Any functionally equivalent product, program, or
service that does not infringe any IBM intellectual property right may be used instead. However, it is the
user's responsibility to evaluate and verify the operation of any non-IBM product, program, or service.
IBM may have patents or pending patent applications covering subject matter described in this
document. The furnishing of this document does not give you any license to these patents. You can
send license inquiries, in writing, to:
For license inquiries regarding double-byte (DBCS) information, contact the IBM Intellectual Property
Department in your country or send inquiries, in writing, to:
The following paragraph does not apply to the United Kingdom or any other country where such
provisions are inconsistent with local law: INTERNATIONAL BUSINESS MACHINES CORPORATION
PROVIDES THIS PUBLICATION "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR
IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some states do not allow disclaimer of
express or implied warranties in certain transactions, therefore, this statement may not apply to you.
This information could include technical inaccuracies or typographical errors. Changes are periodically
made to the information herein; these changes will be incorporated in new editions of the publication.
IBM may make improvements and/or changes in the product(s) and/or the program(s) described in this
publication at any time without notice.
Any references in this information to non-IBM websites are provided for convenience only and do not in
any manner serve as an endorsement of those websites. The materials at those websites are not part of
the materials for this IBM product and use of those websites is at your own risk.
IBM may use or distribute any of the information you supply in any way it believes appropriate without
incurring any obligation to you.
Licensees of this program who want to have information about it for the purpose of enabling: (i) the
exchange of information between independently created programs and other programs (including this
one) and (ii) the mutual use of the information which has been exchanged, should contact:
974 Notices
and the "IBM Software Products and Software-as-a-Service Privacy Statement" at http://www.ibm.com/
software/info/product-privacy.
Trademarks
IBM, the IBM logo, and ibm.com® are trademarks or registered trademarks of International Business
Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be
trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at
“Copyright and trademark information” at www.ibm.com/legal/copytrade.shtml.
Intel is a registered trademark of Intel Corporation or its subsidiaries in the United States and other
countries.
Java and all Java-based trademarks and logos are trademarks or registered trademarks of Oracle and/or
its affiliates.
Microsoft and Windows are trademarks of Microsoft Corporation in the United States, other countries, or
both.
UNIX is a registered trademark of The Open Group in the United States and other countries.
Other product and service names might be trademarks of IBM or other companies.
Notices 975
976 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Glossary
The terms in this glossary are defined in accordance with their meaning in COBOL. These terms might or
might not have the same meaning in other languages.
This glossary includes terms and definitions from the following publications:
• ANSI INCITS 23-1985, Programming languages - COBOL, as amended by ANSI INCITS 23a-1989,
Programming Languages - COBOL - Intrinsic Function Module for COBOL, and ANSI INCITS 23b-1993,
Programming Languages - Correction Amendment for COBOL
• ISO 1989:1985, Programming languages - COBOL, as amended by ISO/IEC 1989/AMD1:1992,
Programming languages - COBOL: Intrinsic function module and ISO/IEC 1989/AMD2:1994,
Programming languages - Correction and clarification amendment for COBOL
• ANSI X3.172-2002, American National Standard Dictionary for Information Systems
• INCITS/ISO/IEC 1989-2002, Information technology - Programming languages - COBOL
• INCITS/ISO/IEC 1989:2014, Information technology - Programming languages, their environments and
system software interfaces - Programming language COBOL
American National Standard definitions are preceded by an asterisk (*).
A
* abbreviated combined relation condition
The combined condition that results from the explicit omission of a common subject or a common
subject and common relational operator in a consecutive sequence of relation conditions.
abend
Abnormal termination of a program.
above the 2 GB bar
Storage located above the so-called 2 GB bar (or boundary). This storage is only addressable by
AMODE 64 programs.
above the 16 MB line
Storage located above the so-called 16 MB line (or boundary) but below the 2 GB bar. This storage
is not addressable by AMODE 24 programs. Before IBM introduced the MVS/XA architecture in the
1980s, the virtual storage for a program was limited to 16 MB. Programs that have been link-edited
as AMODE 24 can address only 16 MB of space, as though they were kept under an imaginary storage
line. Since VS COBOL II, a program can have AMODE 31 and can be loaded above the 16 MB line.
* access mode
The manner in which records are to be operated upon within a file.
* actual decimal point
The physical representation, using the decimal point characters period (.) or comma (,), of the decimal
point position in a data item.
actual document encoding
For an XML document, one of the following encoding categories that the XML parser determines by
examining the first few bytes of the document:
• ASCII
• EBCDIC
• UTF-8
• UTF-16, either big-endian or little-endian
• Other unsupported encoding
• No recognizable encoding
978 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Character Meaning
+ Addition
- Subtraction
* Multiplication
/ Division
** Exponentiation
* arithmetic statement
A statement that causes an arithmetic operation to be executed. The arithmetic statements are ADD,
COMPUTE, DIVIDE, MULTIPLY, and SUBTRACT.
array
An aggregate that consists of data objects, each of which can be uniquely referenced by subscripting.
An array is roughly analogous to a COBOL table.
* ascending key
A key upon the values of which data is ordered, starting with the lowest value of the key up to the
highest value of the key, in accordance with the rules for comparing data items.
ASCII
American National Standard Code for Information Interchange. The standard code uses a coded
character set that is based on 7-bit coded characters (8 bits including parity check). The standard
is used for information interchange between data processing systems, data communication systems,
and associated equipment. The ASCII set consists of control characters and graphic characters.
IBM has defined an extension to ASCII (characters 128-255).
ASCII DBCS
See double-byte ASCII.
assignment-name
A name that identifies the organization of a COBOL file and the name by which it is known to the
system.
* assumed decimal point
A decimal point position that does not involve the existence of an actual character in a data item. The
assumed decimal point has logical meaning but no physical representation.
AT END condition
A condition that is caused during the execution of a READ, RETURN, or SEARCH statement under
certain conditions:
• A READ statement runs on a sequentially accessed file when no next logical record exists in the file,
or when the number of significant digits in the relative record number is larger than the size of the
relative key data item, or when an optional input file is not available.
• A RETURN statement runs when no next logical record exists for the associated sort or merge file.
• A SEARCH statement runs when the search operation terminates without satisfying the condition
specified in any of the associated WHEN phrases.
B
basic character set
The basic set of characters used in writing words, character-strings, and separators of the language.
The basic character set is implemented in single-byte EBCDIC. The extended character set includes
DBCS characters, which can be used in comments, literals, and user-defined words.
Synonymous with COBOL character set in the 85 COBOL Standard.
batch compilation
Synonymous with sequence of programs.
Glossary 979
big-endian
The default format that the mainframe and the AIX workstation use to store binary data and UTF-16
characters. In this format, the least significant byte of a binary data item is at the highest address and
the least significant byte of a UTF-16 character is at the highest address. Compare with little-endian.
binary item
A numeric data item that is represented in binary notation (on the base 2 numbering system). The
decimal equivalent consists of the decimal digits 0 through 9, plus an operational sign. The leftmost
bit of the item is the operational sign.
binary search
A dichotomizing search in which, at each step of the search, the set of data elements is divided by
two; some appropriate action is taken in the case of an odd number.
* block
A physical unit of data that is normally composed of one or more logical records. For mass storage
files, a block can contain a portion of a logical record. The size of a block has no direct relationship
to the size of the file within which the block is contained or to the size of the logical records that are
either contained within the block or that overlap the block. Synonymous with physical record.
boolean condition
A boolean condition determines whether a boolean literal is true or false. A boolean condition can only
be used in a constant conditional expression.
boolean literal
Can be either B'1', indicating a true value, or B'0', indicating a false value. Boolean literals can only be
used in constant conditional expressions.
breakpoint
A place in a computer program, usually specified by an instruction, where external intervention or a
monitor program can interrupt the program as it runs.
buffer
A portion of storage that is used to hold input or output data temporarily.
built-in function
See intrinsic function.
business method
A method of an enterprise bean that implements the business logic or rules of an application. (Oracle)
byte
A string that consists of a certain number of bits, usually eight, treated as a unit, and representing a
character or a control function.
byte order mark (BOM)
A Unicode character that can be used at the start of UTF-16 or UTF-32 text to indicate the byte order
of subsequent text; the byte order can be either big-endian or little-endian.
bytecode
Machine-independent code that is generated by the Java compiler and executed by the Java
interpreter. (Oracle)
C
callable services
In Language Environment, a set of services that a COBOL program can invoke by using the
conventional Language Environment-defined call interface. All programs that share the Language
Environment conventions can use these services.
called program
A program that is the object of a CALL statement. At run time the called program and calling program
are combined to produce a run unit.
* calling program
A program that executes a CALL to another program.
980 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
canonical decomposition
A way to represent a single precomposed Unicode character using two or more Unicode characters. A
canonical decomposition is typically used to separate latin letters with a diacritical mark so that the
latin letter and the diacritical mark are represented individually. See precomposed character for an
example showing a precomposed Unicode character and its canonical decomposition.
case structure
A program-processing logic in which a series of conditions is tested in order to choose between a
number of resulting actions.
cataloged procedure
A set of job control statements that are placed in a partitioned data set called the procedure library
(SYS1.PROCLIB). You can use cataloged procedures to save time and reduce errors in coding JCL.
CCSID
See coded character set identifier.
century window
A 100-year interval within which any two-digit year is unique. Several types of century window are
available to COBOL programmers:
• For the windowing intrinsic functions DATE-TO-YYYYMMDD, DAY-TO-YYYYDDD, and YEAR-TO-
YYYY, you specify the century window with argument-2.
• For Language Environment callable services, you specify the century window in CEESCEN.
* character
The basic indivisible unit of the language.
character encoding unit
A unit of data that corresponds to one code point in a coded character set. One or more character
encoding units are used to represent a character in a coded character set. Also known as encoding
unit.
For USAGE NATIONAL, a character encoding unit corresponds to one 2-byte code point of UTF-16.
For USAGE DISPLAY, a character encoding unit corresponds to a byte.
For USAGE DISPLAY-1, a character encoding unit corresponds to a 2-byte code point in the DBCS
character set.
character position
The amount of physical storage or presentation space required to hold or present one character. The
term applies to any class of character. For specific classes of characters, the following terms apply:
• Alphanumeric character position, for characters represented in USAGE DISPLAY
• DBCS character position, for DBCS characters represented in USAGE DISPLAY-1
• National character position, for characters represented in USAGE NATIONAL; synonymous with
character encoding unit for UTF-16
character set
A collection of elements that are used to represent textual information, but for which no coded
representation is assumed. See also coded character set.
character string
A sequence of contiguous characters that form a COBOL word, a literal, a PICTURE character string, or
a comment-entry. A character string must be delimited by separators.
checkpoint
A point at which information about the status of a job and the system can be recorded so that the job
step can be restarted later.
* class
The entity that defines common behavior and implementation for zero, one, or more objects. The
objects that share the same implementation are considered to be objects of the same class. Classes
can be defined hierarchically, allowing one class to inherit from another.
Glossary 981
class (object-oriented)
The entity that defines common behavior and implementation for zero, one, or more objects. The
objects that share the same implementation are considered to be objects of the same class.
* class condition
The proposition (for which a truth value can be determined) that the content of an item is wholly
alphabetic, is wholly numeric, is wholly DBCS, is wholly Kanji, or consists exclusively of the characters
that are listed in the definition of a class-name.
* class definition
The COBOL source unit that defines a class.
class hierarchy
A tree-like structure that shows relationships among object classes. It places one class at the top and
one or more layers of classes below it. Synonymous with inheritance hierarchy.
* class identification entry
An entry in the CLASS-ID paragraph of the IDENTIFICATION DIVISION; this entry contains
clauses that specify the class-name and assign selected attributes to the class definition.
class-name (object-oriented)
The name of an object-oriented COBOL class definition.
* class-name (of data)
A user-defined word that is defined in the SPECIAL-NAMES paragraph of the ENVIRONMENT
DIVISION; this word assigns a name to the proposition (for which a truth value can be defined)
that the content of a data item consists exclusively of the characters that are listed in the definition of
the class-name.
class object
The runtime object that represents a class.
* clause
An ordered set of consecutive COBOL character strings whose purpose is to specify an attribute of an
entry.
client
In object-oriented programming, a program or method that requests services from one or more
methods in a class.
COBOL character set
The set of characters used in writing COBOL syntax. The complete COBOL character set consists of
these characters:
Character Meaning
0,1, . . . ,9 Digit
A,B, . . . ,Z Uppercase letter
a,b, . . . ,z Lowercase letter
Space
+ Plus sign
- Minus sign (hyphen)
* Asterisk
/ Slant (forward slash)
= Equal sign
$ Currency sign
, Comma
; Semicolon
. Period (decimal point, full stop)
982 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Character Meaning
" Quotation mark
' Apostrophe
( Left parenthesis
) Right parenthesis
> Greater than
< Less than
: Colon
_ Underscore
* COBOL word
See word.
code page
An assignment of graphic characters and control function meanings to all code points. For example,
one code page could assign characters and meanings to 256 code points for 8-bit code, and another
code page could assign characters and meanings to 128 code points for 7-bit code. For example, one
of the IBM code pages for English on the workstation is IBM-1252 and on the host is IBM-1047. A
coded character set.
code point
A unique bit pattern that is defined in a coded character set (code page). Graphic symbols and control
characters are assigned to code points.
coded character set
A set of unambiguous rules that establish a character set and the relationship between the characters
of the set and their coded representation. Examples of coded character sets are the character sets as
represented by ASCII or EBCDIC code pages or by the UTF-16 encoding scheme for Unicode.
coded character set identifier (CCSID)
An IBM-defined number in the range 1 to 65,535 that identifies a specific code page.
* collating sequence
The sequence in which the characters that are acceptable to a computer are ordered for purposes of
sorting, merging, comparing, and for processing indexed files sequentially.
* column
A byte position within a print line or within a reference format line. The columns are numbered from 1,
by 1, starting at the leftmost position of the line and extending to the rightmost position of the line. A
column holds one single-byte character.
* combined condition
A condition that is the result of connecting two or more conditions with the AND or the OR logical
operator. See also condition and negated combined condition.
combining characters
A Unicode character used to modify other succeeding or preceding Unicode characters. Combining
characters are typically Unicode diacritical mark used to modify latin letters. See precomposed
character for an example of combining character U+0308 (¨) used with latin letter U+0061 (a).
* comment-entry
An entry in the IDENTIFICATION DIVISION that is used for documentation and has no effect on
execution.
comment line
A source program line represented by an asterisk (*) in the indicator area of the line or by an asterisk
followed by greater-than sign (*>) as the first character string in the program text area (Area A plus
Area B), and any characters from the character set of the computer that follow in Area A and Area B of
that line. A comment line serves only for documentation. A special form of comment line represented
Glossary 983
by a slant (/) in the indicator area of the line and any characters from the character set of the
computer in Area A and Area B of that line causes page ejection before the comment is printed.
* common program
A program that, despite being directly contained within another program, can be called from any
program directly or indirectly contained in that other program.
compilation group
Synonymous with sequence of programs.
compilation unit
A unit of COBOL source code that can be separately compiled: a program, class, user-defined
function, or prototype definition. Also known as a source unit.
compilation variable
A symbolic name for a particular literal value or the value of a compile-time arithmetic expression as
specified by the DEFINE directive or by the DEFINE compiler option.
* compile
(1) To translate a program expressed in a high-level language into a program expressed in an
intermediate language, assembly language, or a computer language. (2) To prepare a machine-
language program from a computer program written in another programming language by making
use of the overall logic structure of the program, or generating more than one computer instruction for
each symbolic statement, or both, as well as performing the function of an assembler.
* compile time
The time at which COBOL source code is translated, by a COBOL compiler, to a COBOL object program.
compile-time arithmetic expression
A subset of arithmetic expressions that are specified in the DEFINE and EVALUATE directives or in
a constant conditional expression. The difference between compile-time arithmetic expressions and
regular arithmetic expressions is that in a compile-time arithmetic expression:
• The exponentiation operator shall not be specified.
• All operands shall be integer numeric literals or arithmetic expressions in which all operands are
integer numeric literals.
• The expression shall be specified in such a way that a division by zero does not occur.
compiler
A program that translates source code written in a higher-level language into machine-language
object code.
compiler-directing statement
A statement that causes the compiler to take a specific action during compilation. The standard
compiler-directing statements are COPY, REPLACE, and USE.
* complex condition
A condition in which one or more logical operators act upon one or more conditions. See also
condition, negated simple condition, and negated combined condition.
complex ODO
Certain forms of the OCCURS DEPENDING ON clause:
• Variably located item or group: A data item described by an OCCURS clause with the DEPENDING ON
option is followed by a nonsubordinate data item or group. The group can be an alphanumeric group
or a national group.
• Variably located table: A data item described by an OCCURS clause with the DEPENDING ON option
is followed by a nonsubordinate data item described by an OCCURS clause.
• Table with variable-length elements: A data item described by an OCCURS clause contains a
subordinate data item described by an OCCURS clause with the DEPENDING ON option.
• Index name for a table with variable-length elements.
• Element of a table with variable-length elements.
984 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
component
(1) A functional grouping of related files. (2) In object-oriented programming, a reusable object
or program that performs a specific function and is designed to work with other components and
applications. JavaBeans is Oracle's architecture for creating components.
composed form
Representation of a precomposed Unicode character through a canonical decomposition. See
precomposed character for details.
* computer-name
A system-name that identifies the computer where the program is to be compiled or run.
condition (exception)
An exception that has been enabled, or recognized, by Language Environment and thus is eligible to
activate user and language condition handlers. Any alteration to the normal programmed flow of an
application. Conditions can be detected by the hardware or the operating system and result in an
interrupt. They can also be detected by language-specific generated code or language library code.
condition (expression)
A status of data at run time for which a truth value can be determined. Where used in this information
in or in reference to "condition" (condition-1, condition-2,. . .) of a general format, the term refers
to a conditional expression that consists of either a simple condition optionally parenthesized or a
combined condition (consisting of the syntactically correct combination of simple conditions, logical
operators, and parentheses) for which a truth value can be determined. See also simple condition,
complex condition, negated simple condition, combined condition, and negated combined condition.
* conditional expression
A simple condition or a complex condition specified in an EVALUATE, IF, PERFORM, or SEARCH
statement. See also simple condition and complex condition.
* conditional phrase
A phrase that specifies the action to be taken upon determination of the truth value of a condition that
results from the execution of a conditional statement.
* conditional statement
A statement that specifies that the truth value of a condition is to be determined and that the
subsequent action of the object program depends on this truth value.
* conditional variable
A data item one or more values of which has a condition-name assigned to it.
* condition-name
A user-defined word that assigns a name to a subset of values that a conditional variable can assume;
or a user-defined word assigned to a status of an implementor-defined switch or device.
* condition-name condition
The proposition (for which a truth value can be determined) that the value of a conditional variable is a
member of the set of values attributed to a condition-name associated with the conditional variable.
* CONFIGURATION SECTION
A section of the ENVIRONMENT DIVISION that describes overall specifications of source and object
programs and class definitions.
CONSOLE
A COBOL environment-name associated with the operator console.
constant conditional expression
A subset of conditional expressions that may be used in IF directives or WHEN phrases of the
EVALUATE directives.
A constant conditional expression shall be one of the following items:
• A relation condition in which both operands are literals or arithmetic expressions that contain only
literal terms. The condition shall follow the rules for relation conditions, with the following additions:
– The operands shall be of the same category. An arithmetic expression is of the category numeric.
Glossary 985
– If literals are specified and they are not numeric literals, the relational operator shall be “IS
EQUAL TO”, “IS NOT EQUAL TO”, “IS =”, “IS NOT =”, or “IS <>”.
See also relation condition.
• A defined condition. See also defined condition.
• A boolean condition. See also boolean condition.
• A complex condition formed by combining the above forms of simple conditions into complex
conditions by using AND, OR, and NOT. Abbreviated combined relation conditions shall not be
specified. See also complex condition.
contained program
A COBOL program that is nested within another COBOL program.
* contiguous items
Items that are described by consecutive entries in the DATA DIVISION, and that bear a definite
hierarchic relationship to each other.
copybook
A file or library member that contains a sequence of code that is included in the source program at
compile time using the COPY statement. The file can be created by the user, supplied by COBOL, or
supplied by another product. Synonymous with copy file.
* counter
A data item used for storing numbers or number representations in a manner that permits these
numbers to be increased or decreased by the value of another number, or to be changed or reset to
zero or to an arbitrary positive or negative value.
cross-reference listing
The portion of the compiler listing that contains information on where files, fields, and indicators are
defined, referenced, and modified in a program.
currency-sign value
A character string that identifies the monetary units stored in a numeric-edited item. Typical examples
are $, USD, and EUR. A currency-sign value can be defined by either the CURRENCY compiler option
or the CURRENCY SIGN clause in the SPECIAL-NAMES paragraph of the ENVIRONMENT DIVISION.
If the CURRENCY SIGN clause is not specified and the NOCURRENCY compiler option is in effect, the
dollar sign ($) is used as the default currency-sign value. See also currency symbol.
currency symbol
A character used in a PICTURE clause to indicate the position of a currency sign value in a numeric-
edited item. A currency symbol can be defined by either the CURRENCY compiler option or the
CURRENCY SIGN clause in the SPECIAL-NAMES paragraph of the ENVIRONMENT DIVISION. If the
CURRENCY SIGN clause is not specified and the NOCURRENCY compiler option is in effect, the dollar
sign ($) is used as the default currency sign value and currency symbol. Multiple currency symbols
and currency sign values can be defined. See also currency sign value.
* current record
In file processing, the record that is available in the record area associated with a file.
* current volume pointer
A conceptual entity that points to the current volume of a sequential file.
D
* data clause
A clause, appearing in a data description entry in the DATA DIVISION of a COBOL program, that
provides information describing a particular attribute of a data item.
* data description entry
An entry in the DATA DIVISION of a COBOL program that is composed of a level-number followed by
a data-name, if required, and then followed by a set of data clauses, as required.
DATA DIVISION
The division of a COBOL program or method that describes the data to be processed by the program
or method: the files to be used and the records contained within them; internal WORKING-STORAGE
986 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
records that will be needed; data to be made available in more than one program in the COBOL run
unit.
* data item
A unit of data (excluding literals) defined by a COBOL program or by the rules for function evaluation.
data set
Synonym for file.
* data-name
A user-defined word that names a data item described in a data description entry. When used in the
general formats, data-name represents a word that must not be reference-modified, subscripted, or
qualified unless specifically permitted by the rules for the format.
DBCS
See double-byte character set (DBCS).
DBCS character
Any character defined in IBM's double-byte character set.
DBCS character position
See character position.
DBCS data item
A data item that is described by a PICTURE character string that contains at least one symbol G, or,
when the NSYMBOL(DBCS) compiler option is in effect, at least one symbol N. A DBCS data item has
USAGE DISPLAY-1.
* debugging line
Any line with a D in the indicator area of the line.
* debugging section
A section that contains a USE FOR DEBUGGING statement.
* declarative sentence
A compiler-directing sentence that consists of a single USE statement terminated by the separator
period.
* declaratives
A set of one or more special-purpose sections, written at the beginning of the PROCEDURE
DIVISION, the first of which is preceded by the key word DECLARATIVE and the last of which is
followed by the key words END DECLARATIVES. A declarative is composed of a section header,
followed by a USE compiler-directing sentence, followed by a set of zero, one, or more associated
paragraphs.
* de-edit
The logical removal of all editing characters from a numeric-edited data item in order to determine the
unedited numeric value of the item.
defined condition
A compile-time condition that tests whether a compilation variable is defined. Defined conditions are
specified in IF directives or WHEN phrases of the EVALUATE directives.
* delimited scope statement
Any statement that includes its explicit scope terminator.
* delimiter
A character or a sequence of contiguous characters that identify the end of a string of characters and
separate that string of characters from the following string of characters. A delimiter is not part of the
string of characters that it delimits.
dependent region
In IMS, the MVS virtual storage region that contains message-driven programs, batch programs, or
online utilities.
* descending key
A key upon the values of which data is ordered starting with the highest value of key down to the
lowest value of key, in accordance with the rules for comparing data items.
Glossary 987
digit
Any of the numerals from 0 through 9. In COBOL, the term is not used to refer to any other symbol.
* digit position
The amount of physical storage required to store a single digit. This amount can vary depending on the
usage specified in the data description entry that defines the data item.
* direct access
The facility to obtain data from storage devices or to enter data into a storage device in such a way
that the process depends only on the location of that data and not on a reference to data previously
accessed.
display floating-point data item
A data item that is described implicitly or explicitly as USAGE DISPLAY and that has a PICTURE
character string that describes an external floating-point data item.
* division
A collection of zero, one, or more sections or paragraphs, called the division body, that are formed and
combined in accordance with a specific set of rules. Each division consists of the division header and
the related division body. There are four divisions in a COBOL program: Identification, Environment,
Data, and Procedure.
* division header
A combination of words followed by a separator period that indicates the beginning of a division. The
division headers are:
IDENTIFICATION DIVISION.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
DLL
See dynamic link library (DLL).
DLL application
An application that references imported programs, functions, or variables.
DLL linkage
A CALL in a program that has been compiled with the DLL and NODYNAM options; the CALL resolves
to an exported name in a separate module, or to an INVOKE of a method that is defined in a separate
module.
do construct
In structured programming, a DO statement is used to group a number of statements in a procedure.
In COBOL, an inline PERFORM statement functions in the same way.
do-until
In structured programming, a do-until loop will be executed at least once, and until a given condition
is true. In COBOL, a TEST AFTER phrase used with the PERFORM statement functions in the same
way.
do-while
In structured programming, a do-while loop will be executed if, and while, a given condition is true. In
COBOL, a TEST BEFORE phrase used with the PERFORM statement functions in the same way.
document type declaration
An XML element that contains or points to markup declarations that provide a grammar for a class of
documents. This grammar is known as a document type definition, or DTD.
document type definition (DTD)
The grammar for a class of XML documents. See document type declaration.
double-byte ASCII
An IBM character set that includes DBCS and single-byte ASCII characters. (Also known as ASCII
DBCS.)
988 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
double-byte EBCDIC
An IBM character set that includes DBCS and single-byte EBCDIC characters. (Also known as EBCDIC
DBCS.)
double-byte character set (DBCS)
A set of characters in which each character is represented by 2 bytes. Languages such as Japanese,
Chinese, and Korean, which contain more symbols than can be represented by 256 code points,
require double-byte character sets. Because each character requires 2 bytes, entering, displaying,
and printing DBCS characters requires hardware and supporting software that are DBCS-capable.
DWARF
DWARF was developed by the UNIX International Programming Languages Special Interest Group
(SIG). It is designed to meet the symbolic, source-level debugging needs of different languages in a
unified fashion by supplying language-independent debugging information. A DWARF file contains
debugging data organized into different elements. For more information, see DWARF program
information in the DWARF/ELF Extensions Library Reference.
* dynamic access
An access mode in which specific logical records can be obtained from or placed into a mass storage
file in a nonsequential manner and obtained from a file in a sequential manner during the scope of the
same OPEN statement.
dynamic CALL
A CALL literal statement in a program that has been compiled with the DYNAM option and the NODLL
option, or a CALL identifier statement in a program that has been compiled with the NODLL option.
dynamic-length
An adjective describing an item whose logical length might change at runtime.
dynamic-length elementary item
An elementary data item whose data declaration entry contains the DYNAMIC LENGTH clause.
dynamic-length group
A group item that contains a subordinate dynamic-length elementary item.
dynamic link library (DLL)
A file that contains executable code and data that are bound to a program at load time or run time,
rather than during linking. Several applications can share the code and data in a DLL simultaneously.
Although a DLL is not part of the executable file for a program, it can be required for an executable file
to run properly.
dynamic storage area (DSA)
Dynamically acquired storage composed of a register save area and an area available for dynamic
storage allocation (such as program variables). A DSA is allocated upon invocation of a program or
function and persists for the duration of the invocation instance. DSAs are generally allocated within
stack segments managed by Language Environment.
E
* EBCDIC (Extended Binary-Coded Decimal Interchange Code)
A coded character set based on 8-bit coded characters.
EBCDIC character
Any one of the symbols included in the EBCDIC (Extended Binary-Coded-Decimal Interchange Code)
set.
EBCDIC DBCS
See double-byte EBCDIC.
edited data item
A data item that has been modified by suppressing zeros or inserting editing characters or both.
* editing character
A single character or a fixed two-character combination belonging to the following set:
Glossary 989
Character Meaning
Space
0 Zero
+ Plus
- Minus
CR Credit
DB Debit
Z Zero suppress
* Check protect
$ Currency sign
, Comma (decimal point)
. Period (decimal point)
/ Slant (forward slash)
EGCS
See extended graphic character set (EGCS).
EJB
See Enterprise JavaBeans.
EJB container
A container that implements the EJB component contract of the J2EE architecture. This contract
specifies a runtime environment for enterprise beans that includes security, concurrency, life cycle
management, transaction, deployment, and other services. An EJB container is provided by an EJB or
J2EE server. (Oracle)
EJB server
Software that provides services to an EJB container. An EJB server can host one or more EJB
containers. (Oracle)
element (text element)
One logical unit of a string of text, such as the description of a single data item or verb, preceded by a
unique code identifying the element type.
* elementary item
A data item that is described as not being further logically subdivided.
encapsulation
In object-oriented programming, the technique that is used to hide the inherent details of an
object. The object provides an interface that queries and manipulates the data without exposing
its underlying structure. Synonymous with information hiding.
enclave
When running under Language Environment, an enclave is analogous to a run unit. An enclave can
create other enclaves by using LINK and by using the system() function in C.
encoding unit
See character encoding unit.
end class marker
A combination of words, followed by a separator period, that indicates the end of a COBOL class
definition. The end class marker is:
990 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
end method marker
A combination of words, followed by a separator period, that indicates the end of a COBOL method
definition. The end method marker is:
enterprise bean
A component that implements a business task and resides in an EJB container. (Oracle)
Enterprise JavaBeans
A component architecture defined by Oracle for the development and deployment of object-oriented,
distributed, enterprise-level applications.
* entry
Any descriptive set of consecutive clauses terminated by a separator period and written in the
IDENTIFICATION DIVISION, ENVIRONMENT DIVISION, or DATA DIVISION of a COBOL program.
* environment clause
A clause that appears as part of an ENVIRONMENT DIVISION entry.
ENVIRONMENT DIVISION
One of the four main component parts of a COBOL program, class definition, or method definition. The
ENVIRONMENT DIVISION describes the computers where the source program is compiled and those
where the object program is run. It provides a linkage between the logical concept of files and their
records, and the physical aspects of the devices on which files are stored.
environment-name
A name, specified by IBM, that identifies system logical units, printer and card punch control
characters, report codes, program switches or all of these. When an environment-name is associated
with a mnemonic-name in the ENVIRONMENT DIVISION, the mnemonic-name can be substituted in
any format in which such substitution is valid.
environment variable
Any of a number of variables that define some aspect of the computing environment, and are
accessible to programs that operate in that environment. Environment variables can affect the
behavior of programs that are sensitive to the environment in which they operate.
escape sequence
A sequence of characters that are used to represent certain special characters within string literals
and character literals.
Escape sequences consist of two or more characters, the first of which is the backslash (\) character,
which is called the "escape character"; the remaining characters determine the interpretation of the
escape sequence. For example, \n is an escape sequence that denotes a newline character.
Escape sequences are used in programming languages such as C, C++, Java, or Python. COBOL does
not have the concept of "escape sequence" or "escape character". To handle special characters within
COBOL literals, see Basic alphanumeric literals and DBCS literals in the Enterprise COBOL for z/OS
Language Reference.
execution time
See run time.
execution-time environment
See runtime environment.
Glossary 991
* explicit scope terminator
A reserved word that terminates the scope of a particular PROCEDURE DIVISION statement.
exponent
A number that indicates the power to which another number (the base) is to be raised. Positive
exponents denote multiplication; negative exponents denote division; and fractional exponents
denote a root of a quantity. In COBOL, an exponential expression is indicated with the symbol **
followed by the exponent.
* expression
An arithmetic or conditional expression.
* extend mode
The state of a file after execution of an OPEN statement, with the EXTEND phrase specified for that file,
and before the execution of a CLOSE statement, without the REEL or UNIT phrase for that file.
extended graphic character set (EGCS)
A graphic character set, such as a kanji character set, that requires two bytes to identify each graphic
character. It is refined and replaced by double-byte character set (DBCS).
Extensible Markup Language
See XML.
extensions
COBOL syntax and semantics supported by IBM compilers in addition to those described in the 85
COBOL Standard.
external code page
For XML documents, the value specified by the CODEPAGE compiler option.
* external data
The data that is described in a program as external data items and external file connectors.
* external data item
A data item that is described as part of an external record in one or more programs of a run unit and
that can be referenced from any program in which it is described.
* external data record
A logical record that is described in one or more programs of a run unit and whose constituent data
items can be referenced from any program in which they are described.
external decimal data item
See zoned decimal data item and national decimal data item.
* external file connector
A file connector that is accessible to one or more object programs in the run unit.
external floating-point data item
See display floating-point data item and national floating-point data item.
external program
The outermost program. A program that is not nested.
* external switch
A hardware or software device, defined and named by the implementor, which is used to indicate that
one of two alternate states exists.
F
factory data
Data that is allocated once for a class and shared by all instances of the class. Factory data is declared
in the WORKING-STORAGE SECTION of the DATA DIVISION in the FACTORY paragraph of the class
definition, and is equivalent to Java private static data.
factory method
A method that is supported by a class independently of an object instance. Factory methods are
declared in the FACTORY paragraph of the class definition, and are equivalent to Java public static
methods. They are typically used to customize the creation of objects.
992 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
* figurative constant
A compiler-generated value referenced through the use of certain reserved words.
* file
A collection of logical records.
* file attribute conflict condition
An unsuccessful attempt has been made to execute an input-output operation on a file and the file
attributes, as specified for that file in the program, do not match the fixed attributes for that file.
* file clause
A clause that appears as part of any of the following DATA DIVISION entries: file description entry
(FD entry) and sort-merge file description entry (SD entry).
* file connector
A storage area that contains information about a file and is used as the linkage between a file-name
and a physical file and between a file-name and its associated record area.
File-Control
The name of an ENVIRONMENT DIVISION paragraph in which the data files for a given source
program are declared.
file control block
Block containing the addresses of I/O routines, information about how they were opened and closed,
and a pointer to the file information block.
* file control entry
A SELECT clause and all its subordinate clauses that declare the relevant physical attributes of a file.
FILE-CONTROL paragraph
A paragraph in the ENVIRONMENT DIVISION in which the data files for a given source unit are
declared.
* file description entry
An entry in the FILE SECTION of the DATA DIVISION that is composed of the level indicator FD,
followed by a file-name, and then followed by a set of file clauses as required.
* file-name
A user-defined word that names a file connector described in a file description entry or a sort-merge
file description entry within the FILE SECTION of the DATA DIVISION.
* file organization
The permanent logical file structure established at the time that a file is created.
file position indicator
A conceptual entity that contains the value of the current key within the key of reference for an
indexed file, or the record number of the current record for a sequential file, or the relative record
number of the current record for a relative file, or indicates that no next logical record exists, or that
an optional input file is not available, or that the AT END condition already exists, or that no valid next
record has been established.
* FILE SECTION
The section of the DATA DIVISION that contains file description entries and sort-merge file
description entries together with their associated record descriptions.
file system
The collection of files that conform to a specific set of data-record and file-description protocols, and
a set of programs that manage these files.
* fixed file attributes
Information about a file that is established when a file is created and that cannot subsequently
be changed during the existence of the file. These attributes include the organization of the file
(sequential, relative, or indexed), the prime record key, the alternate record keys, the code set, the
minimum and maximum record size, the record type (fixed or variable), the collating sequence of the
keys for indexed files, the blocking factor, the padding character, and the record delimiter.
Glossary 993
* fixed-length record
A record associated with a file whose file description or sort-merge description entry requires that all
records contain the same number of bytes.
fixed-point item
A numeric data item defined with a PICTURE clause that specifies the location of an optional sign, the
number of digits it contains, and the location of an optional decimal point. The format can be either
binary, packed decimal, or external decimal.
floating comment indicators (*>)
A floating comment indicator indicates a comment line if it is the first character string in the program-
text area (Area A plus Area B), or indicates an inline comment if it is after one or more character
strings in the program-text area.
floating point
A format for representing numbers in which a real number is represented by a pair of distinct
numerals. In a floating-point representation, the real number is the product of the fixed-point part
(the first numeral) and a value obtained by raising the implicit floating-point base to a power denoted
by the exponent (the second numeral). For example, a floating-point representation of the number
0.0001234 is 0.1234 -3, where 0.1234 is the mantissa and -3 is the exponent.
floating-point data item
A numeric data item that contains a fraction and an exponent. Its value is obtained by multiplying the
fraction by the base of the numeric data item raised to the power that the exponent specifies.
* format
A specific arrangement of a set of data.
* function
A temporary data item whose value is determined at the time the function is referenced during the
execution of a statement.
* function-identifier
A syntactically correct combination of character strings and separators that references a function.
The data item represented by a function is uniquely identified by a function-name with its arguments,
if any. A function-identifier can include a reference-modifier. A function-identifier that references an
alphanumeric function can be specified anywhere in the general formats that an identifier can be
specified, subject to certain restrictions. A function-identifier that references an integer or numeric
function can be referenced anywhere in the general formats that an arithmetic expression can be
specified.
function-name
A word that names the mechanism whose invocation, along with required arguments, determines the
value of a function.
function-pointer data item
A data item in which a pointer to an entry point can be stored. A data item defined with the USAGE
IS FUNCTION-POINTER clause contains the address of a function entry point. Typically used to
communicate with C and Java programs.
G
garbage collection
The automatic freeing by the Java runtime system of the memory for objects that are no longer
referenced.
* global name
A name that is declared in only one program but that can be referenced from the program and from
any program contained within the program. Condition-names, data-names, file-names, record-names,
report-names, and some special registers can be global names.
global reference
A reference to an object that is outside the scope of a method.
994 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
group item
(1) A data item that is composed of subordinate data items. See alphanumeric group item and national
group item. (2) When not qualified explicitly or by context as a national group or an alphanumeric
group, the term refers to groups in general.
grouping separator
A character used to separate units of digits in numbers for ease of reading. The default is the
character comma.
H
header label
(1) A data-set label that precedes the data records in a unit of recording media. (2) Synonym for
beginning-of-file label.
hide (a method)
To redefine (in a subclass) a factory or static method defined with the same method-name in a parent
class. Thus, the method in the subclass hides the method in the parent class.
* high-order end
The leftmost character of a string of characters.
hiperspace
In a z/OS environment, a range of up to 2 GB of contiguous virtual storage addresses that a program
can use as a buffer.
I
IBM COBOL extension
COBOL syntax and semantics supported by IBM compilers in addition to those described in the 85
COBOL Standard.
IDENTIFICATION DIVISION
One of the four main component parts of a COBOL program, class definition, or method definition.
The IDENTIFICATION DIVISION identifies the program, class, or method. The IDENTIFICATION
DIVISION can include the following documentation: author name, installation, or date.
* identifier
A syntactically correct combination of character strings and separators that names a data item.
When referencing a data item that is not a function, an identifier consists of a data-name, together
with its qualifiers, subscripts, and reference-modifier, as required for uniqueness of reference. When
referencing a data item that is a function, a function-identifier is used.
IGZCBSN
The bootstrap routine for COBOL/370 1.1. It must be link-edited with any module that contains a
COBOL/370 1.1 program.
IGZCBSO
The bootstrap routine for COBOL for MVS & VM 1.2, COBOL for OS/390 & VM and Enterprise COBOL.
It must be link-edited with any module that contains a COBOL for MVS & VM 1.2, COBOL for OS/390 &
VM or Enterprise COBOL program.
IGZEBST
The bootstrap routine for VS COBOL II. It must be link-edited with any module that contains a VS
COBOL II program.
ILC
InterLanguage Communication. Interlanguage communication is defined as programs that call or are
called by other high-level languages. Assembler is not considered a high-level language; thus, calls to
and from assembler programs are not considered ILC.
* imperative statement
A statement that either begins with an imperative verb and specifies an unconditional action to be
taken or is a conditional statement that is delimited by its explicit scope terminator (delimited scope
statement). An imperative statement can consist of a sequence of imperative statements.
Glossary 995
* implicit scope terminator
A separator period that terminates the scope of any preceding unterminated statement, or a phrase of
a statement that by its occurrence indicates the end of the scope of any statement contained within
the preceding phrase.
IMS
Information Management System, IBM licensed product. IMS supports hierarchical databases, data
communication, translation processing, and database backout and recovery.
* index
A computer storage area or register, the content of which represents the identification of a particular
element in a table.
* index data item
A data item in which the values associated with an index-name can be stored in a form specified by
the implementor.
indexed data-name
An identifier that is composed of a data-name, followed by one or more index-names enclosed in
parentheses.
* indexed file
A file with indexed organization.
* indexed organization
The permanent logical file structure in which each record is identified by the value of one or more keys
within that record.
indexing
Synonymous with subscripting using index-names.
* index-name
A user-defined word that names an index associated with a specific table.
inheritance
A mechanism for using the implementation of a class as the basis for another class. By definition,
the inheriting class conforms to the inherited classes. Enterprise COBOL does not support multiple
inheritance; a subclass has exactly one immediate superclass.
inheritance hierarchy
See class hierarchy.
* initial program
A program that is placed into an initial state every time the program is called in a run unit.
* initial state
The state of a program when it is first called in a run unit.
inline
In a program, instructions that are executed sequentially, without branching to routines, subroutines,
or other programs.
inline comments
An inline comment is identified by a floating comment indicator (*>) preceded by one or more
character-strings in the program-text area, and can be written on any line of a compilation group.
All characters that follow the floating comment indicator up to the end of area B are comment text.
* input file
A file that is opened in the input mode.
* input mode
The state of a file after execution of an OPEN statement, with the INPUT phrase specified, for that file
and before the execution of a CLOSE statement, without the REEL or UNIT phrase for that file.
* input-output file
A file that is opened in the I-O mode.
996 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
* INPUT-OUTPUT SECTION
The section of the ENVIRONMENT DIVISION that names the files and the external media required by
an object program or method and that provides information required for transmission and handling of
data at run time.
* input-output statement
A statement that causes files to be processed by performing operations on individual records or
on the file as a unit. The input-output statements are ACCEPT (with the identifier phrase), CLOSE,
DELETE, DISPLAY, OPEN, READ, REWRITE, SET (with the TO ON or TO OFF phrase), START, and
WRITE.
* input procedure
A set of statements, to which control is given during the execution of a format 1 SORT statement, for
the purpose of controlling the release of specified records to be sorted.
instance data
Data that defines the state of an object. The instance data introduced by a class is defined in
the WORKING-STORAGE SECTION of the DATA DIVISION in the OBJECT paragraph of the class
definition. The state of an object also includes the state of the instance variables introduced by
classes that are inherited by the current class. A separate copy of the instance data is created for each
object instance.
* integer
(1) A numeric literal that does not include any digit positions to the right of the decimal point. (2) A
numeric data item defined in the DATA DIVISION that does not include any digit positions to the
right of the decimal point. (3) A numeric function whose definition provides that all digits to the right
of the decimal point are zero in the returned value for any possible evaluation of the function.
integer function
A function whose category is numeric and whose definition does not include any digit positions to the
right of the decimal point.
Interactive System Productivity Facility (ISPF)
An IBM software product that provides a menu-driven interface for the TSO or VM user. ISPF includes
library utilities, a powerful editor, and dialog management.
interlanguage communication (ILC)
The ability of routines written in different programming languages to communicate. ILC support lets
you readily build applications from component routines written in a variety of languages.
intermediate result
An intermediate field that contains the results of a succession of arithmetic operations.
* internal data
The data that is described in a program and excludes all external data items and external file
connectors. Items described in the LINKAGE SECTION of a program are treated as internal data.
* internal data item
A data item that is described in one program in a run unit. An internal data item can have a global
name.
internal decimal data item
A data item that is described as USAGE PACKED-DECIMAL or USAGE COMP-3, and that has a
PICTURE character string that defines the item as numeric (a valid combination of symbols 9, S, P, or
V). Synonymous with packed-decimal data item.
* internal file connector
A file connector that is accessible to only one object program in the run unit.
internal floating-point data item
A data item that is described as USAGE COMP-1 or USAGE COMP-2. COMP-1 defines a single-
precision floating-point data item. COMP-2 defines a double-precision floating-point data item. There
is no PICTURE clause associated with an internal floating-point data item.
* intrarecord data structure
The entire collection of groups and elementary data items from a logical record that a contiguous
subset of the data description entries defines. These data description entries include all entries
Glossary 997
whose level-number is greater than the level-number of the first data description entry describing the
intra-record data structure.
intrinsic function
A predefined function, such as a commonly used arithmetic function, called by a built-in function
reference.
* invalid key condition
A condition, at run time, caused when a specific value of the key associated with an indexed or relative
file is determined to be not valid.
* I-O-CONTROL
The name of an ENVIRONMENT DIVISION paragraph in which object program requirements for rerun
points, sharing of same areas by several data files, and multiple file storage on a single input-output
device are specified.
* I-O-CONTROL entry
An entry in the I-O-CONTROL paragraph of the ENVIRONMENT DIVISION; this entry contains
clauses that provide information required for the transmission and handling of data on named files
during the execution of a program.
* I-O mode
The state of a file after execution of an OPEN statement, with the I-O phrase specified, for that file
and before the execution of a CLOSE statement without the REEL or UNIT phase for that file.
* I-O status
A conceptual entity that contains the two-character value indicating the resulting status of an input-
output operation. This value is made available to the program through the use of the FILE STATUS
clause in the file control entry for the file.
is-a
A relationship that characterizes classes and subclasses in an inheritance hierarchy. Subclasses that
have an is-a relationship to a class inherit from that class.
ISPF
See Interactive System Productivity Facility (ISPF).
iteration structure
A program processing logic in which a series of statements is repeated while a condition is true or
until a condition is true.
J
J2EE
See Java 2 Platform, Enterprise Edition (J2EE).
Java 2 Platform, Enterprise Edition (J2EE)
An environment for developing and deploying enterprise applications, defined by Oracle. The J2EE
platform consists of a set of services, application programming interfaces (APIs), and protocols that
provide the functionality for developing multitiered, Web-based applications. (Oracle)
Java Batch Launcher and Toolkit for z/OS (JZOS)
A set of tools that helps you develop z/OS Java applications that run in a traditional batch
environment, and that access z/OS system services.
Java batch-processing program (JBP)
An IMS batch-processing program that has access to online databases and output message queues.
JBPs run online, but like programs in a batch environment, they are started with JCL or in a TSO
session.
Java batch-processing region
An IMS dependent region in which only Java batch-processing programs are scheduled.
Java Database Connectivity (JDBC)
A specification from Oracle that defines an API that enables Java programs to access databases.
Java message-processing program (JMP)
A Java application program that is driven by transactions and has access to online IMS databases and
message queues.
998 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Java message-processing region
An IMS dependent region in which only Java message-processing programs are scheduled.
Java Native Interface (JNI)
A programming interface that lets Java code that runs inside a Java virtual machine (JVM)
interoperate with applications and libraries written in other programming languages.
Java virtual machine (JVM)
A software implementation of a central processing unit that runs compiled Java programs.
JavaBeans
A portable, platform-independent, reusable component model. (Oracle)
JBP
See Java batch-processing program (JBP).
JDBC
See Java Database Connectivity (JDBC).
JMP
See Java message-processing program (JMP).
job control language (JCL)
A control language used to identify a job to an operating system and to describe the job's
requirements.
JSON
JSON (JavaScript Object Notation) is a lightweight data-interchange format.
JVM
See Java virtual machine (JVM).
JZOS
See Java Batch Launcher and Toolkit for z/OS.
K
K
When referring to storage capacity, two to the tenth power; 1024 in decimal notation.
* key
A data item that identifies the location of a record, or a set of data items that serve to identify the
ordering of data.
* key of reference
The key, either prime or alternate, currently being used to access records within an indexed file.
* keyword
A context-sensitive word or a reserved word whose presence is required when the format in which the
word appears is used in a source unit.
kilobyte (KB)
One kilobyte equals 1024 bytes.
L
* language-name
A system-name that specifies a particular programming language.
Language Environment
Short form of z/OS Language Environment. A set of architectural constructs and interfaces that
provides a common runtime environment and runtime services for C, C++, COBOL, FORTRAN and PL/I
applications. It is required for programs compiled by Language Environment-conforming compilers
and for Java applications.
Language Environment-conforming
A characteristic of compiler products (such as Enterprise COBOL, COBOL for OS/390 & VM, COBOL
for MVS & VM, C/C++ for MVS & VM, PL/I for MVS & VM) that produce object code conforming to the
Language Environment conventions.
Glossary 999
last-used state
A state that a program is in if its internal values remain the same as when the program was exited (the
values are not reset to their initial values).
* letter
A character belonging to one of the following two sets:
1. Uppercase letters: A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z
2. Lowercase letters: a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z
* level indicator
Two alphabetic characters that identify a specific type of file or a position in a hierarchy. The level
indicators in the DATA DIVISION are: CD, FD, and SD.
* level-number
A user-defined word (expressed as a two-digit number) that indicates the hierarchical position of
a data item or the special properties of a data description entry. Level-numbers in the range from
1 through 49 indicate the position of a data item in the hierarchical structure of a logical record.
Level-numbers in the range 1 through 9 can be written either as a single digit or as a zero followed by
a significant digit. Level-numbers 66, 77, and 88 identify special properties of a data description entry.
* library-name
A user-defined word that names a COBOL library that the compiler is to use for compiling a given
source program.
* library text
A sequence of text words, comment lines, inline comments, the separator space, or the separator
pseudo-text delimiter in a COBOL library.
Lilian date
The number of days since the beginning of the Gregorian calendar. Day one is Friday, October 15,
1582. The Lilian date format is named in honor of Luigi Lilio, the creator of the Gregorian calendar.
* linage-counter
A special register whose value points to the current position within the page body.
link
(1) The combination of the link connection (the transmission medium) and two link stations, one
at each end of the link connection. A link can be shared among multiple links in a multipoint or
token-ring configuration. (2) To interconnect items of data or portions of one or more computer
programs; for example, linking object programs by a linkage-editor to produce an executable file.
LINKAGE SECTION
The section in the DATA DIVISION of the called program or invoked method that describes data
items available from the calling program or invoking method. Both the calling program or invoking
method and the called program or invoked method can refer to these data items.
linker
A term that refers to either the z/OS binder (linkage-editor).
literal
A character string whose value is specified either by the ordered set of characters comprising the
string or by the use of a figurative constant.
little-endian
The default format that Intel processors use to store binary data and UTF-16 characters. In this
format, the most significant byte of a binary data item is at the highest address and the most
significant byte of a UTF-16 character is at the highest address. Compare with big-endian.
local reference
A reference to an object that is within the scope of your method.
locale
A set of attributes for a program execution environment that indicates culturally sensitive
considerations, such as character code page, collating sequence, date and time format, monetary
value representation, numeric value representation, or language.
1000 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
* LOCAL-STORAGE SECTION
The section of the DATA DIVISION that defines storage that is allocated and freed on a per-
invocation basis, depending on the value assigned in the VALUE clauses.
* logical operator
One of the reserved words AND, OR, or NOT. In the formation of a condition, either AND, or OR, or both
can be used as logical connectives. NOT can be used for logical negation.
* logical record
The most inclusive data item. The level-number for a record is 01. A record can be either an
elementary item or a group of items. Synonymous with record.
* low-order end
The rightmost character of a string of characters.
M
main program
In a hierarchy of programs and subroutines, the first program that receives control when the programs
are run within a process.
makefile
A text file that contains a list of the files for your application. The make utility uses this file to update
the target files with the latest changes.
* mass storage
A storage medium in which data can be organized and maintained in both a sequential manner and a
nonsequential manner.
* mass storage device
A device that has a large storage capacity, such as a magnetic disk.
* mass storage file
A collection of records that is stored in a mass storage medium.
* megabyte (MB)
One megabyte equals 1,048,576 bytes.
* merge file
A collection of records to be merged by a MERGE statement. The merge file is created and can be used
only by the merge function.
message-processing program (MPP)
An IMS application program that is driven by transactions and has access to online IMS databases and
message queues.
message queue
The data set on which messages are queued before being processed by an application program or
sent to a terminal.
method
Procedural code that defines an operation supported by an object and that is executed by an INVOKE
statement on that object.
* method definition
The COBOL source code that defines a method.
* method identification entry
An entry in the METHOD-ID paragraph of the IDENTIFICATION DIVISION; this entry contains a
clause that specifies the method-name.
method invocation
A communication from one object to another that requests the receiving object to execute a method.
method-name
The name of an object-oriented operation. When used to invoke the method, the name can be an
alphanumeric or national literal or a category alphanumeric or category national data item. When used
in the METHOD-ID paragraph to define the method, the name must be an alphanumeric or national
literal.
Glossary 1001
method hiding
See hide.
method overloading
See overload.
method overriding
See override.
* mnemonic-name
A user-defined word that is associated in the ENVIRONMENT DIVISION with a specified
implementor-name.
module definition file
A file that describes the code segments within a program object.
MPP
See message-processing program (MPP).
multitasking
A mode of operation that provides for the concurrent, or interleaved, execution of two or more tasks.
multithreading
Concurrent operation of more than one path of execution within a computer. Synonymous with
multiprocessing.
N
name
A word (composed of not more than 30 characters) that defines a COBOL operand.
namespace
See XML namespace.
national character
(1) A UTF-16 character in a USAGE NATIONAL data item or national literal. (2) Any character
represented in UTF-16.
national character data
A general reference to data represented in UTF-16.
national character position
See character position.
national data
See national character data.
national data item
A data item of category national, national-edited, or numeric-edited of USAGE NATIONAL.
national decimal data item
An external decimal data item that is described implicitly or explicitly as USAGE NATIONAL and that
contains a valid combination of PICTURE symbols 9, S, P, and V.
national-edited data item
A data item that is described by a PICTURE character string that contains at least one instance of the
symbol N and at least one of the simple insertion symbols B, 0, or /. A national-edited data item has
USAGE NATIONAL.
national floating-point data item
An external floating-point data item that is described implicitly or explicitly as USAGE NATIONAL and
that has a PICTURE character string that describes a floating-point data item.
national group item
A group item that is explicitly or implicitly described with a GROUP-USAGE NATIONAL clause. A
national group item is processed as though it were defined as an elementary data item of category
national for operations such as INSPECT, STRING, and UNSTRING. This processing ensures correct
padding and truncation of national characters, as contrasted with defining USAGE NATIONAL data
items within an alphanumeric group item. For operations that require processing of the elementary
1002 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
items within a group, such as MOVE CORRESPONDING, ADD CORRESPONDING, and INITIALIZE, a
national group is processed using group semantics.
* native character set
The implementor-defined character set associated with the computer specified in the OBJECT-
COMPUTER paragraph.
* native collating sequence
The implementor-defined collating sequence associated with the computer specified in the OBJECT-
COMPUTER paragraph.
native method
A Java method with an implementation that is written in another programming language, such as
COBOL.
* negated combined condition
The NOT logical operator immediately followed by a parenthesized combined condition. See also
condition and combined condition.
* negated simple condition
The NOT logical operator immediately followed by a simple condition. See also condition and simple
condition.
nested program
A program that is directly contained within another program.
* next executable sentence
The next sentence to which control will be transferred after execution of the current statement is
complete.
* next executable statement
The next statement to which control will be transferred after execution of the current statement is
complete.
* next record
The record that logically follows the current record of a file.
* noncontiguous items
Elementary data items in the WORKING-STORAGE SECTION and LINKAGE SECTION that bear no
hierarchic relationship to other data items.
* noncontiguous items
Elementary data items in the WORKING-STORAGE and LINKAGE SECTIONs that bear no hierarchic
relationship to other data items.
* nonnumeric item
A data item whose description permits its content to be composed of any combination of characters
taken from the computer's character set. Certain categories of nonnumeric items may be formed from
more restricted character sets.
null
A figurative constant that is used to assign, to pointer data items, the value of an address that is not
valid. NULLS can be used wherever NULL can be used.
* numeric character
A character that belongs to the following set of digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
numeric data item
(1) A data item whose description restricts its content to a value represented by characters chosen
from the digits 0 through 9. If signed, the item can also contain a +, -, or other representation of
an operational sign. (2) A data item of category numeric, internal floating-point, or external floating-
point. A numeric data item can have USAGE DISPLAY, NATIONAL, PACKED-DECIMAL, BINARY, COMP,
COMP-1, COMP-2, COMP-3, COMP-4, or COMP-5.
numeric-edited data item
A data item that contains numeric data in a form suitable for use in printed output. The data item can
consist of external decimal digits from 0 through 9, the decimal separator, commas, the currency sign,
Glossary 1003
sign control characters, and other editing characters. A numeric-edited item can be represented in
either USAGE DISPLAY or USAGE NATIONAL.
* numeric function
A function whose class and category are numeric but that for some possible evaluation does not
satisfy the requirements of integer functions.
* numeric item
A data item whose description restricts its content to a value represented by characters chosen from
the digits from '0' through '9'; if signed, the item may also contain a '+', '-', or other representation of
an operational sign.
* numeric literal
A literal composed of one or more numeric characters that can contain a decimal point or an algebraic
sign, or both. The decimal point must not be the rightmost character. The algebraic sign, if present,
must be the leftmost character.
O
object
An entity that has state (its data values) and operations (its methods). An object is a way to
encapsulate state and behavior. Each object in the class is said to be an instance of the class.
object code
Output from a compiler or assembler that is itself executable machine code or is suitable for
processing to produce executable machine code.
* OBJECT-COMPUTER
The name of an ENVIRONMENT DIVISION paragraph in which the computer environment, where the
object program is run, is described.
* object computer entry
An entry in the OBJECT-COMPUTER paragraph of the ENVIRONMENT DIVISION; this entry contains
clauses that describe the computer environment in which the object program is to be executed.
object deck
A portion of an object program suitable as input to a linkage-editor. Synonymous with object module
and text deck.
object instance
A single object, of possibly many, instantiated from the specifications in the object paragraph of a
COBOL class definition. An object instance has a copy of all the data described in its class definition
and all inherited data. The methods associated with an object instance includes the methods defined
in its class definition and all inherited methods.
An object instance can be an instance of a Java class.
object module
Synonym for object deck or text deck.
* object of entry
A set of operands and reserved words, within a DATA DIVISION entry of a COBOL program, that
immediately follows the subject of the entry.
object-oriented programming
A programming approach based on the concepts of encapsulation and inheritance. Unlike procedural
programming techniques, object-oriented programming concentrates on the data objects that
comprise the problem and how they are manipulated, not on how something is accomplished.
object program
A set or group of executable machine-language instructions and other material designed to interact
with data to provide problem solutions. In this context, an object program is generally the machine
language result of the operation of a COBOL compiler on a source program or class definition. Where
there is no danger of ambiguity, the word program can be used in place of object program.
object reference
A value that identifies an instance of a class. If the class is not specified, the object reference is
universal and can apply to instances of any class.
1004 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
* object time
The time at which an object program is executed. Synonymous with run time.
* obsolete element
A COBOL language element in the 85 COBOL Standard that was deleted from the 2002 COBOL
Standard.
ODO object
In the example below, X is the object of the OCCURS DEPENDING ON clause (ODO object).
WORKING-STORAGE SECTION.
01 TABLE-1.
05 X PIC S9.
05 Y OCCURS 3 TIMES
DEPENDING ON X PIC X.
The value of the ODO object determines how many of the ODO subject appear in the table.
ODO subject
In the example above, Y is the subject of the OCCURS DEPENDING ON clause (ODO subject). The
number of Y ODO subjects that appear in the table depends on the value of X.
* open mode
The state of a file after execution of an OPEN statement for that file and before the execution of a
CLOSE statement without the REEL or UNIT phrase for that file. The particular open mode is specified
in the OPEN statement as either INPUT, OUTPUT, I-O, or EXTEND.
* operand
(1) The general definition of operand is "the component that is operated upon." (2) For the purposes
of this document, any lowercase word (or words) that appears in a statement or entry format can
be considered to be an operand and, as such, is an implied reference to the data indicated by the
operand.
operation
A service that can be requested of an object.
* operational sign
An algebraic sign that is associated with a numeric data item or a numeric literal, to indicate whether
its value is positive or negative.
optional file
A file that is declared as being not necessarily available each time the object program is run.
* optional word
A reserved word that is included in a specific format only to improve the readability of the language.
Its presence is optional to the user when the format in which the word appears is used in a source
unit.
* output file
A file that is opened in either output mode or extend mode.
* output mode
The state of a file after execution of an OPEN statement, with the OUTPUT or EXTEND phrase specified,
for that file and before the execution of a CLOSE statement without the REEL or UNIT phrase for that
file.
* output procedure
A set of statements to which control is given during execution of a format 1 SORT statement after the
sort function is completed, or during execution of a MERGE statement after the merge function reaches
a point at which it can select the next record in merged order when requested.
overflow condition
A condition that occurs when a portion of the result of an operation exceeds the capacity of the
intended unit of storage.
overload
To define a method with the same name as another method that is available in the same class, but
with a different signature. See also signature.
Glossary 1005
override
To redefine an instance method (inherited from a parent class) in a subclass.
P
package
A group of related Java classes, which can be imported individually or as a whole.
packed-decimal data item
See internal decimal data item.
padding character
An alphanumeric or national character that is used to fill the unused character positions in a physical
record.
page
A vertical division of output data that represents a physical separation of the data. The separation is
based on internal logical requirements or external characteristics of the output medium or both.
* page body
That part of the logical page in which lines can be written or spaced or both.
* paragraph
In the PROCEDURE DIVISION, a paragraph-name followed by a separator period and by zero, one,
or more sentences. In the IDENTIFICATION DIVISION and ENVIRONMENT DIVISION, a paragraph
header followed by zero, one, or more entries.
* paragraph header
A reserved word, followed by the separator period, that indicates the beginning of a paragraph in the
IDENTIFICATION DIVISION and ENVIRONMENT DIVISION. The permissible paragraph headers in
the IDENTIFICATION DIVISION are:
SOURCE-COMPUTER.
OBJECT-COMPUTER.
SPECIAL-NAMES.
REPOSITORY. (Program or Class
CONFIGURATION SECTION)
FILE-CONTROL.
I-O-CONTROL.
* paragraph-name
A user-defined word that identifies and begins a paragraph in the PROCEDURE DIVISION.
parameter
(1) Data passed between a calling program and a called program. (2) A data element in the USING
phrase of a method invocation. Arguments provide additional information that the invoked method
can use to perform the requested operation.
Persistent Reusable JVM
A JVM that can be serially reused for transaction processing by resetting the JVM between
transactions. The reset phase restores the JVM to a known initialization state.
* phrase
An ordered set of one or more consecutive COBOL character strings that form a portion of a COBOL
procedural statement or of a COBOL clause.
1006 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
* physical record
See block.
pointer data item
A data item in which address values can be stored. Data items are explicitly defined as pointers with
the USAGE IS POINTER clause. ADDRESS OF special registers are implicitly defined as pointer data
items. Pointer data items can be compared for equality or moved to other pointer data items.
port
(1) To modify a computer program to enable it to run on a different platform. (2) In the Internet
suite of protocols, a specific logical connector between the Transmission Control Protocol (TCP) or the
User Datagram Protocol (UDP) and a higher-level protocol or application. A port is identified by a port
number.
portability
The ability to transfer an application program from one application platform to another with relatively
few changes to the source program.
precomposed character
A single Unicode character that can be represented using two or more Unicode characters through a
canonical decomposition. A precomposed character does not have the same physical representation
as its composed character form. For example, Unicode character U+00E4 (ä) is a precomposed
character that can be represented as a combination of Unicode characters U+0061 + U+0308 (ä) -
latin small letter a + combining diaeresis. A precomposed character is typically used to represent a
latin letter with a diacritical mark or some other combining character.
preinitialization
The initialization of the COBOL runtime environment in preparation for multiple calls from programs,
especially non-COBOL programs. The environment is not terminated until an explicit termination.
* prime record key
A key whose contents uniquely identify a record within an indexed file.
* priority-number
A user-defined word that classifies sections in the PROCEDURE DIVISION for purposes of
segmentation. Segment numbers can contain only the characters 0 through 9. A segment number
can be expressed as either one or two digits.
private
As applied to factory data or instance data, accessible only by methods of the class that defines the
data.
* procedure
A paragraph or group of logically successive paragraphs, or a section or group of logically successive
sections, within the PROCEDURE DIVISION.
* procedure branching statement
A statement that causes the explicit transfer of control to a statement other than the next executable
statement in the sequence in which the statements are written in the source code. The procedure
branching statements are: ALTER, CALL, EXIT, EXIT PROGRAM, GO TO, MERGE (with the OUTPUT
PROCEDURE phrase), PERFORM and SORT (with the INPUT PROCEDURE or OUTPUT PROCEDURE
phrase), XML PARSE.
PROCEDURE DIVISION
The COBOL division that contains instructions for solving a problem.
procedure integration
One of the functions of the COBOL optimizer is to simplify calls to performed procedures or contained
programs.
PERFORM procedure integration is the process whereby a PERFORM statement is replaced by its
performed procedures. Contained program procedure integration is the process where a call to a
contained program is replaced by the program code.
* procedure-name
A user-defined word that is used to name a paragraph or section in the PROCEDURE DIVISION. It
consists of a paragraph-name (which can be qualified) or a section-name.
Glossary 1007
procedure pointer
A data item in which a pointer to an entry point can be stored. A data item defined with the USAGE IS
PROCEDURE-POINTER clause contains the address of a procedure entry point.
procedure-pointer data item
A data item in which a pointer to an entry point can be stored. A data item defined with the USAGE
IS PROCEDURE-POINTER clause contains the address of a procedure entry point. Typically used to
communicate with COBOL and Language Environment programs.
process
The course of events that occurs during the execution of all or part of a program. Multiple processes
can run concurrently, and programs that run within a process can share resources.
program
(1) A sequence of instructions suitable for processing by a computer. Processing may include the use
of a compiler to prepare the program for execution, as well as a runtime environment to execute it. (2)
A logical assembly of one or more interrelated modules. Multiple copies of the same program can be
run in different processes.
program-name
In the IDENTIFICATION DIVISION and the end program marker, a user-defined word or an
alphanumeric literal that identifies a COBOL source program.
* program identification entry
In the PROGRAM-ID paragraph of the IDENTIFICATION DIVISION, an entry that contains clauses
that specify the program-name and assign selected program attributes to the program.
program-name
In the IDENTIFICATION DIVISION and the end program marker, a user-defined word or
alphanumeric literal that identifies a COBOL source program.
project
The complete set of data and actions that are required to build a target, such as a dynamic link library
(DLL) or other executable (EXE).
* pseudo-text
A sequence of text words, comment lines, inline comments, or the separator space in a source
program or COBOL library bounded by, but not including, pseudo-text delimiters.
* pseudo-text delimiter
Two contiguous equal sign characters (==) used to delimit pseudo-text.
* punctuation character
A character that belongs to the following set:
Character Meaning
, Comma
; Semicolon
: Colon
. Period (full stop)
" Quotation mark
( Left parenthesis
) Right parenthesis
Space
= Equal sign
1008 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
QSAM (Queued Sequential Access Method)
An extended version of the basic sequential access method (BSAM). When this method is used, a
queue is formed of input data blocks that are awaiting processing or of output data blocks that have
been processed and are awaiting transfer to auxiliary storage or to an output device.
* qualified data-name
An identifier that is composed of a data-name followed by one or more sets of either of the
connectives OF and IN followed by a data-name qualifier.
* qualifier
(1) A data-name or a name associated with a level indicator that is used in a reference either together
with another data-name (which is the name of an item that is subordinate to the qualifier) or together
with a condition-name. (2) A section-name that is used in a reference together with a paragraph-name
specified in that section. (3) A library-name that is used in a reference together with a text-name
associated with that library.
R
* random access
An access mode in which the program-specified value of a key data item identifies the logical record
that is obtained from, deleted from, or placed into a relative or indexed file.
* record
See logical record.
* record area
A storage area allocated for the purpose of processing the record described in a record description
entry in the FILE SECTION of the DATA DIVISION. In the FILE SECTION, the current number of
character positions in the record area is determined by the explicit or implicit RECORD clause.
* record description
See record description entry.
* record description entry
The total set of data description entries associated with a particular record. Synonymous with record
description.
recording mode
The format of the logical records in a file. Recording mode can be F (fixed-length), V (variable-length),
S (spanned), or U (undefined).
record key
A key whose contents identify a record within an indexed file.
* record-name
A user-defined word that names a record described in a record description entry in the DATA
DIVISION of a COBOL program.
* record number
The ordinal number of a record in the file whose organization is sequential.
recording mode
The format of the logical records in a file. Recording mode can be F (fixed length), V (variable length),
S (spanned), or U (undefined).
recursion
A program calling itself or being directly or indirectly called by one of its called programs.
recursively capable
A program is recursively capable (can be called recursively) if the RECURSIVE attribute is on the
PROGRAM-ID statement.
reel
A discrete portion of a storage medium, the dimensions of which are determined by each implementor
that contains part of a file, all of a file, or any number of files. Synonymous with unit and volume.
reentrant
The attribute of a program or routine that lets more than one user share a single copy of a program
object.
Glossary 1009
* reference format
A format that provides a standard method for describing COBOL source programs.
reference modification
A method of defining a new category alphanumeric, category DBCS, or category national data item
by specifying the leftmost character and length relative to the leftmost character position of a USAGE
DISPLAY, DISPLAY-1, or NATIONAL data item.
* reference-modifier
A syntactically correct combination of character strings and separators that defines a unique data
item. It includes a delimiting left parenthesis separator, the leftmost character position, a colon
separator, optionally a length, and a delimiting right parenthesis separator.
* relation
See relational operator or relation condition.
* relation character
A character that belongs to the following set:
Character Meaning
> Greater than
< Less than
= Equal to
* relation condition
The proposition (for which a truth value can be determined) that the value of an arithmetic expression,
data item, alphanumeric literal, or index-name has a specific relationship to the value of another
arithmetic expression, data item, alphanumeric literal, or index name. See also relational operator.
* relational operator
A reserved word, a relation character, a group of consecutive reserved words, or a group of
consecutive reserved words and relation characters used in the construction of a relation condition.
The permissible operators and their meanings are:
Character Meaning
IS GREATER THAN Greater than
IS > Greater than
IS NOT GREATER THAN Not greater than
IS NOT > Not greater than
IS EQUAL TO Equal to
IS = Equal to
IS NOT EQUAL TO Not equal to
IS NOT = Not equal to
1010 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Character Meaning
IS LESS THAN OR EQUAL TO Less than or equal to
IS <= Less than or equal to
* relative file
A file with relative organization.
* relative key
A key whose contents identify a logical record in a relative file.
* relative organization
The permanent logical file structure in which each record is uniquely identified by an integer value
greater than zero, which specifies the logical ordinal position of the record in the file.
* relative record number
The ordinal number of a record in a file whose organization is relative. This number is treated as a
numeric literal that is an integer.
* reserved word
A COBOL word that is specified in the list of words that can be used in a COBOL source program, but
that must not appear in the program as a user-defined word or system-name.
* resource
A facility or service, controlled by the operating system, that an executing program can use.
* resultant identifier
A user-defined data item that is to contain the result of an arithmetic operation.
reusable environment
A reusable environment is created when you establish an assembler program as the main program by
using either the old COBOL interfaces for preinitialization (RTEREUS runtime option), or the Language
Environment interface, CEEPIPI.
routine
A set of statements in a COBOL program that causes the computer to perform an operation or series
of related operations. In Language Environment, refers to either a procedure, function, or subroutine.
* routine-name
A user-defined word that identifies a procedure written in a language other than COBOL.
* run time
The time at which an object program is executed. Synonymous with object time.
runtime environment
The environment in which a COBOL program executes.
* run unit
A stand-alone object program, or several object programs, that interact by means of COBOL CALL or
INVOKE statements and function at run time as an entity.
A run unit is also called an enclave in Language Environment terminology.
S
SBCS
See single-byte character set (SBCS).
scope terminator
A COBOL reserved word that marks the end of certain PROCEDURE DIVISION statements.It can be
either explicit (END-ADD, for example) or implicit (separator period).
* section
A set of zero, one, or more paragraphs or entities, called a section body, the first of which is preceded
by a section header. Each section consists of the section header and the related section body.
* section header
A combination of words followed by a separator period that indicates the beginning of a section in
any of these divisions: ENVIRONMENT, DATA, or PROCEDURE. In the ENVIRONMENT DIVISION and
Glossary 1011
DATA DIVISION, a section header is composed of reserved words followed by a separator period.
The permissible section headers in the ENVIRONMENT DIVISION are:
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE SECTION.
WORKING-STORAGE SECTION.
LOCAL-STORAGE SECTION.
LINKAGE SECTION.
1012 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
serial search
A search in which the members of a set are consecutively examined, beginning with the first member
and ending with the last.
session bean
In EJB, an enterprise bean that is created by a client and that usually exists only for the duration of a
single client/server session. (Oracle)
77-level-description-entry
A data description entry that describes a noncontiguous data item that has level-number 77.
* sign condition
The proposition (for which a truth value can be determined) that the algebraic value of a data item or
an arithmetic expression is either less than, greater than, or equal to zero.
signature
(1) The name of an operation and its parameters. (2) The name of a method and the number and types
of its formal parameters.
* simple condition
Any single condition chosen from this set:
• Relation condition
• Class condition
• Condition-name condition
• Switch-status condition
• Sign condition
See also condition and negated simple condition.
single-byte character set (SBCS)
A set of characters in which each character is represented by a single byte. See also ASCII and
EBCDIC (Extended Binary-Coded Decimal Interchange Code).
slack bytes (within records)
Bytes inserted by the compiler between data items to ensure correct alignment of some elementary
data items. Slack bytes contain no meaningful data. The SYNCHRONIZED clause instructs the
compiler to insert slack bytes when they are needed for proper alignment.
slack bytes (between records)
Bytes inserted by the programmer between blocked logical records of a file, to ensure correct
alignment of some elementary data items. In some cases, slack bytes between records improve
performance for records processed in a buffer.
* sort file
A collection of records to be sorted by a format 1 SORT statement. The sort file is created and can be
used by the sort function only.
* sort-merge file description entry
An entry in the FILE SECTION of the DATA DIVISION that is composed of the level indicator SD,
followed by a file-name, and then followed by a set of file clauses as required.
* SOURCE-COMPUTER
The name of an ENVIRONMENT DIVISION paragraph in which the computer environment, where the
source program is compiled, is described.
* source computer entry
An entry in the SOURCE-COMPUTER paragraph of the ENVIRONMENT DIVISION; this entry contains
clauses that describe the computer environment in which the source program is to be compiled.
* source item
An identifier designated by a SOURCE clause that provides the value of a printable item.
source program
Although a source program can be represented by other forms and symbols, in this document the
term always refers to a syntactically correct set of COBOL statements. A COBOL source program
Glossary 1013
commences with the IDENTIFICATION DIVISION or a COPY statement and terminates with the end
program marker, if specified, or with the absence of additional source program lines.
source unit
A unit of COBOL source code that can be separately compiled: a program or a class definition. Also
known as a compilation unit.
special character
A character that belongs to the following set:
Character Meaning
+ Plus sign
- Minus sign (hyphen)
* Asterisk
/ Slant (forward slash)
= Equal sign
$ Currency sign
, Comma
; Semicolon
. Period (decimal point, full stop)
" Quotation mark
' Apostrophe
( Left parenthesis
) Right parenthesis
> Greater than
< Less than
: Colon
_ Underscore
SPECIAL-NAMES
The name of an ENVIRONMENT DIVISION paragraph in which environment-names are related to
user-specified mnemonic-names.
* special names entry
An entry in the SPECIAL-NAMES paragraph of the ENVIRONMENT DIVISION; this entry provides
means for specifying the currency sign; choosing the decimal point; specifying symbolic characters;
relating implementor-names to user-specified mnemonic-names; relating alphabet-names to
character sets or collating sequences; and relating class-names to sets of characters.
* special registers
Certain compiler-generated storage areas whose primary use is to store information produced in
conjunction with the use of a specific COBOL feature.
* standard data format
The concept used in describing the characteristics of data in a COBOL DATA DIVISION under which
the characteristics or properties of the data are expressed in a form oriented to the appearance of the
data on a printed page of infinite length and breadth, rather than a form oriented to the manner in
which the data is stored internally in the computer, or on a particular external medium.
* statement
A syntactically valid combination of words, literals, and separators, beginning with a verb, written in a
COBOL source program.
1014 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
structured programming
A technique for organizing and coding a computer program in which the program comprises a
hierarchy of segments, each segment having a single entry point and a single exit point. Control
is passed downward through the structure without unconditional branches to higher levels of the
hierarchy.
* subclass
A class that inherits from another class. When two classes in an inheritance relationship are
considered together, the subclass is the inheritor or inheriting class; the superclass is the inheritee or
inherited class.
* subject of entry
An operand or reserved word that appears immediately following the level indicator or the level-
number in a DATA DIVISION entry.
* subprogram
See called program.
* subscript
An occurrence number that is represented by either an integer, a data-name optionally followed by an
integer with the operator + or -, or an index-name optionally followed by an integer with the operator
+ or -, that identifies a particular element in a table. A subscript can be the word ALL when the
subscripted identifier is used as a function argument for a function allowing a variable number of
arguments.
* subscripted data-name
An identifier that is composed of a data-name followed by one or more subscripts enclosed in
parentheses.
substitution character
A character that is used in a conversion from a source code page to a target code page to represent a
character that is not defined in the target code page.
* superclass
A class that is inherited by another class. See also subclass.
surrogate pair
In the UTF-16 format of Unicode, a pair of encoding units that together represents a single Unicode
graphic character. The first unit of the pair is called a high surrogate and the second a low surrogate.
The code value of a high surrogate is in the range X'D800' through X'DBFF'. The code value of a low
surrogate is in the range X'DC00' through X'DFFF'. Surrogate pairs provide for more characters than
the 65,536 characters that fit in the Unicode 16-bit coded character set.
switch-status condition
The proposition (for which a truth value can be determined) that an UPSI switch, capable of being set
to an on or off status, has been set to a specific status.
* symbolic-character
A user-defined word that specifies a user-defined figurative constant.
syntax
(1) The relationship among characters or groups of characters, independent of their meanings or
the manner of their interpretation and use. (2) The structure of expressions in a language. (3) The
rules governing the structure of a language. (4) The relationship among symbols. (5) The rules for the
construction of a statement.
* system-name
A COBOL word that is used to communicate with the operating environment.
T
* table
A set of logically consecutive items of data that are defined in the DATA DIVISION by means of the
OCCURS clause.
* table element
A data item that belongs to the set of repeated items comprising a table.
Glossary 1015
text deck
Synonym for object deck or object module.
* text-name
A user-defined word that identifies library text.
* text word
A character or a sequence of contiguous characters between margin A and margin R in a COBOL
library, source program, or pseudo-text that is any of the following characters:
• A separator, except for space; a pseudo-text delimiter; and the opening and closing delimiters for
alphanumeric literals. The right parenthesis and left parenthesis characters, regardless of context
within the library, source program, or pseudo-text, are always considered text words.
• A literal including, in the case of alphanumeric literals, the opening quotation mark and the closing
quotation mark that bound the literal.
• Any other sequence of contiguous COBOL characters except comment lines and the word COPY
bounded by separators that are neither a separator nor a literal.
thread
A stream of computer instructions (initiated by an application within a process) that is in control of a
process.
token
In the COBOL editor, a unit of meaning in a program. A token can contain data, a language keyword, an
identifier, or other part of the language syntax.
top-down design
The design of a computer program using a hierarchic structure in which related functions are
performed at each level of the structure.
top-down development
See structured programming.
trailer-label
(1) A data-set label that follows the data records on a unit of recording medium. (2) Synonym for
end-of-file label.
troubleshoot
To detect, locate, and eliminate problems in using computer software.
* truth value
The representation of the result of the evaluation of a condition in terms of one of two values: true or
false.
typed object reference
A data-name that can refer only to an object of a specified class or any of its subclasses.
U
* unary operator
A plus (+) or a minus (-) sign that precedes a variable or a left parenthesis in an arithmetic expression
and that has the effect of multiplying the expression by +1 or -1, respectively.
unbounded table
A table with OCCURS integer-1 to UNBOUNDED instead of specifying integer-2 as the upper
bound.
Unicode
A universal character encoding standard that supports the interchange, processing, and display of text
that is written in any of the languages of the modern world. There are multiple encoding schemes to
represent Unicode, including UTF-8, UTF-16, and UTF-32. Enterprise COBOL supports Unicode using
UTF-16 in big-endian format as the representation for the national data type.
Uniform Resource Identifier (URI)
A sequence of characters that uniquely names a resource; in Enterprise COBOL, the identifier of a
namespace. URI syntax is defined by the document Uniform Resource Identifier (URI): Generic Syntax.
1016 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
unit
A module of direct access, the dimensions of which are determined by IBM.
universal object reference
A data-name that can refer to an object of any class.
unrestricted storage
In AMODE 31, unrestricted storage is below the 2 GB bar and can be above or below the 16 MB line.
In AMODE 64, unrestricted storage encompasses all the storage available to your program, both
above and below the 2 GB bar.
* unsuccessful execution
The attempted execution of a statement that does not result in the execution of all the operations
specified by that statement. The unsuccessful execution of a statement does not affect any data
referenced by that statement, but can affect status indicators.
UPSI switch
A program switch that performs the functions of a hardware switch. Eight are provided: UPSI-0
through UPSI-7.
URI
See Uniform Resource Identifier (URI).
* user-defined word
A COBOL word that must be supplied by the user to satisfy the format of a clause or statement.
V
* variable
A data item whose value can be changed by execution of the object program. A variable used in an
arithmetic expression must be a numeric elementary item.
variable-length item
A group item that contains a table described with the DEPENDING phrase of the OCCURS clause.
* variable-length record
A record associated with a file whose file description or sort-merge description entry permits records
to contain a varying number of character positions.
* variable-occurrence data item
A variable-occurrence data item is a table element that is repeated a variable number of times.
Such an item must contain an OCCURS DEPENDING ON clause in its data description entry or be
subordinate to such an item.
* variably located group
A group item following, and not subordinate to, a variable-length table in the same record. The group
item can be an alphanumeric group or a national group.
* variably located item
A data item following, and not subordinate to, a variable-length table in the same record.
* verb
A word that expresses an action to be taken by a COBOL compiler or object program.
volume
A module of external storage. For tape devices it is a reel; for direct-access devices it is a unit.
volume switch procedures
System-specific procedures that are executed automatically when the end of a unit or reel has been
reached before end-of-file has been reached.
VSAM file system
A file system that supports COBOL sequential, relative, and indexed organizations.
W
web service
A modular application that performs specific tasks and is accessible through open protocols like HTTP
and SOAP.
Glossary 1017
white space
Characters that introduce space into a document. They are:
• Space
• Horizontal tabulation
• Carriage return
• Line feed
• Next line
as named in the Unicode Standard.
* word
A character string of not more than 30 characters that forms a user-defined word, a system-name, a
reserved word, or a function-name.
* WORKING-STORAGE SECTION
The section of the DATA DIVISION that describes WORKING-STORAGE data items, composed either
of noncontiguous items or WORKING-STORAGE records or of both.
workstation
A generic term for computers, including personal computers, 3270 terminals, intelligent workstations,
and UNIX terminals. Often a workstation is connected to a mainframe or to a network.
wrapper
An object that provides an interface between object-oriented code and procedure-oriented code.
Using wrappers lets programs be reused and accessed by other systems.
X
x
The symbol in a PICTURE clause that can hold any character in the character set of the computer.
XML
Extensible Markup Language. A standard metalanguage for defining markup languages that was
derived from and is a subset of SGML. XML omits the more complex and less-used parts of SGML and
makes it much easier to write applications to handle document types, author and manage structured
information, and transmit and share structured information across diverse computing systems. The
use of XML does not require the robust applications and processing that is necessary for SGML. XML is
developed under the auspices of the World Wide Web Consortium (W3C).
XML data
Data that is organized into a hierarchical structure with XML elements. The data definitions are
defined in XML element type declarations.
XML declaration
XML text that specifies characteristics of the XML document such as the version of XML being used
and the encoding of the document.
XML document
A data object that is well formed as defined by the W3C XML specification.
XML namespace
A mechanism, defined by the W3C XML Namespace specifications, that limits the scope of a collection
of element names and attribute names. A uniquely chosen XML namespace ensures the unique
identity of an element name or attribute name across multiple XML documents or multiple contexts
within an XML document.
XML schema
A mechanism, defined by the W3C, for describing and constraining the structure and content of XML
documents. An XML schema, which is itself expressed in XML, effectively defines a class of XML
documents of a given type, for example, purchase orders.
Z
1018 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
z/OS UNIX file system
A collection of files and directories that are organized in a hierarchical structure and can be accessed
by using z/OS UNIX.
zoned decimal data item
An external decimal data item that is described implicitly or explicitly as USAGE DISPLAY and that
contains a valid combination of PICTURE symbols 9, S, P, and V. The content of a zoned decimal data
item is represented in characters 0 through 9, optionally with a sign. If the PICTURE string specifies a
sign and the SIGN IS SEPARATE clause is specified, the sign is represented as characters + or -. If
SIGN IS SEPARATE is not specified, the sign is one hexadecimal digit that overlays the first 4 bits of
the sign position (leading or trailing).
#
85 COBOL Standard
The COBOL language defined by the following standards:
• ANSI INCITS 23-1985, Programming languages - COBOL, as amended by ANSI INCITS 23a-1989,
Programming Languages - COBOL - Intrinsic Function Module for COBOL and ANSI INCITS 23b-1993,
Programming Languages - Correction Amendment for COBOL
• ISO 1989:1985, Programming languages - COBOL, as amended by ISO/IEC 1989/AMD1:1992,
Programming languages - COBOL: Intrinsic function module and ISO/IEC 1989/AMD2:1994,
Programming languages - Correction and clarification amendment for COBOL
2002 COBOL Standard
The COBOL language defined by the following standard:
• INCITS/ISO/IEC 1989-2002, Information technology - Programming languages - COBOL
2014 COBOL Standard
The COBOL language defined by the following standard:
• INCITS/ISO/IEC 1989:2014, Information technology - Programming languages, their environments
and system software interfaces - Programming language COBOL
Glossary 1019
1020 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
List of resources
Softcopy publications
The following collection kits contain Enterprise COBOL and other product publications. You can find them
at https://www.ibm.com/resources/publications.
• z/OS Software Products Collection
• z/OS and Software Products DVD Collection
Support
If you have a problem using Enterprise COBOL for z/OS, see the following site that provides up-to-date
support information: https://www.ibm.com/support/pages/node/6560933.
Related publications
z/OS library publications
You can find the following publications in the z/OS library.
Run-Time Library Extensions
• Common Debug Architecture Library Reference
• Common Debug Architecture User’s Guide
• DWARF/ELF Extensions Library Reference
z/Architecture
• Principles of Operation
z/OS DFSMS
• Access Method Services for Catalogs
• Checkpoint/Restart
• Macro Instructions for Data Sets
• Using Data Sets
1022 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
• API (EXEC CICS) Reference
• Developing CICS System Programs
• Global User Exit Reference
• XPI Reference
• Using EXCI with CICS
IBM z/OS Debugger (formerly IBM Debug for z Systems and Debug Tool)
You can find information about IBM z/OS Debugger in the IBM z/OS Debugger library.
IMS
• Application Programming API Reference, SC18-9699
• Application Programming Guide, SC18-9698
Java
• IBM SDK for Java - Tools Documentation, publib.boulder.ibm.com/infocenter/javasdk/tools/index.jsp
• The Java 2 Enterprise Edition Developer's Guide, download.oracle.com/javaee/1.2.1/devguide/html/
DevGuideTOC.html
• Java 2 on z/OS, www.ibm.com/servers/eserver/zseries/software/java/
• The Java EE 5 Tutorial, download.oracle.com/javaee/5/tutorial/doc/
• The Java Language Specification, Third Edition, by Gosling et al., java.sun.com/docs/books/jls/
JSON
• JavaScript Object Notation (JSON), www.json.org
XML
• Extensible Markup Language (XML), www.w3.org/XML/
• Namespaces in XML 1.0, www.w3.org/TR/xml-names/
• Namespaces in XML 1.1, www.w3.org/TR/xml-names11/
• XML specification, www.w3.org/TR/xml/
1024 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
Index
Index 1025
AFP compiler option (continued) ALTERNATE RECORD KEY clause
multioption interaction 344 identify alternate indexes 207
performance considerations 778 identifying alternate keys in KSDS files 193
AIXBLD runtime option alternate reserved-word
effect on performance 783 table
ALL subscript CICS 502
examples 88 specifying 425
processing table elements iteratively 87 AMODE
table elements as function arguments 57 and DLLs 584
ALL31 runtime option description 39
multioption interaction 40 of EXIT modules 826
OFF for AMODE switching 550 switching
ALLOCATE command (TSO) ALL31(OFF) 550
compiler data sets 262 examples 550
with z/OS UNIX files overview 550
263 AMODE 31/64
allocation of files considerations and restrictions 542
description 164 AMODE 64
line-sequential 216 applications 335, 337
QSAM 180 CALL statement 534
under TSO 262 compiler limits 534
VSAM 208 compiler options 534
ALPHABET clause, establishing collating sequence with 7 considerations 535, 537–540
alphabetic data developing programs 533
comparing to national 141 DLL considerations 336
comparing to UTF-8 152 AMODE 64 programs
MOVE statement with 32 POINTER data items 533
alphanumeric comparison 95 AMODE 64under z/OS UNIX
alphanumeric data compiling and binding 336
comparing AMODE COBOL/JAVA
effect of ZWB 431 considerations and restrictions 540
to national 141 AMODE3164 541
to UTF-8 152 AMP parameter 208
converting ANNUITY intrinsic function 61
to DBCS with IGZCA2D 803 APIs, UNIX and POSIX
to national with MOVE 134 calling 528
to national with NATIONAL-OF 135 APOST compiler option 347
to UTF-8 with MOVE 150 APPLY WRITE-ONLY clause 10
MOVE statement with 32 ARCH compiler option
with double-byte characters 803 performance considerations 778
alphanumeric group item arguments
a group without GROUP-USAGE NATIONAL 25 describing in calling program 565
definition 24 from main program
alphanumeric literals accessing in z/OS 576
conversion of mixed DBCS/EBCDIC 803 accessing in z/OS UNIX
description 25 530
with DBCS content 159 passing BY VALUE 566
with double-byte characters 803 specifying OMITTED 567
alphanumeric-edited data testing for OMITTED arguments 567
initializing ARITH compiler option
example 29 description 349
using INITIALIZE 74 performance considerations 778
MOVE statement with 32 arithmetic
alternate collating sequence COMPUTE statement simpler to code 55
choosing 231 error handling 242
example 7 with intrinsic functions 56
alternate entry point, calling 560 arithmetic comparisons 63
alternate index arithmetic evaluation
creating 206 conversions and precision 52
example of 207 data format conversion 51
password for 205 examples 62, 63
path 207 fixed-point contrasted with floating-point 62
performance considerations 212 intermediate results 793
using 193 performance tips 772
1026 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
arithmetic evaluation (continued) batch compilation (continued)
precedence 56, 794 precedence of options
precision 793 example 278
arithmetic expression overview 278
as reference modifier 111 Bibliography 1021
description of 56 big-endian, converting to little-endian 125
in nonarithmetic statement 801 binary data 388
in parentheses 56 binary data item
arrays general description 48
COBOL 39 intermediate results 798
Java synonyms 46
declaring 724 using efficiently 48, 773
manipulating 726 binary digits, converting from 117
ASCII binary digits, converting to 116
alphabet, QSAM 187 binary search
code pages supported in XML documents 640 description 86
converting to EBCDIC 116 example 86
job control language (JCL) 187 binder
record formats, QSAM 187 c89 command 285
tape files, QSAM 187 options needed for DLLs 581
ASCII files recommended for DLLs 581
CODE-SET clause 13 binding OO applications
OPTCD= parameter in DCB 13 example 297
assembler using JCL or TSO/E 296
expansion of PROCEDURE DIVISION 464 BIT-OF intrinsic function 116
programs BIT-TO-CHAR intrinsic function 117
calls from (in CICS) 497 BLANK WHEN ZERO clause
compiling from 264 coded for numeric data 126
listing of 382, 776 example with numeric-edited data 45
with multithreading 594 BLOCK CONTAINS clause
ASSIGN clause FILE SECTION entry 13
corresponds to ddname 8 no meaning for VSAM files 195
QSAM files 167 QSAM files 169, 174, 350
assigning values 26 block size
assistive technologies 971 ASCII files 188
associated-data file, creating 272 compiler data sets 269
asynchronous signals with multithreading 595 QSAM files
AT END (end-of-file) phrase 246 fixed-length 168
ATTACH macro 264 record layout 171
attribute methods 691 using DCB 181
automatic restart 760 variable-length 170
available files system-determined
QSAM 177 compiler data sets 269
VSAM 205 QSAM files 175, 350
AWO compiler option BLOCK0 compiler option
APPLY-WRITE ONLY clause performance description 350
10 performance considerations 779
description 350 blocking factor, definition 169
performance considerations 778 blocking QSAM files
using BLOCK CONTAINS clause 174
using BLOCK0 350
B blocking records 174
Base class BPXBATCH utility
equating to java.lang.Object 684 calling z/OS UNIX programs
using for java.lang.Object 683 526
base cluster name 207 running OO applications 296
base locator 460, 461 branch, implicit 99
base locator table 481 buffers
basis libraries 270 best use of 10
BASIS statement 439 obtaining for QSAM 186
batch compilation BUFSIZE compiler option 351
description 276 building and running COBOL/Java interoperable
LANGUAGE option applications
example 279 AMODE considerations 330
Index 1027
building and running COBOL/Java interoperable applications (continued)
calls (continued)
building Java programs 308 between COBOL and non-COBOL programs 545
linking COBOL programs 307 between COBOL programs 545, 547
Building and running non-OO applications CICS restrictions 497
Example: building a COBOL/Java interoperable dynamic
applications 302 example 553
BY CONTENT 563 making 548
BY REFERENCE 563 performance 552
BY VALUE restrictions 548
description 563 with static calls 552
restrictions 566 exception condition 251
valid data types 566 interlanguage 545
byte order mark not generated 668 LINKAGE SECTION 567
BYTE-LENGTH intrinsic function OMITTED arguments 567
using 118 overflow condition 251
with national data 121 passing arguments 565
byte-stream files passing data 563
processing with QSAM 186 receiving parameters 566
recursive 557
static
C example 553
C/C++ programs making 548
with COBOL DLLs 587 performance 552
with multithreading 594 with dynamic calls 552
c89 command for link step 285 to and from object-oriented programs 557
CALL command (TSO) 262 to JNI services 719
CALL identifier to Language Environment callable services 789
always dynamic 550 CANCEL statement
dynamic calls 548 cannot use with DLL linkage 584
making from DLLs 583 for subprograms 549
with NODLL 548 handling of program-name in 398
with NODYNAM 552 with dynamic CALL 549
CALL literal case structure, EVALUATE statement for 93
dynamic calls 548 cataloged procedure
static calls 548 JCL for compiling 256
with DYNAM 548 to compile (IGYWC) 257
with NODLL 548 to compile and link-edit (IGYWCL) 258
with NODYNAM 548, 552 to compile, link-edit, run (IGYWCLG) 259
CALL statement CBL statement
AMODE processing 550 overview 439
BY CONTENT 563 specifying compiler options 274
BY REFERENCE 563 cbl suffix with cob2 289
BY VALUE CBLPSHPOP runtime option 503
description 563 CBLQDA
restrictions 566 DEBUG 337
CICS restrictions 497 CBLQDA runtime option 177
effect of EXIT option on registers 826 CCSID
exception condition 251 conflict in XML documents 647, 648
for error handling 251 definition 125
function-pointer 559 EBCDIC multibyte CCSIDs 354
handling of program-name in 398 in PARSE statement 626
Language Environment callable services 789 of Db2 string data 510
overflow condition 251 of XML documents 640
RETURNING 572 of XML documents to be parsed 626
to alternate entry points 560 specifying with CODEPAGE option 353
USING 566 chained-list processing
with AMODE 64 support 534 example 570
with CANCEL 550 overview 569
with DYNAM 366 changing
with ON EXCEPTION 251 characters to numbers 115
with ON OVERFLOW 19, 251 file-name 9
calls title on source listing 5
31-bit addressing mode 550 CHAR intrinsic function, example 118
AMODE switching for 24-bit programs 550 character set, definition 124
1028 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
checking for valid data CICS (continued)
conditional expressions 95 restrictions (continued)
checkpoint separate translator 500
85 COBOL Standard 757 sorting 238
designing 758 separate translator
example of JCL for restart 762 calling nested programs 498
messages generated during 760 compiler options for 501
methods 757 restrictions 500
multiple 757, 759 using 501
overview 757 sorting under
record data set 758 change reserved-word table
restart during DFSORT 237 503
restrictions during sort 758 overview 238
setting 757 restrictions 238
single system date, getting 497
disk 759 CICS compiler option
tape 759 description 352
testing 758 enables integrated translator 500
Chinese GB 18030 data multioption interaction 344
processing 157 specifying suboptions 352, 500
CHKPT keyword 237 using 499
CICS CISZ (control interval size), performance considerations 212,
alternate reserved-word table 502 783
calling nested programs 498 cjbuild
CICS HANDLE command reference 330
example 504 CKPT keyword 237
LABEL value 503 class
coding programs to run under defining 682
calls 497 definition of 679
DISPLAY statement 496 factory data 708
I/O 496 instance data 685
overview 495 instantiating
restrictions 495 COBOL 702
SORT statement 503 Java 702
command-level interface 495 name
commands and the PROCEDURE DIVISION 495 external 684, 695
compiling with CICS option 499 in a program 683
developing programs for 495 object, obtaining reference with JNI 720
DFHCOMMAREA parameter user-defined 8
calling nested programs 498 class condition
calling separately compiled programs 497 testing
DFHEIBLK parameter for DBCS 159
calling nested programs 498 for Kanji 159
calling separately compiled programs 497 for numeric 54
ECI calls and RETURN-CODE special register 498 overview 95
EXIT compiler option and 844 validating data 445
in a multithreaded environment 594 CLASSPATH environment variable
integrated translator description 527
advantages 500 example of setting 296
calling nested programs 498 specifying location of Java classes 293
compiler options for 499 client
overview 500 defining 694
interlanguage communication under 497 definition of 694
macro-level interface 495 CLIST for compiling under TSO 264
NODYNAM compiler option 497 CLOSE statement
performance line-sequential files 217
overview 771 QSAM 176
performance considerations 503, 783 VSAM 196
restrictions closing files
16 MB line 496 line-sequential 219
files 5 multithreading serialization 592
OO programs 495, 679 QSAM
OUTDD compiler option 396 overview 179
parsing with validation using FILE 635 with multithreading 179
Index 1029
closing files (continued) COBOL/Java interoperability outside of object-oriented COBOL (continued)
VSAM array semantics 748
overview 203 byte arrays 747
with multithreading 204 group parameters 747
closing files, automatic using Java-compatible array types in COBOL 747
line-sequential 219 COBOL/Java interoperability outside of the Object-Oriented
QSAM 179 (OO) COBOL framework
VSAM 203 AMODE considerations 753
cluster, VSAM 205 COBOL/Java interoperability
cob2 command outside of object-oriented COBOL 749
compiling with Error handling in Java-interoperable COBOL applications
examples 286 751
overview 285 COBOL3 translator option 501
description 287 COBOPT environment variable 283
for compiling OO applications 291 code
for creating DLLs 286 copy 786
for linking OO applications 292 optimized 776
input and output 289 code page
linking with conflict in XML documents 647, 648
examples 286 DBCS 354
overview 285 definition 124
options and syntax 287 euro currency support 64
COBJVMINITOPTIONS environment variable hexadecimal values of special characters 643
description 527 of Db2 string data 510
specifying JVM options 294 overriding 135
COBOL specifying 353
and Java specifying for alphanumeric XML document 642
binding 296 code point, definition 124
communicating between 719 CODE-SET clause 13
compatibility 299 coded character set
compiling under z/OS UNIX 291 definition 124
compiling using JCL or TSO/E 295 in XML documents 640
linking 292 CODEPAGE compiler option
running 293, 296 DBCS code pages 354
structuring applications 715 description 353
under IMS 521 for national literals 139
object-oriented items that are not affected 353
binding 296 operations that override 354
compiling under z/OS UNIX 291 coding
compiling using JCL or TSO/E 295 class definition 682
linking 292 clients 694
running 293 condition tests 96
under IMS 521 constructor methods 709
COBOL client DATA DIVISION 11
example 711 decisions 91
example of passing object references 699 efficiently 771
COBOL DLL programs, calling 585 ENVIRONMENT DIVISION 5
COBOL only errors, avoiding 771
runtime options specifications 337 EVALUATE statement 93
COBOL runtime factory definition 707
options 432 factory methods 709
COBOL terms 23 file input/output (overview) 161
COBOL_INSTALL_DIR environment variable 283 IDENTIFICATION DIVISION 3
COBOL-calls-Java IF statement 91
application input/output overview 163
building and running 321 input/output statements
COBOL/Java interoperability for line-sequential files 217
Calling static Java methods from COBOL 745 for QSAM files 176
Making an existing program callable from Java 741 for VSAM files 196
outside of object-oriented COBOL 739, 741, 745 instance methods 686, 706
troubleshooting 329 interoperable data types with Java 723
COBOL/Java interoperability outside of object-oriented loops 99
COBOL OO programs
array restrictions 748 must be reentrant 560
1030 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
coding (continued) COMP (COMPUTATIONAL) 48
OO programs (continued) COMP-1 (COMPUTATIONAL-1)
overview 679 format 49
PROCEDURE DIVISION 17 performance tips 773
programs to run under CICS COMP-2 (COMPUTATIONAL-2)
calls 497 format 49
DISPLAY statement 496 performance tips 773
I/O 496 COMP-3 (COMPUTATIONAL-3) 49
must be reentrant 560 COMP-4 (COMPUTATIONAL-4) 48
overview 495 COMP-5 (COMPUTATIONAL-5) 48
restrictions 495 comparing data items
SORT statement 503 national
system date, getting 497 overview 140
programs to run under Db2 to alphabetic, alphanumeric, or DBCS 141
CCSID of string data 510 to alphanumeric groups 142
overview 505 to numeric 141
stored procedures must be reentrant 560 two operands 140
programs to run under IMS object references 696
must be reentrant 560 UTF-8
overview 517 overview 151
restrictions 517 to alphabetic, alphanumeric 152
simplifying 785 to alphanumeric groups 152
SQL statements two operands 152
overview 506 zoned decimal and alphanumeric, effect of ZWB 431
restriction 506 compatibility
SQLIMS statements Java and COBOL 299
overview 518 object-oriented syntax 299
subclasses compatibility mode 43, 793
example 706 compilation
overview 704 conformance to 85 COBOL Standard 343
tables 67 results 275
techniques 11, 771 with z/OS UNIX files 257
test conditions 96 compilation statistics 458
coding user-defined functions 597 COMPILE compiler option
collating sequence description 355
alternate use NOCOMPILE to find syntax errors 448
choosing 231 compile-time considerations
example 7 compiler-directed errors 281
ASCII 7 display compile and link steps 289
binary for national keys 229 dump, generating a 365
EBCDIC 7 error messages
HIGH-VALUE 7 determining what severity level to produce 369
ISO 7-bit code 7 severity levels 282
LOW-VALUE 7 executing compile and link steps after display 289
MERGE 7, 231 compiler
NATIVE 7 calculation of intermediate results 794
nonnumeric comparisons 7 environment variables under z/OS UNIX 283
ordinal position of a character 118 generating list of error messages 281
SEARCH ALL 7 invoking in the z/OS UNIX
SORT 7, 231 shell
specifying 7 examples 286
STANDARD-1 7 overview 285
STANDARD-2 7 limits
symbolic characters in the 8 DATA DIVISION 11
COLLATING SEQUENCE phrase messages
does not apply to national keys 229 choosing severity to be flagged 450
overrides PROGRAM COLLATING SEQUENCE clause 7, customizing 835
231 determining what severity level to produce 369
use in SORT or MERGE 231 embedding in source listing 450
columns in tables 67 from exit modules 842
comment lines 983 sending to terminal 271
comments severity levels 282, 836
sending xxxv return code
COMMON attribute 4, 554 depends on highest severity 282
Index 1031
compiler (continued) compiler options (continued)
return code (continued) EXIT 367
effect of message customization 837 EXPORTALL 369
overview 282 FASTSRT
compiler data sets performance considerations 779
in the z/OS UNIX file system 256, FLAG 369, 450
261 FLAGSTD 370
input and output 267 for AMODE 64 534
required for compilation 267 for CICS integrated translator 499
SYSADATA (ADATA records) 272 for CICS separate translator 499, 501
SYSDEBUG (debug records) 272 for debugging
SYSIN 269 overview 447
SYSJAVA 272 TEST restriction 446
SYSLIB (libraries) 270 THREAD restriction 446
SYSLIN (object code) 271 HGPR
SYSMDECK (library processing) 273 performance considerations 779
SYSOPTF 270 IMS, recommended for 520
SYSOUT (listing) 271 in effect 466
SYSPUNCH (object code) 271 INITCHECK
SYSTERM (messages) 271 performance considerations 779
with cob2 289 INITIAL 374
Compiler directive INLINE
DATA 540 performance considerations 779
compiler limits INTDATE 375
with AMODE 64 support 534 INVDATA 376
compiler listings JAVAIOP 379
getting 453 LANGUAGE
compiler options description 381
85 COBOL Standard conformance 343 example in batch compilation 279
abbreviations 339 LINECOUNT 381
ADATA 345 LIST 382, 453
ADV 346 LP 383
AFP MAP 384, 452, 453
performance considerations 778 MAXPCF 385
APOST 347 MAXPCF(nnn)
ARCH performance considerations 780
performance considerations 778 MDECK 386
ARITH NAME 387
description 349 NOCOMPILE 448
performance considerations 778 NOFASTSRT 234
AWO NSYMBOL 387
description 350 NUMBER 388, 455
performance considerations 778 NUMCHECK
BLOCK0 performance considerations 780
description 350 NUMPROC 392
performance considerations 779 NUMPROC(PFD)
BUFSIZE 351 performance considerations 780
CICS 352 NUMPROC(PFD|NOPFD) 53
CODEPAGE 353 OBJECT 393
COMPILE 355 OFFSET 393
CONDCOMP 356 on compiler invocation 457
conflicting 344 OPTFILE 394
COPYLOC 356 OPTIMIZE
COPYRIGHT 357 description 395
CURRENCY 358 performance considerations 776, 780
DATA 359 OUTDD 396
DBCS 360 PARMCHECK
DECK 360 performance considerations 780
DEFINE 360 performance considerations 778
DIAGTRUNC 362 PGMNAME 398
DISPSIGN 362 precedence of
DLL 363 example 278
DUMP 365 in batch 278
DYNAM 366, 779 in SYSOPTF data sets 270, 394
1032 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
compiler options (continued) compiler options (continued)
precedence of (continued) ZONEDATA 428
under z/OS 273 ZWB 431
under z/OS UNIX 284 Compiler options
QUALIFY 400 listing example 477
QUOTE 347 compiler output 453
RENT compiler-directing statements
description 401 description 439
performance considerations 780 overview 19
RMODE compiling
description 402 AMODE 64 programs 534, 535, 537–540
performance considerations 781 and binding 335
RULES 403 batch 276
SEQUENCE 405 control of 273
SERVICE 405 data sets for 267
signature information bytes 466 DLLs 286
SMARTBIN from an assembler program 264
performance considerations 781 OO applications
SOURCE 407, 453 cob2 command 291
SPACE 408 example 293, 297
specifying under z/OS UNIX 291
using PROCESS (CBL) 274 using JCL or TSO/E 295
specifying under TSO 275 under TSO
specifying under z/OS 275 example CLIST 264
specifying under z/OS UNIX 284 overview 262
specifying with SYSOPTF data set 270 under z/OS 255
SQL under z/OS UNIX 283
description 408 using shell script 290
using with Db2 509 using the cob2 command
SQLCCSID examples 286
description 409 overview 285
effect on CCSID of string data 510 with cataloged procedures
performance considerations 512 compile 257
recommended with Db2 coprocessor 512 compile and link-edit 258
SQLIMS 410 compile, link-edit, run 259
SSRANGE with JCL (job control language) 255
performance considerations 781 Compiling and binding AMODE 64 programs
status 457 under z/OS UNIX 336
STGOPT 412 Compiling and debugging your program
SUPPRESS 413 Compiling, linking, and running non-OO COBOL/Java
table of 339 interoperable applications 301
TERMINAL 413 compiling and linking in the z/OS UNIX
TEST shell
description 414 DLLs 286
performance considerations 781 examples 286
use for debugging 453 OO applications
THREAD cob2 command 292
debugging restriction 446 example 293
description 418 overview 285
performance considerations 781 compiling user-defined functions 598
TRUNC Compiling, linking, and running non-OO COBOL/Java
description 419 interoperable applications
performance considerations 781 Building and running non-OO applications 301
TUNE Preparing non-OO applications under z/OS UNIX 303
performance considerations 781 completion code
under IMS and CICS 496 merge 231
VBREF 422, 453 sort 231
VLR complex OCCURS DEPENDING ON
description 422 basic forms of 81
VSAMOPENFS 424 complex ODO item 81
WORD 425 variably located data item 81
XMLPARSE 425 variably located group 81
XREF 426, 452 computation
ZONECHECK 427 arithmetic data items 773
Index 1033
computation (continued) control (continued)
of indexes 72 program flow 91
of subscripts 775 transfer 545
COMPUTATIONAL (COMP) 48 control interval size (CISZ), performance considerations 212,
COMPUTATIONAL-1 (COMP-1) 783
format 49 CONTROL statement 439
performance tips 773 converting data items
COMPUTATIONAL-2 (COMP-2) between code pages 116
format 49 between data formats 51
performance tips 773 exceptions with national data 136
COMPUTATIONAL-3 (COMP-3) from binary digits 117
description 49 from hexadecimal digits 117
COMPUTATIONAL-4 (COMP-4) 48 from hexadecimal or binary digits
COMPUTATIONAL-5 (COMP-5) 48 with intrinsic functions 117
COMPUTE statement precision 52
assigning arithmetic results 34 reversing order of characters 114
simpler to code 55 to alphanumeric
computer, describing 5 with DISPLAY 36
concatenating data items (STRING) 103 with DISPLAY-OF 135
CONDCOMP compiler option to binary digits 116
description 356 to Chinese GB 18030 from national 157
condition handling to hexadecimal digits 116
closing QSAM files 179 to hexadecimal or binary digits
closing VSAM files 203 with intrinsic functions 116
in input or output procedures 227 to integers with INTEGER, INTEGER-PART 112
using Language Environment 787 to national
condition testing 96 from Chinese GB 18030 157
conditional compilation output, example 488 from UTF-8 153
conditional expression with ACCEPT 35
EVALUATE statement 91 with MOVE 134
IF statement 91 with NATIONAL-OF 135, 151
PERFORM statement 100 to numbers with NUMVAL, NUMVAL-C 115
conditional statement to uppercase or lowercase
overview 18 with INSPECT 113
with NOT phrase 19 with intrinsic functions 114
with object references 696 to UTF-8
CONFIGURATION SECTION 5 with MOVE 150
conflicting compiler options 344 to UTF-8 from national 153
conformance requirements with INSPECT 112
85 COBOL Standard 343 with intrinsic functions 113
example of passing object references in INVOKE 699 CONVERTING phrase (INSPECT), example 113
RETURNING phrase of INVOKE 700 converting UTF-8 data items
USING phrase of INVOKE 698 to alphanumeric
considerations with DISPLAY-OF 151
for AMODE 64 535, 537–540 coprocessor, Db2
considerations and restrictions CCSID determination of string data 510
for AMODE 31/64 542 differences from the precompiler 513
for AMODE COBOL/JAVA 540 enable with SQL compiler option 509
Constant area 480 overview 505
constants recommended compiler option SQLCCSID 512
data items 772 using SQL INCLUDE with 507
definition 26 coprocessor, IMS
figurative, definition 26 enable with SQLIMS compiler option 519
contained program integration 777 overview 517
CONTENT-CHARACTERS XML event copy libraries
example 659 COPY statement 439
when parsing segments 638 data set 267
continuation example 786
entry 236 search order 440
of program 243 specifying 270
syntax checking 355 SYSLIB 270
CONTINUE statement 91 z/OS UNIX search order 283,
control 288
in nested programs 554 COPY statement
1034 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
COPY statement (continued) data (continued)
description 439 converting between alphanumeric and DBCS 803
example 786 efficient execution 771
nested 786, 828 format conversion of 51
z/OS considerations 270 format, numeric types 46
z/OS UNIX considerations grouping 568
440 incompatible 53
copybook naming 12
description 439 numeric 43
obtaining from user-supplied module 367 passing 563
searching for 288, 440 record size 13
copybook cross-reference, description 452 splitting (UNSTRING) 105
copybooks validating 53
cross-reference 485 DATA 540
using 786 data and procedure-name cross-reference, description 452
COPYLOC compiler option 356 data areas, dynamic 366
COPYRIGHT compiler option 357 DATA compiler option
COUNT IN phrase description 359
UNSTRING 105 influencing data location 41
XML GENERATE 668 multioption interaction 39, 344
counting performance considerations 779
characters (INSPECT) 112 when passing data 41
generated XML characters 664 data compression 765
creating data definition 460
associated-data file 272 data description entry 11
library-processing output file 273 DATA DIVISION
line-sequential files in z/OS 216 client 695
object code 271 coding 11
objects 701 description 11
QSAM files, z/OS 180, 182 entries for line-sequential files 215
SYSJAVA file 272 entries for QSAM files 168
variable-length tables 78 entries for VSAM files 195
cross-reference factory data 708
COPY/BASIS 485 factory method 709
COPY/BASIS statements 453 FD entry 11
copybooks 453 FILE SECTION 11
data and procedure-names 452 GROUP-USAGE NATIONAL clause 68
embedded 453 instance data 685, 706
list 426 instance method 688
program-name 484 items present in 466
special definition symbols 487 limits 11
statement list 422 LINKAGE SECTION 11, 16
statements 453 listing 453
text-names and data sets 452 LOCAL-STORAGE SECTION 11
CRP (file position indicator) 198, 201 mapping of items 384, 453
CURRENCY compiler option 358 OCCURS clause 67
currency signs OCCURS DEPENDING ON (ODO) clause 78
euro 64 REDEFINES clause 75
hexadecimal literals 64 restrictions 11
multiple-character 64 signature information bytes 466
using 64 USAGE clause at the group level 25
CURRENT-DATE intrinsic function USAGE IS INDEX clause 72
example 60 USAGE NATIONAL clause at the group level 133, 150
under CICS 497 WORKING-STORAGE SECTION 11
customer support xxxiii, 1021 data item
alphanumeric with double-byte characters 803
coding Java types 723
D common, in subprogram linkage 566
D-format record concatenating (STRING) 103
layout 171 converting characters (INSPECT) 112
requesting 170 converting characters to numbers 115
DASD (direct-access storage device) 212 converting from hexadecimal or binary digits 117
data converting to hexadecimal or binary digits 116
concatenating (STRING) 103 converting to uppercase or lowercase 114
Index 1035
data item (continued) Db2 (continued)
converting with intrinsic functions 113 coprocessor (continued)
counting characters (INSPECT) 112 CCSID determination of string data 510
DBCS 803 database request module (DBRM) 505, 509
elementary, definition 24 differences from the precompiler 513
evaluating with intrinsic functions 117 enable with SQL compiler option 509
finding the smallest or largest item 118 overview 505
group, definition 24 recommended compiler option SQLCCSID 512
index, referring to table elements with 70 using SQL INCLUDE with 507
initializing, examples of 28 DYNAM compiler option with TSO or IMS 515
map 275 NODYNAM compiler option with CICS or CAF 515
numeric 43 precompiler
reference modification 109 differences from the coprocessor 513
referring to a substring 109 recommended compiler option NOSQLCCSID 512
replacing characters (INSPECT) 112 specifying code page for host variables 507
reversing characters 114 using 506
splitting (UNSTRING) 105 SQL compiler option 509
unused 395, 460 SQL statements
variably located 81 CCSID determination 510
data manipulation coding 506
character data 103 overview 505
DBCS data 803 return codes 509
DATA RECORDS clause 13 SQL DECLARE 507
data set SQL INCLUDE 507
alternate data-set names 264 using binary data in 509
checkpoint record 758 using character data in 507
compiler-option 270 using national decimal data 508
defining with environment variable 164 SQLCCSID compiler option 510
example of checkpoint/restart 762 Db2 precompiler
file, same meaning as 5 using 506
JAVAERR 296 DBCS comparison 95
JAVAIN 296 DBCS compiler option
JAVAOUT 296 description 360
names, alternate 265 for Java interoperability 291, 295
output 271 for OO COBOL 291, 295
source code 269 multioption interaction 345
SYSADATA 272 DBCS data
SYSDEBUG 272 comparing
SYSIN 269 to national 141
SYSJAVA 272 converting
SYSLIB 270 to alphanumeric with IGZCD2A 805
SYSLIN 271 to and from alphanumeric 803
SYSMDECK 273 to national, overview 160
SYSOPTF 270 declaring 158
SYSPRINT 271 encoding and storage 139
SYSPUNCH 271 literals
SYSTERM 271 description 25
data sets used for compiling 267 maximum length 159
data-definition attribute codes 460 using 159
data-name MOVE statement with 32
cross-reference 483 notation for 803
cross-reference list 276 testing for 159
in MAP listing 460 dbg suffix with cob2 290
OMITTED 13 DBRM data set
password for VSAM files 204 defining 509
date and time operations description 505
Language Environment callable services 788 dbrm suffix with cob2 290
date operations DBRMLIB DD statement 505, 509
finding date of compilation 121 DCB 176
DATE-COMPILED paragraph 3 DD control statement
DATE-OF-INTEGER intrinsic function 60 allocating line-sequential files 216
Db2 AMP parameter 208
coding considerations 505 ASCII tape files 187
coprocessor creating QSAM files 180, 182
1036 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
DD control statement (continued) DELETE statement (continued)
DBRMLIB 509 compiler-directing 441
DCB overrides data-set label 181 multithreading serialization 592
define file 8 VSAM, coding 196
defining merge data sets 227 deleting records from VSAM file 203
defining sort data sets 227 delimited scope statement
JAVAERR 296 description of 19
JAVAIN 296 nested 20
JAVAOUT 296 DEPENDING ON clause 170, 196
RLS parameter 209 depth in tables 69
SYSADATA 272 developing
SYSDEBUG 272 AMODE 64 programs 533
SYSIN 269 device
SYSJAVA 272 classes 267
SYSLIB 270 requirements 267
SYSLIN 271 DFHCOMMAREA parameter
SYSMDECK 273 calling nested CICS programs 498
SYSOPTF 270 calling separately compiled CICS programs 497
SYSPRINT 271 DFHEIBLK parameter
SYSPUNCH 271 calling nested CICS programs 498
ddname definition 8 calling separately compiled CICS programs 497
deadlock in I/O error declarative 246 DFSORT
debugging defining data sets for 227
and performance 416 error message for RETURN statement 226
compiler options for diagnostics, program 457
overview 447 DIAGTRUNC compiler option 362
TEST restriction 446 direct-access
THREAD restriction 446 direct indexing 72
defining data set 272 file organization 162
overview 443 storage device (DASD) 212
runtime options for 446 directories
using COBOL language features 444 adding a path to 288
using the debugger 453 disability 971
debugging, language features disabling COBOL runtime options report option
class test 445 DISABLEUOPTREPORT 434
debugging lines 446 DISPLAY (USAGE IS)
debugging statements 446 encoding and storage 139
declaratives 446 external decimal 47
DISPLAY statements 444 floating point 48
file status keys 445 display floating-point data (USAGE DISPLAY) 47
INITIALIZE statements 445 DISPLAY statement
scope terminators 444 directing output 396
SET statements 445 displaying data values 35
WITH DEBUGGING MODE clause 446 displaying on the system logical output device 36
DECK compiler option 360 interaction with OUTDD 36
declarative procedures suppressing line spacing 37
EXCEPTION/ERROR under CICS 496
with multithreading 246 using in debugging 444
USE FOR DEBUGGING 446 writing to stdout or stderr 36
deferred restart 761 DISPLAY-1 (USAGE IS)
DEFINE compiler option 360 encoding and storage 139
defining DISPLAY-OF intrinsic function
debug data set 272 example with Chinese data 157
files, overview 8, 161 example with Greek data 136
libraries 270 example with UTF-8 data 153
line-sequential files to z/OS 216 using 135, 151
QSAM files with XML documents 641
to z/OS 180, 182 DISPSIGN compiler option 362
sort or merge files under z/OS DLL
227 considerations 336
VSAM files DLL compiler option
to z/OS 205 description 363
dek suffix with cob2 290 for Java interoperability 291, 295
DELETE statement for OO COBOL 291, 295
Index 1037
DLL compiler option (continued) dynamic link libraries (continued)
multioption interaction 344 programs with DLL support must be reentrant 560
DLL igzcjava.x search order for in z/OS UNIX file system 584
binding with using CALL identifier with 583
example 297 using with C/C++ programs 587
preparing OO applications 296 using with dynamic calls 584
linking with using with Java interoperability 293
example 293 using with OO 293
preparing OO applications 292
DLL libjvm.x
binding with
E
example 297 E-level error message 282, 450
preparing OO applications 296 EBCDIC
linking with code pages supported in XML documents 640
example 293 converting to ASCII 116
preparing OO applications 292 JNI services 729
with EBCDIC services 730 multibyte CCSIDs supported for DBCS 354
DLLs (see dynamic link libraries) 579 ECI calls and RETURN-CODE special register 498
do loop 100 efficiency of coding 771
do-until 100 EGCS 992
do-while 100 EJECT statement 441
documentation of program 5 embedded cross-reference
DSA memory map 464 description 453
dump example 486
requesting 241 embedded error messages 450
with DUMP compiler option 275 embedded MAP summary 452, 461
DUMP compiler option enclave 545
description 365 encoding
output 275 conflicts in XML documents 647, 648
DYNAM compiler option controlling in generated XML output 668
description 366 description 139
multioption interaction 344 language characters 124
performance considerations 779 of XML documents 640, 641
under Db2 with TSO or IMS 515 of XML documents to be parsed 626
with dynamic calls 548 specifying for alphanumeric XML document 642
dynamic calls specifying with CODEPAGE option 353
example 553 encoding declaration
making 548 preferable to omit 642
performance 552 specifying 643
restrictions 548 end-of-file (AT END phrase) 246
using with DLL linkage 584 END-OF-INPUT XML event
when to use 549 example 659
with static calls 552 when parsing segments 637
dynamic data areas, allocating storage 41 enhancing XML output
dynamic file allocation example of modifying data definitions 674
order of allocation 165 rationale and techniques 673
using CBLQDA 177 ENTER statement 441
using environment variables entry point
line-sequential files 216 alternate 560
QSAM files 180 alternate in ENTRY statement 558
VSAM files 208 ENTRY label 560
dynamic link libraries passing entry addresses of 558
about 579 procedure-pointer data item 558
binder options for DLLs 581 ENTRY statement
compiler options required 286 for alternate entry points 558
compiling 580 handling of program-name in 398
creating ENVAR runtime option 296
from the z/OS UNIX shell ENVIRONMENT DIVISION
286 class 684
overview 579 client 695
creating for OO 292 collating sequence coding 7
for Java interoperability 292 CONFIGURATION SECTION 5
in OO COBOL applications 588 description 5
linking 581 entries for line-sequential files 215
1038 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
ENVIRONMENT DIVISION (continued) error (continued)
entries for QSAM files 167 processing (continued)
entries for VSAM files 191 QSAM files 179
INPUT-OUTPUT SECTION 5 VSAM files 204
instance method 688 XML GENERATE 668
items present in, program initialization code 466 XML PARSE 647
signature information bytes 466 routines for handling 252
subclass 705 error messages
environment variables compiler
_BPX_SHAREAS 529 choosing severity to be flagged 450
_CEE_ENVFILE correcting source 280
description 527 customizing 835
indicating Java settings 296 determining what severity level to produce 369
_CEE_RUNOPTS embedding in source listing 450
description 527 format 281
setting XPLINK 298 from exit modules 842
specifying runtime options 525 generating a list of 281
_IGZ_SYSOUT 527 location in listing 281
allocating line-sequential files 216 sending to terminal 271
and copybooks 439 severity levels 282, 836
CLASSPATH compiler-directed 281
description 527 ESDS (entry-sequenced data sets)
example of setting 296 file access mode 194
specifying location of Java classes 293 organization 192
COBJVMINITOPTIONS euro currency sign 64
description 527 EVALUATE statement
specifying JVM options 294 case structure 93
COBOL_INSTALL_DIR 283 coding 93
COBOPT 283 contrasted with nested IFs 94
compiler 283 example that tests several conditions 95
defining files, example 8 example with multiple WHEN phrases 94
defining QSAM files 180 example with THRU phrase 94
example of setting and accessing 528 performance 94
LIBPATH structured programming 772
description 527 testing multiple values, example 97, 98
example of setting 296 use to test multiple conditions 91
specifying location for COBOL classes 293 evaluating data item contents
library-name 284, 439 class test
PATH for numeric 54
description 527 overview 95
example of setting 296 INSPECT statement 112
runtime 527 intrinsic functions 117
setting and accessing 526 Example: COBPROD application
STEPLIB Example: COBPROD application 308
description 527 exception condition
example 285 CALL 251
SYSLIB XML GENERATE 668
description 283 XML PARSE 647
specifying location of JNI.cpy 291 exception handling
text-name 284, 439 with Java 720
using to allocate files 164 with XML GENERATE 668
environment-name 5 with XML PARSE 645
ERRMSG, for generating list of error messages 281 EXCEPTION XML event 647
error EXCEPTION/ERROR declarative
arithmetic 242 description 246
compiler options, conflicting 344 file status key 248
handling 241 line-sequential error processing 219
handling for I/O 165 QSAM error processing 179
listing 275 VSAM error processing 204
message table EXEC control statement, RD parameter of 760
example using indexing 77 EXIT compiler option
example using subscripting 76 considerations for SQL and CICS statements 844
processing description 367
line-sequential files 219 MSGEXIT suboption 833
Index 1039
EXIT compiler option (continued) factory section, defining 707
register usage 826 FASTSRT compiler option
user-exit work area 825 description 369
using 367 improving sort performance 232, 779
exit modules information message 232
called for SYSADATA data set 832 requirements
calling COBOL programs 826 JCL 232
error messages generated 842 QSAM 233
message severity customization 833 sort input and output files 233
used in place of library-name 827 VSAM 234
used in place of SYSLIB 827 FD (file description) entry 12
used in place of SYSPRINT 830 feedback
EXIT PROGRAM statement sending xxxv
in subprogram 546 figurative constants
with multithreading 546 definition 26
explicit scope terminator 20 HIGH-VALUE restriction 132,
exponentiation 148
evaluated in fixed-point arithmetic 796 national-character 132
evaluated in floating-point arithmetic 800 UTF-8-character 147
performance tips 774 file access mode
EXPORTALL compiler option choosing 162
description 369 dynamic 194
DLL considerations 580 example 195, 435
multioption interaction 344 for indexed files (KSDS) 194
extended mode 43, 793 for relative files (RRDS) 194
external class-name 684, 695 for sequential files (ESDS) 194
EXTERNAL clause performance considerations 211
example for files 573 random 194
for data items 572 sequential 194
for sharing files 12, 573 summary table of 191
external data file allocation 164
obtaining storage for 42 file availability
sharing 572 QSAM files under z/OS
storage location of 42 177
external decimal data VSAM files under z/OS 205
national 47 file description (FD) entry 12
zoned 47 file organization
external file 573 choosing 162
external floating-point data comparison of ESDS, KSDS, RRDS 190
display 47 indexed 161, 192
national 48 line-sequential 215
External symbols 482 overview 161
QSAM 167
relative 162
F relative-record 193
F-format record sequential 161, 192
layout 169 VSAM 190
requesting 168 file position indicator (CRP) 198, 201
factoring expressions 772 FILE SECTION
factory data BLOCK CONTAINS clause 13
defining 708 CODE-SET clause 13
definition of 679 DATA RECORDS clause 13
making it accessible 708 description 11
private 708 EXTERNAL clause 12
factory definition, coding 707 FD entry 12
factory methods GLOBAL clause 12
defining 709 LABEL RECORDS clause 13
definition of 679 LINAGE clause 13
hiding 710 OMITTED 13
invoking 710 RECORD CONTAINS clause 13
using to wrap procedural programs 715 record description 11
FACTORY paragraph RECORD IS VARYING 13
factory data 708 RECORDING MODE clause 14
factory methods 709 VALUE OF 13
1040 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
FILE STATUS clause files (continued)
description 165 sort performance (continued)
example 251 FASTSRT 232
line-sequential error processing 219 variable-length files 228
NOFASTSRT error processing 234 storage of file-definition records 592
QSAM error processing 179 unavailable
using 247 QSAM 177
VSAM error processing 204 VSAM 205
with VSAM status code 248 usage explanation 9
file status code FIPS messages
02 201 categories 836
30 200 FLAGSTD compiler option 370
37 176 fixed-length records
39 177, 183, 186 QSAM
49 203 layout 169
90 175, 179, 204 requesting 168
92 203, 528 VSAM
file status key defining 195
05 198 RRDS 190
35 198 fixed-point arithmetic
39 199 comparisons 63
checking for I/O errors 247 evaluation 62
checking for successful OPEN 247, 248 example evaluations 63
error handling 445 exponentiation 796
set for error handling 165 fixed-point data
used with VSAM status code 248 binary 48
VSAM, importance of in 204 conversions and precision 52
FILE-CONTROL paragraph conversions between fixed- and floating-point 52
example of entries 6 external decimal 47
relation to FD entries 8 intermediate results 795
files packed-decimal 49
associating program files to external files 5 planning use of 772
attributes 183 FLAG compiler option
available compiler output 451
QSAM 177 description 369
VSAM 205 using 450
changing name 9 flags and switches 96
CICS, restrictions under 5 FLAGSTD compiler option
COBOL coding multioption interaction 345
DATA DIVISION entries 168, 195, 215 floating comment indicators (*>) 994
ENVIRONMENT DIVISION entries 167, 191, 215 floating-point arithmetic
input/output statements 176, 196, 217 comparisons 63
overview 163 evaluation 62
data sets, same meaning as 5 example evaluations 63
defining to operating system 8 exponentiation 800
describing 11 floating-point data
external 573 conversions and precision 52
identifying to z/OS 180, 182, 205 conversions between fixed- and floating-point 52
line-sequential, allocating 216 external 47
multithreaded processing intermediate results 800
example 593 internal
recommended organization 593 format 49
recommended usage patterns 593 performance tips 773
serialization 592 planning use of 772
optional format of record
QSAM 177 fixed-length
VSAM 199 defining for VSAM 195
overview 162 layout of QSAM 169
processing requesting for QSAM 168
line-sequential 215 for QSAM ASCII tape 187
QSAM 167 format D
VSAM 189 layout 171
with multithreading 592 requesting 170
sort performance format F
Index 1041
format of record (continued) group item (continued)
format F (continued) cannot subordinate alphanumeric group within national
layout 169 group 137
requesting 168 comparing to national data 142
format S comparing wtih UTF-8 data 152
layout 173 definition 24
overview 172 for defining tables 67
requesting 171 group move contrasted with elementary move 33, 138
format U initializing
layout 174 using a VALUE clause 75
requesting 173 using INITIALIZE 31, 73
format V MOVE statement with 33
layout 171 passing as an argument 568
requesting 170 treated as a group item
spanned example with INITIALIZE 73
layout 173 in INITIALIZE 31
overview 172 variably located 81
requesting 171 group move contrasted with elementary move 33, 138
undefined GROUP-USAGE NATIONAL clause
layout 174 communicating with Java 724
requesting 173 defining a national group 137
variable-length defining tables 68
defining for VSAM 196 example of declaring a national group 24
layout of QSAM 171 initializing a national group 31
requesting for QSAM 170 grouping data to pass as an argument 568
formatted dump 241
freeing object instances 703
function prototype
H
best practices 602 handling JSON null values 614
external name 601 header on listing 5
language standard considerations 603 HEAP runtime option
using 601 influencing data location 41
function-pointer data item multioption interaction 40
addressing JNI services 847 HEX-OF intrinsic function 116
CALL statement 559 HEX-TO-CHAR intrinsic function 117
calling COBOL 559 hexadecimal digits, converting from 117
calling DLL program hexadecimal digits, converting to 116
example 586 hexadecimal literals
calling Language Environment services 559 as currency sign 64
definition 558 national
SET function-pointer 558 description 25
with DLLs 585 using 126
HGPR compiler option
G multioption interaction 344
performance considerations 779
garbage collection 703 hiding factory methods 710
GB 18030 data hierarchy of compiler options
converting to or from national 157 in batch 278
processing 157 in SYSOPTF data sets 394
generating JSON null values 621 under z/OS 273
generating XML output under z/OS UNIX 284
example 669
overview 663
get and set methods 691
I
GETMAIN, saving address of 825 I-level message 282, 450
GLOBAL clause for files 12, 16 IDENTIFICATION DIVISION
global names 557 class 683
Glossary 977 CLASS-ID paragraph 683,
GOBACK statement 705
in main program 546 client 694
in subprogram 546 coding 3
with multithreading 546 DATE-COMPILED paragraph 3
group item errors 3
1042 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
IDENTIFICATION DIVISION (continued) index (continued)
listing header example 5 initializing 72
method 687 key, detecting faulty 250
PROGRAM-ID paragraph 3 range checking 449
required paragraphs 3 referencing other tables with 72
subclass 705 index data item
TITLE statement 5 cannot use as subscript or index 72
IF statement creating with USAGE IS INDEX clause 72
coding 91 indexed file organization
nested 92 description 161
use EVALUATE instead for multiple conditions 92 specifying 192
with null branch 91 indexing
IGZCA2D service routine 803 computation of element displacement, example 70
IGZCD2A service routine 805 definition 70
igzcjava.x example 77
binding with preferred to subscripting 774
example 297 tables 72
preparing OO applications 296 INEXIT suboption of EXIT option
linking with processing of 826
example 293 syntax 368
preparing OO applications 292 inheritance hierarchy, definition of 680
IGZEOPT module INITCHECK compiler option
with multithreading 595 description 373
IGZETUN module invalid COBOL data 449
with multithreading 595 INITIAL attribute
IGZSRTCD data set 236 effect on subprograms 548
IGZUOPT use of dynamic call and CANCEL instead 550
runtime options INITIAL clause
JCL samples 435 effect on main program 547
IGZUOPT and IGZQUOPT runtime option 435 effect on nested programs 4
imperative statement, list 18 setting programs to initial state 4
implicit scope terminator 20 INITIAL compiler option
IMS description 374
COBOL-Java interoperability Initial heap storage map 479
accessing databases 523 INITIALIZE statement
calling COBOL method from Java 521 examples 28
calling Java method from COBOL 522 loading group values 31
messages 523 loading national group values 31
restriction on EXEC SQL 523 loading table values 73
STOP RUN 522 REPLACING phrase 73
synchronizing transactions 523 using for debugging 445
using the AIB 523 initializing
coding programs under a group item
overview 517 using a VALUE clause 75
restrictions 5, 517 using INITIALIZE 31, 73
compiling and linking for 520 a national group item
coprocessor using a VALUE clause 75
overview 517 using INITIALIZE 31, 74
performance considerations 783 a structure using INITIALIZE 31
SQLIMS compiler option 519 a table
SQLIMS statements all occurrences of an element 76
return codes 519 at the group level 75
SQLIMS INCLUDE 518 each item individually 75
using character data in 518 using INITIALIZE 73
using EXEC SQL under IMS 523 using PERFORM VARYING 101
IMS SQL examples 28
coprocessor 518 instance data 701
incrementing addresses 569 variable-length group 80
index inline comments 996
assigning a value to 72 INLINE compiler option
computation of element displacement, example 70 description 375
creating with OCCURS INDEXED BY clause 72 inline PERFORM
definition 70 example 100
incrementing or decrementing 72 overview 99
Index 1043
input Interactive System Productivity Facility (ISPF) 953
coding for CICS 496 interlanguage communication
coding for line-sequential files 217 and PL/I tasking 594
coding for QSAM files 176 between COBOL and Java 719
coding for VSAM files 196 IMS applications 522
from files 161 subprograms 545
to compiler, under z/OS 267 under CICS 497
input procedure with multithreading 594
coding 224 intermediate results 793
example 230 internal floating-point data (COMP-1, COMP-2) 49
FASTSRT option not effective 233 interoperable data types with Java 723
requires RELEASE or RELEASE FROM 224 interrupts 757
restrictions 227 intrinsic functions
INPUT-OUTPUT SECTION 5 as reference modifiers 111
input/output converting alphanumeric data items with 113
checking for errors 247 converting national data items with 113
coding overview 163 evaluating data items 117
controlling with FASTSRT option 369 example of
logic flow after error 243 ANNUITY 61
overview 161 BIT-OF 117
processing errors BIT-TO-CHAR 117
line-sequential files 219 CHAR 118
QSAM files 179, 243 CURRENT-DATE 60
VSAM files 204, 243 DISPLAY-OF 136
input/output coding HEX-OF 116
AT END (end-of-file) phrase 246 HEX-TO-CHAR 117
checking for successful operation 247 INTEGER 112
checking VSAM status codes 248 INTEGER-OF-DATE 60
detecting faulty index key 250 LENGTH 60, 119, 120
error handling techniques 243 LOG 61
EXCEPTION/ERROR declaratives 246 LOWER-CASE 114
INSERT statement 441 MAX 60, 88, 118, 119
INSPECT statement MEAN 61
avoid with UTF-8 data 644 MEDIAN 61, 88
examples 112 MIN 111
using 112 NATIONAL-OF 136
inspecting data (INSPECT) 112 NUMVAL 115
instance NUMVAL-C 60, 115
creating 701 ORD 118
definition of 679 ORD-MAX 88, 119
deleting 703 PRESENT-VALUE 61
instance data RANGE 61, 88
defining 685, 706 REM 61
definition of 679 REVERSE 114
initializing 701 SQRT 61
making it accessible 691 SUM 88
private 685 UPPER-CASE 114
instance methods WHEN-COMPILED 121
defining 686, 706 example of Unicode functions 155
definition of 679 finding date of compilation 121
invoking overridden 701 finding largest or smallest item 118
overloading 690 finding length of data items 120
overriding 690 intermediate results 798, 801
INTDATE compiler option introduction to 38
description 375 nesting 38
effect on calendar starting date 59 numeric functions
INTEGER intrinsic function, example 112 differences from Language Environment callable
INTEGER-OF-DATE intrinsic function 60 services 58
INTEGER-PART intrinsic function 112 equivalent Language Environment callable services
integrated CICS translator 58
advantages 500 examples of 57
compiler options for 499 integer, floating-point, mixed 56
overview 500 nested 57
interactive program, example 953 special registers as arguments 57
1044 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
intrinsic functions (continued) Java (continued)
numeric functions (continued) exception (continued)
table elements as arguments 57 handling 720
uses for 56 throwing 720
processing table elements 87 float array 725
UTF-8 153 float type 724
INVALID KEY phrase global references
description 250 JNI services for 722
example 251 managing 721
INVDATA compiler option object 721
description 376 passing 722
INVOKE statement int array 724
RETURNING phrase 700 int type 724
USING phrase 698 interoperability 719
using to create objects 701 interoperable data types, coding 723
using to invoke methods 697 invoking from a batch COBOL program 734
with ON EXCEPTION 698, 710 jstring class 723
with PROCEDURE DIVISION RETURNING 572 local references
invoking deleting 722
COBOL programs under z/OS 576 freeing 722
COBOL programs under z/OS UNIX 525 JNI services for 722
factory or static methods 710 managing 721
instance methods 697 object 721
Language Environment callable services 789 passing 722
invoking user-defined functions 598 per multithreading 722
ISAM data set, analogous to VSAM KSDS data set 189 saving 722
ISPF (Interactive System Productivity Facility) 953 long array 724
long type 724
methods
J access control 723
J2EE client object array 725
example 731 running with COBOL
running 294 under z/OS UNIX 293
Java using JCL or TSO/E 296
and COBOL XPLINK linkage 298
binding 296 sharing data with 723
communicating between 719 short array 724
compatibility 299 short type 724
compiling under z/OS UNIX 291 string array 725
compiling using JCL or TSO/E 295 strings
linking 292 declaring 724
running 293, 296 manipulating 728
structuring applications 715 Java virtual machine
array classes 723 exceptions 720
arrays initializing 294
declaring 724 object references 721
example 727 java.lang.Object
manipulating 726 referring to as Base 683
boolean array 724 javac command
boolean type 724 compiling Java class definitions 291
byte array 724 recompile for Java 6 or later 299
byte type 724 JAVAERR data set 296
char array 724 JAVAIN data set 296
char type 724 JAVAIOP compiler option
class types 724 description 379
double array 725 JAVAOUT data set 296
double type 724 JCL
example ASCII tape files 187
exception handling 721 cataloged procedures 256
J2EE client 731 example of checkpoint/restart 762
processing an integer array 727 FASTSRT requirement 232
exception for compiling 255
catching 720 for compiling in the z/OS UNIX file system
example 721 257
Index 1045
JCL (continued) JZOS
for line-sequential files 216 example 734
for merge 227 Java Batch Launcher and Toolkit for z/OS
for OO applications 737
example 297
for QSAM files 181
for sort 227
K
for VSAM data sets 208 Kanji comparison 95
JNI Kanji data, testing for 159
accessing services 719 keyboard navigation 971
comparing object references 696 keys
converting local references to global 702 alternate in KSDS file 193
EBCDIC services 729 for binary search 86
environment structure for merging
addressability for 719 defining 229
exception handling services 720 overview 222
Java array services 726 for sorting
Java string services 728 defining 229
obtaining class object reference 720 overview 222
restrictions when using 720 permissible data types
Unicode services 728 in MERGE statement 229
UTF-8 services 731 in OCCURS clause 68
JNI.cpy in SORT statement 229
for compiling 291 prime in KSDS file 192
for JNINativeInterface 719 relative-record 193
listing 847 to specify order of table elements 68
JNIEnvPtr special register keyword 999
use for JNI callable services 719 KSDS (key-sequenced data sets)
JNINativeInterface file access mode 194
environment structure 719 organization 192
JNI.cpy 719
JOB control statement, RD parameter of 760
job resubmission 762 L
job stream 545
LABEL RECORDS clause
JSON document
FILE SECTION entry 13
generating
LANGUAGE compiler option
null values 621
description 381
overview 619
Language Environment callable services
parsing
condition handling 787
description 609
corresponding math intrinsic functions 58
example 615
date and time computations 788
null values 614
differences from intrinsic functions 58
overview 609
dynamic storage services 787
JSON exception codes
example of using 790
for generating 819
feedback code 789
for parsing 819
for date and time 59
JSON generation
for mathematics 58
overview 619
invoking with CALL 789
JSON input
mathematics 788
parsing
message handling 788
example 615
national language support 788
overview 609
omitted feedback code 790
JSON output
overview 787
generating
return code 790
overview 619
RETURN-CODE special register 790
JSON parse
sample list of 788
example 615
types of 787
overview 609
large block interface (LBI) 175
JSON-CODE special register
largest or smallest item, finding 118
exception codes for generating 819
last-used state
exception codes for parsing 819
subprograms with EXIT PROGRAM or GOBACK 547
JSON-STATUS special register
subprograms without INITIAL attribute 548
nonexception reason codes for parsing 819
LBI (large block interface) 175
jstring Java class 723
1046 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
LENGTH intrinsic function line-sequential files (continued)
compared with LENGTH OF special register 121 under z/OS
example 60, 120 allocating 216
using 118 creating 216
variable-length results 119 job control language (JCL) 216
with national data 120 writing to 217
length of data items, finding 120 LINECOUNT compiler option 381
LENGTH OF special register LINK macro 264
passing 564 link-editing user-defined functions 599
using 121 LINKAGE SECTION
level-88 item coding 567
conditional expressions 95 for describing parameters 566
setting switches off, example 99 with recursive calls 16
setting switches on, example 98 with the THREAD option 16
switches and flags 96 linked-list processing, example 570
testing multiple values, example 97 linking in the z/OS UNIX shell
testing single values, example 97 c89 command 285
level-number 460 passing information to cob2 287
LIBEXIT suboption of EXIT option using the cob2 command
processing of 827 DLLs 286
syntax 368 examples 286
libjvm.x overview 285
binding with linking OO applications
example 297 cob2 command 292
preparing OO applications 296 under z/OS UNIX
linking with example 293
example 293 overview 292
preparing OO applications 292 using JCL or TSO/E
with EBCDIC services 730 example 297
LIBPATH environment variable overview 296
description 527 LIST compiler option
example of setting 296 assembler code for source program 464
specifying location for COBOL classes 293 base locator table 481
library compiler output 466, 475
BASIS 270 conflict with OFFSET option 453
COPY 270 Constant area section 480
defining 270 description 382
directory entry 264 DSA memory map 464, 482
specifying path for 439 External symbols section 482
library-name getting output 453
alternative if not specified 288 Initial heap storage map section 479
cross-reference to data-set names 485 MD5 signature example 476
when not used 827 multioption interaction 345
library-name environment variable 284 reading output 464
limits of the compiler special register table 481
DATA DIVISION 11 symbols used in output 463
user data 11 Timestamp and version information example 476
line number 458, 489 List of resources 1021
line-sequential files listing output 453
adding records to 218 listings
blocking 12 assembler expansion of PROCEDURE DIVISION 464
closing 219 data and procedure-name cross-reference 452
closing to prevent reopening 217 embedded error messages 450
control characters in 216 generating a short listing 453
DATA DIVISION entries 215 line numbers, user-supplied 455
ENVIRONMENT DIVISION entries 215 sorted cross-reference of program-names 484
input/output error processing 219 sorted cross-reference of text-names 485
input/output statements for 217 terms used in MAP output 462
national data not supported 218 text-name cross-reference 452
opening 217 literals
organization 215 alphanumeric
processing 215 description 25
reading from 217 with DBCS content 159
reading records from 218 DBCS
Index 1047
literals (continued) MAP compiler option (continued)
DBCS (continued) description 384
description 25 embedded MAP summary 453
maximum length 159 example 459, 464
using 159 nested program map
definition 25 example 464
hexadecimal symbols used in output 463
using 126 terms used in output 462
national using 452, 453
description 25 mapping of DATA DIVISION items 453
using 126 mathematics
numeric 25 intrinsic functions 57, 61
using 25 Language Environment callable services 58, 788
little-endian, converting to big-endian 125 MAX intrinsic function
loading a table dynamically 73 example table calculation 88
local names 556 example with functions 60
local references, converting to global 702 using 118
LOCAL-STORAGE SECTION MAXPCF compiler option 385
client 695, 696 MDECK compiler option
comparison with WORKING- description 386
STORAGE MEAN intrinsic function
example 14 example statistics calculation 61
OO client 696 example table calculation 88
overview 14 MEDIAN intrinsic function
determining location 41 example statistics calculation 61
LOG intrinsic function 61 example table calculation 88
logical record memory map
description 161 DSA 464
fixed-length format merge
defining for VSAM 195 alternate collating sequence 231
requesting for QSAM 168 completion code 231
QSAM, definition 168 criteria 229
variable-length format data sets needed under z/OS 227
defining for VSAM 196 DD statements for defining z/OS data sets
layout for QSAM 171 227
requesting for QSAM 170 description 221
loops determining success 231
coding 99 diagnostic message 231
conditional 100 files, describing 223
do 100 keys
in a table 101 defining 229
performed an explicit number of times 100 overview 222
LOWER-CASE intrinsic function 114 pass control statements to 236
lowercase, converting to 114 process 222
LP compiler option restrictions 221
multioption interaction 344 storage use 236
lst suffix with cob2 290 terminating 232
work files
describing 222
M MERGE statement
main program ASCENDING|DESCENDING KEY phrase 229
accessing parameter list in COLLATING SEQUENCE phrase 7, 231
z/OS description 228
example 576 GIVING phrase 228
overview 576 overview 221
accessing parameter list in z/OS restrictions 221
UNIX USING phrase 228
example 530 message handling, Language Environment callable services
overview 530 788
and subprograms 545 messages
dynamic calls 548 compiler
main storage, allocating to buffers 351 choosing severity to be flagged 450
MAP compiler option customizing 835
data items and relative addresses 275 determining what severity level to produce 369
1048 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
messages (continued) multithreading (continued)
compiler (continued) COBOL programs 589
embedding in source listing 450 coding file I/O
generating a list of 281 example 593
sending to terminal 271 recommended organization 593
severity levels 282, 836 recommended usage patterns 593
compiler-directed 281 serialization 592
from exit modules 842 control transfer 591
sending to SYSTERM 413 ending programs 591
METHOD-ID paragraph 687 EXIT PROGRAM statement 546
methods GOBACK statement 546
constructor 709 I/O error declaratives 246
factory 709 IGZEOPT 595
hiding factory 710 IGZETUN 595
instance 686, 706 interlanguage communication 594
invoking 697, 710 limitations 594
invoking superclass 701 nested programs 594
Java access control 723 older compilers 595
obtaining passed arguments 689 overview 589
overloading 690 preinitializing 591
overriding 690, 710 preparing COBOL programs for 589
returning a value from 689 recursion 591
signature 687 recursive requirement 594
migration considerations reentrancy 594
Java and COBOL 299 reentrancy requirement 594
MIN intrinsic function runtime restrictions 595
example 111 sort and merge restriction 221
using 118 STOP RUN statement 546
Mixed AMODE 537 synchronizing access to resources 594
mixed DBCS/EBCDIC literal terminology 589
alphanumeric to DBCS conversion 803 THREAD compiler option
DBCS to alphanumeric conversion 805 restrictions with 418
mnemonic-name when to choose 590
SPECIAL-NAMES paragraph 5 UPSI switches 595
MOVE statement with PL/I tasks 594
assigning arithmetic results 34
converting to national data 134
converting to UTF-8 data 150
N
CORRESPONDING 33 N delimiter for national or DBCS literals 25
effect of ODO on lengths of sending and receiving items NAME compiler option
78 description 387
group move contrasted with elementary move 33, 138 using 3
with elementary receiving items 32 name declaration
with group receiving items 33 searching for 557
with national items 32 NAMESPACE-DECLARATION XML event 633
MSGEXIT suboption of EXIT option naming
effect on compilation return code 837 files 8
example user exit 837 programs 3
message severity levels 836 NATIONAL (USAGE IS)
processing of 833 external decimal 47
syntax 368 floating point 48
MSGFILE runtime option 396 national comparison 95
multiple currency signs national data
example 65 BYTE-LENGTH intrinsic function and 121
using 64 communicating with Java 724
multiple inheritance, not permitted 682, 704 comparing
multiple thread environment, running in 418 overview 140
multithreading to alphabetic, alphanumeric, or DBCS 141
AMODE setting 595 to alphanumeric groups 142
asynchronous signals 595 to numeric 141
choosing data section two operands 140
in an OO client 696 concatenating (STRING) 103
closing QSAM files 179 converting
closing VSAM files 204 exceptions 136
Index 1049
national data (continued) national group item (continued)
converting (continued) LENGTH intrinsic function and 120
from alphanumeric or DBCS with NATIONAL-OF 135 MOVE statement with 33
from alphanumeric, DBCS, or integer with MOVE overview 133
134 passing as an argument 568
from UTF-8 with NATIONAL-OF 151 treated as a group item
overview 134 example with INITIALIZE 138
to alphanumeric with DISPLAY-OF 135 in INITIALIZE 31
to numbers with NUMVAL, NUMVAL-C 115 in MOVE CORRESPONDING 33
to or from Chinese GB 18030 157 summary 138
to or from Greek alphanumeric, example 136 treated as an elementary item
to or from UTF-8 153 example with MOVE 33
to uppercase or lowercase 114 in most cases 24, 133
to UTF-8 with DISPLAY-OF 151 using
with INSPECT 112 as an elementary item 138
defining 126 overview 137
displaying on output 36 VALUE clause with alphanumeric literal, example 75
encoding in XML documents 641 national language support (NLS)
evaluating with intrinsic functions 117 DBCS 158
external decimal 47 LANGUAGE compiler option 381
external floating-point 48 processing data 123
figurative constants 132 national literals
finding the smallest or largest item 118 description 25
in conditional expressions 140 using 126
in generated XML documents 663 national-edited data
in keys defining 126
in MERGE statement 229 editing symbols 126
in OCCURS clause 68 initializing
in SORT statement 229 example 29
initializing, example of 29 using INITIALIZE 74
input with ACCEPT 35 MOVE statement with 32
inspecting (INSPECT) 112 PICTURE clause 126
LENGTH intrinsic function and 120 NATIONAL-OF intrinsic function
LENGTH OF special register 121 example with Chinese data 157
literals example with Greek data 136
using 126 example with UTF-8 data 153
MOVE statement with 32, 134 using 135, 151
NSYMBOL compiler option if no USAGE clause 126 with XML documents 641
reference modification of 109 nested COPY statement 786, 828
reversing characters 114 nested delimited scope statements 20
specifying 125 nested IF statement
splitting (UNSTRING) 105 coding 92
VALUE clause with alphanumeric literal, example 120 CONTINUE statement 91
national decimal data (USAGE NATIONAL) EVALUATE statement preferred 92
defining 132 with null branches 91
example 43 nested intrinsic functions 57
format 47 nested program integration 777
initializing, example of 30 nested program map
national floating-point data (USAGE NATIONAL) description 453
defining 132 example 464
definition 48 nested programs
national group item calling 554
advantages over alphanumeric groups 133 description 555
BYTE-LENGTH intrinsic function and 121 effect of INITIAL clause 4
can contain only national data 24, 137 guidelines 554
communicating with Java 724 map 453, 464
contrasted with USAGE NATIONAL group 25 scope of names 556
defining 137 transfer of control 554
example 24 nesting level
for defining tables 68 program 458, 464, 489
in generated XML documents 663 statement 458, 489
initializing NEXT SENTENCE statement 92
using a VALUE clause 75 NOCBLCARD translator option 501
using INITIALIZE 31, 74 NOCOMPILE compiler option
1050 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
NOCOMPILE compiler option (continued) numeric data (continued)
use to find syntax errors 448 national decimal (USAGE NATIONAL) 47
NODLL compiler option national floating-point (USAGE NATIONAL) 48
with dynamic calls 548 packed-decimal
with static calls 548 sign representation 53
NODYNAM compiler option USAGE COMPUTATIONAL-3 (COMP-3) 49
under CICS 497 USAGE PACKED-DECIMAL 49
under Db2 with CICS or CAF 515 PICTURE clause 43, 45
with static and dynamic calls 552 storage formats 46
with static calls 548 USAGE DISPLAY 43
with stored procedures 515 USAGE NATIONAL 43
NOFASTSRT compiler option 234, 237 zoned decimal (USAGE DISPLAY)
NORENT compiler option format 47
multioption interaction 345 sign representation 53
NOSQLCCSID compiler option recommended for numeric intrinsic functions
compatibility with Db2 precompiler 512 differences from Language Environment callable
Notices 973 services 58
NSYMBOL compiler option equivalent Language Environment callable services 58
description 387 example of
effect on N literals 25 ANNUITY 61
for DBCS literals 126 CURRENT-DATE 60
for national data items 126 INTEGER 112
for national literals 126 INTEGER-OF-DATE 60
multioption interaction 345 LENGTH 60, 119
null branch 91 LOG 61
null-terminated strings MAX 60, 88, 118, 119
example 108 MEAN 61
handling 568 MEDIAN 61, 88
manipulating 108 MIN 111
NUMBER compiler option NUMVAL 115
description 388 NUMVAL-C 60, 115
for debugging 455 ORD 118
NUMCHECK compiler option ORD-MAX 88
invalid COBOL data 449 PRESENT-VALUE 61
NUMCLS installation option, effect on numeric class test 54 RANGE 61, 88
numeric class test REM 61
checking for valid data 54 SQRT 61
effect of NUMPROC, NUMCLS 54 SUM 88
numeric comparison 95 integer, floating-point, mixed 56
numeric data nested 57
binary special registers as arguments 57
USAGE BINARY 48 table elements as arguments 57
USAGE COMPUTATIONAL (COMP) 48 uses for 56
USAGE COMPUTATIONAL-4 (COMP-4) 48 numeric literals, description 25
USAGE COMPUTATIONAL-5 (COMP-5) 48 numeric-edited data
can compare algebraic values regardless of USAGE 141 BLANK WHEN ZERO clause
comparing to national 141 coding with numeric data 126
converting example 45
between fixed- and floating-point 51 defining 126
precision 52 editing symbols 45
to national with MOVE 134 initializing
to UTF-8 with MOVE 150 examples 30
defining 43 using INITIALIZE 74
display floating-point (USAGE DISPLAY) 47 PICTURE clause 45
editing symbols 45 USAGE DISPLAY
external decimal displaying 45
USAGE DISPLAY 47 initializing, example of 30
USAGE NATIONAL 47 USAGE NATIONAL
external floating-point displaying 45
USAGE DISPLAY 47 initializing, example of 30
USAGE NATIONAL 48 NUMPROC compiler option
internal floating-point affected by NUMCLS 54
USAGE COMPUTATIONAL-1 (COMP-1) 49 description 392
USAGE COMPUTATIONAL-2 (COMP-2) 49 effect on sign processing 53
Index 1051
NUMPROC compiler option (continued) object-oriented COBOL (continued)
performance considerations 780 restrictions (continued)
NUMVAL intrinsic function SQL compiler option 679
description 115 SQL statements 506
NUMVAL-C intrinsic function running
description 115 under z/OS UNIX 293
example 60 using JCL or TSO/E 296
NX delimiter for national literals 25 XPLINK linkage 298
writing OO programs 679
OCCURS clause
O ASCENDING|DESCENDING KEY phrase
o suffix with cob2 289, 290 example 86
object needed for binary search 86
creating 701 specify order of table elements 68
definition of 679 cannot use in a level-01 item 67
deleting 703 defining tables 67
object code for defining table elements 67
compilation and listing 275 INDEXED BY phrase for creating indexes 72
creating 271 nested for creating multidimensional tables 68
generating 355 OCCURS DEPENDING ON (ODO) clause
producing in 80-column record 360 complex 81
OBJECT compiler option for creating variable-length tables 78
description 393 initializing ODO elements 80
multioption interaction 345 ODO object 78
object instances, definition of 679 ODO subject 78
OBJECT paragraph optimization 775
instance data 685, 706 simple 78
instance methods 686 variable-length records
object references QSAM 170
comparing 696 VSAM 196
converting from local to global 702 OCCURS INDEXED BY clause, creating indexes with 72
example of passing 699 ODO object 78
setting 697 ODO subject 78
typed 696 OFFSET compiler option
universal 696 description 393
OBJECT-COMPUTER paragraph 5 multioption interaction 345
object-oriented COBOL output 487
binding OMITTED clause, FILE SECTION 13
example 297 OMITTED parameters 790
overview 296 OMITTED phrase for omitting arguments 567
calls to and from OO programs 557 ON EXCEPTION phrase
communicating with Java 723 INVOKE statement 698, 710
compatibility 299 OPEN statement
compiling file availability 177, 198, 217
under z/OS UNIX 291 file status key 247
using JCL or TSO/E 295 line-sequential files 217
DLLs in 588 multithreading serialization 592
IMS QSAM files 176
accessing databases 523 VSAM files 196
calling COBOL method from Java 521 opening files
calling Java method from COBOL 522 line-sequential 217
linking multithreading serialization 592
example 293 QSAM 177
overview 292 VSAM
preparing applications empty 199
under z/OS UNIX 292 overview 198
using JCL or TSO/E 296 OPTFILE compiler option 394
programs must be reentrant 560 optimization
restrictions avoid ALTER statement 772
cannot run under CICS 495 BINARY data items 773
CICS 679 consistent data 773
EXEC CICS statements 679 constant data items 772
EXEC SQL statements 679 contained program integration 777
sort and merge 221 effect of compiler options on 777
1052 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
optimization (continued) overriding (continued)
effect on parameter passing 566 factory methods 710
effect on performance 771 instance methods 690
factor expressions 772
index computations 775
indexing 774
P
nested program integration 777 packed decimal data 388
OCCURS DEPENDING ON 775 packed-decimal data item
out-of-line PERFORM 772 description 49
packed-decimal data items 773 sign representation 53
performance implications 775 synonym 46
procedure integration 777 using efficiently 49, 773
structured programming 771 page
subscript computations 775 control 178
subscripting 774 depth 13
table elements 774 paragraph
top-down programming 772 definition 18
unreachable code 777 grouping 101
unused data items 395, 460 parameters
OPTIMIZE compiler option accessing from main program in
description 395 z/OS
effect on parameter passing 566 example 576
performance considerations 776, 780 overview 576
optimizer accessing from main program in z/OS
overview 776 UNIX
optional files example 530
QSAM 177 overview 530
VSAM 199 ADEXIT 832
options describing in called program 566
runtime 431 INEXIT 826
ORD intrinsic function, example 118 LIBEXIT 829
ORD-MAX intrinsic function MSGEXIT 834
example table calculation 88 PRTEXIT 831
using 119 PARMCHECK compiler option
ORD-MIN intrinsic function 119 invalid COBOL program 449
order of evaluation parse data item, definition 626
arithmetic operators 56, 794 parsing JSON documents 609
compiler options 344 parsing XML documents
out-of-line PERFORM 99 description 625
OUTDD compiler option one segment at a time
DD not allocated 36 example 658
description 396 overview 637
interaction with DISPLAY 36 overview 624
output UTF-8 644
coding for CICS 496 white space 641
coding for line-sequential files 217 with validation
coding for QSAM files 176 example 660
coding for VSAM files 196 overview 634
data set 271 performance considerations 635
from compiler, under z/OS 268 restrictions 635
to files 161 XML declaration 641
output files with cob2 289 passing arguments BY CONTENT to user-defined functions
output procedure 599
coding 225 passing data between programs
example 226, 230 addresses 569
FASTSRT option not effective 233 arguments in calling program 565
requires RETURN or RETURN INTO 225 BY CONTENT 563
restrictions 227 BY REFERENCE 563
overflow condition BY VALUE
CALL 251 overview 563
joining and splitting strings 242 restrictions 566
UNSTRING 105 EXTERNAL data 572
overloading instance methods 690 JNI services 720
overriding OMITTED arguments 567
Index 1053
passing data between programs (continued) performance (continued)
options considerations 41 compiler option (continued)
parameters in called program 566 RENT 780
RETURN-CODE special register 571 RMODE 781
with Java 723 SMARTBIN 781
password SQLCCSID 512
alternate index 205 SSRANGE 781
example 205 TEST 781
VSAM files 204 THREAD 419, 781
PASSWORD clause 204 TRUNC 419, 781
PATH environment variable TUNE 781
description 527 consistent data types 773
example of setting 296 data usage 773
path name effect of compiler options on 777
for copybook search 288, 439 effects of buffer size 351
PERFORM statement exponentiations 774
coding loops 99 FASTSRT 232
for a table IMS environment 520, 783
example using indexing 77 OCCURS DEPENDING ON 775
example using subscripting 76 optimizer
for changing an index 72 overview 776
inline 99 order of WHEN phrases in EVALUATE 94
out-of-line 99 out-of-line PERFORM compared with inline 99
performed an explicit number of times 100 parsing XML documents with validation 635
TEST AFTER 100 programming style 771
TEST BEFORE 100 sorting with FASTSRT 232
THRU 101 striped extended-format QSAM data sets 185
TIMES 100 table handling 775
UNTIL 100 table searching
VARYING 101 binary compared with serial 84
VARYING WITH TEST AFTER 101 improving serial search 85
WITH TEST AFTER . . . UNTIL 100 tape, QSAM 175
WITH TEST BEFORE . . . UNTIL 100 tuning 771
performance variable subscript data format 71
AIXBLD runtime option 783 VSAM files 211, 783
and debugging 416 worksheet 782
APPLY WRITE-ONLY clause 10 period as scope terminator 20
arithmetic evaluations 772 PGMNAME compiler option
arithmetic expressions 773 COMPAT suboption 398
blocking QSAM files 174, 350 description 398
calls 552 LONGMIXED suboption 399
CBLPSHPOP considerations 503 LONGUPPER suboption 399
CBLPSHPOP runtime option 503 phrase, definition of 18
CICS physical block 161
overview 771 physical record 14, 161
CICS coding 783 PICTURE clause
coding for 771 cannot use for internal floating point 44
coding tables 774 determining symbol used 358
compiler option incompatible data 53
AFP 778 N for national data 126
ARCH 778 national-edited data 126
ARITH 778 numeric data 43
AWO 778 numeric-edited data 126
BLOCK0 779 Z for zero suppression 45
DYNAM 779 PL/I tasking
FASTSRT 779 POSIX runtime option 594
HGPR 779 with COBOL 594
INITCHECK 779 pointer data item
INLINE 779 description 39
MAXPCF 780 incrementing addresses with 569
NUMCHECK 780 NULL value 569
NUMPROC 53, 780 passing addresses 569
OPTIMIZE 776, 780 processing chained lists 569
PARMCHECK 780 used to process chained list 570
1054 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
porting applications PROCESS (CBL) statement (continued)
effect of separate sign 44 specifying compiler options 274
POSIX processing
calling APIs 528 chained lists
threads 594 example 570
POSIX runtime option overview 569
effect on DLL search order 584 tables
use in OO applications 296 example using indexing 77
precedence example using subscripting 76
arithmetic operators 56, 794 processing JSON input 609
CICS options 499 producing JSON output 619
compiler options producing XML output 663
in batch 278 product support xxxiii, 1021
in SYSOPTF data sets 270, 394 program
under z/OS 273 attribute codes 464
under z/OS UNIX 284 compiling and linking using cob2
copybook search order 283 DLLs 286
preferred sign 53 examples 286
preinitializing the COBOL environment overview 285
with multithreading 591 compiling under z/OS 255
PRESENT-VALUE intrinsic function 61 compiling under z/OS UNIX 283
preserving original sequence in a sort 231 decisions
priority numbers, segmentation 778 EVALUATE statement 91
procedure and data-name cross-reference, description 452 IF statement 91
PROCEDURE DIVISION loops 100
additional information 466 PERFORM statement 100
client 694 switches and flags 96
description 17 developing for z/OS UNIX 525
in subprograms 568 diagnostics 457
instance method 689 initialization code 475
RETURNING limitations 771
to return a value 17 main 545
using 572 nesting level 458, 489
s present in 466 reentrant 560
signature information bytes 466 restarting 760
statements signature information bytes 466
compiler-directing 19 statistics 458
conditional 18 structure 3
delimited scope 19 subprogram 545
imperative 18 PROGRAM COLLATING SEQUENCE clause
terminology 17 does not affect national or DBCS operands 7
USING establishing collating sequence 7
BY VALUE 568 overridden by COLLATING SEQUENCE phrase 7
to receive parameters 17, 566 overrides default collating sequence 231
procedure integration 777 Program information
procedure-pointer data item listing example 477
calling C/C++ 559 program processing table 497
calling JNI services 559 Program prolog area
definition 558 listing example 478
entry address for entry point 558 program termination
passing parameters to callable services 558 actions taken in main and subprogram 546
SET procedure-pointer 558 statements 546
with DLLs 585 PROGRAM-ID paragraph
process coding 3
definition 589 COMMON attribute 4
PROCESS (CBL) statement INITIAL clause 4
batch compiling 278 program-names
conflicting options in 344 avoid using certain prefixes 3
overview 441 cross-reference 484
precedence handling of case 398
in batch 278 specifying 3
under z/OS 273 protecting VSAM files 204
under z/OS UNIX PRTEXIT suboption of EXIT option
284 processing of 830
Index 1055
PRTEXIT suboption of EXIT option (continued) READ statement (continued)
syntax 368 multithreading serialization 592
publications 1021 QSAM 176
VSAM 196
reader comments
Q sending xxxv
QSAM files reading records
adding records to 178 block size 174
ASCII tape file 187 from line-sequential files 218
ASSIGN clause 167 reading records from VSAM files
attributes 183 dynamically 201
BLOCK CONTAINS clause 174, 350 randomly 201
block size 174, 350 sequentially 201
blocking enhances performance 174, 350 reason code from XML parsing 645, 809
blocking records 174, 186 record
closing 179 description 11
closing to prevent reopening 177 format
DATA DIVISION entries 168 fixed-length QSAM 168, 169
ENVIRONMENT DIVISION entries 167 fixed-length VSAM 195
FASTSRT requirements 233 format D 170, 171, 187
input/output error processing 179, 243 format F 168, 169, 187
input/output statements for 176 format S 171–173
obtaining buffers for 186 format U 173, 174, 187
opening 177 format V 170, 171, 187
processing QSAM ASCII tape 187
existing files 184 spanned 171–173
in reverse order 177 undefined 173, 174
new files 185 variable-length QSAM 170, 171
overview 167 variable-length VSAM 196
z/OS UNIX files 186 order, effect of organization on 161
replacing records 178 RECORD CONTAINS clause
retrieving 182 FILE SECTION entry 13
striped extended-format 185 RECORD KEY clause
tape performance 175 identifying prime key in KSDS files 192
under z/OS RECORDING MODE clause
creating files 180, 182 fixed-length records, QSAM 168
DD statement for 180, 182 QSAM files 14
defining 180, 182 specify record format 168
environment variable for 180 variable-length records, QSAM 170, 171
file availability 177 recursive calls
job control language (JCL) 181 and the LINKAGE SECTION 16
updating files 178 coding 557
using same input/output file under FASTSRT identifying 4
233 REDEFINES clause, making a record into a table using 75
writing to a printer 178 reentrant programs 560
QUALIFY compiler option 400 reference modification
QUOTE compiler option 347 example 110
expression checking with SSRANGE 411
generated XML documents 664
R intrinsic functions 109
national data 109
railroad track diagrams, how to read xxxi
out-of-range values 110
random numbers, generating 58
tables 71, 109
RANGE intrinsic function
UTF-8 documents 153
example statistics calculation 61
reference modifier
example table calculation 88
arithmetic expression as 111
RCFs
intrinsic function as, example 111
sending xxxv
variables as 110
RD parameter of JOB or EXEC statement 760
registers used by EXIT compiler option 826
READ INTO for format-V VSAM files 196
relation condition 95
READ NEXT statement 196
relative file organization 162
READ statement
RELEASE FROM statement
AT END phrase 246
compared to RELEASE 224
line-sequential files 217
example 224
1056 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
RELEASE statement restrictions (continued)
compared to RELEASE FROM 224 subscripting 71
with SORT 224 resubmitting a job 762
REM intrinsic function 61 return code
RENT compiler option compiler
description 401 depends on highest severity 282
for DLLs 580 effect of message customization 837
for IMS 520 overview 282
for Java interoperability 291, 295 feedback code from Language Environment services
for OO COBOL 291, 295 790
influencing addressability 41 from CICS ECI 498
multioption interaction 40, 344 from Db2 SQL statements 509
performance considerations 780 from XML parsing 645, 809
when passing data 41 RETURN-CODE special register 572, 790
REPLACE statement VSAM files
Db2 considerations 513 description 248
description 441 example 249
replacing RLS mode 210
data items (INSPECT) 112 when control returns to operating system 572
records in QSAM file 178 RETURN statement
records in VSAM file 203 required in output procedure 225
text, Db2 considerations 513 with INTO phrase 226
REPLACING phrase (INSPECT), example 112 RETURN-CODE special register
REPOSITORY paragraph calls to Language Environment services 790
class 684 CICS ECI calls 498
client 695 considerations for Db2 509
coding 5 not set by INVOKE 698
subclass 705 passing data between programs 572
representation sharing return codes between programs 571
data 53 when control returns to operating system 572
sign 53 RETURNING phrase
RERUN clause CALL statement 572
checkpoint/restart 237 INVOKE statement 700
reserved-word table, CICS PROCEDURE DIVISION header 572, 689
alternate REVERSE intrinsic function 114
overview 502 reverse order of tape files 177
specifying with WORD 425 reversing characters 114
residency mode, definition 39 REWRITE statement
restart multithreading serialization 592
automatic 760 QSAM 176
automatic or deferred 757 VSAM 196
deferred 761 RLS parameter 209
overview 757 RMODE
restarting a program 760 description 39
restrictions of EXIT modules 826
CICS RMODE compiler option
16 MB line 496 description 402
calls 497 influencing addressability 40
coding 495 multioption interaction 40
files 5 performance considerations 781
OUTDD compiler option 396 when passing data 41
parsing with validation using FILE 635 ROUNDED phrase 794
separate translator 500 rows in tables 69
sorting 238 RRDS (relative-record data sets)
Db2 coprocessor 510 file access mode 194
IMS fixed-length records 190, 194
16 MB line 496 organization 193
coding 5, 517 performance considerations 212
IMS SQL coprocessor 519 simulating variable-length records 194
input/output procedures 227 variable-length records 190, 194
OO programs 679 RULES compiler option
SQL compiler option 510 description 403
SQL statements 506 run time
SQLIMS compiler option 519
Index 1057
run time (continued) scope terminator
accessing arguments in aids in debugging 444
z/OS explicit 19, 20
example 576 implicit 20
overview 576 SD (sort description) entry, example 223
accessing arguments in z/OS SEARCH ALL statement
UNIX binary search 86
example 530 example 86
overview 530 for changing an index 72
changing file-name 9 table must be ordered 86
multithreading restrictions 595 search order
performance 771 DLLs in the z/OS UNIX file system
run unit 584
description 545 SEARCH statement
role in multithreading 589 example 85
Running for changing an index 72
COBOL AMODE 64 applications 337 nesting to search more than one level of a table 85
running OO applications serial search 85
under z/OS UNIX searching
overview 293 for name declarations 557
XPLINK linkage 298 tables
using JCL or TSO/E 296 binary search 86
XPLINK linkage 298 overview 84
runtime performance 84
options 431 serial search 85
runtime option section
AMODE3164 541 declarative 21
runtime options definition 18
85 COBOL Standard conformance 343 grouping 101
AIXBLD 783 segmentation 778
ALL31 550 SELECT clause
CBLOPTS 576 ASSIGN clause 8
CBLPSHPOP 503 naming files 8
DEBUG 446 vary input-output file 9
ENVAR 296 SELECT OPTIONAL
MSGFILE 396 QSAM 177
POSIX VSAM 199
DLL search order 584 SELF 697
use in OO applications 296 sentence, definition of 18
specifying under z/OS 576 separate CICS translator
specifying under z/OS UNIX 525 compiler options for 499, 501
TRAP restrictions 500
closing files in QSAM 179 using 501
closing files in VSAM 203 separate sign
closing line-sequential files 219 for line-sequential files 218
ON SIZE ERROR 242 portability 44
XPLINK printing 44
not recommended as a default 298 required for signed national decimal 44
setting 298 SEQUENCE compiler option 405
sequential file organization 161
sequential search
S description 85
S-format record example 85
layout 173 sequential storage device 162
overview 172 serial search
requesting 171 description 85
S-level error message 282, 450 example 85
sample JCL serialization of files with multithreading 592
COBOL-calls-java 324 SERVICE compiler option 405
sample JCL 314 SERVICE LABEL statement 441
sample programs 949 SET condition-name TO TRUE statement
scope of names example 100, 101
global 557 switches and flags 98
local 556 SET statement
1058 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
SET statement (continued) sort (continued)
for changing an index 72 diagnostic message 231
for changing index data items 72 FASTSRT compiler option
for function-pointer data items 557 improving performance 232
for object references 697 requirements 233
for procedure-pointer data items 557 using same QSAM file for input and output 233
for setting a condition, example 98 files, describing 223
handling of program-name in 398 input procedures
using for debugging 445 coding 224
setting example 230
index data items 72 keys
indexes 72 defining 229
switches and flags 98 overview 222
sharing NOFASTSRT compiler option 234
data output procedures
between separately compiled programs 572 coding 225
coding the LINKAGE SECTION 567 example 226, 230
from another program 16 pass control statements to 236
in recursive or multithreaded programs 16 performance
in separately compiled programs 16 FASTSRT 232
overview 563 variable-length files 228
parameter-passing mechanisms 563 preserving original sequence 231
passing arguments to a method 698 process 222
PROCEDURE DIVISION header 568 restrictions 221
RETURN-CODE special register 571 restrictions on input/output procedures 227
returning a value from a method 700 special registers 235
scope of names 556 storage use 236
with Java 723 terminating 232
files under CICS 238
scope of names 556 variable-length records 227
using EXTERNAL clause 12, 573 work files
using GLOBAL clause 12 describing 222
short listing, example 455 workspace 237
sign condition SORT statement
testing sign of numeric operand 95 ASCENDING|DESCENDING KEY phrase 229
SIGN IS SEPARATE clause COLLATING SEQUENCE phrase 7, 231
for line-sequential files 218 description 228
portability 44 GIVING phrase 228
printing 44 overview 221
required for signed national decimal data 44 restrictions 221
sign representation 53 restrictions for CICS applications 238
signature under CICS
definition of 687 change reserved-word table
must be unique 687 503
signature information bytes USING phrase 228
compiler options in effect 466 SORT-CONTROL special register 235
DATA DIVISION 466 SORT-CORE-SIZE special register 235
ENVIRONMENT DIVISION 466 SORT-FILE-SIZE special register 235
PROCEDURE DIVISION 466 SORT-MESSAGE special register 235
size of printed page, control 178 SORT-MODE-SIZE special register 235
skip a block of records 174 SORT-RETURN special register
SMARTBIN compiler option determining sort or merge success 231
performance considerations 781 terminating sort or merge 232
softcopy information xxxiii SORTCKPT DD statement 237
sort sorting
alternate collating sequence 231 tables
checkpoint/restart 237 overview 87
completion code 231 SOURCE and NUMBER output, example 458
controlling behavior of 235 source code
criteria 229 compiler data set 269
data sets needed under z/OS 227 line number 458, 460, 464, 489
DD statements for defining z/OS data sets 227 listing, description 453
description 221 program listing 275
determining success 231 SOURCE compiler option
Index 1059
SOURCE compiler option (continued) SQLCA (continued)
description 407 declare for programs that use SQLIMS statements 518
getting output 453 return codes from Db2 509
SOURCE-COMPUTER paragraph 5 SQLCCSID compiler option
SPACE compiler option 408 description 409
spanned files 172 effect on CCSID of string data 510
spanned record format performance considerations 512
description 171 recommended with Db2 coprocessor 512
layout 173 SQLIMS compiler option
requesting 171 restrictions
special feature specification 5 compiling in batch 519
special register using 519
ADDRESS OF SQLIMS statements
use in CALL statement 564 coding
arguments in intrinsic functions 57 overview 518
JNIEnvPtr EXIT compiler option and 844
use for JNI callable services 719 SQLIMS INCLUDE 518
LENGTH OF 121, 564 SQRT intrinsic function 61
RETURN-CODE 571 SSRANGE compiler option
SORT-RETURN description 411
determining sort or merge success 231 performance considerations 781
terminating sort or merge 232 reference modification 110
using in XML parsing 627, 629 using 449
WHEN-COMPILED 121 STACK runtime option
XML-CODE 627, 630 influencing data location 41
XML-EVENT 627, 629 multioption interaction 40
XML-INFORMATION 627 STANDARD clause, FD entry 13
XML-NAMESPACE 628, 633 START statement
XML-NAMESPACE-PREFIX 628, 633 multithreading serialization 592
XML-NNAMESPACE 628, 633 VSAM 196
XML-NNAMESPACE-PREFIX 628, 633 statement
XML-NTEXT 627, 632 compiler-directing 19
XML-TEXT 627, 632 conditional 18
special register table 481 definition 18
SPECIAL-NAMES paragraph delimited scope 19
coding 5 explicit scope terminator 20
QSAM files 187 imperative 18
Specifying implicit scope terminator 20
COBOL only runtime options 337 nesting level 458, 489
COBOL runtime options 432 statement cross-reference listing
splitting data items (UNSTRING) 105 description 453
SQL compiler option statements used in program 453
description 408 static calls
restrictions example 553
compiling in batch 510 making 548
OO programs 679 performance 552
using 509 with dynamic calls 552
SQL statements static data areas, allocating storage 41
CCSID determination 510 static data, definition of 679
coding static methods
overview 506 definition of 679
restriction 506 invoking 710
EXIT compiler option and 844 statistics intrinsic functions 61
overview 505 status code, VSAM files
restrictions 506 description 248
return codes 509 example 249
SQL DECLARE 507 stderr
SQL INCLUDE 507 controlling line spacing 37
use for Db2 services 505 directing with DISPLAY 36
using binary data in 509 setting DISPLAY to 527
using character data in 507 stdin
using national decimal data 508 reading with ACCEPT 35
SQLCA stdout
declare for programs that use SQL statements 506 controlling line spacing 37
1060 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
stdout (continued) subscripting (continued)
directing with DISPLAY 36 restrictions 71
setting DISPLAY to 527 use data-name or literal 71
STEPLIB environment variable variable, example 70
description 527 substitution character 132
example of specifying compiler 285 substrings
STGOPT compiler option 412 of table elements 109
STOP RUN statement reference modification of 109
in main program 546 SUM intrinsic function, example table calculation 88
in subprogram 546 SUPER 701
with multithreading 546 support xxxiii, 1021
storage SUPPRESS compiler option 413
character data 139 switch-status condition 95
device switches and flags
direct-access 162 defining 97
sequential 162 description 96
for arguments 565 resetting 98
management with Language Environment callable setting switches off, example 99
services 787 setting switches on, example 98
mapping 453 testing multiple values, example 97
use during sort 236 testing single values, example 97
Storage 479 SYMBOLIC CHARACTERS clause 8
stride, table 775 symbolic constant 772
STRING statement syntax diagrams, how to read xxxi
example 104 syntax errors
overflow condition 242 finding with NOCOMPILE compiler option 448
using 103 SYSABEND file
with DBCS data 803 description 268
strings SYSADATA
handling 103 file, creating 272
Java output 345
declaring 724 records, exit module 832
manipulating 728 SYSADATA file
null-terminated 568 description 268
striped extended-format QSAM file 185 example 853
structure, initializing using INITIALIZE 31 file contents 851
structured programming 772 record descriptions 854
structuring OO applications 715 record types 852
structuring user-defined functions 597 SYSDEBUG data set
subclass defining 272
coding use of 415
example 706 SYSDEBUG file
overview 704 description 268
instance data 706 SYSIN data set
subprogram defining 269
and main program 545 description 267
definition 563 SYSJAVA file
description 545 defining 272
linkage description 268
common data items 566 SYSLIB data set
PROCEDURE DIVISION in 568 defining 270
termination description 267
effects 546 when not used 827
subscript SYSLIB environment variable
definition 70 description 283
literal, example 70 specifying location of JNI.cpy 291
range checking 449 SYSLIN data set
variable, example 70 description 268
subscripting SYSMDECK file
definition 70 defining 273
example 76 description 268
literal, example 70 SYSMDUMP file
reference modification 71 description 268
relative 71 SYSOPTF data set
Index 1061
SYSOPTF data set (continued) table (continued)
defining 270 sorting
description 267 overview 87
SYSPRINT data set stride computation 775
defining 271 subscript, definition 70
description 268 three-dimensional 69
when not used 830 two-dimensional 69
SYSPUNCH data set variable-length
description 268, 271 creating 78
requirements for DECK compiler option 360 example of loading 80
system date initializing 80
under CICS 497 preventing overlay in 83
system dump 241 TALLYING phrase (INSPECT), example 112
system-determined block size tape files
compiler data sets 269 performance 175
QSAM files 175, 350 reverse order 177
system-name 5 TERMINAL compiler option 413
SYSTERM data set terminal, sending messages to the 413
defining 271 terminating XML parsing 649
description 268 termination 546
sending messages to 413 terminology
SYSUDUMP file VSAM 189
description 268 terms used in MAP output 462
SYSUT data set 267 test
conditions 100
data 95
T numeric operand 95
table UPSI switch 95
assigning values to 74 TEST AFTER 100
columns 67 TEST BEFORE 100
compare to array 39 TEST compiler option
defining with OCCURS clause 67 description 414
definition 67 multioption interaction 345
depth 69 performance considerations 781
description 39 use for debugging 453
dynamically loading 73 text-name cross-reference, description 452
efficient coding 774, 775 text-name environment variable 284
elements 67 THREAD compiler option
identical element specifications 774 and the LINKAGE SECTION 16
index, definition 70 cannot use with nested programs 555
initializing description 418
all occurrences of an element 76 for Java interoperability 291, 295
at the group level 75 for OO COBOL 291, 295
each item individually 75 multioption interaction 345
using INITIALIZE 73 performance considerations 781
using PERFORM VARYING 101 threading
loading values in 73 and preinitialization 591
looping through 101 control transfer 591
multidimensional 68 ending programs 591
one-dimensional 67 z/OS UNIX considerations
processing with intrinsic functions 87 525
redefining a record as 75 TITLE statement
reference modification 71 controlling header on listing 5
referencing substrings of elements 109 top-down programming
referencing with indexes, example 70 constructs to avoid 772
referencing with subscripts, example 70 TRACK OVERFLOW option 176
referring to elements 70 Trademarks 975
rows 69 transferring control
searching between COBOL and non-COBOL programs 545
binary 86 between COBOL programs 547, 554
overview 84 called program 545
performance 84 calling program 545
sequential 85 main and subprograms 545
serial 85 nested programs 555
1062 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
transforming COBOL data to XML USAGE clause (continued)
example 669 incompatible data 53
overview 663 INDEX phrase, creating index data items with 72
TRAP runtime option NATIONAL phrase at the group level 133
closing line-sequential files 219 OBJECT REFERENCE 696
closing QSAM files 179 UTF-8 phrase at the group level 150
closing VSAM files 203 USE FOR DEBUGGING declaratives
ON SIZE ERROR 242 overview 446
troubleshooting USE statement 442
COBOL/Java interoperability 329 user exit routine
TRUNC compiler option DFSORT 237
description 419 user-defined condition 95
performance considerations 781 user-defined functions
suboptions for separate CICS translator 501 coding 597
TSO compiling 598
ALLOCATE command 262 invoking 598
CALL command 262 link-editing 599
compiling under passing arguments BY CONTENT 599
example CLIST 264 specifying external names 599
overview 262 structuring 597
SYSTERM for compiler messages 271 using 597, 601
TUNE compiler option user-exit work area 825
performance considerations 781 using function prototype 601
tuning considerations, performance 777, 778 USING phrase
typed object references 696 INVOKE statement 698
PROCEDURE DIVISION header 568, 689
using user-defined functions 597, 601
U UTF-16
u suffix with cob2 290 definition 125
U-format record encoding for national data 125
layout 174 UTF-8
requesting 173 'U' pic symbol 142
U-level error message 282, 450 avoid INSPECT 644
unavailable files avoid moves that truncate 644
QSAM 177 avoid reference modification with XML documents 153
VSAM 205 Character-data 144
UNBOUNDED groups converting to or from national 153
processing 88 data items 142
undefined record format Db2 considerations 147
layout 174 definition 125
QSAM 187 DYNAMIC LENGTH 142
requesting 173 dynamic-length 142
unfilled tracks 176 encoding and storage 139
Unicode encoding for ASCII invariant characters 125
description 124 example of generating an XML document 665
encoding and storage 139 fixed byte-length 142
JNI services 728 fixed character-length 142
processing data 123 intrinsic functions supported 146
using with Db2 507 JNI services 731
universal object references 696 literals 144
UNIX parsing XML documents 644
calling APIs 528 PICTURE 142
unreachable code 777 processing data items 153
UNSTRING statement statements supported 145
example 106 using intrinsic functions 153
overflow condition 242 UTF-8 data
using 105 comparing
with DBCS data 803 overview 151
updating VSAM records 201 to alphabetic, alphanumeric 152
UPPER-CASE intrinsic function 114 to alphanumeric groups 152
uppercase, converting to 114 two operands 152
UPSI switches with multithreading 595 converting
USAGE clause from alphanumeric or national with MOVE 150
at the group level 25 overview 150
Index 1063
UTF-8 data (continued) VBREF compiler option
converting (continued) description 422
to national with NATIONAL-OF 151 output example 488
figurative constants 147 using 453
in conditional expressions 151, 152 VLR compiler option
MOVE statement with 150 description 422
using Unicode intrinsic functions 155 VSAM
UTF-8 data items dynamic access
reference modifiers 148 option 434
UTF-8 data types 142 VSAM files
UTF-8 group item adding records to 202
advantages over alphanumeric groups 149 allocating with environment variable 208
overview 149 closing 203
treated as an elementary item coding input/output statements 196
in most cases 149 comparison of file organizations 190
creating alternate indexes 206
DATA DIVISION entries 195
V deleting records from 203
V-format record ENVIRONMENT DIVISION entries 191
layout 171 error processing 243
requesting 170 extended addressability 212
validating XML documents file position indicator (CRP) 198, 201
example 660 file status key 204
overview 634 input/output error processing 204
performance considerations 635 loading
restrictions 635 dynamically or randomly 199
VALUE clause extended format 200
alphanumeric literal with national data, example 120 sequentially 199
alphanumeric literal with national group, example 75 with access method services 200
assigning table values opening
at the group level 75 empty 199
to each item individually 75 overview 198
to each occurrence of an element 76 performance considerations 211
assigning to a variable-length group 80 processing files 189
cannot use for external floating point 48 protecting with password 204
initializing internal floating-point literals 44 reading records from 201
large literals with COMP-5 49 record-level sharing (RLS)
large, with TRUNC(BIN) 420 error handling 210
VALUE IS NULL 569 overview 209
VALUE OF clause 13 preventing update problems 210
variable restrictions 210
as reference modifier 110 replacing records in 203
definition 23 status codes
variable-length records description 248
OCCURS DEPENDING ON (ODO) clause 775 example 249
QSAM under z/OS
layout 171 defining data sets 205
requesting 170 file availability 205
sorting 227 JCL 208
VSAM RLS mode 209
defining 196 updating records 201
RRDS 190 VSAM terminology
variable-length table BDAM data set 189
assigning values to 80 comparison to non-VSAM terms
creating 78 189
example 79 ESDS for QSAM 189
example of loading 80 KSDS for ISAM 189
preventing overlay in 83 RRDS for BDAM 189
variables, environment VSAMOPENFS compiler option 424
example of setting and accessing 528
library-name 439 W
runtime 527
variably located data item 81 W-level message 282, 450
variably located group 81 WHEN phrase
1064 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
WHEN phrase (continued) XML document (continued)
EVALUATE statement 93 generating (continued)
SEARCH ALL statement 86 example 669
SEARCH statement 85 overview 663
WHEN-COMPILED intrinsic function 121 handling parsing exceptions 645
WHEN-COMPILED special register 121 national language 641
white space in XML documents 641 parser 624
with AMODE 64 programs parsing
POINTER data items 533 description 625
WITH DEBUGGING MODE clause example 650, 654, 658
for debugging lines 446 large documents 639
for debugging statements 446 one segment at a time 637
WITH POINTER phrase UTF-8 644
STRING 103 parsing with validation
UNSTRING 105 example 660
WORD compiler option overview 634
description 425 performance considerations 635
multioption interaction 345 restrictions 635
recommended for CICS integrated translator 499 processing 623
recommended for CICS separate translator 501 specifying encoding if alphanumeric 642
work data sets for compiling 267 white space 641
WORKING-STORAGE SECTION XML declaration 641
client 695, 696 XML event
comparison with LOCAL- CONTENT-CHARACTERS
STORAGE example 659
example 14 when parsing segments 638
OO client 696 encoding conflicts 647, 648
overview 14 END-OF-INPUT
factory data 708 example 659
instance data 685, 706 when parsing segments 637
instance method 688 EXCEPTION 647
multithreading considerations 696 fatal errors 647
storage location for data 359 NAMESPACE-DECLARATION 633
workspace overview 629
use during sort 237 processing 624, 627
wrapper, definition of 715 processing procedure 625
wrapping procedure-oriented programs 715 XML exception codes
write a block of records 174 for generating 817
WRITE ADVANCING statement 178 for parsing 809
WRITE statement for parsing with XMLPARSE(COMPAT)
line-sequential files 217 handleable 811
multithreading serialization 592 not handleable 814
QSAM 176 for parsing with XMLPARSE(XMLSS) 809
VSAM 196 XML GENERATE statement
COUNT IN 668
NAME 666
X NAMESPACE 665
x suffix with cob2 289, 290 NAMESPACE-PREFIX 665
XML declaration NOT ON EXCEPTION 667
generating 665 ON EXCEPTION 668
specifying encoding declaration 643 SUPPRESS 666
white space cannot precede 641 TYPE 667
XML document WITH ATTRIBUTES 664
accessing 625 WITH ENCODING 668
code pages supported 640 XML-DECLARATION 665
controlling the encoding of 668 XML generation
EBCDIC special characters 643 controlling type of XML data 667
encoding 640, 641 counting generated characters 664
enhancing description 663
example of modifying data definitions 674 enhancing output
rationale and techniques 673 example of modifying data definitions 674
events rationale and techniques 673
example 654 example 669
generating generating attributes 664
Index 1065
XML generation (continued) XML-CODE special register (continued)
generating elements 664 continuation after nonzero value 648
handling errors 668 control flow between parser and processing procedure
ignored data items 664 630
naming attributes or elements 666 description 627
no byte order mark 668 exception codes for generating 817
overview 663 exception codes for parsing 809
suppressing generation of specified attributes or exception codes for parsing with XMLPARSE(COMPAT)
elements 666 encoding conflicts 646
using namespace prefixes 665 handleable 811
using namespaces 665 not handleable 814
XML output exception codes for parsing with XMLPARSE(XMLSS)
controlling the encoding of 668 809
enhancing fatal errors 647
example of modifying data definitions 674 reason code 645, 809
rationale and techniques 673 return code 645, 809
generating setting to -1 630, 649
example 669 setting to 1 637
overview 663 subtracting 100,000 from 648
XML PARSE statement terminating parsing 649
NOT ON EXCEPTION 626 using in generating 667
ON EXCEPTION 626 using in parsing 623
overview 624 with code-page conflicts 647
using 625 with encoding conflicts 648
XML parser with generating exceptions 668
error handling 647 with parsing exceptions 647
overview 624 XML-EVENT special register
XML parsing content 629, 649
control flow with processing procedure 630 description 627
description 625 using 623, 627
fatal errors 647 with parsing exceptions 647
handling encoding conflicts 647, 648 XML-INFORMATION special
handling exceptions 645 register
one segment at a time content 632
example 658 description 627
overview 637 XML-NAMESPACE special register
overview 623 content 633
reason code 645, 809 description 628
return code 645, 809 using 623
special registers 627, 629 XML-NAMESPACE-PREFIX special register
terminating 649 content 633
with validation description 628
example 660 using 623
overview 634 XML-NNAMESPACE special register
performance considerations 635 content 633
restrictions 635 description 628
XML processing procedure using 623
control flow with parser 630 XML-NNAMESPACE-PREFIX special register
error with EXIT PROGRAM or GOBACK 628 content 633
example description 628
one segment at a time 658 using 623
parsing with validation 660 XML-NTEXT special register
program for processing XML 650 content 632
handling encoding conflicts 648 description 627
handling parsing exceptions 645 using 623
multiple segments 637 with parsing exceptions 647
restriction on XML PARSE 628 XML-TEXT special register
setting XML-CODE in 648 content 632, 649
specifying 625 description 627
using special registers 627, 629 using 623
writing 627 with parsing exceptions 647
XML schemas 636 XMLPARSE compiler option
XML-CODE special register choosing the parser 623
content 630 description 425
1066 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
XPLINK linkage convention in OO applications 298 z/OS UNIX file system (continued)
XPLINK runtime option search order for DLLs in 584
not recommended as a default 298 writing files with DISPLAY 36
setting 298 zero suppression
XREF compiler option example of BLANK WHEN ZERO clause 45
description 426 PICTURE symbol Z 45
finding copybook data sets 452 zlib 765
finding data- and procedure-names 452 ZONECHECK compiler option 427
getting output 453 zoned decimal data (USAGE DISPLAY)
XREF output effect of ZWB on comparison to alphanumeric 431
COPY/BASIS cross-references 485 example 43
data-name cross-references 483 format 47
program-name cross-references 484 sign representation 53
ZONEDATA compiler option 428
ZWB compiler option 431
Z
z/OS
accessing main parameters under
example 576
overview 576
compiling under 255
running programs under 576
z/OS Debugger
compiler options for 453
description 443
z/OS UNIX
accessing environment variables
example 528
overview 526
accessing main parameters under
example 530
overview 530
compiler environment variables 283
compiling from script 290
compiling OO applications
example 293
overview 291
compiling under 283
copybook search order 283, 288, 440
copybooks 440
developing programs 525
execution environments 525
linking OO applications
example 293
overview 292
preparing OO applications
example 293
overview 292
programs must be reentrant 560
restrictions 525
running OO applications
overview 293
XPLINK linkage 298
running programs 525
setting environment variables
example 528
overview 526
sort and merge restriction 221
specifying compiler options 284
z/OS UNIX file system
compiler data sets 257
defining file with environment variable 164
processing files with QSAM 186
reading file with ACCEPT 35
Index 1067
1068 Enterprise COBOL for z/OS: Enterprise COBOL for z/OS 6.4 Programming Guide
IBM®
SC27-8714-03