cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a WDA component and calling it from another WDA component - how?

Former Member
0 Kudos

Hi, everyone!

I have created two WebDynpro (ABAP) Components: Z_COMP_1 and Z_COMP_2. Z_COMP_1 has an ALV that displays some data, incluinding PO number. Z_COMP_2 is a component that displays some data from the purchase order. What I need is to call component Z_COMP_2 from Z_COMP_1, when the user clicks on a button. As I will use Z_COMP_2 from other components, I decided to develop it separately.

My question is: what are the needed steps to create a "reusable" component? I'd like to share the PO number through an interface Context attribute (inside a node), and I'd like to have a method to "refresh" all data (select it from PO tables again).

Hope I made myself clear.

Thanks in advance!

Andre

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Andre,

Every component is a reusable component and the CONTEXT, METHODS, EVENTS of one component can be reused in other components by checking the INTERFACE property of it in the component controller. Then it is availaible in the INTERFACECONTROLLER of the same component.

Various steps that you should follow.

1: In the properties of the WD component create a component usage of the z_comp_2 in z_comp_1.

2: Embed the window of the z_comp_2 in the window of z_comp_2 and also define the navigation, as you would like.

- outbound plug from the view of z_comp_1.

- inbound plug in the window of z_comp_2 with the interface property checked.

- define navigation in z_comp_1'w window.

now since you want to transfer the parameters from z_comp_1 to z_comp_2 there are many ways:

- Context Mapping.

- Passing parameters through outbound plugs.

- Passing parameters through function calls.

- Passing parameters through URL of child component.

In your case if you want to transfer the PO number only then its better you pass them through function calls or through parameters of outbound plugs. Based on this PO you can call a function of a child component by instanciating the child component's inteface controller.

sample code for this:

  • Call interface method of child component usage

DATA: l_ref_interfacecontroller TYPE REF TO zwci_<alias name of your child comp> .

l_ref_interfacecontroller = wd_this->wd_cpifc_<alias name of your child comp> ..

l_ref_interfacecontroller->showcustomer(

customer_id = item_customid ).

here i am calling a method showcustomer of my child component and passing it the customer_id, which is the import parameter in the method.

Use code inspector to generate the code.

Hope this helps.

Let me know if still some doubts.

Cheers!

Ashish

Former Member
0 Kudos

Thank you very much, Ashish!

I'll try your solution and post the results here.

Andre

Answers (0)