Specifying the Source Field at Runtime

You can use the WRITE TO statement to specify the source field at runtime. To do this, enclose the name of the data object which contains the name of the source field in parentheses and place it in the source field position:

Syntax

WRITE (<f>) TO <g>.

The system places the value of the data object assigned to <f> in <g>.

However, if you want to specify target fields at runtime, you must use field symbols as described in Working with Field Symbols.

DATA: NAME(10) VALUE 'SOURCE',
SOURCE(10) VALUE 'Antony',
TARGET(10).

...
WRITE (NAME) TO TARGET.
WRITE: TARGET.

This produces the output

Antony

The connection between field names and field contents is shown in the following diagram.