VARUCS2(length {:2 | 4})

The VARUCS2 keyword is used in a free-form definition to indicate that the item is variable-length UCS-2.

It must be the first keyword.

The first parameter is required. It specifies the length in bytes. It can be between 1 and 8,386,550.

The second parameter is optional. It specifies the number of bytes used to store the current length of the variable-length item. See Size of the Length-Prefix for a Varying Length Item.

Each parameter can be a literal or a named constant. If it is a named constant, the constant must be defined prior to the definition statement.

In the following example
  • field cust_name is defined as a variable-length UCS-2 field with a maximum length of 50 characters
  • field message is defined as a variable-length UCS-2 field with a maximum length of 500 characters and a prefix size of 4 bytes.

  DCL-S cust_name VARUCS2(50);
  DCL-S message VARUCS2(500 : 4);

For information on defining a fixed-length UCS-2 item, see UCS2(length).