The text environment is a part of the runtime environment of an ABAP program. It affects all operations that depend on the character set, which include:
The text environment is made up of a language, a locale, and a code page. The code page of the text environment must be a system code page. All programs of an internal session work in a common text environment, which can be changed during program execution.
The locale attributes that belong to a country and a language are defined in Unicode systems in an ICU library (International Components for Unicode) that exists on the application server and that is independent of its operating system.
In Unicode systems, UTF-16 is the only system code page, and therefore the only code page in every text environment. There is a special feature whereby the non-Unicode code page is used that would be assigned to the current text environment in a non-Unicode system. This only applies for specific statements, such as reading and writing legacy files.
The locale attributes of a country or language in a non-Unicode system depend on the operating system of the current application server. Every operating system has predefined locales for every language.
The code page of the text environment is always a non-Unicode code page. In non-Unicode single code page systems, there is only one system code page. Only text environments with this code page can be set. In MDMP systems, there are multiple system code pages. All text environments that contain one of these code pages can be set. The code page of the current text environment is the active system code page of an internal session.
The possible text environments of non-Unicode systems are predefined in the database table TCP0C. This system table is supplied by SAP and its content should not normally be changed. In Unicode systems, the entries in TCP0C are only used for setting the code page in the special cases referred to above.
The following table shows the columns of the table TCP0C. The text environment depends on four key fields and is defined in the columns LOCALE (Locale) and CHARCO (code page).
Name | Key | Meaning |
PLATFORM | X | Operating system of the application server |
LANGU | X | Language key |
COUNTRY | X | Country key |
MODIFIER | X | Locale key (is not used) |
LOCALE | Operating system locale | |
CHARCO | SAP code page number | |
CHARCOMNLS | obsolete |
The SAP code page number specified in the column CHARCO identifies a non-Unicode code page. Before release 6.10, the assignment of SAP code page numbers to code pages was defined using the transaction SPAD, and as of release 6.10 can be defined using the transaction SCP.
When an internal session is opened, the text environment is set according to the logon language of the current user. During the execution of an ABAP program, the text environment of the current internal session can be set using the statement SET LOCALE, and read using GET LOCALE.
The system field sy-langu always contains the single-character abbreviation for the language of the current text environment of an internal session. The possible abbreviations are stored as language keys in the column SPRAS of the database table T002.