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: 

BAPI_SALESORDER_CREATEFROMDAT2

Former Member
0 Kudos

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.

7 REPLIES 7

former_member181962
Active Contributor
0 Kudos

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??

0 Kudos

I know it is created because when I go to the document flow of the contract I can see the new order.

0 Kudos

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??

0 Kudos

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.

0 Kudos

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

0 Kudos

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.

0 Kudos

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.