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

Utility program for sales order deletion using BAPI

Former Member
0 Likes
1,319

I need to delete sales order but i am unable to delete that, although i have used the BAPI_SALESORDER_CHANGE also and provided the D as the deletion flag at item and header section .After that i have used the commit also then also it is showing the error of the document could not be deleted.

Please provide some useful solutions.

7 REPLIES 7
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
1,275

Is this the only message you get in return table or their are more?? A small thing when you want to delete sales order only pass header for deletion

nabheet

Read only

0 Likes
1,275

This small message i am only getting and i have checked with header only then also i am geting that error i.e.,this document cannot be deleted .Now what could be the possible cause of it i am not getting.

Read only

Former Member
0 Likes
1,275

Hi,

Have you done this like below!

     ls_order_header_in-doc no =
       ls_order_header_inx-updateflag = 'U'.

        lt_ord_itm_inx-updateflag = 'U'.
         lt_ord_itm_in-itm_number  = ltem
         lt_ord_itm_inx-itm_number = ltems

Read only

0 Likes
1,275

i am doing like this

wg_order_header_in-collect_no  = g_vbak-vbeln.
wg_order_header_inx-collect_no = 'X'.
wg_order_header_inx-updateflag = 'D'.


   wg_order_item_in-itm_number  = wg_vbap-posnr.
   wg_order_item_inx-itm_number = 'X'.
   wg_order_item_inx-updateflag = 'D'.

Read only

Former Member
0 Likes
1,275

Hi Abhigyan,

Not sure which user you are using to execute the BAPI.  Might sounds silly but who knows if its executed from an external user triggered via web service?  My suggestion is to login using that User and try deleting the order manually using VA02 first.  See what is the error you faced.

Thanks

Leonard

Read only

0 Likes
1,275

Leonard thanks for your answer but i need to delete many sales order and with this utility program it would  be very easy if it executes as i can give some further conditions so that at a time the particular category sales order will be deleted at once no need to go again and again to delete them .

Read only

0 Likes
1,275

Yes. I understand and i am not suggesting you not doing the bapi. All i recommend is to make sure you can at least manually delete the sales order in foreground before you test in bapi due to the limited error logs provided. The user you used to test in foreground is critical. It has to be the username that you used to test your bapi as well.