‎2007 Jun 09 3:17 PM
hi experts,
what is difference between internal table with or without headerline.when can we use with or without headerlines.i heared with header line decreses the performance .how it is?explaine me in brief
thanks in advance.
‎2007 Jun 09 4:14 PM
Hi,
<u><b>INTERNAL TABLE</b></u>
Internal tables provide a means of taking data from a fixed structure and storing it in working memory in ABAP. The data is stored line by line in memory, and each line has the same structure. In ABAP, internal tables fulfill the function of arrays. Since they are dynamic data objects, they save the programmer the task of dynamic memory management in his or her programs.
<b>If we r working with ABAP OBJECT(oops), it doesn't support internal table creation with headerline</b>
<b>if we can create internal table with header line then internal table created with explict work area. header line having the same name of internal table.
if we can create internal table without header line then internal table created with out explict work area. for proecssing internal table we must create workarea.
or by using fieldsymbols to processing.</b>
When you create an internal table object you can also declare a header line with the same name. You can use the header line as a work area when you process the internal table. The ABAP statements that you use with internal tables have short forms that you can use if your internal table has a header line. These statements automatically assume the header line as an implicit work area. The following table shows the statements that you must use for internal tables without a header line, and the equivalent statements that you can use for internal tables with a header line:
<b>Operations without header line</b> <b>Operations with header line</b>
Operations for all Table Types
INSERT <wa> INTO TABLE <itab>. INSERT TABLE ITAB.
COLLECT <wa> INTO <itab>. COLLECT <itab>.
READ TABLE <itab> ... INTO <wa>. READ TABLE <itab> ...
MODIFY TABLE <itab> FROM <wa> ... MODIFY TABLE <itab> ...
MODIFY <itab> FROM <wa> ...WHERE ... MODIFY <itab> ... WHERE ...
DELETE TABLE <itab> FROM <wa>. DELETE TABLE <itab>.
LOOP AT ITAB INTO <wa> ... LOOP AT ITAB ...
Operations for Index Tables
APPEND <wa> TO <itab>. APPEND <itab>.
INSERT <wa> INTO <itab> ... INSERT <itab> ...
MODIFY <itab> FROM <wa> ... MODIFY <itab> ...
Using the header line as a work area means that you can use shorter statements; however, they are not necessarily easier to understand, since you cannot immediately recognize the origin and target of the assignment. Furthermore, the fact that the table and its header line have the same name can cause confusion in operations with entire internal tables. To avoid confusion, you should use internal tables with differently-named work areas.
Example
The following example shows two programs with the same function. One uses a header line, the other does not.
With header line:
TYPES: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA ITAB TYPE HASHED TABLE OF LINE WITH UNIQUE KEY COL1
WITH HEADER LINE.
DO 4 TIMES.
ITAB-COL1 = SY-INDEX.
ITAB-COL2 = SY-INDEX ** 2.
INSERT TABLE ITAB.
ENDDO.
ITAB-COL1 = 2.
READ TABLE ITAB FROM ITAB.
ITAB-COL2 = 100.
MODIFY TABLE ITAB.
ITAB-COL1 = 4.
DELETE TABLE ITAB.
LOOP AT ITAB.
WRITE: / ITAB-COL1, ITAB-COL2.
ENDLOOP.
Without header line:
TYPES: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA: ITAB TYPE HASHED TABLE OF LINE WITH UNIQUE KEY COL1,
WA LIKE LINE OF ITAB.
DO 4 TIMES.
WA-COL1 = SY-INDEX.
WA-COL2 = SY-INDEX ** 2.
INSERT WA INTO TABLE ITAB.
ENDDO.
WA-COL1 = 2.
READ TABLE ITAB FROM WA INTO WA.
WA-COL2 = 100.
MODIFY TABLE ITAB FROM WA.
WA-COL1 = 4.
DELETE TABLE ITAB FROM WA.
LOOP AT ITAB INTO WA.
WRITE: / WA-COL1, WA-COL2.
ENDLOOP.
The list, in both cases, appears as follows:
1 1
2 100
3 9
The statements in the program that does not use a header line are easier to understand. As a further measure, you could have a further work area just to specify the key of the internal table, but to which no other values from the table are assigned.
<b>follow this link for more information.</b>
http://www.erpgenie.com/abaptips/content/view/104/62/
regards,
Ashokreddy.
Message was edited by:
Ashok Reddy
‎2007 Jun 09 3:21 PM
Hi
If u want to process some action in internal table then u should use headerline. if u do in internal table body, it will take lot of time.
So u have to create a internal table with header line or else u can create a workarea for the same.
Regards
ravi
‎2007 Jun 09 3:30 PM
Hello ,
<b>Internal table with header line</b>
when you use internal table with header line ,data will be both header and body,so you can able to perform ,when internal table has header ,then it is performance issue,since header line takes more memory.
<b>Internal table without header line</b>
Here internal table does not have header ,you need decalre one work area,move the data from internal table body one recored to work area.
work area does not contain any memory,
‎2007 Jun 09 3:53 PM
See the both internal table with header line and without header line :
Internal table with header line
here i am using get time field command ,so use both program and see comparision time
report zxyz.
Internal table with header line.
DATA:BEGIN OF itab OCCURS 0,
lifnr LIKE lfa1-lifnr,
name1 LIKE lfa1-name1,
END OF itab.
data : f1 type i,
f2 type i,
f3 type i.
start-of-selection.
get run time field f1.
SELECT lifnr name1 FROM lfa1 INTO TABLE itab up to 200 rows.
loop at itab.
endloop.
get run time field f2.
f3 = f2 - f1 .
write 😕 'Time taken by query in Micro seconds', f3.
Internal table without header line
report zxyz1.
Internal table without header line.
types : begin of ty_itab ,
lifnr LIKE lfa1-lifnr,
name1 LIKE lfa1-name1,
end of ty_itab.
data itab type standard table of ty_itab.
data wa_itab like line of itab.
data : f1 type i,
f2 type i,
f3 type i.
start-of-selection.
get run time field f1.
SELECT lifnr name1 FROM lfa1 INTO TABLE itab up to 200 rows.
loop at itab into wa_itab.
endloop.
get run time field f2.
f3 = f2 - f1 .
write 😕 'Time taken by query in Micro seconds', f3.
i have given answer to other thread about when to use or not
Reward Points if it is helpful
Thanks
Seshu
‎2007 Jun 09 4:14 PM
Hi,
<u><b>INTERNAL TABLE</b></u>
Internal tables provide a means of taking data from a fixed structure and storing it in working memory in ABAP. The data is stored line by line in memory, and each line has the same structure. In ABAP, internal tables fulfill the function of arrays. Since they are dynamic data objects, they save the programmer the task of dynamic memory management in his or her programs.
<b>If we r working with ABAP OBJECT(oops), it doesn't support internal table creation with headerline</b>
<b>if we can create internal table with header line then internal table created with explict work area. header line having the same name of internal table.
if we can create internal table without header line then internal table created with out explict work area. for proecssing internal table we must create workarea.
or by using fieldsymbols to processing.</b>
When you create an internal table object you can also declare a header line with the same name. You can use the header line as a work area when you process the internal table. The ABAP statements that you use with internal tables have short forms that you can use if your internal table has a header line. These statements automatically assume the header line as an implicit work area. The following table shows the statements that you must use for internal tables without a header line, and the equivalent statements that you can use for internal tables with a header line:
<b>Operations without header line</b> <b>Operations with header line</b>
Operations for all Table Types
INSERT <wa> INTO TABLE <itab>. INSERT TABLE ITAB.
COLLECT <wa> INTO <itab>. COLLECT <itab>.
READ TABLE <itab> ... INTO <wa>. READ TABLE <itab> ...
MODIFY TABLE <itab> FROM <wa> ... MODIFY TABLE <itab> ...
MODIFY <itab> FROM <wa> ...WHERE ... MODIFY <itab> ... WHERE ...
DELETE TABLE <itab> FROM <wa>. DELETE TABLE <itab>.
LOOP AT ITAB INTO <wa> ... LOOP AT ITAB ...
Operations for Index Tables
APPEND <wa> TO <itab>. APPEND <itab>.
INSERT <wa> INTO <itab> ... INSERT <itab> ...
MODIFY <itab> FROM <wa> ... MODIFY <itab> ...
Using the header line as a work area means that you can use shorter statements; however, they are not necessarily easier to understand, since you cannot immediately recognize the origin and target of the assignment. Furthermore, the fact that the table and its header line have the same name can cause confusion in operations with entire internal tables. To avoid confusion, you should use internal tables with differently-named work areas.
Example
The following example shows two programs with the same function. One uses a header line, the other does not.
With header line:
TYPES: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA ITAB TYPE HASHED TABLE OF LINE WITH UNIQUE KEY COL1
WITH HEADER LINE.
DO 4 TIMES.
ITAB-COL1 = SY-INDEX.
ITAB-COL2 = SY-INDEX ** 2.
INSERT TABLE ITAB.
ENDDO.
ITAB-COL1 = 2.
READ TABLE ITAB FROM ITAB.
ITAB-COL2 = 100.
MODIFY TABLE ITAB.
ITAB-COL1 = 4.
DELETE TABLE ITAB.
LOOP AT ITAB.
WRITE: / ITAB-COL1, ITAB-COL2.
ENDLOOP.
Without header line:
TYPES: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA: ITAB TYPE HASHED TABLE OF LINE WITH UNIQUE KEY COL1,
WA LIKE LINE OF ITAB.
DO 4 TIMES.
WA-COL1 = SY-INDEX.
WA-COL2 = SY-INDEX ** 2.
INSERT WA INTO TABLE ITAB.
ENDDO.
WA-COL1 = 2.
READ TABLE ITAB FROM WA INTO WA.
WA-COL2 = 100.
MODIFY TABLE ITAB FROM WA.
WA-COL1 = 4.
DELETE TABLE ITAB FROM WA.
LOOP AT ITAB INTO WA.
WRITE: / WA-COL1, WA-COL2.
ENDLOOP.
The list, in both cases, appears as follows:
1 1
2 100
3 9
The statements in the program that does not use a header line are easier to understand. As a further measure, you could have a further work area just to specify the key of the internal table, but to which no other values from the table are assigned.
<b>follow this link for more information.</b>
http://www.erpgenie.com/abaptips/content/view/104/62/
regards,
Ashokreddy.
Message was edited by:
Ashok Reddy