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.

    • 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.


0 comments:

Post a Comment

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.