Previous Topic: TRAILING-TO-ZONEDNext Topic: VERIFY


TRANSLATE

Purpose

Returns the string that results from translating characters in a string value.

The characters are translated to corresponding characters that are specified in a substitution string:

Syntax

►►─── TRANSlate ( string, substitution-string ───┬─────────────────────┬─ ) ──►◄
                                                 └─ ,selection-string ─┘

Parameters

string

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

String can be:

substitution-string

Specifies the substitution string.

Substitution-string can be:

selection-string

Specifies the selection string. Characters in selection-string will be replaced by corresponding characters in substitution-string.

Selection-string can be:

Usage

Considerations

Example

In the following example, the translate function is used to translate all occurrences in PART-CODE (PIC X(20)) of the characters A, B, C, and D (selection-string), to W, blank, Y, and Z (substitution-string), respectively:

Initial value:
    PART-CODE:  'B53A22B1E50D40C94   '
Statement:
    MOVE TRANS(PART-CODE,'W YZ','ABCD') TO WK-PART-CODE.
Returned string:
    ' 53W22 1E50Z40Y94   '