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

Internal Tables!!

Former Member
0 Likes
1,877

Hi All,

I have a concern on the declaration of Internal tables:

As per my knowledge, i can declare the internal table in the following ways :

1. Data : Begin of Internal table name occurs 0,

field 1, field 2, field 3...

End of Internal table name.

2. Types : Begin of structure name,

field names,

end of structure name.

Data : Internal table name type standard table of structure name,

workarea type internal table name.

Now can I create a Internal table without DATA statement directly i.e., by using Types statement can i create a Internal table or not?

Please clarify..

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,853

yes but best way to do this is

TYPES: BEGIN OF t_ekko,

bukrs TYPE bukrs,

lifnr TYPE lifnr,

rlwrt TYPE rlwrt,

ebeln TYPE ebeln,

aedat TYPE aedat,

END OF t_ekko.

DATA: w_ekko TYPE t_ekko,

i_ekko TYPE TABLE OF t_ekko.

it will improve ur efficiency.

21 REPLIES 21
Read only

Former Member
0 Likes
1,853

hi,

Yes you can do that

types  : begin of <str>,
              fld1,
              fld2,
              fld3,
            end of <str>.

data itab *type* str occurs o with header line.

You can only use like this

the difference is

DATA -> LIKE

TYPES -> TYPE

Regards,

V.Balaji

Reward if Usefull...

Read only

Former Member
0 Likes
1,853

Types mean indicating the characteristic of the data. Only if u create a data variable you can hold data.

Read only

Former Member
0 Likes
1,853

By using TYPE statement we are not actually creating internal table, it is like defining the structure. We use the definition later and define internal table with DATA statement. Memory allocation happens only with variables are defined with DATA statement.

Read only

Former Member
0 Likes
1,853

Hi,

By using types u declare the structure that cant contain data, means it doesn't have body or hat for containig data .

that u have to define using data statement .

reward if doubt is clear

Read only

Former Member
0 Likes
1,853

yes u can, see the below example:

TYPES : BEGIN OF ty_lfa1 ,

lifnr TYPE lfa1-lifnr ,

name1 TYPE lfa1-name1 ,

END OF ty_lfa1 .

DATA : i_lfa1 TYPE STANDARD TABLE OF ty_lfa1 ,

w_lfa1 TYPE ty_lfa1.

Read only

Former Member
0 Likes
1,853

Hi,

U cannot create any data-obj using only types statement

u hav to either use data / create data statements......

Cheers,

jose.

Read only

Former Member
0 Likes
1,853

Hi

you cannot create internal tables without using data.you can create structure by using types then you write data for creating internal table for that structure.

for example...

*................structure declaration

types:begin of st_kna1,

kunnr type kunnr,

name1 type name1_gp,

land1 type land1_gp,

end of st_kna1.

*...............work area , internal table declaration

data:wa_kna1 type st_kna1,

it_kna1 type standard table of st_kna1.

Read only

Former Member
0 Likes
1,853

Hi Ramesh,

Yes u can create an internal table using TYPES.Try below

statement.

TYPES BEGIN OF struc_type.

...

{TYPES dtype ...} | {INCLUDE {TYPE|STRUCTURE} ...}.

...

TYPES END OF struc_type.

Regards

Lakshman

Read only

0 Likes
1,853

Hi,

So i can create an Internal table with out Data statement.am i correct?

Read only

0 Likes
1,853

U have to use Data statement to create an internal table ..

Using types UR just declaring the structure .. and not internal table ..

Read only

0 Likes
1,853

Thanks for the information.

still i have the following concern: see, when ever we use occurs statement then it indicates Internal table.

But here if we use Types and Data statment, we are not using occurs statement. then how do we know whether this is an internal table or not?

for ex 😕

Types : Begin of Structure,

fields,

End of Structure.

Data : Internal table type table type of structure.

here in the above statement, we are not using the occurs statement. now how the system is allocating the memory to the table? Please clarify/.

Read only

0 Likes
1,853

Considering your example:

Types : Begin of Structure,   " Just a plain Definition
            fields,
        End of Structure.
