12-27-2013 6:54 PM
Hi Experts,
A hopefully simple ABAP question: I have a very large internal abap table of line type AA which shall be append to another internal table of line type BB.
Curret implementation is pretty straightforeward:
LOOP AT AA ASSINGING <FA>.
MOVE-CORRESPONDING <FA> TO <FB>.
APPEND <FB> TO BB.
ENDLOOP.
FREE AA.
Issue: AA is a very very big table (> 1.000.000 entries, with a pretty big column size). The table needs ~1.5GB RAM. When using the way above for a very short time ~3GB RAM will be required (which will finally put the process into private mode, causing big performance problems).
Sadly I do not know any way to free the memory of an internal table partially. I've tried to do the following code snipped (which does not work, because DELETE does not free memory).
WHILE AA[] IS NOT INITIAL.
READ TABLE aa assinging <fa> INDEX 1.
MOVE-CORRESPONDING <FA> TO <fB>.
APPEND <FB> TO BB.
DELETE aa INDEX 1.
ENDWHILE.
As I said, this does not work, because DELETE does not shrink the memory extension of a table.
Do you know ANY way to complete the described use case, without having the table two times in RAM?
REgards,
Timo
12-28-2013 12:06 AM
Hi Timo,
Good one
How the AA table is filled at the first place?
If possible what about splitting the AA data into smaller tables (AA1, .., AAn) and then processing & freeing them one by one ?
Br,
Manu.
12-28-2013 12:06 AM
Hi Timo,
Good one
How the AA table is filled at the first place?
If possible what about splitting the AA data into smaller tables (AA1, .., AAn) and then processing & freeing them one by one ?
Br,
Manu.
12-28-2013 3:29 AM
Hello Manu D'Haeyer.
If internal tables AA and BB have their fields declared in same order, then
BB[] = AA[].
REFRESH: AA.
Regards.
12-28-2013 8:52 PM
This will double the memory exhaust directly after BB[] = AA[]. Of course the memory is directly cleared again afterwards - nevertheless for very big tables this can cause the process going into private mode.
12-28-2013 4:39 AM
If your AA and BB internal table have same structure, then you can directly use:
Append lines of AA to BB.
Vivek
12-28-2013 8:52 PM
This will double the memory exhaust directly after BB[] = AA[]. Of course the memory is directly cleared again afterwards - nevertheless for very big tables this can cause the process going into private mode.
12-28-2013 5:43 AM
Hi Timo Stark
Accounting to Manu D'Haeyer, here is how you restrict data from database. for example
(note* Please notice the headline contents)
REPORT z_test.
TABLES: mseg, mara, vbap.
TYPES: BEGIN OF s_matnr,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
matnr LIKE mseg-matnr,
menge LIKE mseg-menge,
END OF s_matnr,
DATA: it_mseg TYPE TABLE OF mseg WITH HEADER LINE,
it_matnr TYPE TABLE OF s_matnr WITH HEADER LINE.
START-OF-SELECTION.
SELECT *
FROM mseg
INTO TABLE it_mseg PACKAGE SIZE 50.
LOOP AT it_mseg.
MOVE-CORRESPONDING it_mseg TO it_matnr.
SELECT SINGLE vp~vbeln vp~posnr
FROM vbap AS vp INNER JOIN aufk AS ak ON vp~vbeln = ak~kdauf
AND vp~posnr = ak~kdpos
INNER JOIN mseg AS ms ON ms~aufnr = ak~aufnr
INTO ( it_matnr-vbeln it_matnr-posnr )
WHERE ms~aufnr = it_mseg-aufnr.
COLLECT it_matnr.
ENDLOOP.
ENDSELECT.
12-28-2013 6:25 AM
12-28-2013 6:59 AM
I think, Timo Stark is using the 'classical' way to get data, otherwise, it is impossible to cost that mush RAM.
12-28-2013 8:51 PM
Hi,
I'm importing the data from a cluster table (IMPORT..), therefore i can not simply "chunk" the data of AA. Generally I can of course "chunk"/split the clusters in the DB, but
I really hoped that ABAP has any instruction to shrink the table memory exhaust to the value actually used.
Nevermind - Thank you very much for your help - especially for the PACKAGE SIZE instruction which I've never heard about before 🙂
Regards,
Timo
12-29-2013 2:58 AM
Timo,
The PACKAGE SIZE addition is of no use in your case since you are doing an IMPORT not SELECT to fill the internal table.
Have you tried using LOOP AT itab with FROM idx addition? Basically its the same idea as the PACKAGE SIZE addition to a SELECT i.e. to do the processing in chunks rather than the entire table content.
In a loop, fill internal table BB say 5,000 rows at a time (using the FROM addition) -> In the same loop, do your all your business logic processing then FREE BB at the end of every 5000th iteration.
Hope this helps.
Sougata.