Skip to content

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

SET COUNTRY

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


SET COUNTRY cntry. 

Effect

This statement sets the formatting settings of the language environment for all following statements of the current internal session.

cntry expects a character-like data object that either contains a value from the column LAND of the database table T005X or is initial.

  • If cntry contains a value from the table T005X, the number format, date format, time format, and time stamp format are set to a country-specific format in accordance with the entries in columns XDEZP, DATFM, and TIMEFM.
  • If cntry is initial (contains a blank in the first place), the formatting is set in accordance with the fixed values in the user master record.

If the content of cntry cannot be found in the table T005X and does not have a blank in the first place, sy-subrc is set to 4 and the following settings are made:

  • The decimal separator is a decimal point and the thousands separator is a comma.
  • Date in the form "mm/dd/yyyy"
  • Time in 24-hour format
  • Time stamp according to the settings for date, time, and decimal separator

System Fields

sy-subrc Meaning
0 The specified country key was found in the database table T005X or a space was specified.
4 The specified country key was not found in database table T005X.


Notes

  • As long as the statement SET COUNTRY is not executed in an internal session, the formatting corresponds to the fixed values in the user master record.
  • If certain formatting settings are only required for one or a few formattings, the formatting option country can be used for embedded expressions in string templates instead of SET COUNTRY.
  • Do not confuse the statement SET COUNTRY with the obsolete addition COUNTRY of the statement SET LOCALE LANGUAGE, used for setting the text environment. In particular, it does not have a corresponding GET COUNTRY statement.

Example

Sets the formatting settings of the language environment and the way they modify the addition ENVIRONMENT in embedded expressions in string templates.

SELECT SINGLE land 
       FROM t005x 
       WHERE timefm <> ' ' 
       INTO @DATA(country). 

SET COUNTRY country. 

cl_demo_output=>display( 
  |{  sy-datlo           DATE      = ENVIRONMENT }\n{ 
      sy-timlo           TIME      = ENVIRONMENT }\n{ 
      utclong_current( ) TIMESTAMP = ENVIRONMENT }| ). 

Executable Examples