cancel
Showing results for 
Search instead for 
Did you mean: 

How to access the assitance class of another compnent

former_member211591
Contributor
0 Kudos

Hello all,

I want to use the assistance class of a component to pass parameters.

For instance:

- component CA calls component CB

- I want to pass parameters from CA to CB (or use CB-assist-methods within CA to set the parameters)

- (parameters are stored as attributes of CB-assist)

Is this possible?

If yes, how can I access the assistance class of CB out of CA?

Thanks a lot...

Accepted Solutions (1)

Accepted Solutions (1)

saravanan_narayanan
Active Contributor
0 Kudos

Hello,

This is possible but better solution would be to go for a separate global class and move the methods from the CB's assistance class to the global class. Then instantiate the global class instance and share the instance between the components.

Coming back to the solution for your question.

1. In the CB, create an interface method and return the referencce of the WD_ASSIST variable

2. in CA, call the interface method to get the reference of CB's assistance class and set the parameters.

BR, Saravanan

Answers (4)

Answers (4)

former_member211591
Contributor
0 Kudos

.

former_member211591
Contributor
0 Kudos

Thanks a lot for your replies.

I used successfully the solution with returning a reference to wd_assist from an interface method.

Regards

i.Durmaz

Former Member
0 Kudos

If both components use same Assistance class then it is possible to use the

IF_WD_COMPONENT_USAGE=>create_component method by passing the wd_assist object. This will make sure that you have one instance of the assistance class among the 2 components.

Thus your component CA passes the WD_ASSIST object to CB.

Another solution is to get rid of assistance class and use a Singleton class. use getter and setter methods to mutate. You are free to use this class where ever you wish.

Former Member
0 Kudos

You just create a reference to it in your application, like for any other class. Personally, I'd create this reference in the attributes list of the assistance class for application A. That way, assistance class CA would be able to instantiate and use assistance class CB.

From within any method in your application A, you would then invoke it as follows:

call method assistance_class_a->lcl_assistance_class_b->method1( )...