2016 Sep 22 8:41 PM
Hi Team,
I need help to get solution for the below issue.
When FLOAT passed to FM CTCV_CONVERT_FLOAT_TO_DATE has exponent with 07, it works well & returns the date.
Example input value = 2.0170731000000000E+07 will return Date as 20170731.
Issue is when the exponent value is more than 07.
Example : 2.0101025000000000E+13 will return Date as 25000000
Please help in overcoming with this issue.
Thanks in advance!!
Anil Sahni
2016 Sep 24 9:54 AM
DATA date_c TYPE string.
DATA date_f TYPE f VALUE '2.0160924E+13'.
date_c = substring( val = |{ date_f }| len = 8 ).
WRITE date_c.
ASSERT date_c = '20160924'.
Hi Sandra,
Thank you for response. it's working.
Just wanted to know significance of last statement if you can explain.
2016 Sep 22 8:56 PM
I think in this case the issue is with the data: 2.0101025000000000E+13 not with the FM.
Check why you are getting that value and the value is definitely NOT a date.
-Chandra
2016 Sep 22 9:04 PM
Hi Chandra,
Data was assigned to modified characteristics values for some other requirement, I agree which is actually not a date after the modification. Still looking for possible options to retrieve date for such a combination.
Any possible thought to extract it.
Thanks!
Anil Sahni
2016 Sep 22 9:19 PM
Well, I would say it is not good to try extracting date from bad data (2.0101025000000000E+13).
If you are sure that the data is bad then try to see how you can get the correct data. Rather than exploring the options to get values from the bad data. I think there is no way to get date from this data.
2016 Sep 24 9:54 AM
DATA date_c TYPE string.
DATA date_f TYPE f VALUE '2.0160924E+13'.
date_c = substring( val = |{ date_f }| len = 8 ).
WRITE date_c.
ASSERT date_c = '20160924'.
2016 Sep 26 5:39 PM
Hi Sandra,
Thank you for response. it's working.
Just wanted to know significance of last statement if you can explain.
2016 Sep 26 7:40 PM
ASSERT is a statement which you should not use/remove from your code. ASSERT (cf ASSERT in ABAP Doc.) is followed by a logical expression which must be true, otherwise the program will short dump. I use it to say "here date_c equals '20160924' for sure! The concept of "assertion" is more used in its ABAP Unit (cf SAP Library) form, i.e. for instance cl_aunit_assert=>assert_not_initial( act = variable ).
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |