‎2007 Jul 11 12:21 PM
Is there any function module i can use to remove zeros in a dec field.
For example
I need to convert 12.300 to 12.3
Thanks.
‎2007 Jul 11 12:27 PM
Hi Jose,
you can do one way..but you need to move the decimal value to a character value, not sure if it suits ur requirement
REPORT ychatest.
DATA : v_dec TYPE p DECIMALS 3 VALUE '12.300',
v_char(20).
WRITE v_dec TO v_char.
CALL FUNCTION 'FTR_CORR_SWIFT_DELETE_ENDZERO'
CHANGING
c_value = v_char.
WRITE : / v_char.
‎2007 Jul 11 12:23 PM
Hi,
Declare decimal places 1 and convert it.
Reward if useful!
‎2007 Jul 11 12:25 PM
Yes but for example i can have:
12,210 and i need to convet it to 12.21
I don't know the number of decimal places.
‎2007 Jul 11 12:24 PM
Move the decimal value to a character field and use the SHIFT RIGHT statement.
data gv_value(15).
gv_value = gv_dec.
shift right gv_value deleting trailing '0'.
‎2007 Jul 11 12:25 PM
create another variable of type P.
assign to that variable.
when you write the value use "UPTO TO 2 DECIMAL".
‎2007 Jul 11 12:25 PM
hi,
U can use the function module 'CONVERSION_EXIT_ALPHA_OUTPUT'.
this would remove leading zeroes
Reward points if useful
Regards
Ashu
‎2007 Jul 11 12:25 PM
Hi,
You may use the option
field(.0) for printing the quantity
field(.2) for printing the amount..
Go through SAP help given below..
Number of Decimal Places
A program symbol of one of the data types DEC, QUAN, and FLTP can contain decimal place data. Use the option below to override the Dictionary definition for the number of decimal places for the formatting of this symbol value.
Syntax
&symbol(.N)&
The EKPO-MENGE field contains the value 1234.56. The Dictionary definition specifies 3 decimal places and an output length of 17.
&EKPO-MENGE& -> 1,234.560
&EKPO-MENGE(.1) -> 1,234.6
&EKPO-MENGE&(.4) -> 1,234.5600
&EKPO-MENGE&(.0) -> 1,235
‎2007 Jul 11 12:27 PM
use this function module:-
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = COMM_STRUCTURE-zcustomer
IMPORTING
OUTPUT = RESULT
Or u can use this FM also:-
ZSOLD_TO
rewards point if useful....
Thanks....
Abhay
‎2007 Jul 11 12:27 PM
Hi Jose,
you can do one way..but you need to move the decimal value to a character value, not sure if it suits ur requirement
REPORT ychatest.
DATA : v_dec TYPE p DECIMALS 3 VALUE '12.300',
v_char(20).
WRITE v_dec TO v_char.
CALL FUNCTION 'FTR_CORR_SWIFT_DELETE_ENDZERO'
CHANGING
c_value = v_char.
WRITE : / v_char.
‎2007 Jul 11 12:29 PM
simply use "DATA pack TYPE p DECIMALS 4 VALUE '1234.5678'."
or "WRITE pack DECIMALS 2"
‎2007 Jul 11 12:31 PM
Hello,
[code]
DATA:
L_MENGE_P5(16) TYPE P DECIMALS 5,
L_MENGE_P3(16) TYPE P DECIMALS 2,
L_ANDEC like T006-ANDEC value 2.
L_MENGE_P5 = '56.42000'.
CALL FUNCTION 'ROUND'
EXPORTING
DECIMALS = L_ANDEC
input = L_MENGE_P5 "over here u need to pass other than char
SIGN = '+'
IMPORTING
OUTPUT = L_MENGE_P3
EXCEPTIONS
INPUT_INVALID = 1
OVERFLOW = 2
TYPE_INVALID = 3
OTHERS = 4
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WRITE:/ L_MENGE_P3.
/code]
Regards,
Deepu.K