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

Remove a column using CL_SALV_COLUMNS_TABLE class

Former Member
0 Likes
2,623

Hi Gurus,

I have a problem using CL_SALV_COLUMNS_TABLE class. I need to remove a colum from the report output and the method that i think it could help me is REMOVE_COLUM. However, this method is protected.

An alternative soluction is to use the method SET_VISIBLE from class CL_SALV_COLUMN, but in this way i cannot eliminate the colum and that is my necesity.

¿Can you help me with this?

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,029

Hi,

I am not sure of an other method..

You can try this..

Create a local class in you program and inherit the class CL_SALV_COLUMNS_TABLE ...

In the new class create a method ..

In the new method..call the protected method using the object ME

Ex..

CALL METHOD me->remove_column

.............

Now in your program create an object for your local class and call the method you created..

Thanks

Naren

7 REPLIES 7
Read only

Former Member
0 Likes
2,030

Hi,

I am not sure of an other method..

You can try this..

Create a local class in you program and inherit the class CL_SALV_COLUMNS_TABLE ...

In the new class create a method ..

In the new method..call the protected method using the object ME

Ex..

CALL METHOD me->remove_column

.............

Now in your program create an object for your local class and call the method you created..

Thanks

Naren

Read only

0 Likes
2,029

Hi Naren,

Finally i can use the method REMOVE_COLUMN thanks to your answer.

However, my problem continue. I used the method GET_COLUMNS from CL_SALV_TABLE class to obtain all columns that belong to the internal table that contain the data to be display in the report. It returned an instance from CL_SALV_COLUMNS_TABLE. I need to link the object that i instantiated from the local class to the object which contains the name of all columns in order to delete from the columns table the column that i don´t need.

Thanks for your help, excuse me if my question is a little complicated.

Read only

0 Likes
2,029

Hi Andres, please use the method SET_TECHNICAL, this should remove your column. For an example, see any program which starts with SALV

Regards,

Rich Heilman

Read only

0 Likes
2,029

Here is a complete example of what I mean.



REPORT zrich_0001.

DATA: ispfli TYPE TABLE OF spfli.

DATA: gr_table TYPE REF TO cl_salv_table.
DATA: gr_columns TYPE REF TO cl_salv_columns_table.
DATA: gr_column TYPE REF TO cl_salv_column_table.
DATA: gr_functions TYPE REF TO cl_salv_functions.

START-OF-SELECTION.

  SELECT * INTO TABLE ispfli FROM spfli.


  cl_salv_table=>factory(
    IMPORTING
      r_salv_table   = gr_table
    CHANGING
      t_table        = ispfli ).

  gr_functions =  gr_table->get_functions( ).
  gr_functions->set_all( abap_true ).

  gr_columns = gr_table->get_columns( ).
  gr_column ?= gr_columns->get_column( 'MANDT' ).
  gr_column->set_technical( abap_true ).

  gr_table->display( ).

Regards,

Rich Heilman

Read only

0 Likes
2,029

Hi Rich,

Thanks for your help. My problem is solved.

Read only

0 Likes
2,029

Hi Narendran ,

CL_SALV_COLUMNS_TABLE is a final class. So it will show a syntax error.

So could you please suggest.

Thanks.

Regards,

Saurabh

Read only

Former Member
0 Likes
2,029

Hi,

I think I understood your question..

When you create an object for the local class(that you inherited the CL_SALV_COLUMNS_TABLE )..That will be your main object to do all the operations..Use this object to remove the columns and call the methods that is available in the class CL_SALV_COLUMNS_TABLE..

Do not create another instance for the class CL_SALV_COLUMNS_TABLE again..

Hope I understood your question..

Thanks

Naren