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: 

Need help to cast

Former Member
0 Kudos

Hi all,

i need some help.

I need to create a new method in class CL_PO_ITEM_HANDLE_MM, so i have created a new class named Z_CL_PO_ITEM_HANDLE_MM and inherited from CL_PO_ITEM_HANDLE_MM class and add a method name CHECK_ASSIGNMENT.

Now i would like to call this method ; in my BADI the CL_PO_ITEM_HANDLE_MM class is used so i wanted to cast CL_PO_ITEM_HANDLE_MM class to Z_CL_PO_ITEM_HANDLE_MM like this :

my_instance ?= standard-instance.

The code is compiled well but when i execute this code i get a dump with this message :

Dynamic type conflict when assigning references

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.

So i can't do that ? if not how can i resolve my problem ?

Thanks for your help.

Cheers

source type: "\CLASS=CL_PO_ITEM_HANDLE_MM"

target type: "\CLASS=Z_CL_PO_ITEM_HANDLE_MM"

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

?= is for downcasting, so it should work if you need to move from Z_CL_PO_ITEM_HANDLE_MM to CL_PO_ITEM_HANDLE_MM

MOVE .... ?TO is for upcasting , so if you need to move from CL_PO_ITEM_HANDLE_MM to Z_CL_PO_ITEM_HANDLE_MM.

But your problem is to get the instance of the BADI:

u should know the name assigned to the instance of the BADI, but you're in the BADI when you try to do the casting, so I don't know if it's possbile.

Max

1 REPLY 1

Former Member
0 Kudos

Hi

?= is for downcasting, so it should work if you need to move from Z_CL_PO_ITEM_HANDLE_MM to CL_PO_ITEM_HANDLE_MM

MOVE .... ?TO is for upcasting , so if you need to move from CL_PO_ITEM_HANDLE_MM to Z_CL_PO_ITEM_HANDLE_MM.

But your problem is to get the instance of the BADI:

u should know the name assigned to the instance of the BADI, but you're in the BADI when you try to do the casting, so I don't know if it's possbile.

Max