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

Commit Work

former_member188001
Active Participant
0 Likes
668

Hello all,

What is the difference between Commit Work and using BAPI_TRANSACTION_COMMIT. when should we use each of these.

Regards,

Salil

4 REPLIES 4
Read only

Former Member
0 Likes
600

Hi ,

If you see the code of the BAPI_TRANSACTION_COMMIT


IF WAIT EQ SPACE.
  COMMIT WORK.
ELSE.
  COMMIT WORK AND WAIT.
  IF SY-SUBRC NE 0.
    CALL FUNCTION 'BALW_BAPIRETURN_GET2'
         EXPORTING
              TYPE       = 'E'
              CL         = 'S&'
              NUMBER     = '150'
         IMPORTING
              RETURN     = RETURN.
  ENDIF.
ENDIF.
CALL FUNCTION 'BUFFER_REFRESH_ALL'.
ENDFUNCTION.

COMMIT WORK IS INTERNALLY USED.

It further provides BAPIRET2 structure as output ,waits and refresh.

So it is always better to use this while using the BAPI.

And there is a rule that..Dont ever write Commit work inside the bapi call.Always use this function after the completion of the BAPI.

When you call BAPIs in your program that change data in the R/3 System,afterwards you must call this method to write the changes to the database.

commit work

Executes a database commit and thus closes a Logical Unit of Work

All database updates are made irrevocable and cannot be reversed with ROLLBACK WORK

All database locks are released.

Thank you...

Read only

Former Member
0 Likes
600

hi check this...

As of Release 4.0 BAPIs must not execute 'COMMIT WORK' commands. Because The caller should have control of the transaction. Several BAPIs should be able to be combined within one LUW.

The BAPI's created with new guidelines will not have COMMIT WORK or

ROLLBACK Statement in it. Based on the Failure/Success of the BAPI we have to explicitly call BAPI_TRANSACTION_ROLLBACK and BAPI_TRANSACTION_COMMIT which will have

ROLLBACK WORK or COMMIT WORK Respectively in it.

Commit work is used when you code directly in ABAP and make changes in the database and

want to commit the database.

BAPI_TRANSACTION_COMMIT is used when you make changes to the SAP database by calling

a BAPI from outside SAP and want to commit the database. When you use a BAPI, you can not

directly use commit work, instead you are allowed to use only

BAPI_TRANSACTION_COMMIT.

Read only

Former Member
0 Likes
600

Both are same except the message handling.

(WAIT we can use with COMMIT WORK) ,

COMMIT WORK we have to manually handle the sy-subrc check.

But in that function BAPI_TRANSACTION_COMMIT it is handled.

Read only

former_member188001
Active Participant
0 Likes
600

Hi all,

The question is closed. I looked at coupel of standard documents to clarify this.