cancel
Showing results for 
Search instead for 
Did you mean: 

how to reuse the code?

Former Member
0 Kudos

Hi

I'm new to Webdynpro.

We have a tool which is developed using Webdynpro ABAP. My task is to improve the performance of this tool.

I see that a lot of code is getting repeated in all the VIEWS. Is it possible to group this similar code into one method and call it wherever needed across all the VIEWS?

My doubt is there is lot of coding done inside the VIEW methods using wd_this and wd_context etc....can i copy this code into a different method (and a different class) as wd_this and wd_context are relevant only in the views in which they are used?

Regards,

Ravikanth

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

Not all the attributes are shared between the view context controller and the component controller...hence creating a common method in component controller might not be possible.

Nithya : Is it ok to proceed with Assistance class in this scenario? Is it enough if i just replace the wd_this and wd_context with wd_assist?

Regards,

Ravikanth

Former Member
0 Kudos

You can proceed with an assistance class, and yeah, access it with wd_assist->method_name. The wd_assist object will be available only if you have the assistance class defined for your component.

Regards

Nithya

Answers (3)

Answers (3)

Former Member
0 Kudos

Thank you guys,

Points have been rewarded.

Regards,

Ravikanth

former_member196517
Contributor
0 Kudos

hi ravi,

ya you can easily reuse code by component controller

you copy this code to component controller method and call this method... You should follow MVC paradigm .. that means attributes and context nodes you should first make in component controller and share them in views wherever required.. now you should write methods in component controller and call this method from views..

Regards

Anuj Goyal

Former Member
0 Kudos

Hi,

Group the common code into a method and place it in your component controller. It can be accessed from all the views using wd_comp_controller->metohd_name.

Or a better thing would be to use an assistance class and have your method there. This can be accessed using the object wd_assist, that will be visible across the component.

Regards

Nithya