Skip to Content
0
Jun 01, 2010 at 12:31 PM

Commit work withour close all open database cursors

1207 Views

Dear all, I have following problem...

I do a open cursor and fetch... than after 100000 records I need to save some data in a other table with insert.

when I do the commit work it will close all open database cursors...and the fetch will dump.

Is there not a command or Function Module which only close the database cursor which I did the insert ?

Or a commit work without closing database cursor.

OPEN CURSOR DBCURSOR FOR
    SELECT * FROM Z1
       WHERE f1 EQ P_F1
      and        f2 eq P_F2
      ORDER BYf1 f2 f3.

  CLEAR DB_INDEX.

  DO.
    FETCH NEXT CURSOR DBCURSOR INTO WA1.

    IF SY-SUBRC EQ 0.
      IF DB_INDEX GE 100000.
        INSERT Z1 from it1.
**** commit work ****
       CLEAR DB_INDEX.
       refresh it1.
      ENDIF.
      ADD 1 TO DB_INDEX.
      APPEND WA1 TO IT1.
    ELSE.
      EXIT.
    ENDIF.
  ENDDO.

  CLOSE CURSOR DBCURSOR.