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: 

getting time based on country

Former Member
0 Kudos

Hi experts,

I need to create a function module to convert time based on country.

i.e if user asked to display the US time it should come and if he wants uk it should come rather than Indian time.

Is there any table where I can get times of all countries?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

check this code


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

2 REPLIES 2

Former Member
0 Kudos

Hi,

check this code


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

Former Member
0 Kudos

hi,

I can't use convert function module,

I need to crearte a function module for this requriement