cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting in a table

Former Member
0 Kudos

Hi,

I'm doing a sorting in my table.

I want to know what is the propose of the method set_key_attribute_name of the interface IF_WD_TABLE_METHOD_HNDL ?

What parameter do I have to pass?

Thanks a lot.

Accepted Solutions (1)

Accepted Solutions (1)

uday_gubbala2
Active Contributor
0 Kudos

Hi Jorge,

This method is used to specify the name of the column based on which you want to sort the table data.

So suppose you chose to sort the data by field MEINS then the table would sort the unit of measurement column in ascending/descending. The rest of the columns wouldn't be in sorted order. Below is an extract of the same coding. Hope that this answers your question.

Regards,

Uday

(table_control is an view attribute of type CL_WD_TABLE & the reference of the table has been saved in to it in the WDDOMODIFYVIEW method)

METHOD wddomodifyview .
  DATA wd_table TYPE REF TO cl_wd_table.

  CHECK first_time = abap_true.

  wd_table ?= view->get_element( 'TABLE_ELEMENT' ).

  wd_this->table_control  ?=  wd_table->_method_handler.

  wd_this->table_control->set_key_attribute_name( 'MATNR' ).
ENDMETHOD.

Former Member
0 Kudos

Uday,

Where, can I switch the ascending/descending sorting?

Thanks all

uday_gubbala2
Active Contributor
0 Kudos

Hi Jorge,

On the top of every column in the table you will have a small triangle displayed for you. You will just have to click on this to switch between ascending/descending orders. However note that it would work properly only for the column on which you had set as the key attribute using set_key_attribute_name.

Regards,

Uday

Former Member
0 Kudos

I want to do this (ascending/descending orders) in code.

"However note that it would work properly only for the column on which you had set as the key attribute using set_key_attribute_name."

Uday,

The sorting is working fine for all columns, not only for that I set as the key attribute. I haven't understood the method set_key_attribute_name yet.

Thanks.

Answers (5)

Answers (5)

Former Member
0 Kudos

column name

Former Member
0 Kudos

Hi

Check the below link

This might help

Regards

Shilpa

Former Member
0 Kudos

Hi Jorge,

This method is used to sort the table contents according to the attribute which you will be passing to the parameter attribute_name of the method.

Regards...

Arun.

Former Member
0 Kudos

check some of the sample components

HRRCF_C_APPLICATIONS_UI

HRRCF_C_JOB_FAVO_UI

HRRCF_C_SEARCH_UI

that method is used in views

Thanks

Bala Duvvuri

Former Member
0 Kudos

pass the coloum id (attribute name)