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

Hide zeros in a column using CL_SALV_TABLE.

MilindMungaji
Participant
0 Likes
11,288

I want to hide zeros for currenzy columns. I have used CL_SALV_TABLE for my ALV display.

like we do NO_ZERO = 'X' in REUSE_ALV_

I want to do the same using class alv CL_SALV_TABLE

I want to hide zeros for currenzy columns. I have used CL_SALV_TABLE for my ALV display.

like we do NO_ZERO = 'X' in REUSE_ALV_

I want to do the same using class alv CL_SALV_TABLE

7 REPLIES 7
Read only

Former Member
0 Likes
5,060

maybe there is such an option in SALV, tho i rather do it manually, and have no numbers in my outputz structure but just chars.

When filling them from a number field you can use the statement: "write var_num to var_char NO-ZERO.".

Read only

0 Likes
5,060

write stmt accepts char data type but my amount is in currency.

please let me know if ther is any method in CL_SALV_TABLE to supress zeros.

give me any inputs.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
5,060

Hello Milind,

That is what exactly Florian wants to put across. May be in CL_SALV_TABLE you donot find any NO-ZERO stuff.

But you can try a workaround make all the fields in your output table as character & before output try to pass the values from the curr field to the character field using NO-ZERO.

DATA:
V_AMT1 TYPE DMBTR,
V_AMT2 TYPE CHAR20.

WRITE V_AMT1 TO V_AMT2 NO-ZERO.

Read only

0 Likes
5,060

Hi Suhas,

thanks for ur reply.

I have tried for the same converting my output columns in char data type.

but the above method is not possible for FLTP data type ,also i m getting dump for certain set of currency values to be converted to char data type using above method.

Read only

5,060

Hello

Class CL_SALV_COLUMN_TABLE have method IS_ZERO. Check this.


data: lo_column  type ref to CL_SALV_COLUMN_TABLE.
...
  lo_column ?= lo_columns->get_column( 'PRICE' ).
  lo_column->set_long_text( 'Price Price Price' ).
  lo_column->set_medium_text( 'Price Price' ).
  lo_column->set_short_text( 'Price' ).
  lo_column->set_tooltip( 'Price Price Price' ).
  lo_column->is_zero( 'X' ).
...

Read only

Former Member
0 Likes
5,060

Example:-



wa_celltab-fieldname = 'KUNNR'.
     wa_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
     INSERT wa_celltab INTO TABLE itab-celltab.

Edited by: krupa jani on Sep 26, 2009 8:57 AM

Read only

Clemenss
Active Contributor
5,060

Hi Milind,

it is interesting but not necessarily helpful what people post here.

Class CL_SALV_COLUMN has a method SET_ZERO (Specify Empty Cell Display). There is a documentation which says

Specify Empty Cell Display

Functionality

By default, a zero is displayed in cells that contain no value.

You use the SET_ZERO method to set whether these rows should contain a blank instead of a zero.

Parameters

VALUE

optional

Set zeros; SAP_BOOL type

Output Constant Value

with a zero ABAP_TRUE 'X'

with a blank ABAP_FALSE ' '

Notes

Concerns:

CL_SALV_COLUMN

CL_SALV_COLUMN_LIST

CL_SALV_COLUMN_TABLE

You may try something like

METHOD grid_columns.
  DATA:
    lo_salv_columns_table    TYPE REF TO cl_salv_columns_table,
    lt_column_ref            TYPE salv_t_column_ref.

  FIELD-SYMBOLS:
    <column_ref>             TYPE LINE OF salv_t_column_ref.

  lo_salv_columns_table = io_salv->get_columns( ).
  lt_column_ref = lo_salv_columns_table->get(  ).

  LOOP AT lt_column_ref ASSIGNING <column_ref>.
    <column_ref>->SET_ZERO( ABAP_FALSE ).
  ENDLOOP.
ENDMETHOD.

Regards,

Clemens