Get Example source ABAP code based on a different SAP table
ID SET-LOCALE-LANGUAGE • SET LOCALE LANGUAGE ABAP Statement
SET LOCALE LANGUAGE> Short Reference >
ABAP_SYNTAX SET LOCALE LANGUAGE lang $[ obsolete_parameters>$].>
What does it do? This statement sets the text environment language> of the current ABAP_ISESS > to the value specified in lang>. This determines the text environment> for all programs in the ABAP_ISESS . 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 ABAP_ASINSTANCE (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>.
ABAP_PGL If possible, do not switch the text environment within the code> ABAP_PGL_END
Latest notes:
The text environment of an ABAP_ISESS 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>>.
Legacy files> are read and written. 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. NON_V5_HINTS
The statement has two obsolete additions, COUNTRY>> and MODIFIER>>, which should no longer be used. ABAP_HINT_END
Example ABAP Coding
Setting of the text environment to a valid value. ABEXA 00655 ABAP_EXAMPLE_END
ABAP_EXAMPLE_ABEXA Setting the Text Environment> ABAP_EXAMPLE_END
Runtime Exceptions
Catchable Exceptions CX_SY_LOCALIZATION_ERROR>>
Reason for error:
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>
Reason for error:
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
Reason for error:
Selection of a 'binary' text environment using the modifier 'BINARY'>, 'C'>, 'POSIX'>, or 'RAW'>.
Runtime error:
TEXTENV_BINARY_NOT_SUPPORTED>
Reason for error:
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>.