cancel
Showing results for 
Search instead for 
Did you mean: 

Calling One Component from Another

Former Member
0 Kudos

Hi,

I have a WDA component, component1 in which I have 2 views, view 1 and view2.

When I click on a button on view1, it should call component 2 which does not have any screens (views), but I am using only for validating the data.

1) What all do I need to do to call component2 from component1?

If the data is not valid, then view1 of component1 should be displayed, but if the data is valid then view2 of component 1 should be dispalyed

2) How do I acheive the return navigation from component2 to component1?

Thanks,

MIck

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Answered

arjun_thakur
Active Contributor
0 Kudos

Hi Mick,

Please refer this link for [Component Usage|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/2064719b-8851-2b10-a399-b356d91ca4ba]

As suggested by Thomas, just make a method , which has the validation code, global in WDA2. Declare that method at component controller level & then go to the methods tab & check the "Interface" checkbox against this method. This will make that method available to other components.

I hope it helps.

Regards

Arjun

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You don't actually have to navigate to Component 2 - in fact I would highly recommend against it. Instead just use a component usage of Component 2 within Component 1 - just like you would with an ALV. You do context mapping between interface nodes and call methods of component 2 as long as they are marked as interface methods.

However using faceless components isn't really the most performant approach. It is really better to put such logic in a normal ABAP class or in a reusable assistance class. Normally you only wnat to use multiple components if you have views you want to share. If you just need reusable logic, then you don't want the overhead of WDA components and contexts.