Work with SAP CRM with ABAP you use a lot of model data, but sometimes using Model not best way for performance.
In my case when I want to delete Order CRM from SAP CRM, Model Data CRM didn’t worked. I tried to get object CL_CRM_BOL_ENTITY by GUID from table CRMD_ORDERADM_H ( Order SAP CRM Tables ) and use method DELETE ( from class CL_CRM_BOL_ENTITY ), but it didn’t work.
Deleting Order in SAP CRM with ABAP
In SAP CRM we also have function module for work with Order CRM. You can find these function module ABAP CRM_ORDER_DELETE in Function Group CRM_ORDER_API.

I tried to use function module CRM_ORDER_DELETE and I deleted 15 orders CRM very fast. You need only send GUIDs to internal table ABAP with type CRMT_OBJECT_GUID_TAB and fill some other parameters. I show you my example with using CRM_ORDER_DELETE and new syntax ABAP for filling internal table ABAP:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
DATA: lt_deleted_objects TYPE crmt_return_objects, lt_exception TYPE crmt_exception_t. DATA(lt_guid) = VALUE crmt_object_guid_tab( FOR ls_list IN lt_ord_list ( ls_list-guid ) ). CALL FUNCTION 'CRM_ORDER_DELETE' EXPORTING it_objects_to_delete = lt_guid iv_update_task_local = abap_true iv_no_check = abap_true IMPORTING et_deleted_objects = lt_deleted_objects et_exception = lt_exception EXCEPTIONS single_deletion_error = 1 deletion_error = 2 no_authority = 3 document_not_found = 4 OTHERS = 5. IF sy-subrc = 0. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'. ENDIF. |
In this ABAP code table lt_ord_list it internal table ABAP with some fields and include also list GUIDs for deleting.