Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

without header line

Former Member
0 Likes
2,424

what is the advantage in using without header line internal table with with header line. explain me with code.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,870

Hi

Apart from the internal table, this addition, which is not allowed in classes, declares another data object, the header line, which has exactly the same name as the internal table and has the row type of the internal table as the data type.

If at an operand position of an ABAP statement, you specify the name of internal table itab, it depends on the statement whether the table body or the header line are used. As a rule, all table-specific statements such as SORT or LOOP use the internal table, while all other statements use the header line. Exceptions are - among others - the statements IMPORT andEXPORT.

To address the table body instead of the header line in a statement, you can append [] to the name (or a field symbol or dereferenced data reference):

... itab[] ...

For internal tables without header line, the table body is always used. An internal table with a header line can not be a component of a structure or a row of another internal table.

These statements for processing individual table rows have short forms that implicitly use the header line as work area. These short forms are allowed only outside of ABAP Objects.

reward if u find useful

so that u can get more response

6 REPLIES 6
Read only

Former Member
0 Likes
1,870

HI,

without header line is better performance wise.

and with header line concept is not supported by the OOPS concept.

rgds,

bharat.

Read only

Former Member
0 Likes
1,870

at any point of time use internal table without header line,it will be good performance as well OO ABAP will allow only internal table without header line.

Just use one simple example :

create one simple program with header line,use get run time field.

create one simple program without header line,use get run time field.

see the results ,here time will be micro seconds,so take 1000 records to internal table and do calculate the time.

***********************************

While adding or retrieving records to / from internal table we have to keep the record temporarily.

The area where this record is kept is called as work area for the internal table. The area must have the same structure as that of internal table. An internal table consists of a body and an optional header line.

Header line is a implicit work area for the internal table. It depends on how the internal table is declared that the itab will have the header line or not.

e.g.

data: begin of itab occurs 10,

ab type c,

cd type i,

end of itab. " this table will have the header line.

data: wa_itab like itab. " explicit work area for itab

data: itab1 like itab occurs 10. " table is without header line.

The header line is a field string with the same structure as a row of the body, but it can only hold a single row.

It is a buffer used to hold each record before it is added or each record as it is retrieved from the internal table. It is the default work area for the internal table.

<b>PLEASE REWARD POINTS IF USEFUL TO U...!!!</b>

Read only

Former Member
0 Likes
1,871

Hi

Apart from the internal table, this addition, which is not allowed in classes, declares another data object, the header line, which has exactly the same name as the internal table and has the row type of the internal table as the data type.

If at an operand position of an ABAP statement, you specify the name of internal table itab, it depends on the statement whether the table body or the header line are used. As a rule, all table-specific statements such as SORT or LOOP use the internal table, while all other statements use the header line. Exceptions are - among others - the statements IMPORT andEXPORT.

To address the table body instead of the header line in a statement, you can append [] to the name (or a field symbol or dereferenced data reference):

... itab[] ...

For internal tables without header line, the table body is always used. An internal table with a header line can not be a component of a structure or a row of another internal table.

These statements for processing individual table rows have short forms that implicitly use the header line as work area. These short forms are allowed only outside of ABAP Objects.

reward if u find useful

so that u can get more response

Read only

Former Member
0 Likes
1,870

Hi,

In with out header line,

You declare header line & body separately like

data: IT_MARA type standard table of MARA,

WA_MARA like line of IT_MARA.

Advantages:

1. Clear differentiation of header line over body

2. It is must in the ABAP Objects to have separate header line & body

3. Use ful in Nested Internal tables

Disadvantages:

1. Long syntax

for example: Loop at IT_MARA into WA_MARA.

In with header line

Data ITAB like MARA occurs 0 with header line.

Advantages:

1. Simple to use & declare over without header line.

Bye,

KC

Read only

Former Member
0 Likes
1,870

Hi,

Examples:

<b>With Header line:</b>

data : itab like <dbtable> occurs 0 with header line.

Data: begin of itab occurs 0,
           f1 type f1,
           f2 type f2,
         end of itab.

<b>Without Header line.</b>

Types: begin of ty_tab,
            f1 type f1,
            f2 type f2,
           end of ty_tab.
Data: itab type table of ty_tab, " Internal Table
         wa type ty_tab. " Work Area

Hope your doubt is clarified.

<b>Reward points for helpful answers</b>

Satish

Read only

Former Member
0 Likes
1,870

Hi

DATA <itab> TYPE <type>|LIKE <obj> [WITH HEADER LINE].

Here, the LIKE addition refers to an existing table object in the same program. The TYPE addition can refer to an internal type in the

program declared using the TYPES statement, or a table type in the ABAP Dictionary.

You must ensure that you only refer to tables that are fully typed. Referring to generic table types (ANY TABLE, INDEX TABLE) or not

specifying the key fully is not allowed (for exceptions, refer to Special Features of Standard Tables).

<b>The optional addition WITH HEADER line declares an extra data object with the same name and line type as the internal table. This data

object is known as the header line of the internal table. You use it as a work area when working with the internal table (see Using the

Header Line as a Work Area). When you use internal tables with header lines, you must remember that the header line and the body of the

table have the same name. If you have an internal table with header line and you want to address the body of the table, you must indicate

this by placing brackets after the table name (<itab>[]). Otherwise, ABAP interprets the name as the name of the header line and not of the

body of the table. You can avoid this potential confusion by using internal tables without header lines. In particular, internal tables nested

in structures or other internal tables must not have a header line, since this can lead to ambiguous expressions.</b>