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: 

About BAPI_PRODORD_CREATE

pole_li
Active Participant
0 Kudos
3,810

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

8 REPLIES 8

Former Member
0 Kudos
463

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

former_member181995
Active Contributor
0 Kudos
463

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.

Former Member
0 Kudos
463

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

0 Kudos
463

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

Former Member
0 Kudos
463

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

0 Kudos
463

Hi, Naren

Thanks a lot for your suggestion.

Maybe we have to use BDC finally.

Regards

Pole

Former Member
0 Kudos
463

Hi,

Can you send me your code for my reference i also facing same issue...

0 Kudos
463

Hi,

Finally we use BDC to create production order.