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

BAPI_SALESORDER_CREATEFROMDAT2

Former Member
0 Likes
1,005

Hi Experts,

I met a problem about Function 'BAPI_SALESORDER_CREATEFROMDAT2'.

The same input parameters, if I use this function in a report , that's ok, A new sales order is created.But if I use this function is a custom-function( eg, 'ZORDER_CREATE), the return messages of BAPI_SALESORDER_CREATEFROMDAT2 are successfully.At this time, I use t-code 'VA02' to display this generated order.occurs a error message 'SD document 18180 is not in the database or has been archived'

Who can you tell me why happen this scenarios?

Thanks

Kelvin

6 REPLIES 6
Read only

Former Member
0 Likes
786

Try to execute the function module BAPI_TRANSACTION_COMMIT after you executed the BAPI_SALESORDER_CREATEFROMDAT2. After executing the BAPI_SALESORDER_CREATEFROMDAT2 a commit must be given.

Read only

Former Member
0 Likes
786

HI ,

i think COMMIT work is missing from ur program .

it should be like this .

Call 'BAPI'.

if return[] is initial.

commit work.

endif.

regards

prabhu

Read only

Former Member
0 Likes
786

The Problem is related to commit .

Try calling BAPI_transaction_commit after the function in your custome function.

Please reward if useful.

Read only

Former Member
0 Likes
786

Thanks.

Ater I executed the BAPI_SALESORDER_CREATEFROMDAT2,To execute the function module BAPI_TRANSACTION_COMMIT looks well. Please see my coding below:

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

EXPORTING

ORDER_HEADER_IN = W_HEAD

IMPORTING

SALESDOCUMENT = ZONC_ORDER_NUMBER

TABLES

RETURN = T_RETURN

ORDER_ITEMS_IN = T_LINE

ORDER_ITEMS_INX = T_LINEX

ORDER_PARTNERS = T_PARTNER

ORDER_CONDITIONS_IN = T_COND

ORDER_CONDITIONS_INX = T_CONDX

ORDER_CCARD = T_CCARD

ORDER_TEXT = T_TEXT

EXTENSIONIN = T_EXTEN.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

      • Why this select can't be implement(I need use related data).How to implement below function?

SELECT SINGLE *

INTO CORRESPONDING FIELDS OF LW_VBAK

FROM VBAK

WHERE VBELN = ZONC_ORDER_NUMBER

Read only

0 Likes
786

Hello Kevin,

Your code looks perfect. Looks like the Sales order not yet saved immediatey to the database. So after commit bapi use a wait statement for 3 seconds and check your results. It will work fine.

Hope this answers your question.

Thanks,

Greetson

Read only

0 Likes
786

Hello Kevin,

maybe you can solve your problem if you use the export parameter WAIT in FM BAPI_TRANSACTION_COMMIT (see coding below). This parameter causes that the FM realy waits until the commit is successfully done. In this case the word area return is empty.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'

IMPORTING

return = wa_return2.

Hope this helps.

Kind regards

Rolf