Data : Internal table type table type of structure." Internal table declaration. Note the TYPE TABLE in the definition
DATA: WA type structure. " This is like the Work Area/ Header  

Read only

0 Likes
1,853

Hi,

see data statement is mandatory to declare an int-table

1) data : begin of itab occurs 0 ,

............

end of itab.

2) data itab type table of srtuc.

3) data itab type tab_type. ( here tab_type is a table type ex 'SOLI_TAB' see this in SE11).

also check the syntax of create data statement in keyword help F1.....

Cheers,

jose.

Read only

0 Likes
1,853

Hi ramesh

when u use

Types : Begin of Structure,

fields,

End of Structure.

Data : Internal table type table type of structure.

it means that only WORK AREA or HEADER is alone created and not the body.

If u specify OCCURS only then body is created.

Regards

Lakshman

Read only

Former Member
0 Likes
1,853

when using Types it is considered as local Data type or local

structured Data Type.

U can create structure type with Types statment

and cannot create an internal table with Types declaration.

Types:begin of str,----->Local Structure type

f1

f2

end of str.

Data:itab type table of str

Data:begin of str, -


>Data Object

f1

f2

end of str.

Data:itab like table of str .

Regards,

priya

Read only

Nawanandana
Active Contributor
0 Likes
1,853

hi

yes u can do it man...

TYPES : BEGIN OF ty_itab,

bukrs LIKE bkpf-bukrs,

gjahr LIKE bkpf-gjahr,

monat LIKE bkpf-monat,

blart LIKE bkpf-blart,

END OF ty_itab.

DATA : it_itab TYPE STANDARD TABLE OF ty_itab,

wa_itab TYPE ty_itab.

wa_itab is the working aria....

it_itab is the internal table...

cheers

nawa

Read only

Former Member
0 Likes
1,853

when using types statment and declare it is not considered as

internal table it is a structure type

when using Types it is considered as local Data type or local

structured Data Type.

U can create structure type with Types statment

and cannot create an internal table with Types declaration.

Types:begin of str,----->Local Structure type

f1

f2

end of str.

Data:itab type table of str

Data:begin of str, -


>Data Object

f1

f2

end of str.

Data:itab like table of str .

Regards,

priya

Read only

Former Member
0 Likes
1,853

Yes , You Can. Read the Following :

Creating Internal Table Data Types

To create an internal table data type, you use the TYPES statement as follows:

Syntax

TYPES <t> <type> OCCURS <n>.

This creates an internal table data type <t> by using the OCCURS option of the TYPES statement. The lines of the internal table have the data type specified in <type>. To specify the data type of the lines, you can use either the TYPE or the LIKE parameter.

TYPES: BEGIN OF LINE,

COLUMN1 TYPE I,

COLUMN2 TYPE I,

COLUMN3 TYPE I,

END OF LINE.

TYPES ITAB TYPE LINE OCCURS 10.

This example creates an internal table data type ITAB which has lines with the same structure as the field string LINE.

Reward Point if Useful.

Read only

Former Member
0 Likes
1,853

when Using types statment it donot have any memory space allocated.

while using Data:itab like or type table of structure. or occurs 0 it is considered as an internal table.

occurs 0 ---used for internal table with header line

like or type table of structure-->used for without header line

here only memory is allocated. not during Types.

reward if helpful

regards,

priya

Read only

Former Member
0 Likes
1,854

yes but best way to do this is

TYPES: BEGIN OF t_ekko,

bukrs TYPE bukrs,

lifnr TYPE lifnr,

rlwrt TYPE rlwrt,

ebeln TYPE ebeln,

aedat TYPE aedat,

END OF t_ekko.

DATA: w_ekko TYPE t_ekko,

i_ekko TYPE TABLE OF t_ekko.

it will improve ur efficiency.

Read only

Former Member
0 Likes
1,853

Hi you can do That

TYPES: BEGIN OF TY_BSID,

BUKRS LIKE BSID-BUKRS,

KUNNR LIKE BSID-KUNNR,

PSWBT LIKE BSID-PSWBT,

END OF TY_BSID

reward if usefull.