Application Development 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: 

Cancel a Sales Order via IDOC processing

Former Member
0 Kudos
1,279

Hello,

I am trying to cancel an item within a sales order using ORDERS05 (IDOC_INPUT_ORDCHG).

My IDOC contains the following data:

E1EDK01-ACTION = 003 (Changes in one or more items)

E1EDK02-QUALF = 002 (Vendor Order)

E1EDK02-BELNR = SAP Sales Order Number to be updated.

E1EDP01-POSEX = SAP Sales Order Item Number to be deleted (eg. 000010).

E1EDP01-ACTION = 003 (Item cancelled)

E1EDP19-QUALF = 002 (Material number used by vendor)

E1EDP19-IDTNR = SAP Material Number of Item to be deleted

However it does not seem to be working correctly. Instead of removing the item from the sales order - it actually creates a new item.

Has anyone had any experience with successfully cancelling an item using IDOC processing?

Any assistance would be greatly appreciated.

Thanks and Regards,

Corinne

5 REPLIES 5

Former Member
0 Kudos
206

Hi Corinne,

I think I know why this is happening. In fact the POSEX parameter is not the SAP sales order item number to be updated (in your case deleted) ie vbap-posnr, but is in fact the sales order item PURCHASE order item, vbap-posex. This field can be found on the purchase order screen of the item data on the sales order (in transaction VA02/VA03).

What SAP tries to do is match the number you supply in the POSEX field with the value in vbap-posex for any of the items currently existing for the sales order. If it finds a match it will flag the item for deletion, if it does not find a match the deletion logic is ignored and SAP treats it as a new item. Strange huh?

Other than by userexit, I'm not sure there is a way in the standard change idoc to refer to the vbap-posnr field when making changes. What you can do, however, is if the vbap-posex field is not in use in your system (and is not likely to be used in the future) is to populate it with the vbap-posnr value when creating the sales order (if you are creating the sales orders via idoc or similar) and then your idoc should work as you intend.

Hope that helps.

Cheers,

Brad

0 Kudos
206

Hi Brad,

Thanks heaps!

After further investigation - I too discovered this in the code and did think it was strange. I have emailed SAP to question this logic and I will keep you updated with what I hear back.

Cheers,

Corinne

0 Kudos
206

Hi Corinne,

I don't think you'll get back the response you want from SAP. This idoc was originally created to support the EDI scenario where your customer makes a change to their purchase order. The EDI message would be sent to SAP to update the corresponding sales order in your system (after being mapped to an Idoc).

As your customer does not normally not have your sales order item number in their system, they can only send their own purchase order item number. SAP then uses this number to look up the corresponding SAP sales order item number via the VBAP-POSEX field (which in this scenario is originally populated by the Idoc which created the order from the customers original purchase order EDI message).

So, I dont think SAP will change this functionality. They may offer, however, a work around!

What I still think is strange though, is that, having not found a match for your item on the POSEX field, SAP ignores the deletion flag and adds a new item to your order. At the very least you would expect it to just ignore the item (a quick look at the code in 4.7 seems to imply that this is what SAP is trying to do - maybe a change from your version?).

Hope that helps.

Brad

Former Member
0 Kudos
206

Hi Brad,

SAP have advised that I should indeed be able to delete a sales order item using this IDOC and I have provided them with a logon and an example scenario - as they have requested. We will wait and see what we hear back.

The work around you suggested works great - however we need to confirm with that we can actually use this field and then ensure that it gets populated correctly!

Further to my post yesterday - when I now run the test of trying to delete an item, it basically does nothing (no items were added) as you suggested it should. I think there were gremlins in the system yesterday !

Will keep you posted.

Thanks,

Corinne

Former Member
0 Kudos
206

Hi Brad,

As you suspected, SAP did advise that the POSEX field had to be completed. We initially thought this could be a problem - however we have sinced disocovered that when you create a sales order using IDOC_INPUT_ORDERS with E1EDP01-POSEX containing a value - this value automatically gets populated into "Item Number of the Underlying Purchase Order" field. Therefore - providing this field is populated on the create interfaces - the change interface will also work. The reason why it was not working for our testing is we were using manually created sales order - and we did not realise this field had to contain a value.

Thanks again for all your help,

Corinne