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

creating an internal table

Former Member
0 Likes
444

What statments do I need to use to create an internal table? i tried TYPE but it isn't working correctly

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
421

Hi,

Try this..

1)

<b>Internal table with header line.</b>

DATA: BEGIN OF ITAB OCCURS 0,

MATNR TYPE MATNR,

END OF ITAB.

2)

<b>Internal table without header line.</b>

DATA: BEGIN OF WA,

MATNR TYPE MATNR,

END OF WA.

DATA: ITAB LIKE STANDARD TABLE OF WA.

3)

TYPES: BEGIN OF TYPE_WA,

MATNR TYPE MATNR,

END OF TYPE_WA.

DATA: ITAB TYPE STANDARD TABLE OF TYPE_WA.

Thanks,

Naren

4 REPLIES 4
Read only

Former Member
0 Likes
422

Hi,

Try this..

1)

<b>Internal table with header line.</b>

DATA: BEGIN OF ITAB OCCURS 0,

MATNR TYPE MATNR,

END OF ITAB.

2)

<b>Internal table without header line.</b>

DATA: BEGIN OF WA,

MATNR TYPE MATNR,

END OF WA.

DATA: ITAB LIKE STANDARD TABLE OF WA.

3)

TYPES: BEGIN OF TYPE_WA,

MATNR TYPE MATNR,

END OF TYPE_WA.

DATA: ITAB TYPE STANDARD TABLE OF TYPE_WA.

Thanks,

Naren

Read only

Former Member
0 Likes
421

Hi LMM,

Use TYPES to create an internal table.

<b>TYPES:

BEGIN OF ty_vbak,

vbeln TYPE vbak-vbeln,

vdatu TYPE vbak-vdatu,

bstnk TYPE vbak-bstnk,

END OF ty_vbak.

DATA: it_vbak TYPE STANDARD TABLE OF ty_vbak WITH HEADER LINE.</b>

Internal table can be declared in the following ways.

1)

<b>Data : Itab like sflight occurs 0 with header line</b>

Here you are declaring internal table, which is similar to sflight i.e., itab like sflight i.e., you are referring to existing table (like).

(By default internal table created with this declaration is without header line).

2)

<b>Data : Begin of itab occurs 0.

Include structure sflight

Data : End of itab</b>

(Internal Table created with this type of declaration is similar to declaration done in ‘a’ type the only difference is by default internal table created by this type is with header line)

3)

<b>Data :

Begin of itab occurs 0

carrid like sflight-carrid,

connid like sflight-connid,

fldate like sflight-f1date

End of itab.</b>

By default internal table created by this type of declaration is with header line. In this type of declaration, you are using only those fields from database table, which you require for processing.

4)

<b>Data :

Begin of itab occurs 0

carrid like sflight-carrid,

connid like sflight-connid,

bookid like sbook-bookid

id like scustom-id,

End of itab.</b>

Here you are combining fields from three different tables in one internal table.

5)

<b>Data :

Begin of itab occurs 0

Carrid1 like sflight-carrid,

End of itab.</b>

Here you are specifying different field names.

Thanks,

Vinay

Read only

Former Member
0 Likes
421

Hi

<b>OCCURS <n>, HEADER LINE are obsolete now. Do not use them.</b>

Try this

  • Dictionary objects

DATA: I_MARA TYPE TABLE OF MARA, " Internal Table

W_MARA TYPE MARA. " Work Area

  • Custom

TYPES: BEGIN OF T_MARA,

MATNR TYPE MARA-MATNR,

MEINS TYPE MARA-MEINS,

END OF T_MARA.

DATA: I_MARA TYPE TABLE OF T_MARA, " Internal Table

W_MARA TYPE T_MARA. " Work Area

Regards

Kathirvel