03-31-2006 3:42 PM
Hi,
I am using BAPI_SALESORDER_CREATEFROMDAT2 inside MV45AFZZ to create an order with reference to a contract. The order gets created but the sales order number is not returned in the BAPI. Any idea on why it is not coming?
When I use BAPI_SALESDOCUMENT_COPY also the same result occurs.
Regards,
Sajith.
03-31-2006 3:48 PM
How do you know that the order has been created?
If it is created , the you must find it in the baoi returns table.
and are you using BAPI_TRANSACTION_COMMIT FM also??
03-31-2006 3:50 PM
I know it is created because when I go to the document flow of the contract I can see the new order.
03-31-2006 3:56 PM
Hi Hari,
As you are creating an order in the exit of another order, I think you should be getting two orders on single save.
Correct me if i am wrong.
And what is the document that you are seeing in the documnet flow, the original document that is being created, or the one that is being created??
03-31-2006 4:01 PM
Hi Ravi,
No, the initial order will not be created because after the order with reference is created the program stops processing the first order.
The order in the flow is the one created with reference.
03-31-2006 4:05 PM
Hi,
let me express a warning: if you cerate an order within another LUW using a BAPI, you must call BAPI_TRANSACTION_COMMIT to get the order saved. But this Commit might also push all pending transaction data to the database. This should never be done before the end of transaction will do it.
Maybe you can move your action to a userexit which is processed after (succesful) save of the main document.
regards,
Clemens
03-31-2006 4:10 PM
Hi Clemens,
Thanks for the warning. The requirement is that if the program finds that there is a valid contract for material-sold to party combination we have to stop processing the current order and create an order with reference to a contract. Hence I am creating the order with reference and then I leave the program so that initial order entered is not created. Shouldn't this be fine?
Rgds,
Saji.
03-31-2006 4:39 PM
OK, maybe the user exit is quite late - you may check the existence before entering the transaction, but - anyway:
Befor you call the BAPI, just do a ROLLBACK WORK just to make sure nothing unwanted will happen.
Then call your BAPI, then the BAPI_COMMIT. Then exit.
The number of created document should be returned. If there is no BAPI_COMMIT, the number is used but the order will nit be stored.
Clemens.