Previous Topic: DTINTNext Topic: FIX


EXTRACT

Purpose

Returns the string that results from removing leading and trailing spaces from a string value.

Syntax

►►─── EXTract ( string ) ─────────────────────────────────────────────────────►◄

Parameters

string

Specifies the string value on which the extract function is performed.

String can be:

Usage

When a field contains only spaces, EXTRACT returns one space. In this example:

FNAME="JANA      "
MID="          "
LNAME="SEDLAKOVA           "
CONCAT(EXT(FNAME),' ',EXT(MID),' ',EXT(LNAME))

Extract returns the following value:

"JANA   SEDLAKOVA"

Example

In the following example, the extract function is used to remove leading and trailing spaces from the string contained in EMP-LNAME:

Initial value:
    EMP-LNAME: '    GAR FIELD        '
Statement:
    MOVE EXTRACT(EMP-LNAME) TO WK-EXTRACTED-NAME.
Returned string:
    'GAR FIELD'

Other examples of the extract function are provided in CONCATENATE and in STRING-LENGTH.