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: 

COMMIT WORK with addition AND WAIT

sap_rocks
Participant
0 Kudos

Consider the following statement:

DATA(ls_mara) = VALUE mara( matnr = 'TEST_10000' ).
INSERT mara FROM ls_mara.
COMMIT WORK AND WAIT.

SELECT SINGLE FROM mara
  FIELDS *
  WHERE matnr EQ 'TEST_10000'
  INTO @DATA(ls_result).

[...]

We want to make sure - after the INSERT - that the record had been written to the db table and only after that want to proceed with the following statements. LS_RESULT shouldn't be empty after the SELECT.

- Would a COMMIT WORK be even necessary or would the INSERT be already enough?

- Is the AND WAIT addition of any use in this scenario? (no usage of UPDATE IN TASK, just plain procedual processing)

3 REPLIES 3

Sandra_Rossi
Active Contributor

If you do the INSERT and SELECT in the same DB LUW, you don't need to commit immediately. It must be done at the moment when all insert/updates are in a consistent state.

No need of AND WAIT. Even COMMIT WORK is excessive, because it does many more things than just a DB Commit (transactional/queue RFC, update task, etc.)

Just look at the ABAP documentation to understand what means COMMIT WORK.

matt
Active Contributor
0 Kudos

Off topic, but inserting directly into MARA? Why?

FredericGirod
Active Contributor
0 Kudos

faster than BAPI ...

😉