Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following example assumes that #VAL01, #VAL02 and #VAL03 are all packed decimal fields of length 7, with 2 decimals:

...

   DEF_ARRAY NAME(#VAL) INDEXES(#II #JJ) OF_FIELDS(#VAL01 #VAL02 #VAL03)

will define the following "fields" in your function:

  • #VAL#II as a packed 7,2 field. This field allows you to make indexed references to array #VAL using index #II.
  • #VAL#JJ as a packed 7,2 field. This field allows you to make indexed references to array #VAL using index #JJ.


Additionally, references to #VAL#II or #VAL#JJ by data validation commands like RANGECHECK and SET_ERROR will cause an error to be set in the associated OF_FIELD field.

For example:

...

 

...

  CHANGE 

...

FIELD(#II) TO(3)

...


...

  SET_ERROR FOR_FIELD(#VAL#II)

...


...

  CHANGE FIELD(#JJ) TO(1)

...


...

  SET_ERROR FOR_FIELD(#VAL#JJ)

...


...

  DISPLAY FIELDS(#VAL01 #VAL02 #VAL03)

will cause fields #VAL01 and #VAL03 to be displayed in the reverse video because they have had their error flags turned on by the SET_ERROR commands.

  • These element fields #VAL#II and #VAL#JJ can be referenced as individual fields in almost all commands. Specific places where they cannot be used include:
  • On any screen panel. DISPLAY FIELDS(#VAL#II) in any form is invalid and will cause a compile failure. Likewise they cannot be placed in browse lists. However, they can be placed into working lists.
  • In EXEC_OS400 or EXEC_CPF commands, use an intermediate work field instead. See the following examples for details.
  • In debug mode .... #VAL#II cannot be shown directly by the debug facility.
  • In database operations. The following code sections are not equivalent. The second operation will yield no result.

...

  

...

 FETCH FIELDS(#VAL01) FROM_FILE(.....)

...


  and   CHANGE #II 1

...


FETCH FIELDS(#VAL#II) FROM_FILE(.....)

#VAL#ARRAY as a character field of length 12. This field is the full representation of array #VAL in character format. In this case 3 * P(7,2) uses 12 bytes of storage. This field is only automatically defined when the aggregate array length is less than or equal to 256 bytes.

...