‎2008 Dec 12 9:17 AM
Hi All,
We use BAPI_PRODORD_CREATE to create production order,
and use BAPI_PRODORD_SCHEDULE to update SCHED_TYPE of the order right after it's created.
the problem is : BAPI_PRODORD_CREATE submit the transaction to system but the order is not
created immediatly, the document of this BAPI said that "The method independently triggers the update to the database. After the method has been called you must not execute a COMMIT WORK again.", so when we call BAPI_PRODORD_SCHEDULE , occasionally the order is not created yet,
now we use FMCT_WAIT_FOR_UPDATE between the two bapis(We think it's not a good solution because we don't know how long the system will need to create the order), Does anyone know if there is better solution? thanks very much.
Pole
‎2008 Dec 12 7:25 PM
Hi
You ca ncreate two programs for this:
In the First you can use BAPI :BAPI_PRODORD_CREATE
and FMCT_WAIT_FOR_UPDATE and the same program you can schedule a Job for another program
which will be using the BAPI to update the schedule type .
Just a suggestion
Neha
‎2008 Dec 12 7:32 PM
Check the Application server Time(SYUZEIT) right Before calling BAPI_PRODORD_CREATE and store this in some temp variable.
And Again Check the Application server time right After BAPI_PRODORD_CREATE or Commit Work with SYUZEIT and store in Temp2 variable ,Just evaluate the time difference between two variable and Give This Time Difference to FMCT_WAIT_FOR_UPDATE.
‎2008 Dec 12 7:43 PM
Hi,
Okay...Try this..
instead of calling the BAPI BAPI_PRODORD_CREATE ..call the function module COXT_BAPI_ORDER_CREATE directly...this is the FM used inside the BAPI..
Now to this function module COXT_BAPI_ORDER_CREATE...there is a parameter...IV_COMMIT...pass it as blank...
After the function module is executed...
Give COMMIT WORK AND WAIT. This will wait for the database updates to be done..
Then call the second BAPI...
Hope this works..
Thanks
Naren
‎2008 Dec 15 1:39 AM
Hi Naren,
Thanks for your reply.
But in our system(Ecc5.0), there are only two import parameters :IS_HEADER and I_ORDER_CATEGORY, No IV_COMMIT.
Maybe you have newer system.
Regards,
Pole
‎2008 Dec 15 4:59 PM
Hi,
oh..I am in ECC 6.0...looks like the parameter was added part of ECC 6.0..
Ok...another suggestion..
create a infinite loop...and check for the existence of the record in the table production order table AUFK/AFKO..
Ex..
If the return table is not having any error / abort message....do the following..
DO.
SELECT SINGLE * FROM AFKO
WHERE AUFNR = 'Production order number'. " Which you got it from BAPI
IF sy-subrc NE 0.
CONTINUE.
WAIT UP TO 10 1 SECONDS. " Wait for 1 second.
ENDIF.
ENDDO.
***We have to be careful about the infinite loop as if there is a update termination...Then this loop will never end..
***Also check in your system..whether COXT_BAPI_ORDER_CREATE is doing commit work AND WAIT or just commit work..
***If it is just commit work...Then inside the DO loop add a condition..that if it is more than 30 seconds then exit the loop...as there might be some problem in the updates..
Hope this helps.
Thanks
Naren
‎2008 Dec 19 8:59 AM
Hi, Naren
Thanks a lot for your suggestion.
Maybe we have to use BDC finally.
Regards
Pole
‎2013 Feb 28 12:57 PM
Hi,
Can you send me your code for my reference i also facing same issue...
‎2013 Mar 01 3:50 AM