简体   繁体   English

从 SAP GUI 中查找系统日期时间格式并在前端使用它

[英]Find system date-time format from SAP GUI and use it in frontend

I have a SAPUI5 free-style app, where I display the date in a smart-table, in format DD/MM/YYYY.我有一个 SAPUI5 自由风格的应用程序,我在智能表中显示日期,格式为 DD/MM/YYYY。

However, in the frontend system in SAP GUI, my date format is MM-DD-YYYY.但是,在 SAP GUI 的前端系统中,我的日期格式是 MM-DD-YYYY。 Is there a way to find this GUI date format and send it to the frontend app, so that I can modify the date format in my coding and display it accordingly?有没有办法找到这个 GUI 日期格式并将其发送到前端应用程序,以便我可以在我的编码中修改日期格式并相应地显示它?

I try to search it online.我尝试在网上搜索它。 There are ways to find system time-zone, but no way to find date-format.有办法找到系统时区,但没有办法找到日期格式。

Thank you in advance.先感谢您。

Why dont you use already present function module: CLSE_SELECT_USR01?为什么不使用已经存在的 function 模块:CLSE_SELECT_USR01?

Try using this:尝试使用这个:

FORM output.
CALL FUNCTION 'CLSE_SELECT_USR01'
EXPORTING     
USERNAME               = sy-uname
IMPORTING
DATE_FORMAT  =
  WRITE: / USERNAME               .
ENDFORM.

The SAP table USR01 contains the GUI dateformat in the field DATFM . SAP 表USR01DATFM字段中包含 GUI 日期格式。 It's only a Char1, but its domain lists you all the specific values.它只是一个 Char1,但它的域列出了所有特定的值。

You could then use a 'function import' in you OData service to get this value from the backend to your UI5 app.然后,您可以在 OData 服务中使用“函数导入”来将此值从后端获取到 UI5 应用程序。

But you might want to reconsider, since formatting the date should be handled by the browser locale instead a backend.但是您可能需要重新考虑,因为格式化日期应该由浏览器区域设置而不是后端处理。 But if your requirement forces you to do that, the way described above would be possible.但是,如果您的要求迫使您这样做,则上述方式是可能的。

The code below will return the format date set for user in transaction SU01下面的代码将返回在事务 SU01 中为用户设置的格式日期

select single ddtext
  from dd07t
  inner join usr01 on usr01~datfm = dd07t~domvalue_l
  into @data(lv_ddtext)
  where usr01~bname      = @sy-uname
    and dd07t~domname    = 'XUDATFM'
    and dd07t~ddlanguage = 'E'.
if sy-subrc is initial.
  find first occurrence of '(' in lv_ddtext match offset data(lv_offset).
  data(formatDate) = lv_ddtext(lv_offset).
endif.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM