Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Program Parameters →  Language Environment 

Text Environment

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:

  • Statements that work with character-like data objects
  • Data transfer between the application layer and the presentation layer
  • Data transfer between external storage systems and the application layer
  • Data transfer with RFC
  • Data output on the screen in SAP GUI
  • Spool

The text environment consists 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 while the program is being executed.

Other versions: 7.31 | 7.40 | 7.54

Text Environment in Unicode Systems

Locale

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.

Code Page

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 to specific statements, such as reading and writing legacy files.


Note

The ABAP programming language supports a subset covered by UCS-2 and not the full UTF-16 set. This contains all UTF characters except those in the surrogate area. ABAP interprets a character from the surrogate area as two characters.

Text Environment in Non-Unicode Systems

Locale

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.

Code Page

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 environment code page of an internal session.

Database Table TCP0C

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 Local key (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. The assignment of SAP code page numbers to code pages is defined using the transaction SCP.

Setting the Text Environment

When an internal session is opened, the text environment is set according to the logon language of the current user. When an ABAP program is executed, 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.

Continue

SET LOCALE LANGUAGE

GET LOCALE LANGUAGE

Set Text Environment - Example