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

INTERNAL TABLE WITH HEADER LINE.

Former Member
0 Likes
56,979

Dear ABAP GURU,

I have very simple question relate to Internal table defined "With Header Line" you see following code. I am trying to learn ABAP. I just don't understand why we need create or why we need to use table, which created "WITH HEADER LINE"? I have attached code for sample, which I came cross. I was debugging the code and saw table ETAB TABLE DEFINED WITH HEADER LINE AND other just without Header line. Please, can you explain me with simple lay man term.

DATA: BEGIN OF LINE,

COL1,

COL2,

END OF LINE.

DATA: ETAB LIKE TABLE OF LINE WITH HEADER LINE,

FTAB LIKE TABLE OF LINE.

LINE-COL1 = 'A'. LINE-COL2 = 'B'.

APPEND LINE TO ETAB.

MOVE ETAB[] TO FTAB.

LOOP AT FTAB INTO LINE.

WRITE: / LINE-COL1, LINE-COL2.

ENDLOOP.

The output is:

A B

Thank you in advance.

Shailesh

1 ACCEPTED SOLUTION
Read only

former_member585060
Active Contributor
17,851

Header line or the work area is used as interface. we can't access data from an internal table or send data to an internal table without header line.

If we define internal table with header line , then we don't require to create explicit work area.

If an in ternal table created with out work area we have create a work are of the similar structure of the table.

work area means a single line of table structure.

ex:-

Types : Begin of ty_itab,

name(5) type c,

End of ty_itab.

without header line

Data : it_itab type table of ty_itab,

wa_itab type ty_itab.

with header line.

Data : it_itab like ty_itab occurs 0 with header line.

6 REPLIES 6
Read only

Former Member
0 Likes
17,851

internal tables with Header line

<<---No Need of explicit work area, by default header line acts as work area

Internal tables without header line

<---work area required for processing the internal table like read/modify etc.

same code can also be done using the without header line concept.

TYPES: BEGIN OF LINE,
COL1,
COL2,
END OF LINE.

DATA: FTAB TYPE TABLE OF LINE ,
           ETAB TYPE TABLE OF LINE,
WA_LINE TYPE LINE.

WA_LINE-COL1 = 'A'. WA_LINE-COL2 = 'B'.
APPEND WA_LINE TO ETAB.
MOVE ETAB[] TO FTAB.

LOOP AT FTAB INTO WA_LINE.
WRITE: / WA_LINE-COL1, WA_LINE-COL2.
ENDLOOP.

Read only

0 Likes
17,851

This message was moderated.

Read only

former_member585060
Active Contributor
17,852

Header line or the work area is used as interface. we can't access data from an internal table or send data to an internal table without header line.

If we define internal table with header line , then we don't require to create explicit work area.

If an in ternal table created with out work area we have create a work are of the similar structure of the table.

work area means a single line of table structure.

ex:-

Types : Begin of ty_itab,

name(5) type c,

End of ty_itab.

without header line

Data : it_itab type table of ty_itab,

wa_itab type ty_itab.

with header line.

Data : it_itab like ty_itab occurs 0 with header line.

Read only

Former Member
17,851

important :

if you are working on latest SAP versions, then working with internal table using header line concept is obsolete. and Header line concept is not supported by Object oriented ABAP .

Read only

Former Member
0 Likes
17,851

hiii

in your code you have written

DATA: ETAB LIKE TABLE OF LINE WITH HEADER LINE,

FTAB LIKE TABLE OF LINE.

here ETAB is an internal table and above addition like WITH HEADER LINE will also create a work area of the same structure at that time soo you do not need to create an explicit work area for internal table.

or else you can define like

DATA : t_kna1 TYPE STANDARD TABLE OF type_s_kna1,

wa_kna1 TYPE type_s_kna1.

here wa_kna1 is a work area...this is an internal table declaration without header line..

so if you want to use internal table in loop then you need to do that by using workarea only..

but when you declare internal table with header line ..you can directly use internal table name as workarea only..no need to define wa_kna1 TYPE type_s_kna1.

LINE-COL1 = 'A'. LINE-COL2 = 'B'.

in above state ment also if you have defined work area then you have to use like

WA_ETAB-col1 = 'A'.

APPEND WA_ETAB TO ETAB.

but in new version table with header line is not working.so you need to define explicit work area there.

i hope it helps you to understand

regards

twinkal

Read only

0 Likes
17,851

Dear Friends,

I really appriciate for your time and reply. All the answers were very helpful to understand. It cleared my concerns and understandings.

Thank you for your help.

Shailesh