7 93 1 SUBSTRING Parameters

LANSA Technical

7.93.1 SUBSTRING Parameters

FIELD

INTO_FIELD

FIELD

Specifies the field from which the string is to be extracted and optionally the start position and length of the string.

The field nominated in this parameter can be type alphanumeric or type numeric. When specifying a specific start position and length for a packed numeric field remember that digit positions and lengths are used not byte positions and lengths.

If no start position is specified for the string then start position 1 is assumed.

If no length is specified for the string then *END is assumed which indicates that all of the string from the start position to the end of the field is to be used.

The start position and length values can be nominated as either a literal value (e.g.: 10) or as the name of a field that contains the value (e.g: #LENGTH).

The start and end positions specified are validated at execution time (since they may be variable). If an invalid start or end position is specified the function will abort with an error message indicating the cause of the failure.

Special notes for substringing an alpha field into a numeric field:

Note 1. The field should only contain the digits 0-9. Any other character, including a sign character ('+' or '-'), will give unpredictable results.

Note 2. Substringing is from left to right, therefore if a field containing '123.45' is substringed into position 1 of a signed (6,2) field (which is initially set to *ZERO), the value will be set to 1234.50.

Note 3. The length and start position for Unicode fields is specified in characters, where every character is a 2-byte unit.

INTO_FIELD

Specifies the field into which the string extracted from the field nominated in the FIELD parameter is to be placed.

The field nominated in this parameter can be type alphanumeric or type numeric. When specifying a specific start position and length for a packed numeric field remember that digit positions and lengths are used not byte positions and lengths.

If no start position is specified for the string then start position 1 is assumed.

If no length is specified for the string then *END is assumed which indicates that all of the string from the start position to the end of the field is to be used.

The start position and length values can be nominated as either a literal value (e.g.: 10) or as the name of a field that contains the value (e.g.: #LENGTH).

The start and end positions specified are validated at execution time (since they may be variable). If an invalid start or end position is specified the function will abort with an error message indicating the cause of the failure.