VAR-LENGTH Directive

By default, the compiler generates fixed-length fields in the XFD. The VAR-LENGTH directive requests that the data item that immediately follows the directive be assigned a type that implies variable length, if possible. This can save considerable space in your database.

The precise variable type that is assigned to the data item depends on which DBMS is in use.

Possible variable types that might be assigned are VARCHAR and VARBINARY.

Syntax

$XFD VAR-LENGTH

or

*(( XFD VAR-LENGTH ))

Example

For example, the directive in the following code indicates that the employee-name field should be entered into a database as a VARCHAR data item.

*(( XFD  VAR-LENGTH ))
  03  employee-name   pic x(45).