‎2008 Jun 29 1:53 PM
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
‎2008 Jun 29 2:15 PM
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.
‎2008 Jun 29 2:14 PM
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
‎2008 Jun 29 2:15 PM
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.
‎2008 Jun 29 2:23 PM
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.
‎2008 Jun 29 2:45 PM
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