I am having an OData Service returning some DateTime
values. They are saved in a table in the back end as TIMESTAMPL
(with some other data).
Now there is the value 20160630084459.5000
. With MOVE-CORRESPONDING
into the et_entityset
, where it is a TIMESTAMP
. Because of the rounding, it gets 20160630084460
, Since a the seconds must be between 00
and 59
, this is not a valid value to return.
My main problem is, that my table has extremely much entries, so I need a performant way to fix this error.
First of all your TIMESTAMPL
value is incorrect. The first eight positions do not conform to the YYYYMMDD
pattern. So I assume it should be 20160630084459.5000
instead of 20163006084459.5000
(20160630
vs. 20163006
).
Second of all here is a way to convert it to what you want.
REPORT zzy NO STANDARD PAGE HEADING.
FORM convert_timestamp.
DATA(l_t1) = CONV timestampl('20160630084459.5000').
DATA: l_t2 TYPE timestamp.
l_t2 = l_t1.
WRITE / : l_t1, l_t2.
CONVERT TIME STAMP l_t1 TIME ZONE sy-zonlo INTO DATE DATA(l_date) TIME DATA(l_time).
CONVERT DATE l_date TIME l_time INTO TIME STAMP l_t2 TIME ZONE sy-zonlo.
WRITE / l_t2.
ENDFORM.
START-OF-SELECTION.
PERFORM convert_timestamp.
Here is the output.
20.160.630.084.459,5000000
20.160.630.084.460
20.160.630.084.459
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With