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

abt internal tables

Former Member
0 Likes
1,252

what is the difference between ITAB EITH HEADER LINE n WITHOUT HEADER LINE with exmples also.

plzzzzzzzz

what is the difference between ITAB EITH HEADER LINE n WITHOUT HEADER LINE with exmples also.

plzzzzzzzz

7 REPLIES 7
Read only

Former Member
0 Likes
935

Hi

If it is with header line, You will enter multiple entries into that Internal table

Without header line means it will becom=e as structure and you can hold only a single record at run time.

you can't store multiple records without header line

<b>Reward points for useful Answers</b>

Regards

Anji

Read only

Former Member
0 Likes
935

Hi,

When you create an internal table 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:

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.

http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb36a1358411d1829f0000e829fbfe/content.htm

<b>Reward points</b>

Regards

Read only

former_member196299
Active Contributor
0 Likes
935

hi V S N ,

There is not much difference though , except , in itab WITH HEADER LINE one work area of the same structure of the ITAB is automatically created and procesed , which the user have to create when we use the ITAB wihout header lines .

example :

data: begin of itab occurs 10 with header line ,

name1(10) type c ,

name2(10) type c,

end of itab.

itab-name1 = 'vsavjhjd'.

itab-name2 = 'gdvhcjvd'.

append itab .

clear itab .

data:begin of itab occurs 10, " itab W/O header line

name1(10) type c ,

name2(10) type c,

end of itab.

data: wa like line of itab, " create a work area

wa-name1 = 'vsavjhjd'.

wa-name2 = 'gdvhcjvd'.

move wa to itab .

append itab .

clear itab .

few other informations are :

Apart from the internal table, this addition, which is not allowed in ABAP Objects, 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 the statements IMPORT and EXPORT.

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.

Regards,

Ranjita

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
935

Hi,

WITH HEADERLINE, creates a WORKAREA as first record of the intenral table, so you can use the name of the internal table itab as the workarea and itab[] as the table.

WITH OUT HEADERLINE meas you have to create your own workarea as follows

DATA: wa like line of itab.

Also tables with out headerlines SYNTAX is different for READ, LOOP, MODIFY, APPEND and INSERT statements there you need to mention the workarea seperately. For tables with headerline you need not mention workarea.

Regards,

Sesh

Read only

0 Likes
935

plz giv me syntax for select statements in with header line n without header line.

n also MIDIFY,DELETE,READ....... syntax also plzz

Read only

Former Member
0 Likes
935

<b>Difference between Work Area and Header Line</b>

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.

rewardd points if it is usefull....

Girish

Read only

Former Member
0 Likes
935

Hi,,

<b>Internal Tables With Header Line:</b>

You access internal tables record by record. You must use a work area as an interface for transferring data to and from the table.

When you read data from an internal table, the contents of a specified table record or line overwrites the contents of the work area. Then, you can reference the contents of the work area in your program. When you write data to an internal table, you must first enter the data in the work area from with the system can transfer the data to the internal table.

To avoid inconsistencies, it is beneficial if the work area has the same data type as the records or lines of the internal table. A safe procedure for creating work areas which are compatible with internal tables is to use the same data type for declaring both the internal table and the work area.

In ABAP/4, you can distinguish between two kinds of internal tables:

Internal tables WITH header lines

Internal tables WITHOUT header lines

A header line is similar to a work area for a database table. A work area is used as temporary storage for one entry of a database table. In a similar way, a header line is used to hold one line of an internal table.

An internal table with header line is a tuple from a work area (header line) and the bulk of the table itself. Both are addressed using the same name,the interpretation of the name is context-sensitive. Hence it would stand for the header line in a MOVE statement, but would stand for the bulk of the table in a SEARCH statement.

When you create an internal table WITH a header line, a work area is created automatically with the same data type as the rows of the internal table. The header line and the internal table have the same name. Then, the system uses this work area implicitly.

In ABAP/4 statements for accessing internal tables, you can specify the work area to be used.For internal tables with header lines, you can leave out this specification.Then, the system uses the table work area implicitly.

<b>Internal Tables Without Header Line:</b>

If a table does not have a header line, you MUST provide a work area as a separate record to hold the content of the current entry for most commands used in processing tables.

Internal tables WITHOUT a header line do NOT have a table work area declared which can be used implicitly. To access internal tables WITHOUT header lines, you must specify a work area explicitly in the corresponding ABAP/4 statements.

It is a matter of your preference whether you use a header line or a work area.

Remember that, for internal tables with header lines, the internal table itself and the table work areas have the same name. If you use the name in a statement, the system interprets it as the name of the table work area and NOT as the table itself. In some statement, however, you can enter square brackets after the name to address the internal table instead of the table work area as follows: <name> [ ].

<b>Pls do reward points.</b>

Regards,

Ameet