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

TABLES vs TYPE STANDARD TABLE

Former Member
0 Likes
11,757

What's the difference exactly in declaring

TABLES T001.

and

itab TYPE STANDARD TABLE OF T001.

?

I understand that with the 1st command we create an internal table with the exact same structure as of the table specified.

It seems the 2nd command doesn't do the same, I'm wondering where exactly does the difference lies.

Thanks !

Avraham

1 ACCEPTED SOLUTION
Read only

vinod_vemuru2
Active Contributor
0 Likes
3,121

Hi Avraham,

TABLES statement will not define internal table rather it defines work area of same structure as the name defined in tables statement and with the same name.

(It can hold single record at any point of time)

eg: TABLES: T001 defines work area with name T001 of structure same as T001.

DATA: i_t001 TYPE STANDARD TABLE OF t001.

Above statement defines internal table without header line having structure same as T001 table.

Hope it is clear.

Thanks,

Vinod.

4 REPLIES 4
Read only

Former Member
0 Likes
3,121

Kahana,

To get this clarified.. Answer these questions then you could differentiation.

1. Are you able to perform table opperations in first case?

2. In first case is the table holds the values selected from database table?

we are just declaring the table structure in the first case.

Thanks,

Sunil

Read only

vinod_vemuru2
Active Contributor
0 Likes
3,122

Hi Avraham,

TABLES statement will not define internal table rather it defines work area of same structure as the name defined in tables statement and with the same name.

(It can hold single record at any point of time)

eg: TABLES: T001 defines work area with name T001 of structure same as T001.

DATA: i_t001 TYPE STANDARD TABLE OF t001.

Above statement defines internal table without header line having structure same as T001 table.

Hope it is clear.

Thanks,

Vinod.

Read only

Former Member
0 Likes
3,121

Hi,

TABLES

Creates an structure - the table work area - in a program, for the database table , view , or structure dbtab with the same name. The structure of the table work area corresponds exactly to the line structure of the database table dbtab. dbtab must be declared in the ABAP Dictionary.

The fields of the table work area are filled with the initial value appropriate for their ABAP data type.

Example : If you want to list all the company code and its text


select * from t001.
  write : / 10 t001-bukrs,
             15 t001-butxt.
endselect.

----


data : itab TYPE STANDARD TABLE OF T001.

Here you are declaring a internal table which has a line type T001. And, you need to explicitily create a header line / work area.

Example :


data : itab TYPE STANDARD TABLE OF T001,
         wa like line of itab.

select * from t001 into table itab.
loop at itab into wa.
 write : 10 wa-bukrs,
           15 wa-butxt.
endloop.

regards,

Advait.

Read only

Clemenss
Active Contributor
0 Likes
3,121

Hi Avraham,

not exactly. Historically (below R/3 3.0) the TABLES statement was necessary for all database accesses involving the table.

Today TABLES is obsolete. It declares a STRUCTURE (one line!), that means a structure variable off the name and structure of the ztable name used.


TABLES T001.
DATA T001 TYPE T001.

is the same and will lead to a syntax error (T001 already declared).


DATA:
  itab TYPE STANDARD TABLE OF T001.

declares an internal table without header line and row structure of T001.

You may use F1 on TABLES and DATA to find out yourself.

Regards,

Clemens