Application Development and Automation 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: 
Read only

cl_gui_alv_grid: Display Zero-Values with 3 decimals digits

Former Member
0 Kudos
735

Hi everybody,

<b>This is the problem:</b>

I need to display quantities with 3 decimals.

This works fine, but only if there are decimal values:

(123.001) but not, if the figure is zero or doesn't have any decimals.

(123 or 0)

But the customer wants to get the figures shown as follows:

123.000

123.001

0.000

<b>REMARK:</b>

If I use FM: call function 'REUSE_ALV_GRID_DISPLAY' it works fine!

<b>These are my settings:</b>

The field <BTGEW> is defined as quantity.

LOOP AT ct_fcat INTO ls_fcat.

ls_fcat-edit = false.

CASE ls_fcat-fieldname.

WHEN 'BTGEW' .

ls_fcat-decimals_o = 3.

ls_fcat-no_zero = false.

ls_fcat-outputlen = '15'.

ls_fcat-do_sum = true.

ls_fcat-qfieldname = 'GEWEI'.

ls_fcat-tabname = 'ZWIT02_AUS_LFK_CNTRL'.

  • clear: ls_fcat-tabname,

  • ls_fcat-qfieldname.

  • ls_fcat-datatype = 'DEC'.

  • ls_fcat-edit_mask = '____________,___'.

</b>

Thanks a lot in advance for your help

Michael<b></b>

1 ACCEPTED SOLUTION
Read only

Former Member
0 Kudos
493

Hi,

You can create a Coversion exit of your own , an try adding that to

ls_fcat-convexit.

Regards,

5 REPLIES 5
Read only

Former Member
0 Kudos
494

Hi,

You can create a Coversion exit of your own , an try adding that to

ls_fcat-convexit.

Regards,

Read only

0 Kudos
493

Hi sreejesh,

Thanks a lot for your reply.

But in fact this way was not necessary but a very good idea!

<b>Funnywise this solution works:</b>

Do not define the field as quantity, define it as DEC 15:3

And now the most important point:

Define the properties of the column as follows:

ls_fcat-decimals_o = 3.

ls_fcat-no_zero = false.

ls_fcat-datatype = 'DEC'.

ls_fcat-outputlen = '15'.

ls_fcat-do_sum = true.

*:--- This is the point! >>>

clear: ls_fcat-tabname,

ls_fcat-qfieldname.

*:--- <<<<

I have rewarded you some points

BR

Michael

Read only

Former Member
0 Kudos
493

Hi

Why dont you define your decimals field as type p decimals 3 and then pass the value to a field of type char when you are passing it to the ALv.

this should solve your problem.

Also check out this link

http://help.sap.com/saphelp_erp2004/helpdata/en/ff/4649baf17411d2b486006094192fe3/content.htm

Read only

0 Kudos
493

Hi Dominic,

This is exactly what i have done first.

But it didn't work as i expected.

Now I found out why:

Additionally to these properties you must clear all field-references, so the parser

will take the field-Type as it is.

ls_fcat-decimals_o = 3.

ls_fcat-no_zero = false.

ls_fcat-datatype = 'DEC'.

ls_fcat-outputlen = '15'.

*:--- AND CLEAR ALL TABLE-REFERENCES!

clear: ls_fcat-tabname,

ls_fcat-qfieldname.

This is the point.

If you don't do this, it won't work.

BR

Michael

Read only

Former Member
0 Kudos
493

The solution is:

ls_fcat-decimals_o = 3.

ls_fcat-no_zero = false.

ls_fcat-datatype = 'DEC'.

ls_fcat-outputlen = '15'.

*:--- AND CLEAR ALL TABLE-REFERENCES!

clear: ls_fcat-tabname,

ls_fcat-qfieldname.