Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get Users laptop Time and date in ABAP ?

Former Member
0 Kudos

sy-uzeit is the system time

sydatum is the system date

I know this, i don't want this i need the time in your laptop. The one on the most right bottom with the date and time.

Does anyone know this ?

1 ACCEPTED SOLUTION

yogendra_bhaskar
Contributor
0 Kudos

Hi Mohamad ,

If the user is a windows user , in that case you can get the time zone of user's laptop.

You can code as below :

data: v_reg_value type string.

CALL METHOD cl_gui_frontend_services=>registry_get_value

   EXPORTING

     root                = CL_GUI_FRONTEND_SERVICES=>HKEY_LOCAL_MACHINE

     key                 = 'SYSTEM\CurrentControlSet\Control\TimeZoneInformation'

     value               = 'TimeZoneKeyName'

   IMPORTING

     reg_value           = v_reg_value

   EXCEPTIONS

     get_regvalue_failed = 1

     cntl_error          = 2

     error_no_gui        = 3

     not_supported_by_gui = 4

     others              = 5.



Regards

Yogendra Bhaskar

6 REPLIES 6

pranay570708
Active Contributor
0 Kudos

Check these fields:

SY-DATLO -  Local Date for Current User

SY-TIMLO - Local Time of Current User

0 Kudos

no this doesn't give me what i want. I want the laptop time of the user. Our application server is based in different location and this follows the server's OS date/time not the client date/time

0 Kudos

Check below code:

DATA:L_TIME  TYPE T,

      L_DATE  TYPE SY-DATUM,

      L_TZONE TYPE TTZDATA-TZONE,

      L_TSTMP TYPE TIMESTAMP.

CONVERT DATE SY-DATUM

         TIME SY-UZEIT

    INTO TIME STAMP L_TSTMP TIME ZONE SY-ZONLO.

CALL FUNCTION 'TZON_LOCATION_TIMEZONE'     "Get current country's timezone

   EXPORTING

     IF_COUNTRY        = 'IN'  "----> Pass country key here

   IMPORTING

     EF_TIMEZONE       = L_TZONE

   EXCEPTIONS

     NO_TIMEZONE_FOUND = 1

     OTHERS            = 2.

CONVERT TIME STAMP L_TSTMP TIME ZONE

        L_TZONE

      INTO DATE L_DATE

        TIME L_TIME.

0 Kudos

DATLO, TIMLO and ZONLO would give you the local values if the user has maintained a local timezone in their user profile (menu option System > User Profile > Own Data > Defaults).

0 Kudos

SY-DATLO/SY-TIMLO provide the user's local time, based on his user profile time zone (transactions SU01/SU3). I know this can be sometimes a problem if the user travels, but it should be sufficient most of the time, and he can also adjust the timezone himself using SU3.

yogendra_bhaskar
Contributor
0 Kudos

Hi Mohamad ,

If the user is a windows user , in that case you can get the time zone of user's laptop.

You can code as below :

data: v_reg_value type string.

CALL METHOD cl_gui_frontend_services=>registry_get_value

   EXPORTING

     root                = CL_GUI_FRONTEND_SERVICES=>HKEY_LOCAL_MACHINE

     key                 = 'SYSTEM\CurrentControlSet\Control\TimeZoneInformation'

     value               = 'TimeZoneKeyName'

   IMPORTING

     reg_value           = v_reg_value

   EXCEPTIONS

     get_regvalue_failed = 1

     cntl_error          = 2

     error_no_gui        = 3

     not_supported_by_gui = 4

     others              = 5.



Regards

Yogendra Bhaskar