Previous Topic: Set CursorNext Topic: Subtract


Substring

The *SUBSTRING built-in function allows you to extract a portion of a character string from one field and insert it into another.

There are five parameters for this function type:

The *For Length field has two special conditions: *FLDLEN which indicates that the entire length of the field or constant is to be used and *END which means that the extraction occurs from the position of the *From position field to the end of the field or constant.

CA 2E implements the *SUBSTRING built-in function in RPG using the SUBSTR statement in COBOL using the STRING statement. For COBOL 85, it uses a reference modification and for COBOL, 74 it is uses string manipulation.

The following is an example of a substring function.

This example extracts the first six characters from the Full Name field.

Substring

The following diagram contains the parameters for the previous example.

Substring (2)