cancel
Showing results for 
Search instead for 
Did you mean: 

Reg:Sorting on date field

Former Member
0 Kudos

Hi all

I am using  a table which contains all subordinates time statement details for a  particular manager .

Here my requirement is i what to sort the records based on date either on ascending or descending .

the code .

method WDDOMODIFYVIEW .

 

*

*data wd_table type ref to cl_wd_table.

**check first_time = abap_true.

** Name of the table UI element to be provided

*wd_table ?= view->get_element( 'TABLE' ).

*wd_this->table_control ?= wd_table->_method_handler.

**Name of the key attribute of the context node to which the table binding is done to be provided

*

*

***wd_this->table_control->set_key_attribute_name( 'DATUM' ).

*

*

*

*CALL METHOD WD_TABLE->SET_ON_SORT

* EXPORTING

* VALUE = 'DATUM'

* .

 

endmethod.

**************************************************************************************************

method ONACTIONON_SORT .

 

 

*

* DATA LO_ND_T_FINAL TYPE REF TO IF_WD_CONTEXT_NODE.

*

* DATA LT_T_FINAL TYPE WD_THIS->ELEMENTS_T_FINAL.

*

** navigate from <CONTEXT> to <T_FINAL> via lead selection

* LO_ND_T_FINAL = WD_CONTEXT->PATH_GET_NODE( PATH = `ZHR_TIMESLIP_FM.CHANGING_2.T_FINAL` ).

*

** @TODO handle non existant child

** IF lo_nd_t_final IS INITIAL.

** ENDIF.

*

* LO_ND_T_FINAL->GET_STATIC_ATTRIBUTES_TABLE( IMPORTING TABLE = LT_T_FINAL ).

* data value type integer .

*

* CALL METHOD LO_ND_T_FINAL->GET_ELEMENT_COUNT

* RECEIVING

* COUNT = value

* .

* do value times .

*

*wd_this->table_control->apply_sorting( ).

*enddo.

 

endmethod.

But this code is  trigger when i click on sort buttons on the table but the records are not getting sorted accordingly either ascending or descending .

Can any one please rectify me wether Am I missing any step .

Thanks & Regards

Deepika

Accepted Solutions (1)

Accepted Solutions (1)

RicardoRomero_1
Active Contributor
0 Kudos

Hi,

Check the following code:

   METHOD wddomodifyview .

  DATA wd_table TYPE REF TO cl_wd_table.

  CHECK first_time = abap_true.

  wd_table ?= view->get_element( 'YOUR_TABLE_UI_NAME' ).
  wd_this->YOUR_ATTRIBUTE ?= wd_table->_method_handler.

  wd_this->YOUR_ATTRIBUTE->set_key_attribute_name( 'DATUM' ).

ENDMETHOD.                    "WDDOMODIFYVIEW

METHOD
ONACTIONON_SORT .

  wd_this->YOUR_ATTRIBUTE->apply_sorting( ).

ENDMETHOD.                    "
ONACTIONON_SORT

Where:

- YOUR_ATTRIBUTE: is the name of an attribute you've created in your view (type ref to IF_WD_TABLE_METHOD_HNDL)

- YOUR_TABLE_UI_NAME: is the name of your Table UI element you've put in the layout.

You need to check also the property multiColSorting of your table UI.

http://www.saptechnical.com/Tutorials/WebDynproABAP/Sort/tablecolumn.htm

chengalarayulu
Active Contributor
0 Kudos

is it resolved

Answers (1)

Answers (1)

chengalarayulu
Active Contributor
0 Kudos

Deepika,

after getting node data(table)

i.e.  LO_ND_T_FINAL->GET_STATIC_ATTRIBUTES_TABLE( IMPORTING TABLE = LT_T_FINAL ).

**perform sorting

sort LT_T_FINAL by DATUM ASCENDING / DESCENDING.

** Bind the values to node.

LO_ND_T_FINAL->bind_table(

          new_items = LT_T_FINAL

          set_initial_elements = abap_true ).