Previous Topic: UsesNext Topic: Copied Code Parameters


Implied Subscript Parameters

Purpose

Provides an alternative name for a multiply-occurring input or work field.

Syntax

      Col
      2
      ▼
►►─┬─ nn ─┬─ 15 ──────────────────────────────────────────────────────────────►
   └─ GW ─┘

 ►─┬─ reference-field-name base-field-name-expression ─┬─────────────┬─┬──────►◄
   │                                                   └─ increment ─┘ │
   └─ GROUP group-id ─┬─ subscript-value ───────┬──────────────────────┘
                      └─ subscript-field-name ──┘

Expansion of Base-field-name-expression

►►─── base-field-name ─┬─────────────────────────┬────────────────────────────►◄
                       ├─ .subscript-value ──────┤
                       └─ .subscript-field-name ─┘

Syntax Rules

nn

Identifies the report with which the implied subscript field is associated. Nn must be a 2-digit number in the range 00 through 99 and must be coded starting in column 2.

GW

Indicates that the implied subscript work field is available to all reports in the run. GW must be coded starting in column 2.

15

Identifies the parameter as an implied subscript definition. The value must be coded in columns 4 and 5. Column 6 must remain blank.

reference-field-name

Is the alternative name for a specific occurrence of a multiply-occurring field. The name can consist of letters, numbers, or hyphens. The following rules apply to specifying reference-field-name:

base-field-name-expression

Is the name of the multiply-occurring field. See expansion of base-field-name-expression below:

base-field-name

Specifies the name of a multiply-occurring input field defined on a REC parameter that specifies the keyword ELMNT, or a multiply-occurring work field defined on a work field definition parameter.

subscript-value

Is a numeric literal that identifies a specific occurrence of base-field-name; for example, EMPLOYEE-NUM.2 specifies the second occurrence of EMPLOYEE-NUM.

subscript-field-name

Is the name of a singly-occurring numeric input field or work field that identifies an occurrence of base-field-name; for example, if INDX has a value of 2, EMPLOYEE-NUM.INDX specifies the second occurrence of EMPLOYEE-NUM. The subscript field definition must not specify a decimal point.

Subscript-value and subscript-field-name must be separated from base-field-name by a period (.). The value of the subscript should be in the range 1 to n, where n is the number of repetitions of the field name. The value of the subscript can be tested in procedure logic.

CA Culprit treats a reference to reference-field-name as though it were a reference to base-field-name-expression, as illustrated in the following example:

13510001 EMP-NUM
1315 EMP-NUM  EMPLOYEE-NUM.INDX

In the above example, a reference to EMP-NUM on a type 5 edit parameter implies a reference to a specific occurrence of EMPLOYEE-NUM depending on the value on INDX.

increment

Is a numeric literal that is added to the subscript value before an occurrence of base-field-name is referenced. Increment must be in the range 1 through 4095; the total of the increment plus the subscript value must not exceed the number of occurrences of base-field-name.

The value of the subscript remains unchanged; therefore, one occurrence of the multiply-occurring field can be referenced relative to another occurrence of the same field.

GROUP

Establishes a common subscripting field for a group of multiply-occurring input fields.

An implied subscript parameter that specifies the keyword GROUP replaces a reference to an alternative field name defined on an implied subscript parameter that specifies reference-field-name. If the GROUP implied subscript option is specified, members of a group of multiply-occurring fields must not be referenced with explicit subscripts for the report for which the implied subscript parameter is defined. GROUP identifies an implied subscript parameter that establishes an index for all members of a group of multiply-occurring input fields. Any reference to an element within the group is interpreted at run time as a reference to the subscripted element. Only one type 15 parameter may be coded for each REC parameter that specifies the keyword GROUP in each report.

group-id

Identifies the associated group, as coded on a REC parameter that specifies GROUP. Group-id must be a 2-byte alphanumeric literal that must be unique for the run.

subscript-value

Is a numeric literal that is the explicit subscript associated with the group.

subscript-field-name

Is the name of a singly-occurring numeric work field whose value is the explicit subscript associated with the group. The subscript field definition must not specify a decimal point.

The value of the subscript should be in the range 1 to n, where n is the number of group repetitions. The subscript value can be tested in procedure logic.

