Wednesday, March 09, 2011

Internal Table Facts

Internal table with header line
   - With header line, the internal table has a header structure that works as a work area and a body that contains the details or the data itself.


  You may access the internal table with header line this way:

 1. itab1 = itab2 -> only the header will be copied
 2. itab1[] = itab2[] -> the body will be copied

With header line, the fields can be accessed directly without putting it to a new work area variable.

Ex.

loop at itab.
write:  itab-fld1.
,,,,,,,,
,,,,,,,,
,,,,,,,,
endloop.


whereas, without header line, you need to supply a work area as shown below:

loop at itab into wa.
write:/10 wa-fld1,
........
........
endloop.

It is better to use OCCURS 0 (obsolete) or initial zize 0 if you don't have a definite number of records to be inserted into your internal table to avoid waste of memory. OCCURS 0 allocates only memory per record being inserted while OCCURS 10 etc, will initially allocate 8kb * 10 memory space for the first page and a 2X of the first page will be allocated for the second page (as long as it is not exceeding 8kb) further pages will utilize 12kb.

Declaring table with occurs is superseded already by STANDARD TABLE, INDEXED etc declarations. This new style has no header thus you need to provide a work area to process your loop statement. This behaves the same as with occurs 0/initial size 0 in terms of memory allocation with 8kb as initial size.

1 comment:

Camellia Canan said...

I am expecting more interesting topics from you. And this was nice content and definitely it will be useful for many people.

SAP SD Training in Chennai | SAP Training in Chennai

Post a Comment