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

Difference between tables statement and by using type statement

Former Member
0 Likes
1,907

Hi all,

I need to know the difference between the two of the below statements

Tables spfli.

and

data spfli type spfli with header line.

As far as i know both seem same to me.

Thanks in advance,

Bala.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,862

Hi,

For

" data spfli type spfli with header line. "

It defines an inetrnal table that has exactly the same structure as of the SPFLI table.

Apart from the internal table, this addition, which is not allowed in ABAP Objects,

declares another data object, the header line, which has exactly the same name as

the internal table and has the row type of the internal table as the data type.

If at an operand position of an ABAP statement,

you specify the name of internal table itab, it depends on the statement whether

the table body or the header line are used. As a rule, all table-specific statements

such as SORT or LOOP use the internal table, while all other statements use the header

line. Exceptions are the statements IMPORT and EXPORT.

For

" Tables spfli. "

declares a data object spfli as a table work area whose data type is adopted from the

identically named structured data type spfli from the ABAP Dictionary.

spfli must be defined as a flat structure in the ABAP Dictionary.

You can specify database tables or Views for spfli.

Work table areas declared with TABLES are interface work areas and should only be

declared in the global declaration section of a program for the following purpose:

The statement TABLES is required for exchanging data between screen fields

that were defined in a program screen when transferring from the ABAP Dictionary

and the ABAP program

Thanks & Regards

18 REPLIES 18
Read only

h_senden2
Active Contributor
0 Likes
1,862

The tables statement declares a work area, but this statement is obsolete in ABAP Objects.

You have to declare the workarea via the DATA statement.

regards,

Hans

Read only

arjun_thakur
Active Contributor
0 Likes
1,862

hi bala,

data spfli type spfli with header line.

this statement is used to create an internal table with header line.

although this statement is not recommended any more. you used create a structure first and the internal table and work areas.

Tables spfli.

this statement is used to include any perticular table in your program.

but this statement is obsolete

Edited by: arjun on Oct 22, 2008 10:14 AM

Read only

JozsefSzikszai
Active Contributor
0 Likes
1,862

>

> Hi all,

>

> I need to know the difference between the two of the below statements

>

>

Tables spfli.

this will create a work area (spfli), looks like DB table spfli, but the statement is obsolate

>

data spfli type spfli with header line.

this will result in a syntax error, because this would also create a work area, but they cannot have header lines, so you should leave the WITH HEADER LINE addition.

To create work area use:

DATA : gw_spfli TYPE spfli.

To create internal table:

DATA : gt_spfli TYPE TABLE OF spfli.

Read only

bpawanchand
Active Contributor
0 Likes
1,862

Hi

With the first statement Tables SPFLI it comes with bydefault header line but with the second one you need to explicitly declare the header line

Read only

Former Member
0 Likes
1,862

Hi,

When you declare Tables: <Tablename> this statement is used to read the table and when the structure is declare for the table fields.

When you declare Data spfli type spfli with header line.

with the above statement we can send the data records one by one to the workarea through header line which mean one by one records.

Cheers!!

Balu

Read only

Former Member
0 Likes
1,862

This message was moderated.

Read only

0 Likes
1,862

Thank you all for your replies.

I am still not clear.

Does these 2 statements create a

1.) internal table of structure similar to spfli

2.) Header line of structure spfli.

if so.. in what situation i have to use these two statements. Also amit was telling me about using tables in screens. I checked and both these statements work fine with screens.

I understood that tables cannot be used in classes.

So the case is that , even though both perform the same operations ,their usage is restricted in some areas of programs?

Thanks in advance,

Bala.

Read only

0 Likes
1,862

>

> Does these 2 statements create a

>

> 1.) internal table of structure similar to spfli

> 2.) Header line of structure spfli.

it will create a work area of spfli (work area = structure in this case), it is like one line of table spfli

>

if so.. in what situation i have to use these two statements. Also amit was telling me about using tables in screens. I checked and both these statements work fine with screens.

never I told already: first one is obsolate, second one will result in syntax error

>

I understood that tables cannot be used in classes.

tables with header lines cannot be used in classes

read my answer again, to get understanding (unfortunately some other answers were completely wrong)

Read only

Former Member
0 Likes
1,863

Hi,

For

" data spfli type spfli with header line. "

It defines an inetrnal table that has exactly the same structure as of the SPFLI table.

Apart from the internal table, this addition, which is not allowed in ABAP Objects,

declares another data object, the header line, which has exactly the same name as

the internal table and has the row type of the internal table as the data type.

If at an operand position of an ABAP statement,

you specify the name of internal table itab, it depends on the statement whether

the table body or the header line are used. As a rule, all table-specific statements

such as SORT or LOOP use the internal table, while all other statements use the header

line. Exceptions are the statements IMPORT and EXPORT.

For

" Tables spfli. "

declares a data object spfli as a table work area whose data type is adopted from the

identically named structured data type spfli from the ABAP Dictionary.

spfli must be defined as a flat structure in the ABAP Dictionary.

You can specify database tables or Views for spfli.

Work table areas declared with TABLES are interface work areas and should only be

declared in the global declaration section of a program for the following purpose:

The statement TABLES is required for exchanging data between screen fields

that were defined in a program screen when transferring from the ABAP Dictionary

and the ABAP program

Thanks & Regards

Read only

0 Likes
1,862

>

> " data spfli type spfli with header line. "

>

> It defines an inetrnal table ...

WRONG!!!

Read only

0 Likes
1,862

Hi,

If you refer to the ABAP documentation. The first statement that they specify is that it defines an internal table.

Thanks & Regards

Read only

0 Likes
1,862

Thanks eric...

You are correct. i tried the second statement throws error.

You said know tables statement is obsolete.

So should i use

data spfli type standard table of spfli.

data spfli_wa type spfli.

instaed of

tables spfli.

Read only

0 Likes
1,862

Any link? I guess you have the wrong documentation... or the wrong understanding...

DATA : spfli TYPE TABLE OF spfli WITH HEADER LINE.

this declares an internal table (pls. note the difference). The original statement will result in a syntax error (I am telling the third time). Anyway, you don't have to believe it to me, just give it a try on your own!

Read only

0 Likes
1,862

Bala: exactly! Forget the TABLES statement and declare everything with DATA...!

Read only

matt
Active Contributor
0 Likes
1,862

And don't use tables with header lines.

matt

Read only

0 Likes
1,862

Hi,

Thanks for updating

Thanks & Regards

Read only

0 Likes
1,862

of course... check my othe replies in the thread

this was just to show the difference between DATA : spfli TYPE spfli WITH HEADER LINE and DATA : spfli TYPE TABLE OF spfli WITH HEADER LINE

Read only

0 Likes
1,862

Thanks all for spending time to help me solve my doubts.

Thank you very much eric