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: 

Problem with BAPI_SALESORDER_CREATEFROMDAT2

Former Member
0 Kudos

Hi

How to Use the Bapi i.e BAPI_TRANSACTION_COMMIT with the

Following BAPI,i.e BAPI_SALESORDER_CREATEFROMDAT2.

While Executing the BAPI_SALESORDER_CREATEFROMDAT2 ,

it is creating the SalesOrders but i dont know where it is updating the tables. Can i know how to use

the BAPI_TRANSACTION_COMMIT?

Regards,

Kiran I

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Kiran,

After the execution of the BAPI, you have to look at the RETURN parameter to see if it has any error messages. You can do this as follows

READ TABLE return WITH KEY type = 'E'.

IF sy-subrc = 0.

*-- error occured

CALL FUNCTION BAPI_TRANSACTION_ROLLBACK.

ELSE.

*-- no error

CALL FUNCTION BAPI_TRANSACTION_COMMIT.

ENDIF.

The commit function will commit all the updates to the database. If you want to wait, you can use the wait parameter, which allows the program control to be returned to your program only after all the updates are made.

Srinivas

5 REPLIES 5

former_member181962
Active Contributor
0 Kudos

after you call the BAPI_SALESORDER_CREATEFROMDAT2 , you should check for the sy-subrc and if it is o,

then,

call the FM BAPI_TRANSACTION_COMMIT.

eg:

call function 'BAPI_SALESORDER_CREATEFROMDAT2'

exporting

.

.

.

tables

.

.

.

exceptions

.

..

.

.if sy-subrc = 0.

call function 'BAPI_TRANSACTION_COMMIT'.

endif.

This is a sample code.

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

EXPORTING

  • SALESDOCUMENTIN =

ORDER_HEADER_IN = I_SORDER_HEADER_IN

  • ORDER_HEADER_INX =

  • SENDER =

  • BINARY_RELATIONSHIPTYPE =

  • INT_NUMBER_ASSIGNMENT =

  • BEHAVE_WHEN_ERROR =

  • LOGIC_SWITCH =

  • TESTRUN =

  • CONVERT = ' '

IMPORTING

SALESDOCUMENT = W_SALESDOCUMENT

TABLES

RETURN = I_SRETURN

ORDER_ITEMS_IN = I_SORDER_ITEMS_IN

  • ORDER_ITEMS_INX =

ORDER_PARTNERS = I_SORDER_PARTNERS

ORDER_SCHEDULES_IN = I_SORDER_SCHEDULE_IN

  • ORDER_SCHEDULES_INX =

  • ORDER_CONDITIONS_IN =

  • ORDER_CFGS_REF =

  • ORDER_CFGS_INST =

  • ORDER_CFGS_PART_OF =

  • ORDER_CFGS_VALUE =

  • ORDER_CFGS_BLOB =

  • ORDER_CFGS_VK =

  • ORDER_CFGS_REFINST =

  • ORDER_CCARD =

  • ORDER_TEXT =

  • ORDER_KEYS =

  • EXTENSIONIN =

  • PARTNERADDRESSES =

.

CLEAR: OK_FLAG.

READ TABLE I_SRETURN WITH KEY TYPE = 'E'.

IF SY-SUBRC <> 0.

READ TABLE I_SRETURN WITH KEY TYPE = 'A'.

IF SY-SUBRC <> 0.

OK_FLAG = 'X'.

ELSE.

CLEAR: OK_FLAG.

ENDIF.

ELSE.

CLEAR: OK_FLAG.

ENDIF.

IF OK_FLAG = 'X'.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

IMPORTING

RETURN = I_CRETURN.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

  • LOOP AT i_sreturn

  • where type = 'E'

  • or type = 'A'.

*

  • ENDLOOP.

ENDIF.

Message was edited by: Ravi Kanth Talagana

Former Member
0 Kudos

Hi Kiran,

After the execution of the BAPI, you have to look at the RETURN parameter to see if it has any error messages. You can do this as follows

READ TABLE return WITH KEY type = 'E'.

IF sy-subrc = 0.

*-- error occured

CALL FUNCTION BAPI_TRANSACTION_ROLLBACK.

ELSE.

*-- no error

CALL FUNCTION BAPI_TRANSACTION_COMMIT.

ENDIF.

The commit function will commit all the updates to the database. If you want to wait, you can use the wait parameter, which allows the program control to be returned to your program only after all the updates are made.

Srinivas

0 Kudos

Hi Srinivas,

I dont have any Error Messages.

But it is(BAPI_SALESORDER_CREATEFROMDAT2) showing the Created Sales Order only.

Where can i get the Updated Table information and How to use the Bapi i.e. BAPI_TRANSACTION_COMMIT

Thanks & Regards

Kiran I

0 Kudos

If you don't have any errors, then all you need to do is call the function module BAPI_TRANSACTION_COMMIT. There are no parameters to this one except the WAIT parameter which you can set to 'X'.

To get the details back into the program, you may have to use BAPI GETDETAILS. I am not in front of the system, but if you search in SE37 for BAPISALESGET* you should find it.

Why do you want to get the details for the order that you just created?

Srinivas

0 Kudos

Hi Kiran,

Refer my earlier reply.And then check for the error messages returned from the bapi as fellow members suggested.

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

EXPORTING

  • SALESDOCUMENTIN =

ORDER_HEADER_IN =

  • ORDER_HEADER_INX =

  • SENDER =

  • BINARY_RELATIONSHIPTYPE =

  • INT_NUMBER_ASSIGNMENT =

  • BEHAVE_WHEN_ERROR =

  • LOGIC_SWITCH =

  • TESTRUN =

  • CONVERT = ' '

  • IMPORTING

  • SALESDOCUMENT =

TABLES

  • RETURN =

  • ORDER_ITEMS_IN =

  • ORDER_ITEMS_INX =

ORDER_PARTNERS =

  • ORDER_SCHEDULES_IN =

  • ORDER_SCHEDULES_INX =

  • ORDER_CONDITIONS_IN =

  • ORDER_CONDITIONS_INX =

  • ORDER_CFGS_REF =

  • ORDER_CFGS_INST =

  • ORDER_CFGS_PART_OF =

  • ORDER_CFGS_VALUE =

  • ORDER_CFGS_BLOB =

  • ORDER_CFGS_VK =

  • ORDER_CFGS_REFINST =

  • ORDER_CCARD =

  • ORDER_TEXT =

  • ORDER_KEYS =

  • EXTENSIONIN =

  • PARTNERADDRESSES =

.

READ TABLE return WITH KEY type = 'E'.

IF sy-subrc = 0.

*-- error occured

CALL FUNCTION BAPI_TRANSACTION_ROLLBACK.

ELSE.

*-- no error

CALL FUNCTION BAPI_TRANSACTION_COMMIT.

ENDIF.

Thanks,

Ravi