‎2021 Jul 05 12:17 PM
Hello,
I am trying to use Commit in cursor so that everytime it updates the data into table but after first iteration of cursor , it is giving dump at fetch statement of cursor.
Can anyone help me with any solution, how to commit the changes on each iteration of cursor?
Thanks
‎2021 Jul 05 3:41 PM
So long as your not trying to change the contents of the table you have the cursor, you can use the alternate database connection. R/3* to update another table and commit to it.
E.g.
DELETE FROM demo_update CONNECTION R/3*my_service_conn.
INSERT demo_update CONNECTION R/3*my_service_conn
FROM @( VALUE #( id = 'X' col1 = 1 col2 = 2 col3 = 3 col4 = 4 ) ).
COMMIT CONNECTION R/3*my_service_conn.
‎2021 Jul 05 3:41 PM
So long as your not trying to change the contents of the table you have the cursor, you can use the alternate database connection. R/3* to update another table and commit to it.
E.g.
DELETE FROM demo_update CONNECTION R/3*my_service_conn.
INSERT demo_update CONNECTION R/3*my_service_conn
FROM @( VALUE #( id = 'X' col1 = 1 col2 = 2 col3 = 3 col4 = 4 ) ).
COMMIT CONNECTION R/3*my_service_conn.
‎2021 Jul 05 9:59 PM
‎2021 Jul 05 5:06 PM
If you use OPEN CURSOR and CALL FUNCTION 'DB_COMMIT', use the addition "WITH HOLD". The database commit won't close the cursors. NB: COMMIT WORK always closes all opened cursors.
‎2021 Jul 05 9:38 PM
I tried that also by using DB_COMMIT in addition with hold but that also causing the same issue. Its not working ..
Have you tried it...if yes please give the example it will be very helpful
‎2021 Jul 06 5:23 AM
Yes, I tried, it works, it's explained in the ABAP documentation, answered also in all the same questions in the forum as yours...
DATA l_cursor TYPE cursor.
OPEN CURSOR WITH HOLD ... SELECT ... FROM dbtab1 ...
DO.
FETCH NEXT CURSOR ... INTO TABLE itab PACKAGE SIZE 1000.
IF sy-subrc <> 0.
EXIT.
ENDIF.
" itab processing
INSERT dbtab2 FROM TABLE itab.
CALL FUNCTION 'DB_COMMIT'.
ENDDO.
CLOSE CURSOR ...If such a simple example doesn't work in your system, there's a bug in the kernel, raise a ticket at SAP support.
‎2021 Jul 06 6:21 AM
Thank you for your support.
I also tried the same only by referring SAP forum but none seems to working thats why i raised the question.