Previous Topic: RECORD ELEMENT SubstatementNext Topic: REMOVE ALL Substatement


COBOL Substatement

The COBOL substatement creates a record-element structure using an approximation of standard COBOL syntax. Elements named in COBOL substatements need not exist in the dictionary.

Syntax

COBOL element substatement

►►─── level-number  element-name ─────────────────────────────────────────────►

 ►─┬────────────────────────────────┬─────────────────────────────────────────►
   └─ REDefines base-element-name ──┘

 ►─┬───────────────────────┬──────────────────────────────────────────────────►
   └─ PICture is picture ──┘

   ┌──────────────────────────────────────────────────────────────────────────
 ►─▼─┬────────────────────────────────────────────────────────────────────────►─
     └─┬─ VALue is ───┬─┬───────┬─────────────────────────────────────────────
       └─ VALues are ─┘ └─ ALL ─┘

  ─────────────────────────────────────────────────────────────────────────┐
─►───────────────────────────────────────────────────────────────────────┬─┴──►
  ─┬─────┬┬ initial-value ──────────────────────────────────────┬┬─────┬─┘
   └─ ( ─┘└ condition-value ─┬────────────────────────────────┬─┘└─ ) ─┘
                             └ THRu ─┬─────┬ condition-value ─┘
                                     └ ALL ┘

 ►─┬───────────────────────────────────────┬──────────────────────────────────►
   └─ USAge is ─┬─ DISplay ◄ ────────────┬─┘
                ├─┬─ COMPUTATIONAL ───┬──┤
                │ ├─ COMP ────────────┤  │
                │ ├─ COMPUTATIONAL-4 ─┤  │
                │ ├─ COMP-4 ──────────┤  │
                │ └─ BINary ──────────┘  │
                ├─┬─ COMPUTATIONAL-1 ─┬──┤
                │ ├─ COMP-1 ──────────┤  │
                │ └─ SHOrt-point ─────┘  │
                ├─┬─ COMPUTATIONAL-2 ─┬──┤
                │ ├─ COMP-2 ──────────┤  │
                │ └─ LONg-point ──────┘  │
                ├─┬─ COMPUTATIONAL-3 ─┬──┤
                │ ├─ COMP-3 ──────────┤  │
                │ └─ PACked ──────────┘  │
                ├─ POInter ──────────────┤
                ├─ BIT ──────────────────┤
                └─ CONdition-name ───────┘

   ┌──────────────────────────────────────────────────────────────────────────
 ►─▼─┬────────────────────────────────────────────────────────────────────────►─
     └─ ELement name SYNonym is element-synonym ──────────────────────────────

  ──────────────────────────────────────────────────────────────────────────┐
─►─────────────────────────────────────────────────────────────────────────┬┴─►
  ─┬─────────────────────────────────────────────────────────────────────┬─┘
   └ FOR RECord synonym record-synonym ─┬───────────────────────────────┬┘
                                        └ Version is ┬ version-number ─┬┘
                                                     ├ HIGhest ────────┤
                                                     └ LOWest ─────────┘

 ►─┬─────────────────────────┬────────────────────────────────────────────────►
   └─┬─ JUStify ───┬─ right ─┘
     └─ JUStified ─┘

 ►─┬───────────────────┬──────────────────────────────────────────────────────►
   └─ BLAnk when ZERo ─┘

 ►─┬───────────────────────────────────────────────────┬──────────────────────►
   └─ SIGn is ─┬─ LEAding ──┬─┬──────────────────────┬─┘
               └─ TRAiling ─┘ └─ SEParate character ─┘

 ►─┬─────────────────────────────┬────────────────────────────────────────────►
   └─ SYNChronized ──┬─ LEFt ──┬─┘
                     └─ RIGht ─┘

 ►─┬──────────────────────────────────────────────────────────────────────────►─
   └─ OCCurs ─────────────────────────────────────────────────────────────────

