Application Development 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: 

Need to get Decimal points dynamically.

former_member196331
Active Contributor
0 Kudos

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

pataselano
Active Contributor

Please check SAP Help round, rescale - Rounding Functions .

You can use mode = ROUND_HALF_DOWN in your round formula.

4 REPLIES 4

FredericGirod
Active Contributor

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

former_member196331
Active Contributor
0 Kudos

No No.. this is different requirement...

pataselano
Active Contributor

Please check SAP Help round, rescale - Rounding Functions .

You can use mode = ROUND_HALF_DOWN in your round formula.

S0010925360
Participant
0 Kudos

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