cancel
Showing results for 
Search instead for 
Did you mean: 

WDA Table: Getting column sequence as it really is for the user

Former Member

Hi Folks!

I need the current sequence of table columns as it really is for the user. He may have personalized his table: he may have removed some columns and may have changed the sequence of some columns. And this is what I need to know.

But unfortunately so far I could only get the column sequence as it is defined in the View Layout using this coding:


  DATA lo_table TYPE REF TO cl_wd_table.
  DATA lo_table_columns TYPE cl_wd_table_column=>tt_table_column.
  DATA lo_table_column TYPE REF TO cl_wd_table_column.
  DATA lt_abstr_table_columns TYPE STANDARD TABLE OF REF TO cl_wd_abstr_table_column.
  DATA ls_abstr_table_column TYPE REF TO cl_wd_abstr_table_column.

  lo_table ?= wd_this->mv_view->get_element( 'RLTAB' ).
  lt_abstr_table_columns = lo_table->get_grouped_columns( ).
  LOOP AT lt_abstr_table_columns INTO ls_abstr_table_column.
    lo_table_column ?= ls_abstr_table_column.
  ENDLOOP.

Thus: How to get the table column information as they are currently outside in the reald user world (only visible columns in the displayed sequence).

Background: I need this information, because I want to export the table to excel and/or print it in exactly the state the user currently sees it (in personalized state).

Thanx and points for any useful hints - ideally coding snippets!

Regards,

Volker

Accepted Solutions (1)

Accepted Solutions (1)

gill367
Active Contributor

It seems a little bit complex.

There is an attribute PERSINDEX in the class CL_WD_ABSTR_TABLE_COLUMN

which containes the index value i.e. the position of the column in the personalised table.

But this attribute is protected. so you might have to do some inheritance by creating a utility class which inherits form

the class CL_WD_ABSTR_TABLE_COLUMN and then fetch that attribute through this utility class.

thanks

sarbjeet singh

Former Member
0 Kudos

Hi both!

1) I have searched the framework like a mad man an dI think I will dream of all these IF_WD... and CL_WD... most having the useful information in protected or even private areas. A fact I cannot really understand.

2) Although some kind of "criminal" I trewd to go the way in the second answer by creating child classes for cl_wd_abstr_table_column and cl_wd_table_column both containing the protected attribute PERSINDEX I need.

I added a public class get_pers_index to the child classes. So far so good.

But when I try to type-cast SAP standard instance to my instance vairables I get type-cast errors in both cases.

Any ideas?

Here's the relevant coding snippet:


DATA lo_table TYPE REF TO cl_wd_table.
  DATA lo_table_columns TYPE cl_wd_table_column=>tt_table_column.
  DATA lo_table_column TYPE REF TO cl_wd_table_column.
  DATA lo_table_column2 TYPE REF TO /rand/cl_wd_table_column.
  DATA lt_abstr_table_columns TYPE STANDARD TABLE OF REF TO cl_wd_abstr_table_column.
  DATA ls_abstr_table_column TYPE REF TO cl_wd_abstr_table_column.
  data lo_abstr_table_column type ref to /rand/cl_wd_abstr_table_column.
  data lv_pers_index type i.
  lo_table ?= wd_this->mv_view->get_element( 'RLTAB' ).
  lt_abstr_table_columns = lo_table->get_grouped_columns( ).
  LOOP AT lt_abstr_table_columns INTO ls_abstr_table_column.
    lo_table_column ?= ls_abstr_table_column.                 "this casting is successful
    lo_table_column2 ?= lo_table_column.                      "this casting throws type-cast exception
    lv_pers_index = lo_table_column2->get_pers_index( ).
    lo_abstr_table_column ?= ls_abstr_table_column.           "this casting throws type-cast exception, too
    lv_pers_index = lo_abstr_table_column->get_pers_index( ).
  ENDLOOP.

Any help very welcome.

Thanx and Regards,

Volker

Former Member
0 Kudos

No more ideas in this forum? I thought this is an allday requirement for lots of people here ... thus resolved in "a couple of minutes" ...

Regards,

Volker

Former Member
0 Kudos

Hi,

regarding the type cast error, as the table columns are of type cl_wd_table_column which is super class of your class /rand/cl_wd_table_column, the widening cast from object of type cl_wd_table_column to /rand/cl_wd_table_column will fail.

I guess inorder to achieve what you want, you would have to extend cl_wd_table also and create your table dynamically.

Then you can refer the columns with the object of type /rand/cl_wd_table_column.

Hope this helps!

Regards,

Srilatha

Former Member
0 Kudos

Hi Volker,

I have used a static class method like this to loop through the columns.

io_table type ref to cl_wd_table is the importing parameter.

You can replace the red lnes to your logic of get_pers_index.

DATA:
    lo_table_method_hndl               TYPE REF TO if_wd_table_method_hndl,
    lt_column                          TYPE cl_wd_table_column=>tt_table_column,
    lo_column                          TYPE REF TO cl_wd_table_column.

  lo_table_method_hndl ?= io_table->_method_handler.
  "lo_table_method_hndl->apply_filter( ).

  lt_column = lo_table_method_hndl->get_all_columns( ).

  LOOP AT lt_column INTO lo_column.
"    IF lo_column->get_filter_value( ) IS NOT INITIAL.
"     lo_column->set_is_filtered( abap_true ).
    ELSE.
     "lo_column->set_is_filtered( abap_false ).
    ENDIF.
  ENDLOOP.

Edited by: Baskaran Senthivel on Feb 11, 2011 12:51 PM

Former Member
0 Kudos

Hi!

Unfortunately this has the same effect. Attribute persindex is stilll protected and I have found no method to gather it.

Regards,

Volker

Former Member
0 Kudos

Hi Srilatha!

Creating table dynamically is not an option for me. If nobody in this forum has another idea I'm planning to modify class cl_wd_table_column by giving it a public mehtod get_pers_index( ). But this of course is a very dirty and ugly solution.

So I am still hoping that this forum here can find a solution.

Thank you!

Regards,

Volker

Answers (2)

Answers (2)

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hallo Volker,

there is a fundamental principle applied to the Web Dynpro ABAP Programming Model: Personalization and Customizing state is transparent for the application logic. This means you cannot read the the Personalized state of your Web Dynpro ABAP table UI element via controller coding.

As an alternative I propose to use the SAP List Viewer component for Web Dynpro ABAP: Its generic Excel export functions also refelcts the personalized table state. For more details see ... [SAP Online Help - Exporting to Excel|http://help.sap.com/saphelp_nw70ehp2/helpdata/en/49/3e0c28347d3ef0e10000000a421937/frameset.htm].

Regards, Bertram

Former Member
0 Kudos

Yes, when you export the table data to excel, we can see all the hidden ones are also getting downloaded to excel. The true image that is shown to the user after applyging personalization is not downloaded to excel.

Have you checked for any inerfaces/classes to get the configuraiton. Will let you know wether we can find any .

Edited by: Lekha on Feb 10, 2011 5:04 PM