Creation and Usage of Freely Programmed Search Help in Web Dynpro for ABAP

...Previous

Step 10

Declare the search help component created till step 8 above here in the "used component" and also in the component controller.

Step 11

Drag drop the node MATERIAL and create an attribute MATNR in the view.

Step 12

Create an event (FREE_VALUE) as shown below in the screen shot. And create a layout and bind the input field with the attribute (MAKTG) of this view. Code the WDDOMODIFYVIEW as shown below

METHOD WDDOMODIFYVIEW .
  
DATA LO_ND_MATERIAL TYPE REF TO IF_WD_CONTEXT_NODE.

  
DATA LO_EL_MATERIAL TYPE REF TO IF_WD_CONTEXT_ELEMENT.
  
DATA LS_MATERIAL TYPE WD_THIS->ELEMENT_MATERIAL.
  
DATA LV_MATNR TYPE WD_THIS->ELEMENT_MATERIAL-MATNR.

*   navigate from <CONTEXT> to <MATERIAL> via lead selection
  LO_ND_MATERIAL = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_MATERIAL ).

*   @TODO handle non existant child
*   IF lo_nd_material IS INITIAL.
*   ENDIF.

*   get element via lead selection
  LO_EL_MATERIAL = LO_ND_MATERIAL->GET_ELEMENT( ).
*   @TODO handle not set lead selection
  
IF LO_EL_MATERIAL IS INITIAL.
  ENDIF.

*   get single attribute
  LO_EL_MATERIAL->GET_ATTRIBUTE(
    
EXPORTING
      NAME =  
`MATNR`
    
IMPORTING
      
VALUE = LV_MATNR ).


   
DATA LO_EL_CONTEXT TYPE REF TO IF_WD_CONTEXT_ELEMENT.
   
DATA LS_CONTEXT TYPE WD_THIS->ELEMENT_CONTEXT.
   
DATA LV_MATKG TYPE WD_THIS->ELEMENT_CONTEXT-MATKG.

*  get element via lead selection
   LO_EL_CONTEXT = WD_CONTEXT->GET_ELEMENT( ).

*  @TODO handle not set lead selection
   
IF LO_EL_CONTEXT IS INITIAL.
   ENDIF.

*  @TODO fill attribute

  
SELECT SINGLE MAKTG FROM MAKT INTO LV_MATKG WHERE MATNR = LV_MATNR.

*  set single attribute
   LO_EL_CONTEXT->SET_ATTRIBUTE(
     NAME =  
`MATKG`
     
VALUE = LV_MATKG ).

ENDMETHOD.

Step 13

Activate and execute the application and check as below.

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