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

Prod Order confirmation using BAPI_PRODORDCONF_CREATE_TT batch created but after sometime

RatneshSisodiy1
Active Participant
0 Likes
3,297

Hi Experts,

Please note that I have already gone through many threads on SDN and did not find any solution to my problem.

I have list of production orders which I am confirming in LOOP ENDLOOP using BAPI BAPI_PRODORDCONF_CREATE_TT.

This functionality is working perfectly fine.

My problem is, when  BAPI_PRODORDCONF_CREATE_TT creates material documents and batch which are returned from parameter  goodsmovements. After BAPI_PRODORDCONF_CREATE_TT, I am calling  BAPI_TRANSACTION_COMMIT to commit the production order confirmation and then using goodsmovements-batch to create a transfer order using  L_TO_CREATE_SINGLE.

The issue is, I am getting error that 'Batch XXXX not created'. This means, before BAPI_PRODORDCONF_CREATE_TT commited into database I am trying to use the batch returned by BAPI_PRODORDCONF_CREATE_TT.

when I put WAIT UP TO 5 SECONDS, before using batch(into L_TO_CREATE_SINGLE), then everything work fine.

My question is, How can I make sure in my program, BAPI_PRODORDCONF_CREATE_TT material document creation(and hence batch creation) completes successfully before I use batch number(internally batch generated).

I already know that BAPI_PRODORDCONF_CREATE_TT is called as BACKGROUND TASK, so It takes time. but how to reduce this time. Please help me. Thank you in advance.

Regards,

Ratnesh

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,483

If you call BAPI_PRODORDCONF_CREATE_TT as BACKGROUND TASK, it will only be executed after commit of the main transaction.


If the creation of transfer order is also execute in the same RFC wrapper, then did you use the WAIT option of COMMIT WORK or parameter of BAPI_TRANSACTION_COMMIT. You could also try to LOCK (ENQUEUE FM) the production order with WAIT option in a small DO/ENDDO loop, then release it before calling the transfer, or even do a SELECT SINGLE [BYPASSING BUFFER]of batch record with a WAIT UP TO 1 second in a similar loop.


Regards,

Raymond

Hi Experts,

Please note that I have already gone through many threads on SDN and did not find any solution to my problem.

I have list of production orders which I am confirming in LOOP ENDLOOP using BAPI BAPI_PRODORDCONF_CREATE_TT.

This functionality is working perfectly fine.

My problem is, when  BAPI_PRODORDCONF_CREATE_TT creates material documents and batch which are returned from parameter  goodsmovements. After BAPI_PRODORDCONF_CREATE_TT, I am calling  BAPI_TRANSACTION_COMMIT to commit the production order confirmation and then using goodsmovements-batch to create a transfer order using  L_TO_CREATE_SINGLE.

The issue is, I am getting error that 'Batch XXXX not created'. This means, before BAPI_PRODORDCONF_CREATE_TT commited into database I am trying to use the batch returned by BAPI_PRODORDCONF_CREATE_TT.

when I put WAIT UP TO 5 SECONDS, before using batch(into L_TO_CREATE_SINGLE), then everything work fine.

My question is, How can I make sure in my program, BAPI_PRODORDCONF_CREATE_TT material document creation(and hence batch creation) completes successfully before I use batch number(internally batch generated).

I already know that BAPI_PRODORDCONF_CREATE_TT is called as BACKGROUND TASK, so It takes time. but how to reduce this time. Please help me. Thank you in advance.

Regards,

Ratnesh

5 REPLIES 5
Read only

RatneshSisodiy1
Active Participant
0 Likes
2,483

This message was moderated.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,484

If you call BAPI_PRODORDCONF_CREATE_TT as BACKGROUND TASK, it will only be executed after commit of the main transaction.


If the creation of transfer order is also execute in the same RFC wrapper, then did you use the WAIT option of COMMIT WORK or parameter of BAPI_TRANSACTION_COMMIT. You could also try to LOCK (ENQUEUE FM) the production order with WAIT option in a small DO/ENDDO loop, then release it before calling the transfer, or even do a SELECT SINGLE [BYPASSING BUFFER]of batch record with a WAIT UP TO 1 second in a similar loop.


Regards,

Raymond

Read only

0 Likes
2,483

"SELECT SINGLE[BYPASSING BUFFER]of batch record with a WAIT UP TO 1 second in a similar loop."



This approach works. Thanks for help.

Read only

0 Likes
2,483

Hello,

We have the same kind of issue with a specific transaction that:

     1 - Confirms a production order using BAPI_PRODORDCONF_CREATE_HDR

     2 - WAIT UP TO l_value SECONDS.

     3 - Then select the last goods movement from AUFM using prod order and mvt code 101.

SELECT  * FROM  aufm WHERE  matnr  = w_matnr  AND aufnr = t_order-aufnr AND bwart EQ '101'

            

The issue is that sometimes at step 3, the batch just confirmed is not available and the program chooses the previous batch confirmed.

Did you solve your issue adding BYPASSING BUFFER to you query? What should be my query to use this command?

Thanks for your help on this experience.

Read only

0 Likes
2,483

I was creating transfer orders after production order confirmation. So I used SELECT query (in endless loop) using BYPASS BUFFER on LQUA. ( Batch- LQUA-CHARG)

It worked.

Regards,

Ratnesh