cancel
Showing results for 
Search instead for 
Did you mean: 

remove_column( ) of cl_wd_table not returning back the column reference

Former Member
0 Kudos

Am using the remove_column( ) of cl_wd_table to remove a particular table column & also get the reference of a the same for inserting at a different position. But the system doesn't return back any value. I tried doing a get_column( ) before doing the remove_column( ) but even that wasn't able to get the reference to that column. I debugged & observed that the system was internally reading an internal table ME->ch_COLUMNS to get the list of columns but this table was empty and so the READ was failing.

method GET_COLUMN.

CLEAR the_COLUMN.

IF index > 0.

READ TABLE ME->ch_COLUMNS INDEX index INTO the_COLUMN.

ELSE.

READ TABLE ME->CH_COLUMNS WITH KEY TABLE_LINE->ID = ID INTO

THE_COLUMN.

ENDIF.

endmethod.

I had bound the TABLE to a context node based on dictionary structure SCARR & 3 fields CARRNAME, CARRCODE & URL. Please advise as to why the column references aren't available.

Uday

Accepted Solutions (0)

Answers (2)

Answers (2)

uday_gubbala2
Active Contributor
0 Kudos

Thanks a lot to Thomas Szuecs. I did finally manage to solve the problem. Below is his explanation to the problem, "The reason for the problem you were experiencing is that the table ui element element had been

enhanced. This happened a good while later after I wrote the blog. The table now features "normal" (or legacy) columns and so called grouped columns. Grouped columns can be used to build i.e. a hierarchy of columns with grouped column headers. Basically, you have two options to solve the problem. The first would be to use the grouped column aggregation in your source code instead

of the old one. This is the standard way, which is my advice. The other way would be to use the old column aggregation consistently in your program. This would work as well. The enhancement was designed to be backwards compatible."

My new modified coding is now as below:

method ONACTIONMOVE_DOWN .

data: old_index type i,

new_index type i,

lr_column type ref to CL_WD_ABSTR_TABLE_COLUMN.

old_index = context_element->get_index( ).

check old_index < 3.

lr_column = wd_this->gr_table->remove_grouped_column( index = old_index ).

new_index = old_index + 1.

wd_this->gr_table->add_grouped_column( the_grouped_column = lr_column

index = new_index ).

endmethod.

Former Member
0 Kudos

I think you are not giving the id of table column.check this below code.

data: obj_table type ref to cl_wd_table,
      lr_column type ref to cl_wd_table_column,
      lr_column1 type ref to cl_wd_table_column.


obj_table ?= view->get_element( 'TABLE1' ).
obj_table->set_visible_row_count( value = 50  ).

lr_column = obj_table->get_column(
               id         = 'TABLE1_PRICE'
*              INDEX      = INDEX
                 ).

lr_column1 = obj_table->remove_column(
               id         = 'TABLE1_FLDATE'
*              INDEX      = INDEX
                 ).

still your problem is not solved paste your code here.

Thanks

Suman

uday_gubbala2
Active Contributor
0 Kudos

Hi Suman,

Thanks for the reply.

In WDDOMODIFYVIEW I have put the below coding:

method WDDOMODIFYVIEW .

check first_time = abap_true.

wd_this->gr_table ?= view->get_element( id = 'TABLE' ).

endmethod.

I need to change the table column position when the user clicks on a pushbutton. The attribute context_element is an importing parameter of type if_wd_context_element and have declared gr_table in view attributes as of type CL_WD_TABLE. The coding is as below:

method ONACTIONMOVE_DOWN .

data: old_index type i,

new_index type i,

lr_column type ref to cl_wd_table_column.

old_index = context_element->get_index( ).

check old_index < 3.

lr_column = wd_this->gr_table->get_column( index = old_index ).

wd_this->gr_table->remove_column( index = old_index ).

new_index = old_index + 1.

wd_this->gr_table->add_column( the_column = lr_column

index = new_index ).

endmethod.

By the way I have noticed something else while debugging inside the standard code for get_column( ). The ME->CH_COLUMNS is empty but there is another attribute ME->CH_GROUPED_COLUMNS which has the type ref info for the 3 columns which am displaying in the TABLE. I haven't set anything specific properties for the table either. Any inputs from your side would be very useful.

Edited by: Uday on Aug 29, 2008 11:09 AM

Former Member
0 Kudos

What is your problem.Are you not able set new position or some thing else and i want to know what your are getting from this.

old_index = context_element->get_index( ).

thanks

Suman

uday_gubbala2
Active Contributor
0 Kudos

Hi Suman,

Am actually trying to implement the dynamic table column sorting as how specified by Thomas in his blog.

[Link To Blog|https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2953] [original link is broken] [original link is broken] [original link is broken];

First we list all the 3 table column texts in the 1st column of a MultiPane & we have the up & down arrows beside each column text. When the user clicks on the up/down button the position of the column in the Table UI Element has to change accordingly. I hope that you can understand what I mean to say. So if the user clicks on the Down button in line with 1st column text then the 1st column should become the 2nd column of the table and the other columns should adjust their positions accordingly. Regards, Uday] ] First we list all the 3 table column texts in the 1st column of a MultiPane & we have the up & down arrows beside each column text. When the user clicks on the up/down button the position of the column in the Table UI Element has to change accordingly. I hope that you can understand what I mean to say. So if the user clicks on the Down button in line with 1st column text then the 1st column should become the 2nd column of the table and the other columns should adjust their positions accordingly.

Regards,

Uday

Edited by: Uday on Aug 29, 2008 1:19 PM

uday_gubbala2
Active Contributor
0 Kudos

Hello Experts,

Any idea about why this is happening so?

Uday