cancel
Showing results for 
Search instead for 
Did you mean: 

Method from View to Component Controller

Former Member
0 Kudos

Hi,

my coding in my View workes fine.

DATA lo_view TYPE REF TO if_wd_view.
        DATA lo_buttonchoice TYPE REF TO cl_wd_button_choice.
        DATA lo_menuactionitem TYPE REF TO cl_wd_menu_action_item.

* Get a reference to the ButtonChoice view object
        lo_view ?= wd_this->wd_get_api( ).
        lo_buttonchoice ?= lo_view->get_element( 'LV_1_BUTTON' ).
        lo_buttonchoice->SET_SELECTED_ACTION_ITEM( 'RUF_1_NEUTRAL' ).

But when i try to convert this in my component Controller as a Method i get an Error

Dynamischer Typkonflikt bei Zuweisung von Referenzen

i think because of my variable "lo_view"

Because this Method is started in my CC maybe he needet the view first ?

please help me

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

i Created an Context-Attribute in my View

VIEW_WD_IF type ref to IF_WD_VIEW

Then in the Method WDDOMODIFYVIEW

i exportet the View Parameter to my context attribute VIEW_WD_IF

My Attribute was mapped with my CC so now i can easily use the Attribute in my CC Method for my Button Choice Method.

I used this coding im my CC Method

* get single attribute
       LO_EL_VIEW_DETAILS->GET_ATTRIBUTE( EXPORTING NAME `VIEW_WD_IF`
                                          IMPORTING VALUE = LV_VIEW_WD_IF ).

       LV_VIEW_WD_IF->GET_ELEMENT( BUTTON_CHOICE_ID  ).

       DATA LO_BUTTONCHOICE TYPE REF TO CL_WD_BUTTON_CHOICE.
       DATA LO_MENUACTIONITEM TYPE REF TO CL_WD_MENU_ACTION_ITEM.
* Button wird auf Neutral zurückgesetzt
       LO_BUTTONCHOICE ?= LV_VIEW_WD_IF->GET_ELEMENT( BUTTON_CHOICE_ID  ).
       LO_BUTTONCHOICE->SET_SELECTED_ACTION_ITEM( ACTION_ITEM_ID ).

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello,

in this line lo_view ?= wd_this->wd_get_api( ). you are taking reference of view where you have menu item. so in component controller we can't create any UI so while proceeding next line it can give u an error..  so this can be the reason for error.

former_member184578
Active Contributor
0 Kudos

Hi,

Obviously you will get the type conflict error because wd_this->wd_get_api( ) in component controller returns the component controller api which is not of type if_wd_view.

If you want to convert it to component controller method and call in your view, get the view reference in view and pass this reference as an exporting parameter to the component controller method.

Hope this helps u.,

Regards,

Kiran