Skip to Content
0
Former Member
Dec 03, 2009 at 05:54 PM

CONVERT DATE lv_date TIME lv_time DAYLIGHT SAVING TIME INTO timestamp

2727 Views

I have a simple ABAP that I have written

DATA : lv_date TYPE d VALUE '20090308',
       lv_time TYPE t VALUE '020000',
       l_from_tstamp TYPE timestampl,
       l_from_tstamp2 TYPE timestampl,
       dst(1) type c value ' ',
       l_system_timezone    TYPE sy-zonlo.


CALL FUNCTION 'GET_SYSTEM_TIMEZONE'
  IMPORTING
    timezone            = l_system_timezone
  EXCEPTIONS
    customizing_missing = 1
    OTHERS              = 2.


CONVERT DATE lv_date TIME lv_time DAYLIGHT SAVING TIME ' '
        INTO TIME STAMP l_from_tstamp
        TIME ZONE l_system_timezone.

WRITE /: l_from_tstamp, sy-subrc.

CONVERT DATE lv_date TIME lv_time DAYLIGHT SAVING TIME 'X'
      INTO TIME STAMP l_from_tstamp2
      TIME ZONE l_system_timezone.

WRITE /:l_from_tstamp2, sy-subrc.

The value of l_system_timezone is PST.

When I run this program I get SY-SUBRC = 12 after each call to CONVERT....

The only thing I could find in the help is

Time specification could not be converted, because dat, tim, or dst contain invalid or inconsistent values.

and also If dst has a different value or the specified value does not suit the value in tim and dat, the time_stamp remains unchanged and sy-subrc is set to 12.

Unfortunately I am not sure what is meant by the specified value does not suit the value in tim and dat

Anyone have any ideas? All I want to do is convert a date/time field into a time stamp

Edited by: Alon Raskin on Dec 3, 2009 7:04 PM