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

Transaction VA01 separate LUW / commit DB when creating in Background PO

0 Likes
1,925

Hi experts,

I have a request to create a PO for a particular item of a sales document, and for the PO created I need to fill one component and to lock it. I found out that the only way to create for sure a PO is the FM BAPI_ORDER_CREATE. To update the components and to lock it I need a BDC. I did not found any FM which might do something like this.

The place where I trigger the creation of PO is user_exit_save_document. My logic is the following: I create the PO with BAPI_ORDER_CREATE in another LUW then trigger commit both with BAPI commit and commit work for this separate LUW, In the same LUW in which I created the PO, after the commit, I call a BDC Function Module that updates the component and locks the PO.

I observed that the BAPI ORDER CREATE works fine - it always creates me a PO. When running in the next step the BDC FM , it always returns me the message "PO (before created) does not exist". In debug Mode everything works fine, PO is created and also BDC FM does not return me any error.

It seems to me that when the logic runs in dialog mode all the PO tables are not updated before I run the BDC. As I am openning a separate LUW and I trigger explicitly COMMIT in this separate LUW I was wondering why does not the update of PO tables take place? Is this because the transaction VA01 does not allow any commits for the programms that are called from the transaction? Or what am I missing?

I did a kind of workaround and I don#t run the BDC only after the batch input is created, but I was wondering why am I wrong.

Thank you for the support,

Florin

Hi experts,

I have a request to create a PO for a particular item of a sales document, and for the PO created I need to fill one component and to lock it. I found out that the only way to create for sure a PO is the FM BAPI_ORDER_CREATE. To update the components and to lock it I need a BDC. I did not found any FM which might do something like this.

The place where I trigger the creation of PO is user_exit_save_document. My logic is the following: I create the PO with BAPI_ORDER_CREATE in another LUW then trigger commit both with BAPI commit and commit work for this separate LUW, In the same LUW in which I created the PO, after the commit, I call a BDC Function Module that updates the component and locks the PO.

I observed that the BAPI ORDER CREATE works fine - it always creates me a PO. When running in the next step the BDC FM , it always returns me the message "PO (before created) does not exist". In debug Mode everything works fine, PO is created and also BDC FM does not return me any error.

It seems to me that when the logic runs in dialog mode all the PO tables are not updated before I run the BDC. As I am openning a separate LUW and I trigger explicitly COMMIT in this separate LUW I was wondering why does not the update of PO tables take place? Is this because the transaction VA01 does not allow any commits for the programms that are called from the transaction? Or what am I missing?

I did a kind of workaround and I don#t run the BDC only after the batch input is created, but I was wondering why am I wrong.

Thank you for the support,

Florin

7 REPLIES 7
Read only

Former Member
0 Likes
1,633

Hi

I suppose the problem is the time taken to run the saving process, this process is still running while your BDC is starting.

U should use a COMMIT WORK and WAIT in order to be sure the saving process is over before calling the BDC.

Now I don't understand where you have place the COMMIT for the BAPI

Max

P.S.: BAPI ORDER CREATE doesn't exist in my systen, I have BAPI_PO_CREATE1

Max

Edited by: max bianchi on Aug 15, 2011 1:40 PM

Read only

0 Likes
1,633

Hi,

the correct bapi name is BAPI_PRODORD_CREATE.

Kind regards,

Florin

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,633

I hope you're triggering a synchronous update i.e., COMMIT WORK AND WAIT. Or passing the WAIT param to the BAPI_TRANSACTION_COMMIT module.

Read only

0 Likes
1,633

Hi,

I am doing synchronous update.

I put in the title transaction VA01, because when I do the same with two reports. R1 is first LUW, R2 is second LUW. Same flow in R2 - create PO, then commit synchronous, then BDC - everything works fine.

Kind regards,

Florin

Read only

Former Member
0 Likes
1,633

If your talking about purchase order to procure that materials to be sold, or a production order for materials to be manufactured, why doesn't your order placement create that as part of your ordering process? Why would you have to do that manually in an SAP system?? If you're talking about the customer's Purchase Order number for this sales order, you have only one of those per sales order...usually required by config at the time the sales order is created.

So I don't understand why you have a manual process following Sales Order creation.

Read only

0 Likes
1,633

Hi,

the requirement is to create a Production Order automatically for a particular item of a sales order, if that item contains a particular material. I am not aware of triggering the Production Order (10) creation using a customizing setting as I do not know very well the settings for SD. Can you elaborate a little bit here?

the total scenario is: I create a sales order, then I create in background automatically an item - if an item that was filled by the operator has a particular value in field material group 3, then for the automatically created item I need to create a production order.

Thanks for the support,

Florin

Read only

0 Likes
1,633

Hi

I don't know if it's possible to set the system in order to create a production order automatically, but if you want to use your solution I'll do:

- Create a function module to run in update task in the user-exit in VA01

- In this function module I schedule the job for the program to create the Production Order and then to change it, but I place a COMMIT WORK and WAIT between the call of BAPI and call of BDC

Max