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: 

Display zero values and display blank if no data in ALV

Former Member
0 Kudos

Is there a way to suppress cells with numeric values in an ALV list? I am expecting the following:

1) non-zero value -> display

2) zero value -> display

3) no data -> blank

I have to write the same output to Excel and would want the Excel download to reflect the above scenarios as well.

I tried using 'no-zero' in my fieldcatalog but columns with zero values appear as blank instead of 0.0. Ideally, zero values should still appear in the ALV list output.

Any suggestions will be greatly appreciated.

Thanks.

4 REPLIES 4

varun_maharshi
Active Participant
0 Kudos

Simple solution. Change the field to Character type it will work

raymond_giuseppi
Active Contributor

If your data are currencies or quantities fields (CURR, QUAN) just clear the associated reference currency code or unit of measure (CUCY, UNIT) the result should be space and not 0 nor 0,00.

Regards.

0 Kudos

Hi Raymond,

Can you provide sample code to illustrate your suggestion?

Thanks.

First some doc

Extract from online help in FM REUSE_ALV_GRID_DISPLAY parameter IT_FIELDCAT

__________________

If a value field has a reference to a unit, this has the following

effects when the list is output:

- The decimal places are displayed with the proper unit.

- An initial value field with reference to a non-initial unit is

displayed as '0' (provided that FIELDCAT-NO_ZERO is initial). If

unit-specific totals are calculated for this value field, the

unit is considered in the analysis of whether homogeneous units

exist.

- An initial value field with reference to an initial unit is

displayed as SPACE. If unit-specific totals are calculated for

this value field, the unit SPACE has no effect on the

homogeneity of the unit if the value field is initial.

- For non-initial value fields with initial unit, the unit SPACE

is considered as a unit when unit-specific totals are

calculated.

__________________

When filling your fieldcat, if you don't use a dictionary structure, you will have to link the unit/currency with the quantity/amount so :

(...)

fieldcat-fieldname = 'WRBTR'.

fieldcat-datatype = 'CURR'.

fieldcat-ref_fieldname = 'WAERS'.

append fieldcat.

(...)

fieldcat-fieldname = 'WAERS'.

fieldcat-datatype = 'CUCY'.

append fieldcat.

(...)

You an hide the unit field with

fieldcat-tech = 'X'.

Of course for your purpose WAERS shall be in the table

When amount is not zero, you will get an output like this 123,45

When amount is zero

- if currency/unit is space, you will get space

- if currency/unit is not space, you will get 0,00

so when no-data, clear (or dont fill) the unit, else fill unit/currency

A more: if you totalize such a field, you will get one total per unit/currency

Regards