Application Development 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: 

header line and work area

Former Member
0 Kudos

Hi,

can anyone please explain me wht is the difference between header line and work area???

10 REPLIES 10

former_member404244
Active Contributor
0 Kudos

Hi,

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

Regards,

Nagaraj

former_member188829
Active Contributor
0 Kudos

Hi,

Check this thread..

Former Member
0 Kudos

Hi,

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.

Reward points if helpful...

Regards,

Goutham.

Former Member
0 Kudos

Hi,

INTERNAL TABLES

- Internal tables are used to obtain data from a fixed structure for

dynamic use in ABAP.

- Each line in the internal table has the same field structure.

- The main use for internal tables is for storing and formatting data from

a database table within a program.

WORK AREAS

- Work areas are single rows of data.

- It should have the same format as any of the internal tables.

- It is used to process the data in an internal table one line at a time.

Internal Tables with Header Line : Here the system automatically creates the work area. The work area has the same data type as internal table. This work area is called the HEADER line. It is here that all the changes or any of the action on the contents of the table are done. As a result of this, records can be directly inserted into the table or accessed from the internal table directly.

Internal Tables without Header Line : Here there is no work area associated with the table. Work area is to be explicitly specified when we need to access such tables. Hence these tables cannot be accessed directly.

HEADER LINE----

CREATED EXPLICITLY------

1.Internal table created by referring to another table

Syntax: Data <f> <type> with header line.

<type> refers to a table data type or table data objects using type or like.

Here internal table <f> is created of the type <type>.

Example:

DATA t_line TYPE line OCCURS 10 with header line.

2. Internal table created by referring to existing structure

Syntax: Data<f> <type> occurs n with header line.

The lines of the internal table <f> have the data type specified in <type> (Can use either like or type).

Example:

DATA flight_tab LIKE sflight OCCURS 10.

CREATED BY DEFAULT---

3. Internal table created With a new structure

Syntax: Data : Begin of <f> occurs <n>,

<component declaration>,

……………………………,

End of <f>.

Work area is created by default.

Example:

Data : Begin of itab occurs 10,

column1 type I,

column2(4) type C,

column3 like mara-ernam,

End of itab.

reward if useful

Regards

Former Member
0 Kudos

Hi,

Both are same the tables when we r explicitly declaring the header line then we r transfering the records from the table to headerline i.e. then we call it as work area.

PLzz reward points if it helps.

Former Member
0 Kudos

Hi,

Work area is a seperate definition which has the same structure as Internal table. Thus the data to be processed is passed to Work area from Internal table.

Declaration:-

types: begin of itab,

.

.

end of tab.

data: itab type standard table of itab.

data: workarea type itab.

Thus structure of internal table and work are are compatible.

Header line works as Work Area when define in the structure of internal table. Data is passed to header line for processing this header line does not has any new name, its name is same as internal table, just when you use it the record of internal table is present in header line.

Declaration:-

data: begin of itab occurs 0,

.

.

end of tab.

or

types: begin of itab,

.

.

end of tab.

data: itab type standard table of itab with header line.

regards

Vijai

Former Member
0 Kudos

HEADER LINE

CREATED EXPLICITLY

1.Internal table created by referring to another table

Syntax: Data <f> <type> with header line.

<type> refers to a table data type or table data objects using type or like.

Here internal table <f> is created of the type <type>.

Example:

DATA t_line TYPE line OCCURS 10 with header line.

2. Internal table created by referring to existing structure

Syntax: Data<f> <type> occurs n with header line.

The lines of the internal table <f> have the data type specified in <type> (Can use either like or type).

Example:

DATA flight_tab LIKE sflight OCCURS 10.

CREATED BY DEFAULT---

3. Internal table created With a new structure

Syntax: Data : Begin of <f> occurs <n>,

<component declaration>,

……………………………,

End of <f>.

Work area is created by default.

Example:

Data : Begin of itab occurs 10,

column1 type I,

column2(4) type C,

column3 like mara-ernam,

End of itab.

reward if useful

Former Member
0 Kudos

hi,

both have the same functionality the only difference is that.

header line will have the same name as internal table.

like if u declare an internal table itab with header line.

itab will refer to its work area and itab[] wwill refer to table.

but if u declare a internal table without header line and a separate work area for it,then itab will refer to the table.

Former Member
0 Kudos

if we define the internal table with occurs 0 it will by default create with header line or if we define itab like standard table with occurs 0 then we won't get work area. then we have to define header line explicitly.

work area is also similar to header line but we have to define explicitly. for standard table we can define in tables statement.

or custom itab we have to define structure then we have to refer that strcutre for creation of internal table.then that itab won't have header line.

we can print the data if it is ther in the header line or workare of the internal table.

tables: kna1.

  • Internal table have Header line.

data: begin of itab occurs 0,

kunnr like kna1-kunnr,

name1 like kna1-name1,

end of itab.

  • Internal table without header line.

  • We can refer kna1 as workarea for itab1.

data: itab1 like kna1 occurs 0.

  • Or

data:itab2 like kna1 occurs 0 with header line.

  • Work area.

data:

Begin of fs_kna1,

kunnr like kna1-kunnr,

name1 like kna1-name1,

end of fs_kna1.

  • Internal table declaration with out header line.

data: i_kna1 like standard table of fs_kna1.

Former Member
0 Kudos

see both are almost same ,

Header line is created in a table at the time of its definition

while

Work area needs to be defined explicitly.

Both are used for operations on a table.

Append modify etc command work with header line only.

Both contain only one record at a time.

It is recommended that you have a explicitly defined work area.

reward points if helpful,

kushagra