04-12-2007 11:20 AM
Hi friends,
is there a way to wether display the decimal part or to not.
eg :
if i have 123,112 -
> 123,112 will be displayed
or 1235,000 -
> only 1235 will be displayed
Thanks
Regards
Soufiane
04-12-2007 11:27 AM
data : pre(7),
after(7),
amt type p decimals 3 value '3456.000',
charo(14).
charo = amt.
split charo at ',' into pre after.
clear : charo
if after cp '*000'.
charo = pre.
else.
shift after right deleting trailing '0'.
concatenate pre after into charo.
endif.
write : / charo.
regards
shiba dutta
04-12-2007 11:23 AM
Hi Soufiane,
Check this info.
Please use FM
CONVERSION_EXIT_ALPHA_INPUT Conversion exit ALPHA, external->internal
CONVERSION_EXIT_ALPHA_OUTPUT Conversion exit ALPHA, internal->external
Ex :
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wf_version
IMPORTING
output = wf_version.
Hope this resolves your query.
Reward all the helpful answers.
Regards
04-12-2007 11:23 AM
hi,
u can use like this
a = '123.111'.
write a no decimals. (it wil not dislay any dec places).
reward points if helpful
ravi
04-12-2007 11:26 AM
u can also move the value to a integer field and then the rounded value will be displayed
04-12-2007 11:27 AM
data : pre(7),
after(7),
amt type p decimals 3 value '3456.000',
charo(14).
charo = amt.
split charo at ',' into pre after.
clear : charo
if after cp '*000'.
charo = pre.
else.
shift after right deleting trailing '0'.
concatenate pre after into charo.
endif.
write : / charo.
regards
shiba dutta
04-12-2007 11:31 AM
Hi..,
Check this code..
data p type p decimals 3 value '123.000'.
data i type p decimals 3.
i = frac( p ).
if i eq 0.
write p decimals 0.
else.
write p.
endif.
**********************************
output 123
**********************************
data p type p decimals 3 value '123.111'.
data i type p decimals 3.
i = frac( p ).
if i eq 0.
write p decimals 0.
else.
write p.
endif.
**********************************
output 123.111
**********************************
reward if it helps u..
sai ramesh
04-12-2007 11:32 AM
chk this
DATA: I TYPE I.
DATA: P TYPE P DECIMALS 3.
DATA: MOD TYPE I.
P = '12.000'.
I = P.
P = P * 1000.
I = I * 1000.
MOD = P MOD I.
IF MOD IS INITIAL.
I = I / 1000.
WRITE: / I.
ELSE.
P = P / 1000.
WRITE: / P.
ENDIF.
If you give P = '12.500', it will display 12.500..
If you give P = '12.000', it will display 12
04-12-2007 11:33 AM
HI,
Using the write statment, you can write the addition DECIMALS d
Effect
d specifies the number of decimal places for a number field (type I , P or F ) in d . If this value is smaller than the number of decimal places in the number, the number is rounded. If the value is greater, the number is padded with zeros.
Since accuracy with floating point arithmetic is up to about 15 decimal places (see ABAP/4 number types ), up to 17 digits are output with floating point numbers (type F ). (In some circumstances, 17 digits are needed to differentiate between two neighboring floating point numbers.) If the output length is not sufficient, as many decimal places as possible are output. Negative DECIMALS specifications are treated as DECIMALS 0 .
Example
Effect of different DECIMALS specifications:
DATA: X TYPE P DECIMALS 3 VALUE '1.267',
Y TYPE F VALUE '125.456E2'.
WRITE: /X DECIMALS 0, "output: 1
/X DECIMALS 2, "output: 1.27
/X DECIMALS 5, "output: 1.26700
/Y DECIMALS 1, "output: 1.3E+04
/Y DECIMALS 5, "output: 1.25456E+04
/Y DECIMALS 20. "output: 1.25456000000000E+04
and also you can use ROUND
Effect
Scaled output of a field of type P .
The decimal point is first moved r places to the left ( r > 0) or to the right ( r < 0); this is the same as dividing with the appropriate exponent 10** r . The value determined in this way is output with the valid number of digits before and after the decimal point. If the decimal point is moved to the left, the number is rounded.
For further information about the interaction between the formatting options CURRENCY and DECIMALS , see the notes below.
&ABAP-EXAMPLE& Effect of different ROUND specifications:
DATA: X TYPE P DECIMALS 2 VALUE '12493.97'.
WRITE: /X ROUND -2, "output: 1,249,397.00
/X ROUND 0, "output: 12,493,97
/X ROUND 2, "output: 124.94
/X ROUND 5, "output: 0.12
So, in your Loop, use the WRITE TO statment to move the internal table data with the perfect decimal places for each single field in the loop
Regards
Sudheer
04-12-2007 11:34 AM
Hi..
this will solves..
data:
w_p type p decimals 3 value '345.000',
w_i type i.
i = frac ( w_p ).
<b>if i > 0.
write w_p.
else.
<b> write: / w_p decimals 0.</b>
endif.</b>
04-12-2007 11:42 AM
04-12-2007 12:07 PM
hi thany all for the replies,
the FM 'FTR_CORR_SWIFT_DELETE_ENDZERO' works for me but there is a little pb with it ex:
if i have 123,112 -
> 123,112 is displayed
or 1235,000 -
> 1235, is displayed (with the comma ! )
here is my code
write ds_items-kwmeng to L_QTY.
CALL FUNCTION 'FTR_CORR_SWIFT_DELETE_ENDZERO'
CHANGING
C_VALUE = L_QTY .
condense L_QTY.
04-12-2007 12:10 PM
just use this
CALL FUNCTION 'FTR_CORR_SWIFT_DELETE_ENDZERO'
CHANGING
C_VALUE = L_QTY .
condense L_QTY.
<b>translate l_qty using ', '.</b>
04-12-2007 12:08 PM
04-12-2007 12:13 PM
Ok but when i'm having 123,012 as a value i will get 123 0123 without ,
04-12-2007 12:16 PM
Check this code..
use FRAC function...
<b>data p type p decimals 3 value '123.000'.
data i type p decimals 3.
i = frac( p ).
if i eq 0.
write p decimals 0.
else.
write p.
endif.
**********************************
output 123
**********************************
data p type p decimals 3 value '123.111'.
data i type p decimals 3.
i = frac( p ).
if i eq 0.
write p decimals 0.
else.
write p.
endif.
**********************************
output 123.111
**********************************</b>
reward if it helps u..
sai ramesh
04-12-2007 12:16 PM
Oh ok,
try this
v_len = strlen(l_qty).
v_len = v_len - 1.
if l_qty+v_len(1) eq ','.
translate l_qty using ', '. " If last character is a comma
endif.
04-12-2007 12:16 PM
try this
data :
ch(30) type c value '563,'.
data : bef(15), aft(15).
split ch at ',' into bef aft.
clear ch.
if not aft is initial.
concatenate bef aft into ch.
else.
ch = bef.
endif.
write : / ch.
regards
shiba dutta
04-12-2007 12:17 PM
Pb resolved i used this
CALL FUNCTION 'FTR_CORR_SWIFT_DELETE_ENDZERO'
CHANGING
C_VALUE = L_QTY .
condense L_QTY.
if L_QTY cp '*,'.
translate l_qty using ', '.
endif.
Thank you all
04-12-2007 12:19 PM
04-12-2007 12:21 PM