Quantcast
Channel: Web Dynpro ABAP
Viewing all articles
Browse latest Browse all 141

Webdynpro Component Interface

$
0
0

Hi Experts,

 

I am sharing my knowledge on Webdynpro Component Interface.

 

By using the component Interface, We can call multiple components dynamically based on action triggered.

 

In this document , I am calling 4 components dynamically based on action .

 

Steps to follow.

 

1.   Create a table named ZCOUNTRY_COMP.

 

  Create the entries as below

 

 

1.  Create a Webdynpro Component Interface with name 'ZRAO_INTERFACE_TEST' with interface view 'INTERFACE_VIEW'.

 

 

2. Create the 4 compoents with the names 'ZRAO_INTERFACE_COMP1,ZRAO_INTERFACE_COMP2,ZRAO_INTERFACE_COMP3

    and ZRAO_INTERFACE_COMP4'.

 

      Creating component 'ZRAO_INTERFACE_COMP1' as follows.

 

       i.  Delete the default window in ZRAO_INTERFACE_COMP1 and Implement the interface in the component ZRAO_INTERFACE_COMP1'.

           This interface will provide common window named 'INTERFACE_VIEW'.

 

         

 

     ii.  Create a view with UI element caption as below.

          

 

   Follow the above two steps for the another 3 components.( ZRAO_INTERFACE_COMP2, ZRAO_INTERFACE_COMP3, ZRAO_INTERFACE_COMP4 ).

 

 

     

 

    

 

&

   

 

After creating all the 4 components , Create a Main component ZRAO_INTERFACE_MAIN with re-use component

ZRAO_INTERFACE_TEST interface as follows.

 

   

 

3. Create the view with dropdownbyindex with action 'DROPDOWN' and one ViewContainerElement as below.

 

   

 

 

4.  Write the code in Action DROPDOWN .

 

     METHOD onactiondropdown .

   DATA lo_nd_country_comp TYPE REF TO if_wd_context_node.
   DATA lo_el_country_comp TYPE REF TO if_wd_context_element.
   DATA lv_wda_component TYPE string .

* navigate from <CONTEXT> to <COUNTRY_COMP> via lead selection
   lo_nd_country_comp = wd_context->get_child_node( name = wd_this->wdctx_country_comp ).
* get element via lead selection
   lo_el_country_comp = lo_nd_country_comp->get_element( ).

   IF lo_el_country_comp IS NOT INITIAL.
* get single attribute
     lo_el_country_comp->get_attribute(
       EXPORTING
         name 'WDA_COMPONENT'
       IMPORTING
         value = lv_wda_component ).

       DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
       lo_cmp_usage =   wd_this->wd_cpuse_dynamic_comp1( ).
       IF lo_cmp_usage->has_active_component( ) IS INITIAL.
         lo_cmp_usage->create_component( lv_wda_component ). "Dynamic wda component name.
       ELSE.
         lo_cmp_usage->delete_component( ).
         lo_cmp_usage->create_component( lv_wda_component ). "Dynamic wda component name.
       ENDIF.

       wd_this->wd_get_api( )->do_dynamic_navigation(
         source_window_name = 'ZRAO_INTERFACE_MAIN' "{this is my window name }
         source_vusage_name = 'MAIN_USAGE_0' "{this one is MAIN--"}
         source_plug_name = 'OUT_PLUG1' "{this plug name can be generated dynamically }
         target_component_name = 'ZRAO_INTERFACE_TEST'
         target_component_usage = 'DYNAMIC_COMP1'
         target_view_name = 'INTERFACE_VIEW' "{the view i want to embed}
         target_plug_name = 'DEFAULT'
         target_embedding_position = 'MAIN/VCE' ).

   ENDIF.

ENDMETHOD.

 

 

Finally run the application.

 

 

If we select COMP2 , second component view will trigger.

 

 

 

 

 

Hope it will helpful.

 

 

Best regards,

Rao.


Viewing all articles
Browse latest Browse all 141

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>