Documentation View

We are hiring and constantly growing! Have a look through our vacancies to find the right role for you!

ABAPSET_LOCALE - SET LOCALE

ABAPSET_LOCALE - SET LOCALE

Fill RESBD Structure from EBP Component Structure   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.
SAP E-Book

SET LOCALE LANGUAGE

Short Reference



SET LOCALE LANGUAGE lang $[obsolete_parameters$].

Effect

This statement sets the text environment language of the current internal session to the value specified in lang. This determines the text environment for all programs in the internal session.

The text environment language lang expects a character-like data object containing a language key with a maximum of one character, for which locale properties are defined in the ICU library of the AS ABAP. The possible language keys are contained in the SPRAS column of the database table T002. The locale of the text environment is set accordingly. If the data object lang contains only blanks, the logon language of the current user session is used.

The statement SET LOCALE LANGUAGE sets the no-modifiable code page of the text environment. In a Unicode system, this is always UTF-16, whereby the ABAP programming language supports the subset UCS-2. After SET LOCALE LANGUAGE is executed, however, the non-Unicode code page that would be set by the statement in a non-Unicode system (see below), is used for conversions in specific statements such as reading and writing legacy files. (See the additions LEGACY, and NON-UNICODE of the statement OPEN DATASET.) If possible, this non-Unicode code page is taken from the column CHARCO of the database table TCP0C. The key used here is created from the current operating system of the host computer of the current (system field sy-opsys), the language key specified in lang, and a language ID set implicitly from the database table TCP0D or set explicitly.

System Fields

If the statement SET LOCALE LANGUAGE is executed successfully, it sets the system field sy-langu to the value specified in lang.

If possible, do not switch the text environment within the code

Notes

  • The text environment of an internal session should only be changed for the following purposes:
  • Processing character-like data objects that are in a different language to the logon language of the current user. The text environment language is important for the statements SORT ... AS TEXT and CONVERT TEXT.

The other consequences for the text environment documented under Text Environment Language and Text Environment should also be noted.
  • After processing in a changed text environment, the text environment should be reset to the previous text environment.
  • The statement SET LOCALE LANGUAGE sets the text environment language contained in sy-langu and returned by the method GET_LANGUAGE of the class CL_ABAP_SYST. It does not set the logon language returned by the method GET_LOGON_LANGUAGE.
  • The statement SET LOCALE LANGUAGE must not be confused with the statement SET LANGUAGE for loading the texts of a text pool.
  • Instead of the SET LOCALE statement, the four function modules whose names begin with SCP_MIXED_LANGUAGES_ can also be used to determine or change the current text environment, and to reset it to the original text environment.
  • The statement has two obsolete additions, COUNTRY and MODIFIER, which should no longer be used.

Example

Setting of the text environment to a valid value.

Setting the Text Environment

Exceptions

Catchable Exceptions

CX_SY_LOCALIZATION_ERROR

  • Cause: The tables TCP0D and TCP0C were used to determine a character set that is not released in your system. The released character sets are in the table TCPDB. Normally this table should contain exactly one character set and this runtime error occurs because an attempt was made to use a non-compatible language.
    Runtime Error: TEXTENV_CODEPAGE_NOT_ALLOWED
  • Cause: No entry exists for the current platform in the SAP text environment table TCP0C for the specified keys lang, cntry, and mod.
    Runtime Error: TEXTENV_KEY_INVALID

Non-Catchable Exceptions

  • Cause: Selection of a 'binary' text environment using the modifier 'BINARY', 'C', 'POSIX', or 'RAW'.
    Runtime Error: TEXTENV_BINARY_NOT_SUPPORTED
  • Cause: One of the key values lang, cntry, or mod is longer than the corresponding fields LANGU, COUNTRY, or MODIFIER in the SAP text environment table TCP0C.
    Runtime Error: TEXTENV_KEY_TOO_LONG






BAL_S_LOG - Application Log: Log header data   BAL_S_LOG - Application Log: Log header data  
This documentation is copyright by SAP AG.

Length: 8383 Date: 20230207 Time: 094140     sap01-206 ( 112 ms )