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

Open cursor

Former Member
0 Likes
411

Help to simplify a code (it is necessary for BW-extraction)

It would be desirable to do without database table zdbasetable1

But the cursor is necessary

************************************************************************
* Data transfer: First Call      OPEN CURSOR + FETCH
*                Following Calls FETCH only
************************************************************************
* íà÷àëî îáðàáîòêè
 
* First data package -> OPEN CURSOR
    IF S_COUNTER_DATAPAKID = 0.
 
delete from zdbasetable1.
import inttable1 inttable2 inttable3 from database INDX(IM) ID 'IDENT'.
 
loop at inttable1.
  move-corresponding inttable1 to zdbasetable1.
  modify zdbasetable1.
  clear  zdbasetable1.
endloop.
 
      OPEN CURSOR WITH HOLD S_CURSOR FOR
      SELECT (S_S_IF-T_FIELDS) FROM zdbasetable1.
 
    ENDIF.                             "First data package ?
 
* Fetch records into interface table.
*   named E_T_'Name of extract structure'.
    FETCH NEXT CURSOR S_CURSOR
               APPENDING CORRESPONDING FIELDS
               OF TABLE inttablerezult
               PACKAGE SIZE S_S_IF-MAXSIZE.
 
    IF SY-SUBRC <> 0.
      CLOSE CURSOR S_CURSOR.
      RAISE NO_MORE_DATA.
    ENDIF.
 
    S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.
 
  ENDIF. 

2 REPLIES 2
Read only

former_member186741
Active Contributor
0 Likes
374

I think you have to continue using the custom table but can populate it a bit more efficiently....

data tzdb type table of zdbasetable1.

IF S_COUNTER_DATAPAKID = 0.

delete from zdbasetable1.

import inttable1 inttable2 inttable3 from database INDX(IM) ID 'IDENT'.

loop at inttable1.

move-corresponding inttable1 to zdbasetable1.

  • modify zdbasetable1.

  • clear zdbasetable1.

append zdbasetable1 to tzdb.

endloop.

insert zdbasetable1 from table tzdb.

Read only

0 Likes
374

of course, if the inttable1 is a table of 'zdbasetable1' you can do the insert direct from there without using the loop!