Thursday, June 27, 2013
Summary.
In order to get FILTER or SORTING functions for Table UI element, need to define attribute with ref to IF_WD_TABLE_METHOD_HND interface.
Procedure with steps.
- Create table UI element and write logic to get elements and bind data elements with table element.
- Go to view->Layout tab
- Click on Table UI element(TABLE_4_FILTER). Create for onSort event(SORT) for table UI element.
- Go to view->Actions tab
- Double click on SORT event handler method.
- Paste the below code
METHOD ONACTIONSORT . WD_THIS->TABLE_CONTROL->APPLY_SORTING( ). ENDMETHOD.
- We have already defined TABLE_CONTROL attribute at Attributes table of view here.
- Paste the below at WDDOMODIFYVIEW method. Replace the existing code mentioned here.
METHOD WDDOMODIFYVIEW . CASE FIRST_TIME. WHEN ABAP_TRUE. "&--------------------------------------------------------* " Code for data retrieval "&--------------------------------------------------------* DATA LO_ND_IT0001 TYPE REF TO IF_WD_CONTEXT_NODE. DATA LT_IT0001 TYPE WD_THIS->ELEMENTS_IT0001. " navigate from to via lead selection LO_ND_IT0001 = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_IT0001 ). SELECT * FROM PA0001 INTO CORRESPONDING FIELDS OF TABLE LT_IT0001 UP TO 20 ROWS. LO_ND_IT0001->BIND_TABLE( NEW_ITEMS = LT_IT0001 SET_INITIAL_ELEMENTS = ABAP_TRUE ). ENDCASE. "&------------------------------------------------------------* " Code for SORTING "&------------------------------------------------------------* DATA WD_TABLE TYPE REF TO CL_WD_TABLE. " Name of the table UI element to be provided WD_TABLE ?= VIEW->GET_ELEMENT( 'TABLE_4_FILTER' ). WD_THIS->TABLE_CONTROL ?= WD_TABLE->_METHOD_HANDLER. "&------------------------------------------------------------* " Code for FILTER "&------------------------------------------------------------* " Name of the table UI element to be provided WD_TABLE ?= VIEW->GET_ELEMENT( 'TABLE_4_FILTER' ). WD_THIS->TABLE_CONTROL ?= WD_TABLE->_METHOD_HANDLER. DATA LO_EL_CONTEXT TYPE REF TO IF_WD_CONTEXT_ELEMENT. DATA LS_CONTEXT TYPE WD_THIS->ELEMENT_CONTEXT. DATA LV_IS_FILTER_ON TYPE WD_THIS->ELEMENT_CONTEXT-IS_FILTER_ON. " get element via lead selection LO_EL_CONTEXT = WD_CONTEXT->GET_ELEMENT( ). " get single attribute LO_EL_CONTEXT->GET_ATTRIBUTE( EXPORTING NAME = `IS_FILTER_ON` IMPORTING VALUE = LV_IS_FILTER_ON ). " Set or cancel the table's filter action IF LV_IS_FILTER_ON = ABAP_TRUE . WD_TABLE->SET_ON_FILTER( 'FILTER' ). ELSE. WD_TABLE->SET_ON_FILTER( '' ). ENDIF. ENDMETHOD.
- Save and Active web dynpro component.
- Run Web dynpro Application.
Followers
Popular Posts
- ABAP - ALV Report example with steps
- ABAP - Step by step tutorial on Smart Forms - Template Node
- ABAP - Sending email with pdf attachment
- SAP Adobe Form - Steps to create simple ADOBE Form and calling it from ABAP Program
- SAP ABAP - CL_ABAP_CHAR_UTILITIES class usage
- ABAP - Multiple value selection from F4 help for SELECT-OPTIONS
- Execute ABAP Report using SUBMIT statement
- ABAP - Select all or Deselect all in ALV or Check box handling in ALV
- Web Dynpro ABAP ALV - ON_CLICK event
- ABAP - Dynamic WHERE clause
0 comments:
Post a Comment
Your useful comments, suggestions are appreciated.Your comments are moderated.