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: 

In OO ALV Hiding columns on Radio button selection

former_member435508
Participant
0 Kudos

Hi,

In my Report according to Radio button selection, I need to hide few columns.

I tried it with Method - IS_HEADER_VISIBLE.

But it's giving syntax error - " You can only omit the parameter name if the method only has a non-optional parameter or an optional IMPORTING parameter that is identified by "PREFERRED PARAMETER".

I am unable to work on this.


DATA: lr_columns   TYPE REF TO cl_salv_columns_table.

TRY.
        CALL METHOD lr_table->get_columns                               
           RECEIVING
             value = lr_columns.
      CATCH cx_salv_not_found .
    ENDTRY.

    lr_columns->set_optimize('X' ).
    lr_columns->is_headers_visible( 'X' ).

1 ACCEPTED SOLUTION

anesh_kumar
Active Participant
0 Kudos

HI

you may have columns in the table that do not need to be included in the display, in order to

make them 'invisible' you must use this code for each of them

OR just remove them from the data table

l_columns = l_table->get_columns( ). "sets the handle for all of the columns

l_column ?= l_columns->get_column( 'FIELDNAME' ).

l_column->set_technical( if_salv_c_bool_sap=>true ).

Regards

4 REPLIES 4

anesh_kumar
Active Participant
0 Kudos

HI

you may have columns in the table that do not need to be included in the display, in order to

make them 'invisible' you must use this code for each of them

OR just remove them from the data table

l_columns = l_table->get_columns( ). "sets the handle for all of the columns

l_column ?= l_columns->get_column( 'FIELDNAME' ).

l_column->set_technical( if_salv_c_bool_sap=>true ).

Regards

Former Member
0 Kudos

Hi Priya,

You can hide columns in SALV using the following statements

In the example below column 'MANDT' is hidden on the output and in the edit layout options of the ALV toolbar.

data: lr_column type ref to cl_salv_column.

try.

lr_column = ir_columns->get_column( 'MANDT' ). " you can replace your column name(that needs to be hidden) here

lr_column->set_technical( if_salv_c_bool_sap=>true ).

catch cx_salv_not_found.

endtry.

For more inofrmation please check and run SAP example program SALV_TEST_TABLE_COLUMNS on your system.

Please close the thread if the above solution helps you.

Thanks

SHRaj

kesavadas_thekkillath
Active Contributor
0 Kudos

You can do it like this


        IF p_simu = abap_true AND p_mess = abap_false.
          lf_column = lf_cols->get_column( 'ICON'(016) ).   "Hides column ICON
          lf_column->set_technical( if_salv_c_bool_sap=>true ).
          lf_column = lf_cols->get_column( 'MESSAGE'(017) ).  "Hides column MESSAGE
          lf_column->set_technical( if_salv_c_bool_sap=>true ).
        ENDIF.

Former Member
0 Kudos

Priya,

In the fieldcat for the fields you want to hide, populate "NO_OUT" with "X".

Bruce