cancel
Showing results for 
Search instead for 
Did you mean: 

regarding smartform

Former Member
0 Kudos

Moved to correct forum by moderator. Please use a more informative subject in future

hi

i am developing a smartform for invoice

while displaying the item data , the qty field i am getting like 280.00.

my requirement is if qty is 280.00 , then i have to display 280

if quantity is 280.56 i have to display 280.56 only.

can any one give me the solution, i tried with trunc , round , ceil

but i couldn't get the exact output

Edited by: Matt on Feb 17, 2009 11:43 AM

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

Try this,

DATA: l_val1 TYPE string,

l_val2 TYPE string,

l_val TYPE string,

l_num TYPE string.

split l_num at '.' into l_val1 l_val2 .

IF l_val2 > 0.

concatenate l_val1 l_val2 into l_val separated by '.'.

else.

l_val = l_val1.

endif.

Write: l_val1, l_val2, l_val.

Regards,

Joan

Former Member
0 Kudos

hi!

use this in your smartform as a formatting option with ur quantity field....

&t_itab-quantity(.0)&

matt
Active Contributor
0 Kudos

Please use a more informative subject in future

christine_evans
Active Contributor
0 Kudos

>

> hi

> i am developing a smartform for invoice

> while displaying the item data , the qty field i am getting like 280.00.

> my requirement is if qty is 280.00 , then i have to display 280

> if quantity is 280.56 i have to display 280.56 only.

>

> can any one give me the solution, i tried with trunc , round , ceil

> but i couldn't get the exact output

Use MOD to get the remainder and use this to decide whether to show the decimal places or not.

lv_out = lv_num1 MOD lv_num2.

Former Member
0 Kudos

if u dnt want to do in smartform and want to do in ur program then test this sample code.

data: p type p decimals 2 value '2.36',
      string type string.
string = p.
shift string right deleting trailing ' .00'.
write: string.

SuhaSaha
Advisor
Advisor
0 Kudos

Hello,

Try like this:

DATA:
v_int TYPE i,
v_dec TYPE i.

v_int = trunc( v_qty ).

v_dec = frac( v_qty ).

IF v_dec = 0. "No. has no decimal places
WRITE: / 'Quantity: ', 10 v_int.
ELSE.
WRITE: / 'Quantity: ', 10 v_qty.
ENDIF.

In SFs, instead of the IF...ELSE you can use an alternative node & proceed.

BR,

Suhas

Former Member
0 Kudos

in text filed when u enetr the key field

just do it as &itab-qty(.0)&

Former Member
0 Kudos

hi

use the SPLIT command check the value after . if it is 00 truncate it else display it.