─►───────────────────────────────────────────────────────────────────┬────────►
  ─┬─ occurrence-count times ────────────────────────────────────────┤
   ├─ occurrence-count times DEPending on control-element-name ──────┤
   └─ 0 TO occurrence-count times DEPending on control-element-name ─┘

 ►─┬─────────────────────────────────────────────────────────────────────┬────►
   └─ INDexed by ─┬─ index-element-name ───────────────────────────────┬─┘
                  │     ┌──────────────────────┐                       │
                  ├─ ( ─▼─ index-element-name ─┴─ ) ───────────────────┤
                  └─ FOR RECord synonym record-synonym-specification ──┘

(expanded record-synonym-specification syntax follows this syntax diagram)

 ►─┬──────────────────────────────────────────────────────────────────────────►─
   └─ INDex KEY is ─┬─ index-element-name ─┬─ ASCending ──┬─────────────┬─────
                    │                      └─ DEScending ─┘             │
                    │     ┌───────────────────────────────────────┐     │
                    └┬───┐▼─ index-element-name ─┬─ ASCending ──┬─┴┬───┬┘
                     └─(─┘                       └─ DEScending ─┘  └─)─┘

─►─┬────────────────────────────────────────────────────────────────┬─────────►
   └─┬─ ASCending ──┬─ key is ─┬─ index-element-name ─────────────┬─┘
     └─ DEScending ─┘          │     ┌──────────────────────┐     │
                               └─ ( ─▼─ index-element-name ─┴─ ) ─┘

 ►─┬───────────────────────────────────────────────────────────────────┬──────►
   │                                   ┌────────────────────────┐      │
   └─ EDIt ─┬─ VALid ◄ ─┬─ TABle is ( ─▼─ value ┬─────────────┬─┴─ ) ──┘
            └─ INValid ─┘                       └ THRu value ─┘

   ┌─────────────────────────────────────────────────────────────┐
 ►─▼─┬─────────────────────────────────────────────────────────┬─┴────────────►
     │                   ┌──────────────────────────────┐      │
     └─ CODe TABle is ( ─▼─ encode-value  decode-value ─┴─ ) ──┘

 ►─┬────────────────────────────────┬─────────────────────────────────────────►
   └─ EXTernal PICture is picture ──┘

   ┌───────────────────────────────────────────────────────────────┐
 ►─▼─┬───────────────────────────────────────────────────────────┬─┴──────────►
     │                            ┌────────────────────┐         │
     └─ EDIt ─┬─ COMments ──────┬─▼─ edit-instruction ─┴─ QUIT ──┘
              ├─ DEFinition ────┤
              ├─ OLQ header ────┤
              ├─ CULprit header ┤
              └─ comment-key ───┘

   ┌──────────────────────────────────────────────────┐
 ►─▼─┬──────────────────────────────────────────────┬─┴───────────────────────►◄
     └─┬─ COMments ───────┬─ is ─┬─ NULl ─────────┬─┘
       ├─ DEFinition ─────┤      └─ comment-text ─┘
       ├─ OLQ header ─────┤
       ├─ CULprit header ─┤
       └─ comment-key ────┘

Expansion of record-synonym-specification

►►─┬──────────────────────────────────────────────────────────────────────────►─
   └─ record-synonym-name ─┬──────────────────────────────────┬───────────────
                           └─ Version is ─┬ version-number ┬──┘
                                          ├ HIGhest ───────┤
                                          └ LOWest ────────┘

─►───────────────────────────────────────────┬────────────────────────────────►◄
  ─── is ─┬─ index-element-name ───────────┬─┘
          │     ┌─────────────────────┐    │
          └─ ( ─▼─ index-element-name ┴─ )─┘

Parameters

level-number element-name

Specifies the level number and name of the COBOL element. Level-n must be an unsigned integer in the range 02 through 49, or 88. Note that the 01-level name is the record name itself or a synonym. Element-name must be the 1- through 32-character name of the element. The specified name will be appended with a prefix or suffix if any record synonyms associated with the record have been assigned prefixes or suffixes.

REDefines base-element-name

Specifies an alternative description for a previously defined element. The requested element is assigned the same storage space as base-element-name. Note that a redefined element cannot be defined with an OCCURS clause; it can, however, be subordinate to an element defined with an OCCURS clause.

PICture is picture

