on 02-17-2009 10:15 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi!
use this in your smartform as a formatting option with ur quantity field....
&t_itab-quantity(.0)&
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please use a more informative subject in future
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>
> 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
in text filed when u enetr the key field
just do it as &itab-qty(.0)&
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.