Convert Time between time zones

By Suresh Kumar Parvathaneni

This is regarding the conversion of time between different time zones. In order to achieve this, first we need to convert the time to standard GMT and from GMT to the required time zone.

The following function modules does the same.

The function module IB_CONVERT_INTO_TIMESTAMP is used to convert the time to the GMT. The input parameters are DATE, TIME and the TIMEZONE(user's time zone, default value SY-ZONLO). The output parameter is the timestamp in GMT.

The function module IB_CONVERT_FROM_TIMESTAMP is used to get the time in required time zone. The input parameters for this are the timestamp obtained from the above function module and the time zone, to which the time needs to be converted.

The output parameters are the date, time in the required time zone.

Code

REPORT ZTIMEZONES .

*****************************************************
* This program is used to convert the times between *
* different time zones. This program deals with the  *
* conversion of time from INDIA time zone to the PST *
* time zone                                          *
*****************************************************

* Declaring the work variables.......................
DATA :
  timestamp like TZONREF-TSTAMPS,
  time      like sy-uzeit,
  date      like sy-datum.

* The following function module is used to convert the
* time and date into GMT timestamp

CALL FUNCTION 'IB_CONVERT_INTO_TIMESTAMP'
  EXPORTING
    i_datlo           = sy-datum
    i_timlo           = sy-uzeit
    I_TZONE           = 'INDIA'
 IMPORTING
   E_TIMESTAMP       = timestamp.

* The following function module is used to convert the
* above obtained timestamp to PST time zone date and time.

CALL FUNCTION 'IB_CONVERT_FROM_TIMESTAMP'
  EXPORTING
    i_timestamp       = timestamp
    I_TZONE           = 'PST'
 IMPORTING
    E_DATLO           = date
    E_TIMLO           = time.

write :/ 'Date and Time at PST zone is ',date, time.


 


 

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image