Application Development and Automation 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: 
Read only

Timezone Conversion

Former Member
0 Likes
1,142

Hi,

I am planning to use the Function Module TZ_LOCAL_TO_SYSTEM in my program however, I found out that it was already marked as obsolete. Would somebody know which FM replaced this ? This function module converts a timezone specific date/time to the system time.

Thanks

3 REPLIES 3
Read only

Former Member
0 Likes
748
Read only

Former Member
0 Likes
748

Hi,

Check this example for converting the time according to the time zone..

TYPE-POOLS: tstr.

DATA :

timestamp LIKE tzonref-tstamps,

time LIKE sy-uzeit,

date LIKE sy-datum.

DATA: timezone TYPE tstr_tzone.

PARAMETERS: p_land1 TYPE land1.

  • Get Timezone for the country.

CALL FUNCTION 'BORRS_LOCATION_TIMEZONE'

EXPORTING

if_country = p_land1

IMPORTING

ef_timezone = timezone

EXCEPTIONS

no_timezone_found = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

  • Get the timestamp.

CALL FUNCTION 'IB_CONVERT_INTO_TIMESTAMP'

EXPORTING

i_datlo = sy-datum

i_timlo = sy-uzeit

i_tzone = sy-zonlo

IMPORTING

e_timestamp = timestamp.

  • Convert timestamp.

CALL FUNCTION 'IB_CONVERT_FROM_TIMESTAMP'

EXPORTING

i_timestamp = timestamp

i_tzone = timezone

IMPORTING

e_datlo = date

e_timlo = time.

WRITE 😕 'Date and Time zone for time zone', timezone, ' is ',

date, time.

Thanks,

Naren

Read only

Former Member
0 Likes
748

Concatenate date and time into a timestamp variable and use the following syntax.


DATA: ic_timestamp(15) TYPE c,
      iv_timestamp     LIKE tzonref-tstamps,
      ev_date          LIKE sy-datum,
      ev_time          LIKE sy-uzeit,
      v_zone           LIKE sy-zonlo.

CONCATENATE sy-datum
            sy-uzeit
       INTO ic_timestamp.
iv_timestamp = ic_timestamp.
v_zone = 'PST'.
CONVERT TIME STAMP iv_timestamp
        TIME ZONE  v_zone
        INTO DATE  ev_date
             TIME  ev_time.

WRITE:/ ev_date, ev_time.