SAP TEXT ENVIRONM - Guide
Get Example source ABAP code based on a different SAP table
GUIDELINE 6.55
Text Environment
ABAP_BACKGROUND
The text environment is part of the runtime environment of an ABAP program and is made up of a language, a locale and a system codepage. All programs in an internal session have a common text environment.
As a default, the text environment of an internal session is determined by the logon language and can be set programmatically by the statement
ABAP_RULE
Set the statement
ABAP_DETAILS
ABAP-coded services usually expect the text environment to be specified by the current user's logon language. The services are not designed to handle text environment switches of internal sessions within the coding.
If you have to switch the text environment for a specific service due to the following exceptions, you must do so only temporarily. This means that you must reset a switched text environment within the same program context, in order to prevent unexpected behavior in other programs within the same internal session.
Exception
Switching the text environment within the coding may be necessary in the following cases:
Bad example
The following source text shows a text environment switch within a method, where the text environment is not reset before exiting the method. This poses the danger of continuing within the wrong text environment after returning from the method.
SET LOCALE LANGUAGE ...
...
ENDMETHOD.
Good example
The following source text shows a text environment switch within a method, where the text environment is reset to its original state before exiting the method.
DATA env_lang TYPE tcp0c-langu.
GET LOCALE LANGUAGE env_lang.
SET LOCALE LANGUAGE ...
...
SET LOCALE LANGUAGE env_lang.
ENDMETHOD.