STRING

STRING returns a string that is the concatenation of all the elements of x.

Read syntax diagramSkip visual syntax diagramSTRING( x)
x
Aggregate or element reference.
STRING is restricted as follows:
  • It cannot be applied to unions or structures containing unions.
  • If applied to a scalar, the scalar must be a bit string, a character string, a pictured character string, a pictured numeric string, a graphic string, a uchar string, or a widechar string.
  • If applied to a structure, the structure must contain no padding bytes and the elements of the structure must be either:
    • All unaligned bit strings
    • All character strings, each of which is either a character string, a pictured string, or a pictured numeric string
    • All graphic strings
    • All uchar strings
    • All widechar strings
  • If applied to an array, all elements in the array are subject to the restrictions as described previously.
The type of string returned has the same type as one of these base elements with these exceptions:
  • If any of the base elements are PICTUREs, then the type returned has CHARACTER type.
  • If any of the base elements have the GRAPHIC type, then the type returned is GRAPHIC unless the STRINGOFGRAPHIC compiler options specifies that it should be CHARACTER.
The following are valid STRING targets:
  dcl
    1 A,
      2 B  bit(8),
      2 C  bit(2),
      2 D  bit(8);

  dcl
    1 W,
      2 X  char(2),
      2 Y  pic'aa',
      2 Z  char(6);

  dcl
    1 W,
      2 X  char(2),
      2 Y  pic'99',
      2 Z char(6);
The following are invalid STRING targets:
  dcl
    1 A,
      2 B  bit(8) aligned,
      2 C  bit(2),
      2 D  bit(8) aligned;