How to avoid displaying zero in data cells in ALV

Sometimes it's useful to avoid displaying zero in ALV data cells, the easiest way is to use set_zero method of a column:
screenshot
REPORT zkm_test.

TYPES:
  BEGIN OF ts_data,
    amount TYPE dmbtr,
    text   TYPE sgtxt,
  END OF ts_data,
  tt_data TYPE STANDARD TABLE OF ts_data.

DATA:
  lt_data    TYPE tt_data,
  ls_data    TYPE ts_data,
  lo_table   TYPE REF TO cl_salv_table,
  lo_columns TYPE REF TO cl_salv_columns,
  lo_column  TYPE REF TO cl_salv_column.

ls_data-amount = 1.   ls_data-text = 'first'.    APPEND ls_data TO lt_data.
ls_data-amount = 0.   ls_data-text = 'second'.   APPEND ls_data TO lt_data.
ls_data-amount = 2.   ls_data-text = 'third'.    APPEND ls_data TO lt_data.

CALL METHOD cl_salv_table=>factory
  IMPORTING
    r_salv_table = lo_table
  CHANGING
    t_table      = lt_data.

lo_columns = lo_table->get_columns( ).
lo_column = lo_columns->get_column( 'AMOUNT' ).
lo_column->set_zero( abap_false ).

lo_table->display( ).
See other related notes in my infodepot:
ALV color palette - example based on class CL_SALV_TABLE
Full list of examples in my infodepot

If you have a question, have found an error or just want to contact me, please use this form.

Copyright (C) 2011 http://www.kerum.pl/infodepot/

Disclaimer: I am not affiliated or related to any division or subsidiary of SAP AG.
Trademarks or registered trademarks of any products or companies referred to on this site belong to those companies.
Anyone using the given solutions, is doing it under his/her own responsibility and at own risk.