‎2007 Feb 28 1:29 PM
‎2007 Feb 28 1:31 PM
Header line used to pass and retrieve tghe records from iternal table. witout header line u have to use work area to access internal table.
‎2007 Feb 28 1:31 PM
Hello,
If useful reward.
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
Vasanth
‎2007 Feb 28 1:33 PM
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).
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.
TYPES VECTOR TYPE SORTED TABLE OF I WITH UNIQUE KEY TABLE LINE.
DATA: ITAB TYPE VECTOR,
JTAB LIKE ITAB WITH HEADER LINE.
MOVE ITAB TO JTAB. <- Syntax error!
MOVE ITAB TO JTAB[].
The table object ITAB is created with reference to the table type VECTOR. The table object JTAB has the same data type as ITAB. JTAB also has a header line. In the first MOVE statement, JTAB addresses the header line. Since this has the data type I, and the table type of ITAB cannot be converted into an elementary type, the MOVE statement causes a syntax error. The second MOVE statement is correct, since both operands are table objects.
Regards,
Sruthi
‎2007 Feb 28 1:33 PM
well header lines are very handy, BUT they are obsolete by now.
if a table has a header line you can do following:
Loop at itab.
endloop.
OR even more head spinning:
modify itab.
what makes it handy? well you dont need to declare a seperate work area where you loop into, you can just use the header line. the header line is a work area and contains the actual recoed if you are in a loop.
there are some more pros and cons, but this should give you enough wisdom to think about those yourself.
Just be aware a Programmer beeing new to SAP might have his problems reading a statement like: modify itab.
‎2007 Feb 28 1:41 PM
hi vamsi,
check these...
https://forums.sdn.sap.com/click.jspa?searchID=1388223&messageID=2918725
regards,
priya.
‎2007 Feb 28 1:45 PM
If you use header line in case of internal table whenever you do any operation in the table (insert , loop ...) table row first of all comes to header . so any table having header line you can use that header line as WORK AREA otherwise you need to create a new separate work area for that internal table.