Variable-length format

Variable-length formats allow variable-length data to be handled as formats. Variable-length formats include variable-length delimiter specification and variable-length field reference.

= Remarks =

A variable-length format can be specified when the field type is 9, X, M, N, I, D, or Z.

(1) Variable-length delimiter specification

The user specifies any code of his or her choice that distinguishes the boundary of the data, and this code is added at the end of every variable-length data item. Variable-length formats that are specified like this are called variable length delimiter specifications.

For example, a text file can be thought to be a variable-length format that uses line break codes as the codes to distinguish data boundaries.

To use variable-length delimiter specification, in the format information, select Variable length (delimiter specified) for Fixed/Variable length, and specify a Delimiter value that acts as the code to identify data boundaries, and whether or not to trim the Delimiter value for input.

For the code to specify as the delimiter value, we recommend that you specify a code that is not used in variable-length data.

Also, if you do not select Trim for delimiters when inputting data, the target of code conversion will be both the variable-length data and the delimiters, and the code specified as the Delimiter value will also be converted to the target encoding. When the data is output, delimiters are added after code conversion, and therefore the delimiters are not subject to the code conversion.

If you do not specify a Delimiter value on the output side, the length of the variable-length data will be unknown. To output the length of the data, in the Output Information Settings dialog box in the Set Mapping Information screen, you need to specify the numeric operation formula $LEN() or $LENNUM(). For details about the Output Information Settings and Set Mapping Information screens, see DataMagic Reference Manual.

Note

When using null characters (0x00) for delimiters, make sure to set Trim for delimiters when inputting data. Without this setting, the delimiters will be regarded as data. (For details, see Handling of null characters in data.)To add null characters (0x00) to output data, set the Delimiter value on the output side.

Table 4.32 List of delimiter specification combinations

 

Output side

Set

Not set

Input side

Trim is not selected

The delimiters of the input side are not trimmed and processed as part of the input data. If there is no delimiter input side, the delimiter is appended.

The delimiters are also subject to the code conversion.

When data is output, delimiters on the output side are added. The fields of the output data terminate at the delimiters specified for the output side.

The delimiters of the input side are not trimmed and processed as part of the input data. If there is no delimiter input side, the delimiter is appended.

The delimiters are also subject to the code conversion.

The fields terminate at the delimiters whose encoding has been converted.

Trim is selected

When data is output, delimiters on the output side are added.

The fields of the output data terminate at the delimiters specified for the output side.

Delimiters are not added.

The end of the output data fields cannot be identified.

Figure 4.124 Variable-length delimiter specification

(2) Variable-length field reference

The user specifies a field of his or her choice that stores the length of variable-length data, and the value of this field is referenced to process the variable-length data. Variable-length formats that are specified like this are called variable-length field references.

For example, this is the same format as the one used for the RDW field of variable-length records for mainframes.

To use variable-length field references, in the format information, select Variable length (field name specified) for Fixed/variable length, and specify a field of your choice that stores the data length for Reference field name.

The field that you specify for Reference field name must meet the following conditions:

  • The field type is 9, B, F, S, P, or Z.

    (If the field type is F, the part after the decimal point is cut off for calculations.)

  • The field comes before the variable-length data.

  • The field is in the first tier and Repetitions is set to 1.

  • The field is valid.

(3) Variable-length field reference for input

To select variable-length field reference for input, specify Multiple and Constant. The following is the formula to calculate the length of variable-length data.

 

Value stored in the area specified by Reference field name x Multiple + Constant

 

In data processing, the valued obtained by the above formula is used as the data length for processing the variable-length data.

Figure 4.125 Variable-length field reference (for input)

(4) Variable-length field reference for output

Only specifying a variable-length field reference and establishing connections from input to output are not enough to allow the data length after data processing to be output to the area specified by Reference field name. To output the data length after data processing, in the Output Information Settings dialog box in the Set Mapping Information screen, you need to specify the numeric operation formula $LEN(). For details about the Output Information Settings and Set Mapping Information screens, see DataMagic Reference Manual.

Figure 4.126 Variable-length field reference (for output)