Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Obsolete Language Elements →  Obsolete Processing of Internal Data →  Obsolete character string and byte string processing 

TRANSLATE - CODE PAGE, NUMBER FORMAT

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Obsolete Syntax

Variants

1. TRANSLATE dobj [FROM CODE PAGE cp1] [TO CODE PAGE cp2].

2. TRANSLATE dobj [FROM NUMBER FORMAT nf1] [TO NUMBER FORMAT nf2].

Effect

These variants of the statement TRANSLATE, which are allowed only in obsolete non-Unicode programs, translate the content of a data object to a different code page or to a different number format (byte order).

Variant 1

TRANSLATE dobj [FROM CODE PAGE cp1] [TO CODE PAGE cp2].

Effect

The character-like content of a data object dobj is translated from code page cp1 to code page cp2. If dobj does not have a character-like data type, no translation takes place. If dobj is a structure, only the components with character-like data type are translated. Apart from strings, no deep data objects can be specified for dobj.

If specified, the code pages cp1, cp2 expect data objects of the data type n with the length 4, which when the statement is executed must contain an SAP code page number of the column CPCODEPAGE in the database table TCP00.

At least one of the additions FROM CODE PAGE or TO CODE PAGE must be specified. If one of the additions is not included, the code page of the current system is used instead of the missing code page cp2 or cp2.

Variant 2

TRANSLATE dobj [FROM NUMBER FORMAT nf1] [TO NUMBER FORMAT nf2].

Effect

The platform-dependent numeric content of a data object dobj is translated from number format nf1 to number format nf2. If dobj is not of data type i or f, the translation does not take place. If dobj is a structure, only the components of the data type i or f are translated. Apart from strings, no deep data objects can be specified for dobj.

If specified, the number formats nf1, nf2 expect data objects of the data type n with the length 4, which when the statement is executed must contain either the value "0000" for the platforms HP, SINIX, IBM, or "0101" for the platform DEC-OSF.

At least one of the additions FROM NUMBER FORMAT or TO NUMBER FORMAT must be specified. If one of the additions is not used, the number format of the current platform is used instead of the missing number format nf1 or nf2.


Note

These variants of the statement TRANSLATE are not allowed in Unicode programs. Their functions are replaced with methods of the following conversion classes:

  • CL_ABAP_CONV_IN_CE
    Reads data from a byte-like data object and converts it from an external format to the system format.
  • CL_ABAP_CONV_OUT_CE
    Converts data from the system format to an external format and writes it to a byte-like data object.
  • CL_ABAP_CONV_X2X_CE
    Converts data from an external format to another external format.

When legacy files are opened in the ABAP file interface, they can be converted directly when reading and writing files.


Example

Translates the components of a structure. The character-like component text is translated from the code page "1100" (HP-UX) to the code page "0100" (IBM- EBCDIC). The numeric component num is converted from the number format "0000" (for platforms by HP IBM, or Siemens, for example) to the number format "0101" (for platforms provided by DIGITAL, for example).

DATA: BEGIN OF struc,
        text TYPE c LENGTH 80 VALUE 'I know You know',
        num  TYPE i VALUE  2505,
      END OF struc.

TRANSLATE struc FROM CODE PAGE '1100'
                TO   CODE PAGE '0100'.

TRANSLATE struc FROM NUMBER FORMAT '0000'
                TO   NUMBER FORMAT '0101'.

Exceptions


Non-Catchable Exceptions

  • Cause: Invalid number format.
    Runtime Error: TRANSLATE_WRONG_NUM_FORMAT