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

CTCV_CONVERT_FLOAT_TO_DATE

0 Likes
2,379

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

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
0 Likes
1,997

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 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

6 REPLIES 6
Read only

Former Member
0 Likes
1,997

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

Read only

0 Likes
1,997

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

Read only

0 Likes
1,997

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.

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,998

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'.

Read only

0 Likes
1,997

Hi Sandra,

Thank you for response. it's working.

Just wanted to know significance of last statement if you can explain.

Read only

0 Likes
1,997

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 ).