Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Language Environment →  Language Settings 

Text Environment Language and Text Environment

Other versions: 7.31 | 7.40 | 7.54

Text Environment Language

The text environment language is part of the language settings of an ABAP program and determines its text environment. It is valid during an internal session.

  • It can also be set to a different language for the current internal session using the statement SET LOCALE LANGUAGE.

The current text environment language can be determined using the method GET_LANGUAGE of the class CL_ABAP_SYST or using the statement GET LOCALE LANGUAGE, and is the nominal content of the system field sy-langu. The possible single-character abbreviations for the text environment language are stored as language keys in the column SPRAS of the database table T002.


Example

Asserts that the system field sy-langu contains the current text environment language, An exception is raised if the system field is overwritten in the program.

ASSERT sy-langu = cl_abap_syst=>get_language( ).

Text Environment

All programs in an internal session run in a shared text environment determined by the text environment language and which can also be set using the statement SET LOCALE LANGUAGE. As well as the language, the text environment comprises the following:

  • A code page
The code page of the text environment is always the system code page UTF-16 of the AS Instances of a Unicode system and cannot be changed. The current release supports Unicode systems only. Text environments with other code pages are no longer supported. There is a special feature in which the non-Unicode code page that is used for conversions is the one 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 using the ABAP file interface.
  • A locale
The locale properties that match the text environment language and country are defined in an ICU (International Components for Unicode) library. This library is made available for AS ABAP and is independent of the operating system of the host computer of the AS Instances.

The text environment handles texts in character-like data objects:

  • The code page of the text environment affects all operations that depend on the current character set, such as
  • Casting character-like data objects to byte-like types
  • The locale of the text environment affects all statements that sort character-like data objects as text, such as
  • In addition, the text environment language, and not the logon language, is used in the following cases:
  • If a language is not specified explicitly in the statement SUBMIT VIA JOB, the logon language of the background session is set implicitly to the current text environment language.
  • The texts on selection screens are determined by the current text environment language.
Any further frameworks based on the nominal value of the system field sy-langu access the current text environment language and not the logon language.


Notes

  • 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.

  • In the non-Unicode single code page systems supported before release 7.50, the code page of the text environment was always the non-Unicode system code page of the current AS Instance. It was possible to configure different system code pages for the code page of the text environment of a system only in the MDMP systems supported before Release 7.0.

Example

Sets the text environment explicitly before an aRFC. The function module DEMO_RFM_CALL_TRANSACTION calls a transaction using a transaction code passed to it. The logon language of the RFC session is not determined by the logon language of the current session and is always English. Afterwards, the text environment language is set back to its previous value.

GET LOCALE LANGUAGE DATA(langu) 
           COUNTRY  DATA(dummy) 
           MODIFIER dummy. 

SET LOCALE LANGUAGE 'E'. 
CALL FUNCTION 'DEMO_RFM_CALL_TRANSACTION' 
  STARTING NEW TASK 'TCODE' 
  EXPORTING 
    tcode = 'SE11'. 
SET LOCALE LANGUAGE langu.

Continue

SET LOCALE LANGUAGE

GET LOCALE LANGUAGE

Setting the Text Environment