0

I created Data element ZDT_NKS_DESCR and flagged Change Document when creating for logging the changes on WebUI table. Everything is good, but the time of changing logging wrong. It adds +3 hours to current time.

For example: if the current time is 10:00 it's logging 13:00 on Web UI.

How can I fix it? Can anybody explain what happens?

Here is my data element (NB: in fact I ticked the "Change Document" checkbox later on):

Flagged the red zone in Data Element Setting

Here is the change logging on Web UI table, the time should be 9:48, 9:48, 9:45 :

Change logging on Web UI table. The time should be 9:48, 9:48, 9:45

P.S: On Web UI timezone is correct.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
user11823122
  • 99
  • 4
  • 16

2 Answers2

2

In ABAP-based softwares, many screens display the dates using the SAP system time unfortunately (that's been always a big problem). Some modules sometimes display the local time (according to user's time) or according to the local time of the partner (transportation modules for instance). So users have to learn for every module or every screen what kind of date/time it is.

Even in database tables, it's impossible to be sure what kind of date/time it is. Usually it's the system time. But some modules may store the date/time according to UTC.

I guess that the times of the change documents are displayed in the system time.

The system time can be seen via the classic SAP GUI, in the menu System > Status > System time.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
  • Thanks a lot, Sandra for your answer. I checked current date in my DEV and Test system. There's correct Date and Time. In `CHANGEDOCUMENT_CLOSE` function I changed `time_of_change` value from `utime` to `sy-timlo` and then to `sy-uzeit`, but it not works. Is there any other way to solve my problem? – user11823122 Aug 19 '19 at 09:09
  • I have just checked how change documents are written by the standard programs, and they store the system time (the system time for "now" is in variables `sy-datum` and `sy-uzeit`). Note that the time zone of `sy-datlo` and `sy-timlo` is the one of the user (cf tcode `SU01` or `SU3`). You shouldn't store the time of a different time zone, use only the system time, or the table (`CDHDR`) will contain mixed time zones and it will be just a mess in the future. You must find the cause before doing anything. The cause is about the display. Maybe you interpret some time zone settings incorrectly. – Sandra Rossi Aug 19 '19 at 10:23
  • My Timezone calls `R03`. On my Web UI setting timezone is not chosen. On Web UI, when I choose `UTC` it shows me a correct time, but when I choose `R03` it shows me `+3 hours` to current day. How can I put my timezone into the `xxxxx_WRITE_DOCUMENT` FM. May be, when I put my timezone it would shows me the correct time? – user11823122 Aug 19 '19 at 10:55
  • As I said, you **must** pass the time in the "system time" time zone (`sy-uzeit`) to `xxxxx_WRITE_DOCUMENT`. The issue concerns only the display. – Sandra Rossi Aug 19 '19 at 11:06
2

Here's my final solution based on Sandra answer:

  1. In xxxxx_WRITE_DOCUMENT FM we should change time_of_change value from utime to sy-uzeit. Your CHANGEDOCUMENT_CLOSE function should look like this:
CALL FUNCTION 'CHANGEDOCUMENT_CLOSE'
    EXPORTING
      objectclass             = 'ZCHD00005'
      objectid                = objectid
      date_of_change          = udate
      time_of_change          = sy-uzeit (it's current system time)
      tcode                   = tcode
      username                = username
      object_change_indicator = object_change_indicator
      no_change_pointers      = no_change_pointers
    EXCEPTIONS
      header_insert_failed    = 1
      object_invalid          = 2
      open_missing            = 3
      no_position_inserted    = 4
      OTHERS                  = 5.
  1. If it's necessary, you should change the timezone on WebUI. I'm using system timezone, because of this on WebUI->Personalization->Timezone I choose UTC from F4.

  2. Save and activate your solution!

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
user11823122
  • 99
  • 4
  • 16