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: 

difference between with and without header line of internal table

Former Member
0 Kudos

Hi all,

can you explain

1) The difference between

whih header line and with out heater line of internal table.

ex:-

a) Data : itab like mara occurs 0 with header line.

b) Data: itab like mara occurs 0.

2)work area / field string and internal table

which one is prefarable for good performance any why ?

Please give the detailed explanation with example code.

Thanks in advance

Ravi

1 ACCEPTED SOLUTION

Former Member

Hi,

When you create internal table with headerline an explicit workarea is attached with the table.

Whenever you loop at table or read a table the value read from the table is stored in the header of the table.

Syntax

loop at internal_table

&

Read table internal_table.

You can use name of the table directly to access the value

where as when create internal table without header you have to create a structure ( Workarea ) for the internal table.

when you read or loop have get stored into structure you specify

Syntax will be

loop at internal_table into structure

&

Reab table internal_table into structure

and you have to read the value from the structure

Structure (Workarea) type should of internal table type

otherwise error.

As per my knowledge explicit defination of workarea is better than declaring internal_table with header line.

Since in our project it standard to use explicit workarea other than internal table with headerline.

Fell free to ask any futher question.

Reward some points if it helps you

Regards,

Manoj B Gupta

8 REPLIES 8

Former Member

Hi,

When you create internal table with headerline an explicit workarea is attached with the table.

Whenever you loop at table or read a table the value read from the table is stored in the header of the table.

Syntax

loop at internal_table

&

Read table internal_table.

You can use name of the table directly to access the value

where as when create internal table without header you have to create a structure ( Workarea ) for the internal table.

when you read or loop have get stored into structure you specify

Syntax will be

loop at internal_table into structure

&

Reab table internal_table into structure

and you have to read the value from the structure

Structure (Workarea) type should of internal table type

otherwise error.

As per my knowledge explicit defination of workarea is better than declaring internal_table with header line.

Since in our project it standard to use explicit workarea other than internal table with headerline.

Fell free to ask any futher question.

Reward some points if it helps you

Regards,

Manoj B Gupta

Former Member
0 Kudos

Hi Ravi,

Header line can be used as a work area while processing internal table. You need not have to create an extra work-area for the int.table.

If you create an internal table with header line, data is sent to header line and when you use APPEND statement , it is sent from Header line to the internal table.

eg: Syntax for int.table with header line is

DATA: ITAB TYPE MARA OCCURS 0 WITH HEADER LINE

Usually what u do with structure is

Data: struct type mara.

struct-matnr = somevalue.

struct-mbrsh = somevalue.

append struct into itab.

You can avoid those statements by directly writing

itab-matnr = somevalue.

append itab.

Initialising Internal tables

1) CLEAR <ITAB>.

If u use itab as one with header line, this stmt clears contents of header line only.

2) CLEAR <ITAB>[].

This clears the body contents of int.table.

So in order to access an internal table with header line, we have to call it as ITAB[] or else only the header line is called.

Also header line eliminates the use of extra structure.

For learning more about Internal table operations with Header line, check this link,

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

Regards,

SP.

Former Member
0 Kudos

Hi Ravi,

have a look at the following link.

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb367a358411d1829f0000e829fbfe/frameset.htm

hope it ll help you.

regards,

Kinshuk

Former Member
0 Kudos

HI Ravi,

1) The difference between

whih header line and with out heater line of internal table.

ex:-

a) Data : itab like mara occurs 0 with header line.

b) Data: itab like mara occurs 0.

-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.

<b>-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.</b>

a) Data : itab like mara occurs 0 with header line.

<b> table is with header line</b>

b) Data: itab like mara occurs 0.

<b> table is without header line</b>

2)work area / field string and internal table

which one is prefarable for good performance any why ?

-The header line is a <b>field string</b> with the same structure as a row of the body, but it can only hold a single row , whereas <b>internal table</b> can have more than one record.

In short u can define a <b>workarea</b> of an internal table which means that area must have the same structure as that of internal table and can have one record only.

Example code:

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.

Hope this will clear your doubts, if ur satisfied then do close this thread by rewrding appropriate points to the helpful answers.

Cheers

Sunny

reward points ,if found helpful

0 Kudos

Hi Sunny,

Thanks for your reply ,but the exampl you have given in the bottom is bit confusing .

can make it clear

Thanks and Regards

Ravi

0 Kudos

Ravi,

In simple terms when you declare an itab with hedaer line, it can hold more than one record in the table during runtime.

Without the header line, the itab is just a header, that is, it can hold only one record at any point of time.

Regards,

Suresh Datti

0 Kudos

Example for Internal table with header line.

types : begin of ty_itab,

name type char30,

age type i,

end of ty_itab.

DATA : itab TYPE ty_itab OCCURS 0 WITH HEADER LINE.

For this internal table you don't need to declare any workarea. Table name is itself is a workarea.

You can access the fields as :

itab-name.

itab-age.

Example for Internal table without header line.

DATA : itab1 TYPE TABLE OF ty_itab.

For this internal table we need to declare explicit workarea.

data : wa_itab like line of itab1.

OR

data : wa_itab type ty_itab.

Access the fields as:

wa_itab-name.

wa_itab-age.

syntax : As same as given by Manoj Gupta earlier

0 Kudos

HI Ravi,

Sorry for the delay as i was not online on SDN,

Well to make it simpler.

Say we have an internal table with an header line which mean nothing that it has got a workarea defined to it.

Eg:

- Data : itab like mara occurs 0 with header line

- data: begin of itab occurs 10,

ab type c,

cd type i,

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

<b>Otherwise</b> u need to define the define a <b>explicit workarea for the same</b> like. <b></b>

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

<b>Another way to define the same</b>.

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

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

Hope you will be clear , if not do let me know.

If ur satisfied then do close this thread by rewrding appropriate points to the helpful answers.

Cheers

Sunny

reward points ,if found helpful

Message was edited by: Sunny