cancel
Showing results for 
Search instead for 
Did you mean: 

Widening cast - Clarification

bharath_k6
Active Participant
0 Kudos

Hi,

In Web Dynpro ABAP, WD code wizard generates below code to do message handling.

wd_this->wd_get_api( ) method returns type IF_WD_VIEW_CONTROLLER. Here it is trying to do widening cast to lo_api_controller which is of type IF_WD_CONTROLLER.

I know widening cast is done to specify the super class reference to subclass reference variable in order to access the methods of subclass methods using superclass reference.

But here i do not see any classes involved. These are Interfaces.Please clarify.

* get message manager
  DATA lo_api_controller     TYPE REF TO if_wd_controller.
  DATA lo_message_manager    TYPE REF TO if_wd_message_manager.

  lo_api_controller ?= wd_this->wd_get_api( ).
  CALL METHOD lo_api_controller->get_message_manager
    RECEIVING
      message_manager = lo_message_manager.

Thanks,

Bharath.

Accepted Solutions (0)

Answers (1)

Answers (1)

chengalarayulu
Active Contributor
0 Kudos

Bharath,

well question,

however you aware of super & sub classes and Inheritance, in similar methodology will happen in Interface level also.

the casting(super) - IF_WD_CONTROLLER will be imported into (sub) - IF_WD_VIEW_CONTROLLER.

now only videning casting can be possible..

if you open Interfaces Tab under IF_WD_VIEW_CONTROLLER, you can understand easily.