Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SAP ALV input decimal problem

Former Member
0 Kudos

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'.

4 REPLIES 4

Former Member
0 Kudos

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

0 Kudos

Sorry, but it doesn't work.

Best regards,

Former Member
0 Kudos

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.

MrWhan
Participant
0 Kudos

I haven't tried it, but I wonder if something like


it_fieldcat-edit_mask = 'RR_______.__' .

would work.