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

CALL FUNCTION 'BAPI_OBJCL_DELETE'

Former Member
0 Likes
1,239

Hi,

I want to delete the classes of a material. I am using this function as:

CALL FUNCTION 'BAPI_OBJCL_DELETE'

EXPORTING

OBJECTKEY = "any MATNR

OBJECTTABLE = 'MARA'

CLASSNUM = "CLASS NUMBER

CLASSTYPE = "KLART

TABLES

RETURN = FUNC_RETURN.

READ TABLE FUNC_RETURN WITH KEY TYPE = 'E'.

IF SY-SUBRC = 0.

ROLLBACK WORK.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING WAIT = 'X'.

ENDIF.

and,

DATA FUNC_RETURN LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

When I debuuged code I am seeing that 'BAPI_TRANSACTION_COMMIT' is reached. But the problem is sometimes class is not deleted. But sometimes it is deleted. It is so interesting. I am commitng the work. But deleting maybe unsuccessful. Why this is so?

Thanks for your helps.

4 REPLIES 4
Read only

Former Member
0 Likes
897
 
<b>p_aennr LIKE cuco-aennr.</b>
 v_objek     = p_objek.
  v_class     = p_class.
  v_classtype = p_klart.
  v_aennr     = p_aennr.

  CALL FUNCTION 'BAPI_OBJCL_DELETE'
       EXPORTING
            objectkey    = v_objek
            objecttable  = c_objtable  " 'MARA'
            classnum     = v_class
            classtype    = v_classtype
<b>            changenumber = v_aennr</b>
            keydate      = c_keydate
       TABLES
            return       = it_return.

try to pass changenumber also...

Read only

Former Member
0 Likes
897

try to pass changenumber also and check it...

it is doing similar to previous or not...

Read only

Former Member
0 Likes
897

Hi Huseyin,

If the table FUNC_RETURN itself is empty?

In that case, the sy-subrc will not be equal to zero.

Check if that table is initial or not.

Regards,

ravi

Read only

Former Member
0 Likes
897
IF NOT FUNC_RETURN[] IS INITIAL.
READ TABLE FUNC_RETURN WITH KEY TYPE = 'E'.
IF SY-SUBRC = 0.
ROLLBACK WORK. 
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' 
EXPORTING WAIT = 'X'.

ENDIF.
ENDIF.