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

Need to get Decimal points dynamically.

former_member196331
Active Contributor
0 Likes
2,531

hi.

Need suggestion. I have one scenario
Values are coming into FM like 5678.65800341 , Char(30). ( should not change data type).

decimal points.. need to pick dynamically.
In t006, Field ANDEC - No of decimals. (values will exists like 0,1,2,3)

if 0 means. 5678 then, 1 means 5678.6 and, 2 means 5678.65

Like suppose to come.

If i use any round function like below.
DATA(lv_round) = round( val = '5678.65800341' dec = 2 ).

The result is '5678.66. I need '5678.65.

How could i achieve this requirement.

1 ACCEPTED SOLUTION
Read only

pataselano
Active Contributor
2,306

Please check SAP Help round, rescale - Rounding Functions .

You can use mode = ROUND_HALF_DOWN in your round formula.

hi.

Need suggestion. I have one scenario
Values are coming into FM like 5678.65800341 , Char(30). ( should not change data type).

decimal points.. need to pick dynamically.
In t006, Field ANDEC - No of decimals. (values will exists like 0,1,2,3)

if 0 means. 5678 then, 1 means 5678.6 and, 2 means 5678.65

Like suppose to come.

If i use any round function like below.
DATA(lv_round) = round( val = '5678.65800341' dec = 2 ).

The result is '5678.66. I need '5678.65.

How could i achieve this requirement.

4 REPLIES 4
Read only

FredericGirod
Active Contributor
2,306

looks like you want to change Idoc input data to quantity field with dynamic unit of quantity. If yes, check the code of FM CIF_GEN_CONVERT_QUANTITY_ISO

Read only

former_member196331
Active Contributor
0 Likes
2,306

No No.. this is different requirement...

Read only

pataselano
Active Contributor
2,307

Please check SAP Help round, rescale - Rounding Functions .

You can use mode = ROUND_HALF_DOWN in your round formula.

Read only

Jorge_Herrero_Blanco
Participant
0 Likes
2,306

If values coming into FM are type char. You can search for the '.' in the number and then shown only the number of characters from the point that are required.

FIND FIRST OCCURRENCE OF '.' IN number MATCH OFFSET(dec_point)
dec_point = dec_point + places + 1. "Plus 1 for the point and places is the number of decimals to be shown
decimal = number(dec_point).