Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Fetch Next Cursor Short Dumps

Hello All,

I have the following code which short dumps after losing its cursor position.

OPEN CURSOR WITH HOLD dbcur FOR
      select * from ekpo where bukrs in s_bukrs2.

      do.
          FETCH NEXT CURSOR dbcur INTO table iekpo package size pkgsize.

          if sy-subrc <> 0.
             close cursor dbcur.
             exit.
          else.
              perform ouput_to_text_file.
              refresh: iekpo.
           endif.
      enddo.

I have millions of records to be extracted and simple select to an internal table causes memory problems. Thus I need to extract a chunk of records write them to a text file, then get the next chunk.

Any suggestions?

Thank you,

Jerry

Tags:
replied

GUI Download probably causes problem, writing to a dataset on app server might not cause the problem, maybe you want to try.

Regarding the select, here is some pseudo code outlining what I mean:

clear wa_ekpo.
do.
  select * from ekpo into table lt_ekpo up to 10,000 rows 
      where ebeln > wa_ekpo-ebeln or ( ebeln = wa_ekpo-ebeln and ebelp > wa_ekpo-ebelp )
      order by primary key.
  if sy-subrc ne 0.
    exit.
  endif.
  download lt_ekpo (appending to existing file)
  l_lines = lines( lt_ekpo ).
  read table lt_ekpo into wa_ekpo index l_lines.
enddo.

Will run for a while, but should not dump out

Thomas

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question