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: 

what is different between cl_salv_column and cl_salv_column_table?

Former Member
0 Kudos

I think gr_column using type <b>cl_salv_column</b>.(Type 1)

But many program using type <b>cl_salv_column_table</b>.(Type 2)

Why using <b>cl_salv_column_table</b> besides <b>cl_salv_column</b>?

what is benefits?

Type 1.

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.

  CREATE OBJECT container
           EXPORTING container_name = 'CONTAINER'.
 
  cl_salv_table=>factory( EXPORTING r_container  = container
                          IMPORTING r_salv_table = gr_table
                           CHANGING t_table      = ispfli ).

  gr_columns = gr_table->get_columns( ).
  gr_column = gr_columns->get_column( 'CITYTO' ).
  gr_column->set_visible( if_salv_c_bool_sap=>false ).
  gr_column->set_technical( if_salv_c_bool_sap=>false ).

Type 2.

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 <b>cl_salv_column_table</b>.

  cl_salv_table=>factory( EXPORTING r_container  = container
                          IMPORTING r_salv_table = gr_table
                           CHANGING t_table      = ispfli ).
  gr_columns = gr_table->get_columns( ).
  gr_column ?= gr_columns->get_column( 'LINE_NUMBER' ).
  gr_column->set_visible( if_salv_c_bool_sap=>false ).
  gr_column->set_technical( if_salv_c_bool_sap=>false ).

Message was edited by:

Ki-Joon Seo

Message was edited by:

Ki-Joon Seo

Message was edited by:

Ki-Joon Seo

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

The difference is that if you use the class CL_SALV_COLUMNS_TABLE you get a lot more methods which you can use to manipulate the grid, such as coloring a column. This class is inheriting these methods from its super class which is CL_SALV_COLUMNS_LIST, this class is a subclass of CL_SALV_COLUMN. So the short answer is that you get more specific methods for manipulating the ALV column when you use the class CL_SALV_COLUMNS_TABLE

Regards,

RIch Heilman

6 REPLIES 6

marcelo_ramos
Active Contributor
0 Kudos

Hi,

The class <b>cl_salv_column_table</b> is one subclass of <b>cl_salv_column</b>, it has others some functionality and thus <b>cl_salv_column_table</b> sumetimes you need to acess an superclass components and others times you need to acess the subclass components. This is a reason to use cl_salv_column_table besides cl_salv_column.

For more information see the links above.

<a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/10/e4eb40c4f8712ae10000000a155106/content.htm">http://help.sap.com/saphelp_nw2004s/helpdata/en/10/e4eb40c4f8712ae10000000a155106/content.htm</a>

<a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/5e/88d440e14f8431e10000000a1550b0/frameset.htm">http://help.sap.com/saphelp_nw2004s/helpdata/en/5e/88d440e14f8431e10000000a1550b0/frameset.htm</a>

Regards.

Marcelo Ramos

Former Member
0 Kudos

Hello Ki-Joon,

If you check the hierarchy of the class CL_SALV_COLUMN_TABLE (Column Description of Simple, Two-Dimensional Tables), it is a child of class CL_SALV_COLUMN_LIST (Column Description for List-Type Tables) that is a child of CL_SALV_COLUMN (Individual Column Object).

Some methods may only implemented in the child classes / may have a different implementation, but in this case there is no difference. It only depends what you want to do with the gr_column object, if you need afterwards a specific method only defined in the child class or not. If you don't need it, you can work with the parent class.

Regards,

Walter

Former Member
0 Kudos

Hello Ki-Joon,

It seems there was a problem with the forum...

If you check the hierarchy of class CL_SALV_COLUMN_TABLE (Column Description of Simple, Two-Dimensional Tables), you can see it's a child of class CL_SALV_COLUMN_LIST (Column Description for List-Type Tables), that is a child of

CL_SALV_COLUMN (Individual Column Object).

In the child classes, methods of the parent class may be redefined / there may be new ones.

But in this case set_visible and set_technical are the same in the child and parent classes -> there is no difference.

Type 1 is better, as you don't have to do a cast with "?=".

It may be important in other cases if you need to use specific methods of the child.

Best regards,

Walter

uwe_schieferstein
Active Contributor
0 Kudos

Hello Ki-Joon

If you want to modify columns of the new object model then you will <b>always need both</b> classes, CL_SALV_COLUMNS_TABLE and CL_SALV_COLUMN? Why?

Because the only way to get a reference for a table column (CL_SALV_COLUMN) is by calling method GET_COLUMN of the columns collection (CL_SALV_COLUMNS_TABLE) which, in turn, you receive by calling gr_table->get_columns( ).

Regards

Uwe

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

The difference is that if you use the class CL_SALV_COLUMNS_TABLE you get a lot more methods which you can use to manipulate the grid, such as coloring a column. This class is inheriting these methods from its super class which is CL_SALV_COLUMNS_LIST, this class is a subclass of CL_SALV_COLUMN. So the short answer is that you get more specific methods for manipulating the ALV column when you use the class CL_SALV_COLUMNS_TABLE

Regards,

RIch Heilman

Former Member
0 Kudos

thanks Walter.

You are watching the thread "what is different between cl_salv_column and cl_salv_column_table?", which was updated Jul 31, 2007 5:54:06 PM by Walter Tighzert.

REMINDER: If you posted the question, please reward points for good answers*. Thanks.

Subject: Re: what is different between cl_salv_column and cl_salv_column_table?

Message: Hello Ki-Joon,

If you check the hierarchy of the class CL_SALV_COLUMN_TABLE (Column Description of Simple, Two-Dimensional Tables), it is a child of class CL_SALV_COLUMN_LIST (Column Description for List-Type Tables) that is a child of CL_SALV_COLUMN (Individual Column Object).

Some methods may only implemented in the child classes / may have a different implementation, but in this case there is no difference. It only depends what you want to do with the gr_column object, if you need a specific method only defined in the child class or not.

Regards,

Walter