SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Program Parameters → Language Environment → Text Environment →Set Text Environment
This example demonstrates how you set the text environment.
Source Code
REPORT demo_set_locale.
CLASS demo DEFINITION.
PUBLIC SECTION.
CLASS-METHODS main.
ENDCLASS.
CLASS demo IMPLEMENTATION.
METHOD main.
DATA text_tab TYPE HASHED TABLE OF string
WITH UNIQUE KEY table_line.
INSERT: `polo` INTO TABLE text_tab,
`pollo` INTO TABLE text_tab,
`chunky` INTO TABLE text_tab,
`crunchy` INTO TABLE text_tab.
SET LOCALE LANGUAGE 'E'.
SORT text_tab AS TEXT.
cl_demo_output=>write( text_tab ).
SET LOCALE LANGUAGE 'S'.
SORT text_tab AS TEXT.
cl_demo_output=>write( text_tab ).
SET LOCALE LANGUAGE ' '.
cl_demo_output=>display( ).
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
demo=>main( ).
Description
This example shows the effect of the locale of the text environment on sort functions. In Unicode and non-Unicode systems, a "ch" in a Spanish (or even Czech) text environment is taken as a single letter and sorted differently than in an English text environment. The double "ll" in Unicode systems in a Spanish text environment is sorted like two separate letters "l". In non-Unicode systems, there can be spanish locales (such as Spanish_Spain.1252 on Windows NT) that take "ll" as a single character and sort it differently. With the last statement SET LOCALE, the text environment is set again to the logon language.