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: 

Removing Zeros from a quantity field in SALV factory method

Former Member
0 Kudos

Hello Experts ,

I have a requirement of removing the zeros after decimal point  while displaying in ALV.

e.g 4.000 --> '4' .

I have used lo_column->set_decimals( '0' ).But I don't find any difference.

I am using SALV factory method for ALV display.

Kindly advice.

Thanks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

The simplest solution is to move the value to a column of type i and display that column.

Neal

7 REPLIES 7

Former Member
0 Kudos

The simplest solution is to move the value to a column of type i and display that column.

Neal

former_member585060
Active Contributor
0 Kudos

Hi,

Declare that quantity field like P LENGTH 16 DECIMALS 3. Then use lo_column->set_decimals( '0' ).

Thanks & Regards

Bala Krishna

manuelhildemaro_ramossanc
Active Participant
0 Kudos

Hi Elakkiya.

If you don't want to change the column type , you need to change some fields of the column when the catalog is generated.

I used the next lines to show 2 decimals instead 3( field type = BRGEW 😞

        <w_fcat>-decimals_o = 2.

         <w_fcat>-decimals    = 2.

         clear: <w_fcat>-domname,

                   <w_fcat>-qfieldname,

                   <w_fcat>-ref_table,

                   <w_fcat>-datatype.

Regards,

Manuel H.

LeonvNiekerk
Explorer

lr_col->set_edit_mask( value = '==DEC0' ).

I think this is the best solution since we are often dealing with native SAP fields in structures and redefining the fields, creating new data elements, etc. is overkill.

This method worked great for me and is just want I wanted. Much appreciation to leon_van_niekerk

0 Kudos

yep, gud 1!

0 Kudos

Thanks, this works well to remove decimals, however is there any way to remove comma using lr_col->set_edit_mask ?

12,123 comma needs to be removed.