cancel
Showing results for 
Search instead for 
Did you mean: 

'CAST' operation ('?=' or 'MOVE ?TO')

Former Member
0 Kudos

Hi Experts,

Need your support to understand and fix below WD A error.

The error is apearing due to casting taking place in Component Controller, could you please redirect me to fix it.

Error:

It was tried to assign a reference to a rereference variable using the

'CAST' operation ('?=' or 'MOVE ?TO').

However, the current content of the source variable does not fit into

the target variable.

Code:



 DATA lv_result TYPE REF TO if_wd_message_area.
  DATA lo_controller TYPE REF TO if_wd_window_controller.

*&* Comments: Cast error happening at below point.

lo_controller ?= wd_this->wd_get_api( ).

 
  CALL METHOD lo_controller->get_message_area
    RECEIVING
      result = lv_result.

  CLEAR lv_result.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

HI,

Declare the reference lo_controller as

DATA lo_controller TYPE REF TO if_wd_component.

Method wd_get_api in component controller return the reference of the component . You cannot use a window controller type to hold it..Hence the cast error.

Thanks,

Aditya.

Former Member
0 Kudos

thanks for the comments.

As per your suggestion i have change to DATA lo_controller TYPE REF TO if_wd_component.

Method "GET_MESSAGE_AREA" does not exist. The following similarly-named methods do exist: "GET_MESSAGE" and "GET_MESSAGE_MANAGER".


 DATA lo_controller TYPE REF TO if_wd_component.

after changing the above line getting error as GET_MESSAGE_AREA" does not exist

CALL METHOD lo_controller->get_message_area

former_member184578
Active Contributor
0 Kudos

Hi.,

What exacly u are trying to do., if u want to display message., use message manager., refer below code..

*       get message manager
       data lo_api_controller     type ref to if_wd_view_controller.
       data lo_message_manager    type ref to if_wd_message_manager.

       lo_api_controller = wd_This1->Wd_Get_Api( ).

       CALL METHOD lo_api_controller->GET_MESSAGE_MANAGER
         RECEIVING
           MESSAGE_MANAGER = lo_message_manager
           .

 *       report message
       CALL METHOD lo_message_manager->REPORT_ATTRIBUTE_ERROR_MESSAGE
         EXPORTING
           MESSAGE_TEXT              = 'Enter user name'  " message text
           ELEMENT                   =       lo_el_user " element
           ATTRIBUTE_NAME            = 'UNAME'   .  " attribute name

hope this helps u.,

Thanks & regards

Kiran

Former Member
0 Kudos

Hi..

What are you trying to achieve?

thanks,

Aditya.

Former Member
0 Kudos

Hi,

Try like this.. code this is WDDOINIT of window..

data:

l_api_mycomp type ref to if_wd_window_controller,

l_wd_message_area type ref to if_wd_message_area.

l_api_mycomp ?= wd_this->wd_get_api( ).

l_wd_message_area = l_api_mycomp->get_message_area( ).

l_wd_message_area->set_display_attributes( i_for_all_instances = ' '

i_msg_lines_visible = '1'

i_use_toggle_area = 'X'

i_show_only_current = ' ' ).

endmethod.

Please go through this..

cheers,

Kris.

Former Member
0 Kudos

Hi ,

I am newto ABAP world and trying to understand what the code is performing and fix the fix to CAST exception.

regards,