Friday, November 23, 2007

With Header and Without Header Internal Table in sap abap

You can define internal tables either with (WITH HEADER LINE addition) or without header lines.

An internal table with header line consists of a work area (header line) and the actual table body. You address both objects
using the same name. The way in which the system interprets the name depends on the context. For example, the MOVE statement applies to the header line, but the SEARCH statement applies to the body of the table.

To avoid confusion, you are recommended to use internal tables without header lines. This is particularly important when you use nested tables. However, internal tables with header line do offer a shorter syntax in several statements
( APPEND, INSERT, MODIFY, COLLECT, DELETE, READ, LOOP ).

Within ABAP Objects, you can only use internal tables without a header line. You can always address the body of an internal table explicitly by using the following syntax: []. This syntax is always valid, whether the internal table has a header line or not.

Example

DATA itab1 TYPE TABLE OF i WITH HEADER LINE.

DATA itab2 TYPE TABLE OF i WITH HEADER LINE.

itab1 = itab2.

" Only header lines will be copied
itab1[] = itab2[].
" Copies table body

No comments:

Blog Archive