Skip to Content
avatar image
Former Member

Want to commit 1000 records at a time in one go using BAPI_TRANSACTION_COMMIT

Hi All,

Please let me know the solution of "Want to commit 1000 records at a time in one go using BAPI_TRANSACTION_COMMIT"

Thanks in advance.

Kirti Bansal.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Oct 21, 2015 at 03:20 PM

    Right now your code might look something like:

    LOOP AT ITAB.
         CALL FUNCTION 'BAPI'.
    ENDLOOP.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.   
        
    
    

    or

    LOOP AT ITAB.
         CALL FUNCTION 'BAPI'.
         CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.   
    ENDLOOP.
    

    Change this to:

    CONSTANTS: RECORDS_PER_COMMIT TYPE I VALUE 1000.
    DATA: DONE TYPE I.
    LOOP AT ITAB.
         AT LAST.
             DONE = RECORDS_PER_COMMIT.
         ENDAT.
         CALL FUNCTION 'BAPI'.
         ADD 1 TO DONE.
         IF ( DONE GE RECORDS_PER_COMMIT ).
              CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
              DONE = 0.
         ENDIF.
    ENDLOOP.
    
    

    Make sure there is no chance to exit possible in the LOOP otherwise you might end up with the last few transactions not being committed.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 21, 2015 at 01:07 PM

    You can just maintain a counter with the entries to created by a BAPI FM and whenever MOD 1000 EQ 0, call the BAPI_TRANSACTION_COMMIT FM.

    Add comment
    10|10000 characters needed characters exceeded