Describes the format of the COBOL element. The maximum length of a COBOL element (including its usage) is 32,767 characters. Picture must be a 1- through 30-character value specified as shown in the table under Usage.

VALue is/VALues are initial-value/condition-value

Specifies a value, range of values, or a list of values assigned to a COBOL level-88 condition-name. A list of values must be enclosed in parentheses. Each value in the list must be separated from the next value by a space or comma. A value can be a 1- through 32-character value specified as shown in the list under the bold heading Usage.

USAge is

Specifies the method of storing elementary item values at program runtime.

DISplay

Specifies that values are stored one character to a byte according to EBCDIC conventions. DISPLAY is the default.

COMPUTATIONAL

Numeric values are stored in binary format; COMP, COMPUTATIONAL-4, COMP-4, and BINary are synonyms for COMPUTATIONAL.

COMPUTATIONAL-1

Numeric values are stored in internal floating point (short precision) format; COMP-1 and SHOrt-point are synonyms for COMPUTATIONAL-1.

COMPUTATIONAL-2

Numeric values are stored in internal floating point (long precision) format. COMP-2 and LONg-point are synonyms for COMPUTATIONAL-2.

COMPUTATIONAL-3

Numeric values are stored in packed decimal format; COMP-3 and PACked are synonyms for COMPUTATIONAL-3.

BIT

Values are stored one bit at a time as 0s or 1s. BIT cannot be used in COBOL programs.

POInter

Fullword address constant.

CONdition-name

COBOL level-88 values. CONDITION-NAME is assumed if the level number specified for the record element is 88.

ELement name SYNonym is element-synonym

Establishes a synonym (alternative name) for the COBOL element. Element-synonym is the 1- to 32-character synonym name. The specified name will be appended with a prefix or suffix if a prefix or suffix has been defined for the associated record-synonym name. This clause can be specified once for each record synonym associated with the record.

FOR RECord synonym record-synonym

Associates the element synonym with the designated record synonym.

Note: If the FOR RECORD SYNONYM parameter is not specified, the ELEMENT NAME SYNONYM clause applies only to the primary record name.

JUStify right

Specifies that the COBOL element's value is to be right justified at runtime.

BLAnk when ZERo

Specifies that when the COBOL element's values contains all zeroes it is to be changed to spaces at runtime.

SIGn is LEAding/TRAiling

Specifies whether the sign for a numeric field is to appear in the leading or trailing position.

SEParate character

Specifies that the sign is to appear as a separate byte.

SYNChronized LEFt/RIGht

Determines whether boundary alignment is to be defined for the named COBOL element. The correct alignment is determined by the USAGE specification. If the element's usage is COMP or COMP-4, the DDDL compiler issues a warning message if the element is not on the proper boundary alignment. This clause is documentation only, unless the DMLC precompiler is used to copy the record; in this case, the specified boundary alignment will be applied by the COBOL compiler. If the COBOL element is copied into a schema, it causes a critical schema error.

OCCurs

Specifies a record-specific OCCURS clause for the named COBOL element.

occurrence-count times

Specifies the number of times the element can occur within the record. Occurrence-count must be an integer in the range 0 through 32,767.

occurrence-count times/0 TO occurrence-count times DEPending on control-element-name

Defines a control element within the record that determines the actual number of times the COBOL element will occur. Occurrence-count must be an integer in the range 1 through 32,767. Control-element-name specifies a previously defined field in the record; this field must be a halfword or fullword binary item if the record is to be used in a schema or by CA ADS.

INDexed by

Specifies one or more indexes for a multiply-occurring element or for a record synonym associated with the named COBOL element.

The INDEXED BY clause can be specified once for each record element or subordinate element and record synonym; the index element name is appended with a prefix or suffix as appropriate. The INDEXED BY clause applies only to records used in COBOL programs and should be specified only when the named element definition contain on OCCURS or OCCURS DEPENDING ON clause. The specified index name is copied into the program's DATA DIVISION by the DMLC precompiler as part of the COPY IDMS function.

index-element-name

Specifies an INDEXED BY name for the named COBOL element. The specified value must be a 1- through 32-character name that does not duplicate an existing element or element-synonym name.

