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 AND WAIT.

kowong
Participant
0 Likes
2,514

Hi all,

May I know what is the usage of 'COMMIT WORK AND WAIT.

' ??

Thank you all...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,822

Hi Kokwei,

You have to use <b>BAPI_TRANSACTION_COMMIT</b> just after you have called the BAPI.

Consider this sample code.


CALL FUNCTION 'BAPI_QUOTATION_CREATEFROMDATA2'
  EXPORTING
    quotation_header_in     = it_quotation_header_in
    quotation_header_inx    = it_quotation_header_inx
    convert                 = 'X'
  IMPORTING
    salesdocument           = salesdocument
  TABLES
    return                  = ret_text1
    quotation_items_in      = it_quotation_items_in
    quotation_items_inx     = it_quotation_items_inx
    quotation_partners      = it_quotation_partners
    quotation_schedules_in  = it_quotation_schedules_in
    quotation_schedules_inx = it_quotation_schedules_inx.


IF sy-subrc = 0.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      wait   = 'X'
    IMPORTING
      return = ret_text2.
ENDIF.

<b>" After this step proceed with your further processing</b>

Regards,

Arun Sambargi.

Message was edited by: Arun Sambargi

11 REPLIES 11
Read only

former_member186741
Active Contributor
0 Likes
1,822

this statement will apply any outstanding database updates and wait until they have actually been put on the database before proceeding to the next statement.

An ordinary commit work will initiate the process to update the databases in a separate task and will press on in your abap.

So if the rest of your program does not rely on any of the database updates you don't need the 'and wait'.

Read only

Former Member
0 Likes
1,822

In standard ABAP reports, the use of this statement is not recommended without FULL knowledge of intent.

It violates SAP's Logical Unit of Work concept, which requires that a business transaction/LUW must run to completion BEFORE a database commit is performed.

Some BAPIs (for example) do require it's usage.

If you are in doubt, do not use it. Research the effects of an "early" DB update before the program completes it's processing.

Read only

ferry_lianto
Active Contributor
0 Likes
1,822

Hi,

Function modules that run in the update task can run synchronously or asynchronously. You determine this by the form of the COMMIT statement you use:

<b>COMMIT WORK AND WAIT</b>

This form specifies synchronous processing. The COMMITstatement waits for the end of processing. Control returns to your program after all high priority (V1) function modules have run successfully.

The AND WAIT form is convenient for switching old programs to synchronous processing without having to re-write the code. Functionally, using AND WAIT for update-task updates is just the same as dialog-task updates with PERFORM ON COMMIT.

<b>COMMIT WORK</b>

This is the standard form, which specifies asynchronous processing. Your program does not wait for the requested functions to finish processing.

Hope this will help.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
1,822

Hi,

'COMMIT WORK AND WAIT' is used when u want to do an update using Synchronous mode... means it will have to wait till the processing is complete then only it could move ahead whereas 'COMMIT WORK' is for asynchronous update mode...

Hope this would help u.

Seema.

Read only

Former Member
0 Likes
1,822

Hi,

COMMIT WORK AND WAIT: ( Synchronous processing ). The next line after this statement in the program will start executing only after getting the acknowledgement.

COMMIT WORK: ( Asynchronous)

Your program does not wait for any acknowledgement. it just start executing the next statment after COMMIT WORK.

Regs,

Venkat Ramanan

Read only

kowong
Participant
0 Likes
1,822

I use BAPI to do an account posting , and after that 'COMMIT WORK AND WAIT.' then only proceed to the next screen, but it seems doesnt work, when the process going too slow, the next screen came out faster than the document number of the posting was generated...

Read only

0 Likes
1,822

maybe try using fm BAPI_TRANSACTION_COMMIT.

Read only

Former Member
0 Likes
1,822

Hi kokwei,

1. I use BAPI to do an account posting

If the BAPI is an UPDATE Module (Update FM)

,

the data is updated in background, in a separate

process,

which is independent of the calling program.

2. Hence, WAIT concept will not work.

regards,

amit m.

Read only

Former Member
0 Likes
1,822

Hi,

After calling a BAPI, use COMMIT WORK and not COMMIT WORK and WAIT.

Regs,

Venkat Ramanan

Read only

Former Member
0 Likes
1,823

Hi Kokwei,

You have to use <b>BAPI_TRANSACTION_COMMIT</b> just after you have called the BAPI.

Consider this sample code.


CALL FUNCTION 'BAPI_QUOTATION_CREATEFROMDATA2'
  EXPORTING
    quotation_header_in     = it_quotation_header_in
    quotation_header_inx    = it_quotation_header_inx
    convert                 = 'X'
  IMPORTING
    salesdocument           = salesdocument
  TABLES
    return                  = ret_text1
    quotation_items_in      = it_quotation_items_in
    quotation_items_inx     = it_quotation_items_inx
    quotation_partners      = it_quotation_partners
    quotation_schedules_in  = it_quotation_schedules_in
    quotation_schedules_inx = it_quotation_schedules_inx.


IF sy-subrc = 0.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      wait   = 'X'
    IMPORTING
      return = ret_text2.
ENDIF.

<b>" After this step proceed with your further processing</b>

Regards,

Arun Sambargi.

Message was edited by: Arun Sambargi