Skip to Content
0
Former Member
Jan 07, 2009 at 02:48 PM

Select up to n rows inside a loop - Good idea?

944 Views

Hi. I have to create some kind of 'backup' of the BSEG table, but as you know, the table is huge. A simple select ends the program in a 'TSV_TNEW_PAGE_ALLOC_FAILED' error, i.e. No memory space is available for the it_bseg table.

   select bukrs
          belnr
          gjahr
          buzei
          hkont
          zumsk
          kunnr
          lifnr
          dmbtr
          wrbtr
          zuonr
          sgtxt
          mwsts
          wmwst
          hwbas
          fwbas
          augbl
          augcp
          augdt
          mwskz
          qsskz
          vbeln
       into corresponding fields of table it_bseg
       from bseg
       for all entries in git_bkpf
       where bukrs = git_bkpf-bukrs and
             belnr = git_bkpf-belnr and
             gjahr = git_bkpf-gjahr and
             buzei in rg_dummy_buzei.

yes, I know the FAE is not the best way, but creating a RANGES does not work either...

I was thinking in the following algorithm, but I do not know if it could be a viable solution and if it is possible to use some kind of 'cursor' to select by blocks, so I do not repeat selections.

loop i times.
  select ...
    into corresponding fields of table it_bseg
    from bseg
    up to n rows
    for all entries in git_bkpf
    where bukrs = git_bkpf-bukrs and
              belnr = git_bkpf-belnr and
              gjahr = git_bkpf-gjahr and
              buzei = rg_dummy_buzei.

    perform process_info tables it_bseg.
    clear it_bseg.
endloop.

Do you think this would help? if it can, how do I select the lines starting from a given row, so I avoid reading the same lines again?

If you think is not an interesting solution, then the question would be: How can I read the whole BSEG table and do not eat up so much memory? Any idea?

Thanks a lot in advance.