I am trying to delete an equipment class using BAPI_OBJCL_DELETE but when running in debug mode, the class gets deleted but it doesn't get deleted in normal mode. I am using below program to delete it. I have tried COMMIT WORK and BAPI_TRANSACTION_COMMIT.
May you provide some insight on this problem?
Program:
Get list of current class assignments.
CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
EXPORTING
classtype = cv_klart
object = iv_objnum
objecttable = cv_object_tab
TABLES
t_class = lt_class
t_objectdata = lt_obj
EXCEPTIONS
no_classification = 1
no_classtypes = 2
invalid_class_type = 3
OTHERS = 4
IF sy-subrc EQ 0 AND lt_class IS NOT INITIAL.
lv_objectkey = iv_objnum.
"Delete all existing classes.
LOOP AT lt_class INTO ls_class.
CALL FUNCTION 'BAPI_OBJCL_DELETE'
EXPORTING
* OBJECTKEY =
objecttable =
classnum =
classtype =
* CHANGENUMBER =
* KEYDATE = SY-DATUM
* OBJECTKEY_LONG =
TABLES
return =
.
CALL FUNCTION 'BAPI_OBJCL_DELETE'
EXPORTING
objectkey = lv_objectkey
objecttable = cv_object_tab
classnum = ls_class-class
classtype = cv_klart
TABLES
return = lt_return.
IF sy-subrc NE 0.
APPEND LINES OF lt_return TO et_messages.
ENDIF.
WAIT UP TO 1 SECONDS.
COMMIT WORK.
ENDIF.
WAIT UP TO 1 SECONDS.
ENDLOOP.
WAIT UP TO 1 SECONDS.
ENDIF.
You are looking for errors by checking
IF sy-subrc NE 0.. This doesn't work on BAPIs. It only works on function modules that communicate error conditions viaEXCEPTIONS. Which BAPI function modules never do. BAPIs communicate error conditions via massages through theirreturntables of typeBAPIRET2.So what you need to do is check if a BAPI worked successfully, do a
Why doesn't this BAPI work in your particular case? There could be a million reasons. And because BAPIs usually also perform any customer events that are supposed to be called for a specific action, the reason might be some custom code that can only be found in your system. But the error message in the return table might provide you some insight on what the problem could be.