How to resolve runtime error UC_OBJECTS_NOT_CONVERTIBLE when removing relationship between IBASE and object
Requirement: After downloading two equipment with parent and children relationship via the steps in Step by step to download equipments from ERP with hierarchy, customer needs to remove the relationship between parent equipment ( ZJERRY0903P1) from Object structure IBASE ( 112254 ).
The relationship between them are modeled and maintained via relationship type “PRDIB”. It could be removed via function module COM_IL_API_DELETE. Then a report could be developed to remove the relationship. The complete source code could be found from last part of this blog.
When the report is executed, there is a runtime exception occurred:
The error is caused because the data type of <wa_db_h> is not compatible with the line type of internal table <il_db_h>:
Both <wa_db_h> and <il_db_h> are defined as general table type, and their dedicated data type are determined via the corresponding entries in configuration table comc_il_struc:
In this case, the data type for <wa_db_h> comes from the value of field BASE_H, in SAP standard delivery, the field for relationship type PRDIB is empty, so the fallback type ‘COMM_IL_PRDIB’ is used, which is not compatible to the line type of COMT_IL_PRDIB_H_TAB.
So the solution is to add the correct data type COMM_IL_PRDIB_H to field BASE_H:
After that the relationship could be removed successfully. The parent equipment ZJERRY0903P1 does not appear in the object structure IBASE any more.
Now it is free to be assigned to any other IBASE:
REPORT zprod_delete_obj_struc_refer. PARAMETERS: obj_id TYPE comm_product-product_id OBLIGATORY DEFAULT 'ZJERRY0903P1'. START-OF-SELECTION. DATA: lt_obj_rel TYPE STANDARD TABLE OF comm_il_prdib, lt_ibib TYPE STANDARD TABLE OF ibib, lv_guid TYPE comm_product-product_guid, lt_messages TYPE comt_il_error_tab, lv_reltype TYPE comt_il_reltype, ls_ident TYPE comt_il_ident, lt_ident TYPE comt_il_ident_tab. lv_reltype = 'PRDIB'. SELECT SINGLE product_guid INTO lv_guid FROM comm_product WHERE product_id = obj_id. IF sy-subrc <> 0. WRITE: / 'invalid object id.'. RETURN. ENDIF. SELECT * INTO TABLE lt_obj_rel FROM comm_il_prdib WHERE reltype = 'PRDIB' AND sourceguid = lv_guid. IF sy-subrc <> 0. WRITE: / 'no relationship between object and IBASE. Nothing to be deleted.'. RETURN. ENDIF. SELECT * INTO TABLE lt_ibib FROM ibib FOR ALL ENTRIES IN lt_obj_rel WHERE ib_guid_16 = lt_obj_rel-destinguid. LOOP AT lt_obj_rel ASSIGNING FIELD-SYMBOL(<il>). READ TABLE lt_ibib ASSIGNING FIELD-SYMBOL(<ibase>) WITH KEY ib_guid_16 = <il>-destinguid. WRITE: 'relationship for IBASE: ' , <ibase>-ibase , ' will be deleted'. CLEAR: ls_ident. ls_ident-ilguid = <il>-ilguid. ls_ident-sourceguid = <il>-sourceguid. ls_ident-destinguid = <il>-destinguid. INSERT ls_ident INTO TABLE lt_ident. ENDLOOP. CALL FUNCTION 'COM_IL_API_DELETE' EXPORTING iv_reltype = 'PRDIB' it_link_idents = lt_ident iv_no_check = 'X' IMPORTING et_messages = lt_messages EXCEPTIONS lock_failed = 1 OTHERS = 2. IF sy-subrc <> 0. WRITE: / 'deletion failed'. RETURN. ENDIF. LOOP AT lt_messages ASSIGNING FIELD-SYMBOL(<message>). WRITE: / 'Error occurred: ', <message>-msgid COLOR COL_NEGATIVE,<message>-msgno COLOR COL_TOTAL. ENDLOOP. IF sy-subrc = 0. WRITE: / 'deletion failed'. RETURN. ENDIF. CALL FUNCTION 'COM_IL_API_SAVE' EXPORTING iv_no_upd_task = 'X'. COMMIT WORK AND WAIT. WRITE:/ 'deletion successful'.