Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Type Casting.

Former Member
0 Kudos

I have two interface references like follwing.

data: o_storable type ref to IF_RECA_STORABLE.

data: contract_object type ref to IF_RECN_CONTRACT.

after calling following method i will receive instance of type IF_RECN_CONTRACT.

CALL METHOD cf_recn_contract=>find

EXPORTING

id_bukrs =

id_recnnr =

ID_ACTIVITY = RECA1_ACTIVITY-DISPLAY

  • IF_AUTH_CHECK = ABAP_FALSE

  • IF_ENQUEUE = ABAP_FALSE

  • IF_USE_ARCHIVE = ABAP_TRUE

receiving

ro_instance = <b>contract_object</b>

  • EXCEPTIONS

  • ERROR = 1

  • others = 2

After getting reference into <b>contract_object</b>, i will have to refer it to <b>o_storable</b>. Before refering i need to type cast <b>contract_object</b> of type IF_RECN_CONTRACT into IF_RECA_STORABLE.

Please explain me how can i do?.

1 REPLY 1

Former Member
0 Kudos

HI,

I need more information:

IF_RECA_STORABLE and IF_RECN_CONTRACT are related to each other?

One can assign interface references to other interface/class reference variables, using the assignment operator (=) .

However, there are certain restrictions while doing so. When one does this in a program, system must be able to recognize in the syntax check whether an assignment is possible.

<iref> = <cref>, The class of the class reference <cref> must be implemnet the interface of the interface reference <iref>.

So, I need more information on relations between to interface and class of contract_object.

Thanks,

Chetan Shah