确定ABAP中的活动格式设置 [英] Determining the active formatting settings in ABAP

查看:138
本文介绍了确定ABAP中的活动格式设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为 ABAP文档格式设置说明:

格式设置如下设置:

The formatting settings are set as follows:

  • 在内部会话开始时,它们将由由相关默认设置确定,该设置由当前用户的用户主记录中的固定值确定.

  • At the start of an internal session they are determined by the related default settings in the fixed values in the user master record of the current user.

使用语句SET COUNTRY,可以使用特定于国家/地区的格式覆盖当前内部会话的默认设置.

Using the statement SET COUNTRY, this default setting for the current internal session can be overwritten using country-specific formats.

但作为 ABAP文档SET COUNTRY 的说明很清楚,无法查询此语句的实际设置:

But as the ABAP documentation of SET COUNTRY makes clear, there is no way to query what's actually been set with this statement:

请勿将语句SET COUNTRY与用于设置文本环境的语句SET LOCALE LANGUAGE的过时加法COUNTRY混淆.特别是,它没有相应的GET 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.

实际上, ABAP文档GET LOCALE-过时的参数提到:

Indeed, the ABAP documentation of GET LOCALE - obsolete parameters mentions:

添加的COUNTRY用于明确读取当前文本环境的国家/地区键. cntry需要一个类似字符的数据对象.添加的功能尚未完全实现,结果不确定.

The addition COUNTRY was intended for reading the country key of the current text environment explicitly. cntry expects a character-like data object. The function of this addition was not implemented in full and the result is undefined.

语句GET LOCALE的加法COUNTRY不会提取可以使用SET COUNTRY设置的格式设置.

The addition COUNTRY of the statement GET LOCALE does not extract the formatting setting that can be set using SET COUNTRY.

这给我留下了一个难题.我可以使用FM SUSR_GET_USER_DEFAULTS确定我的用户默认设置.我可以从表T005X找出国家/地区的设置. 但是我无法确定设置了哪种特定国家格式的 ,或者即使在活动会话中设置了 ,也无法确定!

Which leaves me with a bit of a conundrum. I could determine my user defaults with FM SUSR_GET_USER_DEFAULTS. I could figure out the setting for the country from table T005X. But I have no way of figuring out which specific country format was set, or even if one was set in the active session!

奖金问题:是否有办法在调试器中解决?

Bonus question: is there a way to figure this out in the Debugger?

推荐答案

ABAP语句

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.

  1. 要检测当前的日期格式,请使用返回字符的官方方法,该字符的可能值在

  1. 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( ).
    

    它返回以下值之一,其示例值对应于正午+ 5分钟10秒(如果该示例值至少以11个字符输出,则给出该示例值):

    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):

    • 0:12:05:10(0至23)
    • 1:12:05:10 PM(0至12)
    • 2:12:05:10 pm(0到12)
    • 3:00:05:10 PM(0至11)
    • 4:00:05:10 pm(0至11)

    要检测当前的数字格式,请根据@Gert Beukema的想法,执行以下操作:

    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:此表达式返回的值 XY与表列USR01-DCPFMT005X-XDEZP中使用的值相同.

    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.

    这篇关于确定ABAP中的活动格式设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