Application Development and Automation 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: 
Read only

Creating object type conflict dump

Former Member
0 Likes
380

Hi All,

I have an interface zintf_1. I getting the list of classes that implemented the zintf_1.

There are some cases where the class wont have implemented the interface.

ZDEMO_AA class has not implemented the interface zintf_1.

data: lr_intf_1 type ref to zintf_1,

lv_clsname type SEOCLSNAME.

lv_clsname = 'ZDEMO_AAA'.

try.

create object lr_intf_1 type (lv_clsname).

catch cx_sy_create_object_error.

.....

endtry.

In that case i m getting the dump "Type conflict with allocation of References".

Please help me to resolve the issue.

thanks

Vimalraj

1 REPLY 1
Read only

matt
Active Contributor
0 Likes
308

I'm assuming that you're trying to trap the case the class lv_clsname doesn't actually implement the interface.

Well, the interface not being there is NOT a catchable error. So you have to find out whether the interface is implemented first.

DATA: lr_intf_1  TYPE REF TO zintf_1,
      lv_clsname TYPE seoclsname,
      lr_object  TYPE REF TO cl_oo_class,
      lt_intf    TYPE seo_relkeys.

lv_clsname = 'ZDEMO_AAA'.

lr_object ?= cl_oo_object=>get_instance( lv_clsname ).
lt_intf = lr_object->get_implemented_interfaces( ).

READ TABLE lt_intf TRANSPORTING NO FIELDS WITH KEY refclsname = 'ZINTF_1'.
IF sy-subrc IS INITIAL.
  CREATE OBJECT lr_intf_1
    TYPE
      (lv_clsname).
  WRITE: 'it worked'.
ELSE.
  WRITE / 'it failed'.
ENDIF.

matt