Ansicht
Dokumentation

ABAPTRANSLATE_CASE - TRANSLATE CASE

ABAPTRANSLATE_CASE - TRANSLATE CASE

rdisp/max_wprun_time - Maximum work process run time   SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up  
This documentation is copyright by SAP AG.
SAP E-Book

TRANSLATE c TO UPPER/LOWER CASE: Additional Information

Variants:

  1. TRANSLATE c TO UPPER CASE.
  2. TRANSLATE c TO LOWER CASE.


The way in which the TRANSLATE statement works depends on the R/3 logon language. In general, users log on to the R/3 System in the same language as that in which the data they want to edit was created. Logging on in the wrong language causes loss of data, unless a conversion has been defined to deal with a different language environment.

For example, if German umlauts are processed in a Russian environment, the TRANSLATE statement returns a '|' for an 'ö' and a '¶' for a 'Ö'. Such discrepancies occur in particular:

  • If the wrong language environment has been set inSET LOCALE LANGUAGE
  • If the user edits data that was not written in the logon language (without using SET LOCALE LANGUAGE)


If, for example, the data to be converted is stored in a structure struwith the language key languand the text field text, then you can work round the problem in one of two ways:



Example

DATA: BEGIN OF stru,
        langu TYPE sy-langu,
        text  TYPE sy-xcode,
      END   OF stru.

SET LOCALE LANGUAGE stru-langu.
TRANSLATE stru-text TO UPPER CASE.
SET LOCALE LANGUAGE SPACE.

This solution ensures that every conversion is made in the appropriate language. If struis an internal table, it should be sorted beforehand, to reduce the number of times the system switches between languages. Depending on the table's range, this can substantially reduce processing time, since SET LOCALE LANGUAGE has a long processing time. The runtime is similar to the runtime for SQL statements.



Example

IF stru-langu = sy-langu.
  TRANSLATE stru-text TO UPPER CASE.
ELSE.
  ....
ENDIF.

The above solution ensures that only texts created in the logon language are edited. If you want, you can bundle all other text lines in another internal table using COLLECT and then convert them using the first solution above.

Note

It is important to reset the language explicitly using SPACE, since SET LOCALE LANGUAGE also changes the system field sy-langu. Note also that a language key may not be meaningful, or a language may not be installed correctly, or you may not be able to edit data from a specific application server. In these special circumstances, the following function modules can be used:



  1. SCP_MIXED_LANGUAGES_1_INIT
  2. SCP_MIXED_LANGUAGES_1_SWITCH
  3. SCP_MIXED_LANGUAGES_1_NORMAL
  4. SCP_MIXED_LANGUAGES_1_FINISH





PERFORM Short Reference   CPI1466 during Backup  
This documentation is copyright by SAP AG.

Length: 3797 Date: 20240419 Time: 025412     sap01-206 ( 57 ms )