As the ABAP documentation of Formatting Settings explains:
The formatting settings are set as follows:
At the start of an internal sessio
The ABAP statement SET COUNTRY may change the date format, the time format (since ABAP 7.02) and the number format, but there's officially no reverse way to get the current active country code (as you quoted in your question, based on the ABAP documentation). It's quite logical because, for instance, the current number format may be different from the current country code, so it's better to test the directly the kind of format you need to use, as follows.
To detect the current date format, use the official way which returns a character, whose possible values are described in the ABAP documentation of Date Formats):
DATA(current_date_format) = CL_ABAP_DATFM=>GET_DATFM( ).
To detect the current time format, use the official way which returns a character:
DATA(current_time_format) = CL_ABAP_TIMEFM=>GET_ENVIRONMENT_TIMEFM( ).
It returns one of the following values, with an example value corresponding to noon + 5 minutes and 10 seconds (the example value is given if it's output on at least 11 characters):
To detect the current number format, based on the idea from @Gert Beukema, you may do as follows:
DATA(current_number_format) = SWITCH usr01-dcpfm(
|{ 1000 NUMBER = ENVIRONMENT DECIMALS = 1 }|
WHEN '1.000,00' THEN ' '
WHEN '1,000.00' THEN 'X'
WHEN '1 000,00' THEN 'Y' ).
NB: the values
, X
and Y
which are returned by this expression are the same values as those used in tables-columns USR01-DCPFM
and T005X-XDEZP
.