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

Query on internal table

Former Member
0 Likes
553

hello all,

i am confusing how affectively we can use the internal table key words. observe the following two sample codes, plz clarify what is the difference between these two.

1.

REPORT z_sample_report1 .

TYPES: t_spfli

TYPE STANDARD TABLE OF spfli.

DATA: itab_flinfo TYPE t_spfli,

wa_flinfo LIKE LINE OF

itab_flinfo.

SELECT * FROM spfli INTO TABLE itab_flinfo.

READ TABLE itab_flinfo INTO wa_flinfo

WITH KEY carrid = 'LH'

connid = '2463'.

IF sy-subrc = 0.

WRITE:/ wa_flinfo-carrid,

wa_flinfo-connid,

wa_flinfo-cityfrom,

wa_flinfo-cityto,

wa_flinfo-deptime,

wa_flinfo-arrtime.

ENDIF.

2.

REPORT z_sample_report1 .

DATA: BEGIN OF itab_flinfo OCCURS 6.

INCLUDE STRUCTURE spfli.

DATA: END OF itab_flinfo.

DATA: wa_flinfo like line of itab_flinfo.

SELECT * FROM spfli INTO TABLE itab_flinfo.

READ TABLE itab_flinfo INTO wa_flinfo

WITH KEY carrid = 'LH'

connid = '2463'.

IF sy-subrc = 0.

WRITE:/ wa_flinfo-carrid,

wa_flinfo-connid,

wa_flinfo-cityfrom,

wa_flinfo-cityto,

wa_flinfo-deptime,

wa_flinfo-arrtime.

ENDIF.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
537

Hai ,

First way of declaring internal table is effective.

Always internal tables without header line are prefered.

Because internal tables with header line are are obsolete,( old ,may not work in future,those keywords(occurs,on- change of,..) may be deleted in the next versions).

So First way of declaring internal table is effective.

Now free from confusion.

Regads,

Rama.Pammi

4 REPLIES 4
Read only

Former Member
0 Likes
537

Hi

TYPES: t_spfli TYPE STANDARD TABLE OF spfli. 
" The above statment does not have the header line, you need to create work area and use that work area

DATA: BEGIN OF itab_flinfo OCCURS 6.
INCLUDE STRUCTURE spfli.
DATA: END OF itab_flinfo.
" This statment will have the header with the internal table, when you looping this internal table there is no need of the Workarea

Regards

Sudheer

Read only

Former Member
0 Likes
537

hi,

both declarations are same

The difference comes when you want to add one more field to your internal table

Say you want to add one more field say CHECK(1) to your internal table , you cannot add this using the first method but you can do this using the second method

DATA: BEGIN OF itab_flinfo OCCURS 6.
INCLUDE STRUCTURE spfli.
data : CHECK(1).
DATA: END OF itab_flinfo.

Read only

Former Member
0 Likes
538

Hai ,

First way of declaring internal table is effective.

Always internal tables without header line are prefered.

Because internal tables with header line are are obsolete,( old ,may not work in future,those keywords(occurs,on- change of,..) may be deleted in the next versions).

So First way of declaring internal table is effective.

Now free from confusion.

Regads,

Rama.Pammi

Read only

Former Member
0 Likes
537

hi all,

thanks for ur help.

Regards

venkata prasad