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: 

How to create an internal table

Former Member
0 Kudos

Hi friends,

In what are the ways can we construct the internal table ? Can you tell me the advantages and disadvantages ?

7 REPLIES 7

Former Member
0 Kudos

Check out for below related threads

Regards,

Santosh

0 Kudos

Hi ,

Please tell me that How many methods can we construct the internal table......

0 Kudos

HI

data:begin of st_itab,

kunnr type kna1-kunnr,

name1 type kna1-name1,

end of st_itab.

types : it_itab type standard table of st_itab,

wa_itab type st_kna1.

data: begin of it_itab occurs 0,

kunnr type kna1-kunnr,

name1 type kna1-name1,

end of it_itab.

types it_kna1 type kna1 occurs 0.

Former Member
0 Kudos

hi,

Like all local data types in programs , you define internal tables using the TYPES statement. If you do not refer to an existing table type using the TYPE or LIKE addition, you can use the TYPES statement to construct a new local internal table in your program.

TYPES <t> TYPE|LIKE <tabkind> OF <linetype> [WITH <key>]

[INITIAL SIZE <n>].

After TYPE or LIKE, there is no reference to an existing data type. Instead, the type constructor occurs:

<tabkind> OF <linetype> [WITH <key>]

The type constructor defines the table type <tabkind>, the line type <linetype>, and the key <key> of the internal table <t>.

ex:

TYPES: BEGIN OF LINE,

COLUMN1 TYPE I,

COLUMN2 TYPE I,

COLUMN3 TYPE I,

END OF LINE.

TYPES ITAB TYPE SORTED TABLE OF LINE WITH UNIQUE KEY COLUMN1

for more details,check the site:

http://help.sap.com/saphelp_nw04/helpdata/en/79/c5547cb3dc11d5993800508b6b8b11/frameset.htm

Former Member
0 Kudos

Hi,

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 <itab> explicitly by using the following syntax: <itab>[]. 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

Regards,

Bhaskar

Former Member
0 Kudos

hi kumar,

you can declatre internal tables in two ways:

occurs N with header line (N is a integer)

without header line

syntax 1: begin of internal table name occurs N with

header line,

filed declarations,

end of internal table name.

syntax 2: begin of internal table name,

filed declarations,

end of internal table name.

if you want copy data base table as internal table,

syntax3: itab like DBtable.

reward if useful

Former Member
0 Kudos

hi kumar,

this is possibly the best link you can get for the INTERNAL TABLEs...it's advantages...the ways of creation etc..

http://venus.imp.mx/hilario/Libros/TeachYrslfAbap4/ch11.htm

give credit if helpful

rohan malik