Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

TRANSLATE( ) Assign result values to input values

&pagelevel(3)&pagelevel

Domain: Conversion functions

The TRANSLATE( ) function can be used to assign any result data to any input data. Up to ten translation operations can be specified; WHEN and THEN clauses must be present in pairs.

Algorithm: the compare strings specified in the WHEN clauses are checked consecutively to see if they match the input string. If they do match, the result string specified in the corresponding THEN clause is supplied as the result. If none of the compare strings indicated in the WHEN clauses match the input string, the string specified in the ELSE branch is supplied as the result.

Format

TRANSLATE( )

STRING = string_expression0

,WHEN1 = *NONE / string_expression1, THEN1 = *NONE / *SAME / string_expression11

,WHEN2 = *NONE / string_expression2, THEN2 = *NONE / *SAME / string_expression12

,WHEN3 = *NONE / string_expression3, THEN3 = *NONE / *SAME / string_expression13

,WHEN4 = *NONE / string_expression4, THEN4 = *NONE / *SAME / string_expression14

,WHEN5 = *NONE / string_expression5, THEN5 = *NONE / *SAME / string_expression15

,WHEN6 = *NONE / string_expression6, THEN6 = *NONE / *SAME / string_expression16

,WHEN7 = *NONE / string_expression7, THEN7 = *NONE / *SAME / string_expression17

,WHEN8 = *NONE / string_expression8, THEN8 = *NONE / *SAME / string_expression18

,WHEN9 = *NONE / string_expression9, THEN9 = *NONE / *SAME / string_expression19

,WHEN10 = *NONE / string_expression10, THEN10 = *NONE / *SAME / string_expression20

,ELSE = *NONE / *SAME / string_expression21

Result type

STRING

Input parameters

STRING = string_expression0
Designates the input string to which the compare strings in the WHEN clauses are to be compared.

WHENi = *NONE
1<= i<= 10; designates a null string.

WHENi = string_expressioni
1<= i<= 10; designates the compare string and determines the translation conditions: if a “string_expressioni” matches the input string, the corresponding THEN branch is executed, ii.e. the result string designated in that branch is supplied.

THENi = *NONE
1<= i<= 10; designates a null string.

THENi = *SAME
1 <= i <= 10; designates the input string as the result when the input string matches the compare string.

THENi = string_expressionj
1<= i<= 10; 11<= j<= 20, designates the result string output as the result when the input string (STRING =) matches the compare string (WHENi =).

ELSE = *NONE
When none of the compare strings in the WHENi clauses match the input string, an empty string is returned as the result.

ELSE = *SAME
When none of the compare strings in the WHENi clauses match the input string, the input string is output as the result.

ELSE = string_expression21
Designates the result string output when none of the compare strings in the WHENi clauses match the input string.

Result

Result string from the THENi or WHENi clause.

Error messages

SDP0410  INCONSISTENCY BETWEEN 'WHEN' AND 'THEN' PARAMETERS

Example

/A = 'ABC'
/C = TRANSLATE(STRING = A -
/,WHEN1 = 'AB', THEN1 = '12'-
/,WHEN2 = 'BC', THEN2 = '23'-
/,WHEN3 = 'ABC', THEN3 = '123'-
/,ELSE = 'NO_MATCH')
/SHOW-VARIABLE C
C = 123
/ B = 'grass-green'
/ D = TRANSLATE(STRING = B -
/,WHEN1 = 'gruen', THEN1 = 'green'-
/,WHEN2 = 'rot', THEN2 = 'red'-
/,WHEN3 = 'blau', THEN3 = 'blue'-
/,ELSE = 'NO_MATCH')
/SHOW-VARIABLE D
D = NO_MATCH