Sign in

docs RPG Reference

Rules for Array Source Records

Rules for Array Source Records

The rules for array source records are:

  • The first array entry for each record must begin in position 1.
  • All elements must be the same length and follow each other with no intervening spaces
  • An entire record need not be filled with entries. If it is not, blanks or comments can be included after the entries (see Figure 1).
  • If the number of elements in the array as specified on the definition specification is greater than the number of entries provided, the remaining elements are filled with the default values for the data type specified.

Figure 1. Array Source Record with Comments

      DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++++++++++++++
      DARC              S              3A   DIM(12) PERRCD(5) CTDATA
**CTDATA ARC
48K16343J64044HComments can be placed here
12648A47349K346Comments can be placed here
50B125         Comments can be placed here
  • Each record, except the last, must contain the number of entries specified with the PERRCD keyword on the definition specifications. In the last record, unused entries must be blank and comments can be included after the unused entries.

  • Each entry must be contained entirely on one record. An entry cannot be split between two records; therefore, the length of a single entry is limited to the maximum length of 100 characters (size of source record). If arrays are used and are described in alternating format, corresponding elements must be on the same record; together they cannot exceed 100 characters.

  • For date and time compile-time arrays the data must be in the same format and use the same separators as the date or time array being loaded.

  • Array data may be specified in one of two ways:

    1. **CTDATA arrayname: The data for the array may be specified anywhere in the compile-time data section.
    2. **b: (b=blank) The data for the arrays must be specified in the same order in which they are specified in the Definition specifications.

    Only one of these techniques may be used in one program.

  • Arrays can be in ascending(ASCEND keyword), descending (DESCEND keyword), or no sequence (no keyword specified).

  • For ascending or descending character arrays when ALTSEQ(*EXT) is specified on the control specification, the alternate collating sequence is used for the sequence checking. If the actual collating sequence is not known at compile time (for example, if SRTSEQ(*JOBRUN) is specified on a control specification or as a command parameter) the alternate collating sequence table will be retrieved at runtime and the checking will occur during initialization at *INIT. Otherwise, the checking will be done at compile time.

  • Graphic and UCS-2 arrays will be sorted by hexadecimal values, regardless of the alternate collating sequence.

  • If L or R is specified on the EXTFMT keyword on the definition specification, each element must include the sign (+ or -). An array with an element size of 2 with L specified would require 3 positions in the source data as shown in the following example.

    *....+....1....+....2....+....3....+....4....+....5....+....6....+....*
          DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++++++++++++++
          D UPDATES                        2 0  DIM(5) PERRCD(5) EXTFMT(L) CTDATA
    **CTDATA UDPATES
    +37-38+52-63-49+51
  • Float compile-time data are specified in the source records as float or numeric literals. Arrays defined as 4-byte float require 14 positions for each element; arrays defined as 8-byte float require 23 positions for each element.

  • Graphic data must be enclosed in shift-out and shift-in characters. If several elements of graphic data are included in a single record (without intervening nongraphic data) only one set of shift-out and shift-in characters is required for the record. If a graphic array is defined in alternating format with a nongraphic array, the shift-in and shift-out characters must surround the graphic data. If two graphic arrays are defined in alternating format, only one set of shift-in and shift-out characters is required for each record.