Skip to Content
author's profile photo Former Member
Former Member

how to reuse the code?

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 08:39 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 08:24 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 08:27 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 08:48 AM

    Thank you guys,

    Points have been rewarded.

    Regards,

    Ravikanth

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.