Use this record-level keyword to indicate that the length of the record sent across the line is variable. The length is specified at run time in the field parameter.
VARLEN(&field-name);
The &field-name parameter is required and specifies the name of the field that contains the length of the user data to be sent. The field name must exist in the record format and the field must be defined as a zoned field of length 5, data type S, usage P, and zero decimal positions.
The length value set in the parameter field is the length of the user data and does not include indicators. The length value is specified in decimal and is checked at run time. The value should not be greater than the length of the DDS record format. The maximum value depends on the communication type you are using.
VARLEN is valid only on output operations.
VARLEN is ignored at run time when an CANCEL, EOS, FAIL, NEGRSP, RSPCONFIRM, or RQSWRT keyword is in effect. These keywords must have option indicators when they apply to a record that has the VARLEN keyword specified. If a CANCEL, EOS, FAIL, NEGRSP, or RQSWRT keyword with no option indicator applies to a record for which VARLEN applies, an error message is issued and the VARLEN keyword is ignored at creation time.
At least one data field (usage B or blank) for the user data must be specified in the record format.
You cannot specify VARLEN with the TIMER keyword.
Option indicators are not valid for this keyword.
The following example shows how to specify the VARLEN keyword.
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 A R RCD VARLEN(&LENFLD); A DATAFLD 32760A A LENFLD 5S P A
On an output operation to RCD, the length of the data in DATAFLD that is sent across the line will be the length set in LENFLD.