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

Time Stamp Conversion

Former Member
0 Likes
2,754

Hi,

I need to convert the following time stamp into date and time. could any one help me how to do this?

Input format:

2008-05-19T01:00:00Z

Convert statement wont work as it has characters in it.

At present i have converted by using split statment. is there any other way of doing it ?

Regards,

Niyaz

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,415

Hi,

The FM ABI_TIMESTAMP_CONVERT_FROM converts timestamp into date and time.

Regards,

Sriram

5 REPLIES 5
Read only

GrahamRobbo
SAP Mentor
SAP Mentor
0 Likes
2,415

Hi Niyaz,

try this...

  DATA:
        lv_timestamp TYPE string VALUE '2008-05-19T01:00:00Z',
        lv_datum TYPE datum,
        lv_time TYPE uzeit.

  lv_datum(4) = lv_timestamp(4).
  lv_datum+4(2) = lv_timestamp+5(2).
  lv_datum+6(2) = lv_timestamp+8(2).

  lv_time(2) = lv_timestamp+11(2).
  lv_time+2(2) = lv_timestamp+14(2).
  lv_time+4(2) = lv_timestamp+17(2).

Cheers

Graham Robbo

Read only

0 Likes
2,415

Hi there,

it just occured to me that this would work as well.

  DATA:
        lv_timestamp TYPE string VALUE '2008-05-19T01:00:00Z',
        lv_datum     TYPE datum,
        lv_time      TYPE uzeit,
        lv_tstamp     TYPE tzntstmps.


  REPLACE ALL OCCURRENCES OF '-' IN lv_timestamp WITH ''.
  REPLACE ALL OCCURRENCES OF 'T' IN lv_timestamp WITH ''.
  REPLACE ALL OCCURRENCES OF ':' IN lv_timestamp WITH ''.
  REPLACE ALL OCCURRENCES OF 'Z' IN lv_timestamp WITH ''.

  MOVE lv_timestamp TO lv_tstamp.
  CONVERT TIME STAMP lv_tstamp TIME ZONE 'GMT   ' "Use sy-zonlo to convert to local timezone
   INTO DATE lv_datum TIME lv_time.

Cheers

Graham Robbo

Read only

Former Member
0 Likes
2,416

Hi,

The FM ABI_TIMESTAMP_CONVERT_FROM converts timestamp into date and time.

Regards,

Sriram

Read only

0 Likes
2,415

Hi,

As in above post u use the FM to get your output. Check the below code:

data : a type string,
       time_stamp type TZONREF-TSTAMPS,
       date type SY-DATLO,
       time type SY-TIMLO.
a = '2008-05-19T01:00:00Z'.
REPLACE ALL occurrences of '-' in a with space.
REPLACE ALL occurrences of ':' in a with space.
REPLACE ALL occurrences of 'T' in a with space.
REPLACE ALL occurrences of 'Z' in a with space.

time_stamp = a.
CALL FUNCTION 'ABI_TIMESTAMP_CONVERT_FROM'
  EXPORTING
    iv_timestamp           = time_stamp
 IMPORTING
   O_DATE                 = date
   O_TIME                 = time
 EXCEPTIONS
   CONVERSION_ERROR       = 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.


write : date, time.

Regards,

Raghu

Read only

Former Member
0 Likes
2,415

Hi,

Use the methods in the class cl_abap_tstmp

Shruthi