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

BAPI creating incorrect Item Texts

Former Member
0 Likes
544

Hi all

I've got a problem where sales orders and credit notes get created via BAPIs but sometimes an item text from the previously created record appears on the following record.

Background

The process is as follows:

1. XI creates a bunch of IDocs containing a mixture of sales order and credit memo doc types

2. These are all processed in one go within a custom function module

3. For Credit notes the BAPI 'BAPI_SALESDOCU_CREATEFROMDATA' is used, if this is successful then the item texts are processed which basically involves adding an item text to the last item. This is done using the SAVE_TEXT function. If there is more than one item the first to penultimate items do not have texts.

4. For other doc types (standard orders, forward orders, paid), function 'SD_SALESDOCUMENT_CREATE' is run in test mode so that a credit check can be performed in advance of creating the document - the sales_text table is populated. If the credit check passes then the order is created using BAPI 'BAPI_SALESORDER_CREATEFROMDAT2'. The texts are created vai the BAPI by populating the order_text table.

5. The next Idoc is then processed.

Five times since this went live (about 18 months ago) a Credit Note has been created where the first item on it has the item text from the previous sales order

What I've done so far

1. I've reviewed the code to make sure variables are being cleared - they are

2. I've run data through the system and stepped through it in debug mode - it works fine

3. Our QAS box was restored from PRD recently so contains some of these incorrect documents. I've re-run the exact same batch that casued the incorrect documents - they are all created correctly

4. I've trawled through SAP Notes and this forum

The fact that the problem is not replicable suggests to me that both the data coming in and the bespoke function module are OK. I'm not sure why the different methods have been used for the different doc types but I wonder if this is what's causing the problem, maybe memory is not being cleared or something.

Any pointers, thoughts, solutions or other genreal musings would be greatly appreciated!

Thanks

Andy

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
432

Hi Andy

Although you have mentioned that, you have checked whether variables are cleared, but from the issue it looks like there must be some variable that does not gets cleared.....i would suggest you to debug once again and check this out.....it might help.

regards

Lokesh

1 REPLY 1
Read only

Former Member
0 Likes
433

Hi Andy

Although you have mentioned that, you have checked whether variables are cleared, but from the issue it looks like there must be some variable that does not gets cleared.....i would suggest you to debug once again and check this out.....it might help.

regards

Lokesh