TRANSLATE


Variants



1. TRANSLATE c TO UPPER CASE.
2. TRANSLATE c TO LOWER CASE.
3. TRANSLATE c USING c1.
4. TRANSLATE c FROM CODE PAGE g1 TO CODE PAGE g2.
5. TRANSLATE c FROM NUMBER FORMAT n1 TO NUMBER FORMAT n2.

Variant 1

TRANSLATE c TO UPPER CASE.

Variant 2

TRANSLATE c TO LOWER CASE.

Effect

In the field c , converts all lower case letters to upper case or all upper case letters to lower case, as specified.

Example

DATA LETTERS(3). MOVE 'abc' TO LETTERS. TRANSLATE LETTERS TO UPPER CASE.

The field LETTERS now contains 'ABC' .

Variant 3

TRANSLATE c USING c1.

Effect

Replaces the letters in the field c according to the contents of c1 .
If a character in c also exists in c1, it is replaced by the letter that f o l l o w s it in c1. If a character from c is not found in c1, it remains unchanged.

Example

DATA: LETTERS(10) VALUE 'abcX', CHANGE(6) VALUE 'aXBY'. TRANSLATE LETTERS USING CHANGE.
The field LETTERS now contains 'XbcX' .

Variant 4

TRANSLATE c ...FROM CODE PAGE g1 ...TO CODE PAGE g2.

TRANSLATE F TO CODE PAGE G2.
TRANSLATE F FROM CODE PAGE G1.

Effect

Performs a character code conversion in the field F . To achieve this, the SAP character code is determined from the conversion table G1 and a new character code derived from G2 . You can use the Transaction SPAD to maintain the conversion tables TCP00 - TCP02 .

Example

DATA F(72). TRANSLATE F FROM CODE PAGE '1110' TO CODE PAGE '0100'.
translates the contents of F from the HP character set to EBCDIC ( IBM 274).

Note

Type I , P , F and X fields remain unchanged. Field strings and work areas of internal tables are converted to the correct type for each individual field. At present, table work areas (as defined in TABLES ... ) are not treated according to type, but are converted as a whole. If necessary, declare a field string with INCLUDE STRUCTURE and then perform a conversion.

Variant 5

TRANSLATE c ...FROM NUMBER FORMAT n1 ...TO NUMBER FORMAT n2.

TRANSLATE F TO NUMBER FORMAT N1.
TRANSLATE F FROM NUMBER FORMAT N1.

Effect

Performs a number format conversion in the field F . The number formats supported at present are '0000' ( HP , SINIX , IBM ) and '0101' ( DEC alpha OSF ). Any attempt to enter formats other than these results in a runtime error. If you omit FROM NUMBER FORMAT or TO NUMBER FORMAT , the system number format is used for the omitted part.

Example

DATA: F TYPE F, HEX (2) TYPE X, NFORM LIKE TCP00-CPCODEPAGE. ... * In /ARCHIV was stored by another platform from HEX and F. * HEX contains the valid number format and can be read on all * platforms. READ DATASET '/ARCHIV' INTO HEX. READ DATASET '/ARCHIV INTO F. NFORM = HEX. "Conversion of machine-independent HEX to NUMC(4) TRANSLATE F FROM NUMBER FORMAT NFORM.

Effect

Converts the contents of F from the format NFORM of a platform to the system format.

Note

Type I and F fields are converted. Field strings and work areas of internal tables are converted to the correct type for each individual field. Table work areas (as defined with TABLES ... ) are treated as type C at present and are not converted. If necessary, declare a field string with INCLUDE STRUCTURE and then perform a conversion.
In the interests of storing additional information for archiving purposes, you can use the function module SYSTEM_FORMAT to display the system code page and system number format.

Note

Performance
Converting lower case letters to upper case letters or upper case letters to lower case letters in a 10-byte long character field takes approx. 7 msn (standardized microseconds).
Replacing two letters in a 10-byte long field with the variant ... c USING c1 ... takes approx. 9 msn.

Note

Runtime errors

Related REPLACE , OVERLAY


Index
© SAP AG 1996