SET LOCALE

Basic form 8

SET LOCALE LANGUAGE lg.

Extras:

1. ... COUNTRY c

2. ... MODIFIER m

Effect

Sets the text environment according to the specified language lg.

The text environment includes the language stored in SY-LANGU, the locale categories LC_CTYPE and LC_COLLATE and the SAP character set.

You determine the text environment by accessing the SAP text environment table TCP0C with the specified key

  LANGUAGE = lg, COUNTRY = c, MODIFIER = m

If the country is not specified, it is taken from the table TCP0D. If TCP0D is empty, the setting COUNTRY = SPACE is used to access TCP0C. If the modifier is not specified, the setting MODIFIER = SPACE is used to access TCP0C.

The text environment affects all operations specific to the character set (such operations include ABAP character processing statements, screen output to the front-end, data transmission between the application server and the front-end, data transmission by RFC, and printing).

The locale category LC_COLLATE affects the behavior of the SORT ... AS TEXT and CONVERT TEXT statements.

When an internal session is opened (in other words, when a roll area is opened), the text environment is automatically set to the active user's language as specified in the user master record. Therefore, you usually do not need an explicit SET LOCALE statement.

You only have to use SET LOCALE if you want to program a special text environment regardless of the active user's language.

You should take particular care when switching back and forth between different text environments or if you use a text environment which is not compatible with the frontend character set.

Addition 1

... COUNTRY c

Effect

If a language spoken in different countries (or, to be more politically precise, in different territories) has different text environments for different countries, you can use the addition COUNTRY c to specify the country for a language.

Addition 2

... MODIFIER m

Effect

If a language in a country has different text environments (for example, in Germany, letters with umlauts are treated in different ways - in a dictionary, ä is treated like a, but in a telephone directory, it is treated like 'ae'), you can use the addition MODIFIER m to specify a further modifier for the language and country.

The values 'BINARY', 'C', 'POSIX' and 'RAW' are not allowed as modifiers because they are reserved for a later development intended to support 'binary' text environments.

Notes

  1. The special form SET LOCALE LANGUAGE SPACE (or lg contains SPACE) resets the text environment to the language of the active user as specified in the user master record. In this case, specifying COUNTRY c and/or MODIFIER m has no effect.


  2. The effect of SET LOCALE is not restricted to the current program, but covers all programs in the current roll area.


  3. If one of the specified key fields lg, c or m is not a character field, or if one of the key values is longer than the corresponding fields LANGU, COUNTRY or MODIFIER in the SAP text environment table TCP0C, the processing terminates with a runtime error.


  4. Although entries in the SAP text environment table TCP0C are platform-specific, the platform is treated as an implicit key component. The system then retrieves the value for the key component PLATFORM = p at runtime when accessing the table TCP0C and you do not have to bother about this when programming.


  5. If the SAP text environment table TCP0C contains no entry for the specified key



    (on the current platform), or the text environment cannot be set according to the values in TCP0C, the processing terminates with a runtime error.


  6. If the boolean SAP profile parameter abap/set_text_env_at_new_mode is set to 0 (the default is 1), the text environment is not set according to the language of the active user when a new internal session is opened, but according to the language of the application server (which is determined by the SAP profile parameter zcsa/system_language). Resetting the text environment with SET LOCALE LANGUAGE SPACE restores the text environment for the language of the application server.


  7. If the boolean SAP profile parameter install/collate/active is set to 0 (the default is 1), SET LOCALE has no effect at all; furthermore, the text environment remains unchanged, even when a new internal mode is opened, and the locale category LC_COLLATE is not set at all by the SAP kernel. Accordingly, the SORT ... AS TEXT and CONVERT TEXT statements then also have no effect.


Note

Please keep the rules for site-specific sorting in mind.

Exceptions

Catchable Exceptions

CX_SY_LOCALIZATION_ERROR

Non-Catchable Exceptions

Related

GET LOCALE

Additional help

Conversion to a Sortable Format