Skip to Content
avatar image
Former Member

How to get references of view controllers

I want to use the following code to validate user input of the required fields on the page:

<b>lr_view_controller = wd_this->wd_get_api( ).

cl_wd_dynamic_tool=>check_mandatory_attr_on_view( view_controller = lr_view_controller ).</b>

Currently, I have 6 views in my component, V_Main contains V_1, V_2,...,V5. and all these required fields are in V_1 to V_5 while the submit button is in V_Main. I don't know how to get reference to the views which is not the current view. Any one can help? Can I refer these views by using "LOOP AT ..." or something else?

Thanks in advance.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Jun 12, 2007 at 06:07 AM

    Hi Jaddy,

    I dont think there is a way to get the reference to another view. However, you can try to validate your fields by validating the context attributes of all the views (since all the context attributes are mapped from the component controller).

    To get the handle to the component controller's context, use the following code:

    DATA comp_context type ref to IF_WD_CONTEXT.
    DATA wd_comp_controller type ref to IG_COMPONENTCONTROLLER.
    comp_context = wd_comp_controller->wd_get_api( )->get_context( ).

    Hope this helps.

    Regards,

    Ram

    Add comment
    10|10000 characters needed characters exceeded

    • Hi

      You should not set the attributes at the DOINIT, as the view will not be created that time.So what i suggest is , create it DOMODIFY .

      As i said in my previous post , create five attributes in the component controller.

      like l_view1,l_view2,l_view3...etc. of type if_wd_view_controller.

      And now go to each view's modify method. And write the following code.

      Data: lo_api TYPE REF TO if_wd_view_controller.

      If first_time = 'X'.

      lo_api = wd_this->wd_get_api( ).

      wd_Comp_Controller->l_view1 = lo_api.

      endif

      And you could access this view controller , anywhere u want by using wd_Comp_Controller->l_view1

      Thanks

      Anzy

      Award points if this solves your issue.

      Message was edited by:

      Mohammed Anzy S

  • Jun 12, 2007 at 06:09 AM

    Hi Jaddy,

    What you could do is , create five view variables in the component controller like

    lv_view1, view2...like that , and add a code in each view's domodify to set these values to the component controller.And you could access these in your main view.

    Thanks

    Anzy

    Award points if this solves your problem

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 13, 2007 at 02:02 AM

    Hi, all

    Thank you very much for your help. Finally, I solved my problem. I put the follow code in each DOBEFOREACTION method of each view and then all the views can get the validation check.

    <b>lr_view_controller = wd_this->wd_get_api( ).

    cl_wd_dynamic_tool=>check_mandatory_attr_on_view( view_controller = lr_view_controller ).</b>

    Thank you very much indeed 😊

    Add comment
    10|10000 characters needed characters exceeded