11-18-2010 7:47 AM
Hi Experts,
I've used the ALV as an input control and make some columns as editable. However, when I input the decimal and update it to internal table, the result will be divied by 10^n (n is the decimal places).
My code is like below
internal table definition:
DATA: BEGIN OF it_output OCCURS 0,
price TYPE p DECIMALS 2,
END OF it_output.
fieldcat definition:
it_fieldcat-fieldname = 'PRICE'.
it_fieldcat-edit = 'X'.
it_fieldcat-seltext_s = text-f07.
it_fieldcat-seltext_m = text-f07.
it_fieldcat-seltext_l = text-f07.
it_fieldcat-decimals_out = 2.
What I want is when I input '100', the result should be '100.00', but not '1.00'.
11-18-2010 9:09 AM
Hi,
DATA: BEGIN OF it_output OCCURS 0,
price(10) TYPE p DECIMALS 2, " Lenght should be given
END OF it_output.
Regards,
Madhukar SHetty
11-18-2010 12:33 PM
11-18-2010 1:01 PM
In a type P field, the decimal point is implied. In your case, SAP is correctly assuming that 100 is 1.00. If you want something different, you need to put the value into a character field, examine for a decimal, add a decimal and two zeroes if it is not there, then put back into your type p field.
something like:
data: charf15) type c.
charf = packedf.
if charf cs '.'.
else.
concatenate charf '.00' into charf.
endif.
pacedf = charf.
11-18-2010 5:35 PM
I haven't tried it, but I wonder if something like
it_fieldcat-edit_mask = 'RR_______.__' .
would work.