Working with unbounded tables and groups
You can process an unbounded group as the input parameter to a called program. The memory for the unbounded group is provided by the calling program. Alternatively, you can define, initialize, and process unbounded groups in a single program.
About this task
- In the
LINKAGE SECTION, define an unbounded table (with the syntax ofOCCURS n TO UNBOUNDED), which will be part of an unbounded group. - In the
WORKING-STORAGE SECTIONorLOCAL-STORAGE SECTION, define theOCCURS DEPENDING ONobjects. - In the
PROCEDURE DIVISION, do these steps to process unbounded groups:- Set the
OCCURS DEPENDING ONobjects. - Use the
LENGTHspecial register or theLENGTHintrinsic function to compute the total size of the group. - Use the
CALLstatement to call a storage allocation service, such as the Language Environment® serviceCEEGTST. Allocate enough memory for the total length of the group. You will need a pointer to this memory (theCEEGTSTservice returns a pointer). - Use the
SETstatement to establish addressability. For example,SET ADDRESS OF group TO pointer.
- Set the
- 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 CONTENTargument in aCALLstatement. - You cannot specify unbounded groups as data-name-2 on
the
PROCEDURE DIVISION RETURNINGphrase. - You cannot specify unbounded groups as arguments to intrinsic
functions, except as an argument to the
LENGTHintrinsic function.
- You cannot specify unbounded groups as a
Related references
Example: Using unbounded tables for parsing XML documents
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)
Example: Using unbounded tables for parsing XML documents
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)