CA Culprit treats a reference to an element within the group as though it were a reference to the field name subscripted by subscript-value or subscript-field-name, as shown in the example below:

REC EMP-INFO 20  GROUP  AA 10.5
REC EMP-ID   1 3 ELMNT  AA
13510010 EMP-ID
1315 GROUP AA 3

In the above example, EMP-ID is a multiply-occurring input field associated with GROUP AA; EMP-ID occurs five times. A reference to EMP-ID on a type 5 edit parameter implies the third occurrence of this field as determined by the subscript value defined on the type 15 parameter.

Examples

Sample implied subscript parameters are shown and described below.

Example 1

REC CUST-INFO        35      GROUP CC  40.6
REC CUSTOMER-NAME     1  20  ELMNT CC  'CUSTOMER NAME'
REC CUSTOMER-ADDRESS 21  20  ELMNT CC  'CUSTOMER ADDRESS'

0115  NAME  CUSTOMER-NAME.3

NAME is defined as the third occurrence of CUSTOMER-NAME. CUSTOMER-NAME is an element of GROUP CC specified on a REC parameter; it occurs six times.

Example 2

010   INDX  1
0115  NAME  CUSTOMER-NAME.INDX

CUSTOMER-NAME is an element of GROUP CC defined in the preceding example. NAME is defined as an occurrence of CUSTOMER-NAME, which varies depending on the value of INDX; INDX is a numeric work field initialized to 1.

Example 3

230  AMT.3   1 2 3   SUBS
2315 TOTAL1  AMT.1
2315 TOTAL2  AMT.2

2351*010 AMT.SUBS
2361*010 TOTAL1
2362*010 TOTAL2

TOTAL1 and TOTAL2 are alternate names for the first and second occurrences of the work field AMT; in this example, TOTAL1 is assigned an initial value of 1 and TOTAL2 is assigned a value of 2. AMT.SUBS accumulates all specific occurrences of AMT in the extract phase. The total value of AMT.SUBS can be referenced during the output phase. References to TOTAL1 and TOTAL2 during the output phase produce the current values of the first and second occurrences of the array that stores values of AMT.

Example 4

REC LOCATION-INFO    20     GROUP AA   8.5
REC LOCATION-ID       1  2  ELMNT AA
REC EFFECTIVE-DATE    3  6  ELMNT AA
01520001 EFFECTIVE-DATE

010   INDX 3
0115  GROUP AA INDX

INDX is the subscript for the elementary fields within GROUP AA; it is a work field initialized to 3. The reference to EFFECTIVE-DATE on a type 5 edit parameter implies the third occurrence of this field. If the value of INDX changes, references to LOCATION-ID and EFFECTIVE-DATE imply the field occurrences equal to the value of INDX. The value of INDX cannot exceed 5, the number of occurrences of GROUP AA. Because an implied subscript is coded for GROUP AA, explicit references to the elements of GROUP AA are not permitted for report 01; for example, the following reference would be invalid:

01610010 LOCATION-ID.4

Example 5

 220 IX 1    TABLE.28 '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'' '
 2215 COLUMN1  TABLE.IX
 2215 COLUMN2  TABLE.IX  1     $INCREMENT IX BY 1
 2215 COLUMN3  TABLE.IX  2     $INCREMENT IX BY 2
 2215 COLUMN4  TABLE.IX  3     $INCREMENT IX BY 3
 227010 PERFORM 500            $CODE EVALUATING VALUE OF IX
 227020 TAKE
 227500 RELS
 227550 IX ADD 4 IX
 227560 IF IX LE 24 500
 227570 RETURN
 2251*010 COLUMN1
 2251*020 COLUMN2
 2251*030 COLUMN3
 2251*040 COLUMN4

In this example, TABLE is a multiply-occurring work field with 28 entries; IX is a numeric work field initialized to 1. COLUMN1, COLUMN2, COLUMN3, and COLUMN4 are alternative names for subscripted values of TABLE; these are defined as implied subscript parameters. An increment is used on all but the first implied subscript parameter for the purpose of automatically incrementing the subscript value of TABLE.

In type 7 procedure logic, the value of IX increases by 4 until it is greater than 24. Before each increment, CA Culprit extracts the type 5 edit parameter information.

An example of the report output appears below:

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
  RECORDS WRITTEN FOR REPORT 22—         7

More information:

Input Definition Parameters