ABAP – ITAB and CLEAR vs REFRESH vs FREE

SAPI experienced lot of confusion when I faced internal tables with header lines during my professional life. Therefore I strongly advice NOT to use internal tables with header lines. But they are heavily used in older programs so it’s good to know what is the difference between how to clear the header line and how to clear the itab contents and how it is different from internal tables WITHOUT header line.

We will have two cases:

  • Case ADATA: lt_itab TYPE STANDARD TABLE OF something.
  • Case BDATA: lt_itab TYPE something OCCURS 0 WITH HEADER LINE.
Case Initialize table contents Operating on work area/structure Operating on table contents Release table header memory space Release table contents memory space
CLEAR A CLEAR lt_itab N/A CLEAR lt_itab N/A N/A
B CLEAR lt_itab[] CLEAR lt_itab CLEAR lt_itab[] N/A N/A
REFRESH A REFRESH lt_itab N/A REFRESH lt_itab N/A N/A
B REFRESH lt_itab N/A REFRESH lt_itab N/A N/A
FREE A FREE lt_itab N/A FREE lt_itab  N/A FREE lt_itab
B FREE lt_itab N/A FREE lt_itab N/A FREE lt_itab

 

Leave a Reply