Sorting a table column in a WebDynpro application

...Previous 

9. Click the Button Context. It will open a Popup for Selecting Context Element.

10. Select MARA and Press Enter.

  

11. It will show all the Context Attributes in that Node. Then Press Enter.

 

12. Go to Attributes Tab, Give TABLE_CONTROL in the Attribute Column , Check the Check Box in the RefTo Column & give IF_WD_TABLE_METHOD_HNDL in the Associated Type. 

 

13. Then create one Event for onSort Event of the Table by Clicking the Create Button as shown below. Then Give the Action Name as ON_TEST_SORT and press Enter. 

 

14. Then go to the Methods Tab. 

 

15. Write the Following Coding in the Corresponding Methods.
WDDOINIT:
method WDDOINIT .
  data LO_ND_MARA type ref to IF_WD_CONTEXT_NODE.
  data LO_EL_MARA type ref to IF_WD_CONTEXT_ELEMENT.
  data LT_MARA type WD_THIS->ELEMENTS_MARA.
  data LS_MARA type WD_THIS->ELEMENT_MARA.
* navigate from <CONTEXT> to <MARA> via lead selection
  LO_ND_MARA = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_MARA ).
  SELECT MATNR MTART MATKL MEINS FROM MARA INTO CORRESPONDING FIELDS OF
         TABLE LT_MARA UP TO 10 ROWS WHERE MATNR LIKE 'A%'.
* Bind Table
  LO_ND_MARA->BIND_TABLE( LT_MARA ).
endmethod.
WDDOMODIFYVIEW:
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( 'MATNR' ).
endmethod.
ONACTIONON_TEST_SORT:
method ONACTIONON_TEST_SORT .
wd_this->table_control->apply_sorting( ).
endmethod. 

16. Save and Activate the Application. 

 

17. Create WebDynpro Application, save it and Test the Application. 

Output:

  1. Initially the Table will look like this.

 

  1. After Clicking the Sort Button, the Output will looks as Follows.

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image