Component Reuse


Create a web dynpro component. Add a method in the component controller and Select the Interface checkbox.

 Provide the exporting parameter of the method and  the below code.

 Go to the Interface Controller method. We can see here the methods which are defined in the component controller with Interface marked.

 Create another web dynpro component and in the used component add the previous component and the component interface and provide a used web dynpro component name.

 Add a Node ( cardinality 0..N) in the component controller node.

Go to the Properties tab and add the reused components by selecting the Create button.

Go to the component controller and open  the INIT method.

Instantiate the reused component and used component interface. Call the used interface method to get the flight table. and bind it to the context node.


METHOD wddoinit.
DATAlr_cmp_usage    TYPE REF TO if_wd_component_usage,
lr_cmp_usg_intf TYPE REF TO ziwci_test_004,
lr_ctrl         TYPE REF TO if_wd_controller,
lt_flight       TYPE        wd_this->elements_sflight,
lo_nd_sflight   TYPE REF TO if_wd_context_node.

lr_cmp_usage wd_this->wd_cpuse_test_004).
IF lr_cmp_usage->has_active_componentIS INITIAL.
component_name ‘ZTEST_004’ ).

lr_cmp_usg_intf wd_this->wd_cpifc_test_004).
et_sflight =  lt_flight ).

lo_nd_sflight wd_context->get_child_nodename wd_this->wdctx_sflight ).
lo_nd_sflight->bind_tablenew_items lt_flight set_initial_elements abap_true ).

 In the layout, add a table and bond it to the context node.

 Create an application and test.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s