FOR REcord synonym record-synonym is index-element-name

Specifies an INDEXED BY name for a record synonym associated with the record element. Index-element-name is a 1- through 32-character name that cannot duplicate an element or element-synonym name in the record.

INDex KEY is

Specifies one or more index keys through one of the following options; note that each option is functionally the same.

INDex KEY is index-element-name ASCending/DEScending

Specifies a record-specific index key for the record element or subordinate record element. Index-element-name identifies an elementary element that is subordinate to the associated element and must be the primary name of the record element. ASCENDING or DESCENDING specifies the manner in which the subordinate element values will be ordered within the multiply-occurring group.

ASCending/DEScending key is index-element-name

Specifies one or more record-specific index keys for the multiply-occurring group element or subordinate element and defines the manner in which subordinate element values will be ordered within the multiply-occurring group. Index-element-name must be the primary name of an element that is subordinate to the named group element. The named element and the ASCENDING/DESCENDING specification govern the ordering of values of the subordinate element within the multiply-occurring group. Each index element name is prefixed or suffixed for each record synonym associated with the element.

EDIt VALid/INValid TABle is value THRu value

Specifies a single value or range of values to be inserted in the edit table (for DC/UCF tables only). Each value can have a maximum size of 34 characters and must be enclosed in parentheses; for example:

('A' 'B' 'D' 'F' 'R' THRU 'T' 'V' 'X' THRU 'Z')
VALid/INValid

Identifies the supplied list as a list of valid values or a list of invalid values. The default is VALID.

CODe TABle is encode-value decode-value

Specifies values to be inserted in the table in pairs (for DC/UCF tables only). The first or encoded value can have a maximum size of 34 characters; the second or decoded value can have a maximum of 64 characters. Null values ('') and the keywords NOT FOUND are also valid. The specified values must be enclosed in parentheses. For example:

('CA' 'CALIFORNIA' 'NY' 'NEW YORK')

For detailed information about defining code tables, refer to the CA IDMS Mapping Facility Guide manual.

EXTernal PICture is picture

Defines the display format for record-element data. The picture is available to all map fields that use the record element. For more information about external pictures, refer to the CA IDMS Mapping Facility Guide manual.

Usage

COBOL substatement considerations

The following considerations apply to the COBOL substatement:

Specifying a picture variable

Picture must be a 1- through 30-character value that describes the types of data shown in the following table.

Category

Character

Description

Alphanumeric data

X

Represents one alphanumeric character. If USAGE IS BIT, X represents one bit; the USAGE clause is described in the parameters list.

 

(n)

An integer in parentheses after an X

Represents n repetitions of the alphanumeric character; for example, X(4) is equivalent to XXXX.

Alphabetic data

A

Represents one alphabetic character (A-Z).

 

(n)

An integer in parentheses after an A

Represents n repetitions of the alphabetic character

Numeric data

9

Represents one numeric character.

 

(n)

An integer in parentheses after a 9

Represents n repetitions of the numeric character.

 

V

Represents an assumed decimal point. No more than one V can appear in an element picture. If the V is omitted and the P option (described below) is not used, the assumed decimal point is after the rightmost 9.

 

P

Represents an assumed zero. Any number of Ps can appear in the leftmost or the rightmost positions of an element picture. An assumed decimal point is automatically placed before the first P or after the last P. The character P does not occupy a storage position (for example, PP9999 has a data length of 4).

 

S

Identifies the number as positive or negative. When used, the S must be the first character in the element picture. When the S is omitted, values for the element description are assumed to be positive.

Numeric- edited data

(Includes the numeric data characters described above, along with the editing characters shown at the right)

 

Z

+

,

B

CR

-

0

DB

*

$

.

Represent edit symbols used in reporting data; quotation marks are not required. Refer to the appropriate programming language manual for the individual interpretations of these symbols.

If the SET OPTIONS statement specifies DECIMAL-POINT IS COMMA, a period (.) is interpreted as an insertion character and a comma (,) is interpreted as a decimal point.

Valid values for the VALUE clause

Valid types of values for the VALUE clause are as follows: