Automatic Event triggering in Web Dynpro ABAP

...Previous

Paste the below code in the method HANDLEDEFAULT. In method, set the value to the context so that values will be automatically populate in UI element of the VIEW. Also set the value of flag which will be read in method WDDOMODIFYVIEW of View controller.

METHOD handledefault.

   DATA lo_nd_node_input TYPE REF TO if_wd_context_node.

  DATA lo_el_node_input TYPE REF TO if_wd_context_element.

  DATA ls_node_input TYPE wd_this->element_node_input.

   DATA lv_pin LIKE ls_node_input-pin.

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

  lo_nd_node_input = wd_context->get_child_node( name = wd_this->wdctx_node_input ).

 *   get element via lead selection

  lo_el_node_input = lo_nd_node_input->get_element(  ).

   lv_pin = pin. "Value from URL Parameter

 **Set the Value to the Context

  lo_el_node_input->set_attribute( EXPORTING

                                  name =  `PIN`

                                  value = lv_pin ).

  IF lv_pin IS NOT INITIAL.

**Set value of Flag which is declared in Component Controller and will be accessible globally in all WD Views methods etc...

    wd_comp_controller->g_flag_call_from_url = 'X'.

  ENDIF.

 ENDMETHOD.

4.     Changes in WDDOMODIFYVIEW

In method WDDOMODIFYVIEW, read the flag value. Here we need to trigger the dummy event WDEVENT automatically and hence create object of Custom event and call the ON_ACTION event method. Also as we need to execute the code only for 1st time, use flag FIRST_TIME given by the WD framework with our flag.

 METHOD wddomodifyview .

  DATA: l_wdevent TYPE REF TO cl_wd_custom_event,

        name      TYPE  string.

 *We need to call the action first time only !!

  IF wd_comp_controller->g_flag_call_from_url = 'X' AND first_time = 'X'.

    name = 'ON_ACTION'. "This will be always "ON_ACTION"

  *Create object of Custom Event

    CREATE OBJECT l_wdevent

      EXPORTING

        name = name.

 *Call On action method. This is potentially simulating User Action!!

    wd_this->onactionshow_data( wdevent =  l_wdevent ). 

                                     " ref to cl_wd_custom_event

   ENDIF.  "  IF wd_comp_controller->g_flag_call_from_url = 'X'.

 ENDMETHOD.

Output

 As shown below, PIN information is passed via URL and the application populated the PIN in the input field. Along with this, button event triggering is done automatically and the PIN related additional information is displayed.  

Figure 6.JPG

SAP Virtual/Onsite Trainings

Document Categories:

What's New?

Contribute?

Sample Specs

What's Hot?

Web Dynpro for ABAP Tutorials 


Join the Mailing List
Enter name and email address below:
Name:
Email:
Subscribe  Unsubscribe 

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