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

condition to be used for numerical value processing

Ranjith_D_Reddy
Participant
0 Likes
692

After passing the material number into a customized function module  I am getting the output value in numerical format.

It may be in the form of 1.2345 or 12 0r 1.2 or 1.22

After getting that result I need to do the following operation on it

If the output has more than 2 decimal places then the value must be trimmed

If the output has 2 decimal places then the value must be showed alike

Here are the samples

4.6 % should be converted to 4.60 %

43 % should be converted to 43.00 %

16.325 % should be converted to 16.32 %

After passing the material number into a customized function module  I am getting the output value in numerical format.

It may be in the form of 1.2345 or 12 0r 1.2 or 1.22

After getting that result I need to do the following operation on it

If the output has more than 2 decimal places then the value must be trimmed

If the output has 2 decimal places then the value must be showed alike

Here are the samples

4.6 % should be converted to 4.60 %

43 % should be converted to 43.00 %

16.325 % should be converted to 16.32 %

5 REPLIES 5
Read only

Former Member
0 Likes
665

hi,

Use below code.Let your variable be lv_variable.

data: lv_var type p decimals 2.

lv_var = lv_variable.

Its very simple 2 line code is enough.

Read only

0 Likes
665

This message was moderated.

Read only

0 Likes
665

hi sai,

how to add zero if he decimal length is 1 for sample

if value is 12.3 i need to get 12.30

Read only

0 Likes
665

it worked only 1f we will pass the values like 12.22,3.65,2.5555

but if the value is 12.6999 means the value is we get the output as 12.70

Read only

0 Likes
665

Hi Ranjith,

Try this code

PARAMETERS: p_menge TYPE mara-brgew.

data: lv_var type p decimals 2.

lv_var = p_menge.

if p_menge < lv_var.

   lv_var = lv_var - '0.01' .

endif.

I tried it is working fine for both of your  requirements.