‎2007 May 01 9:35 AM
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.
‎2007 May 01 12:06 PM
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
‎2007 May 01 9:40 AM
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 WorkareaRegards
Sudheer
‎2007 May 01 9:43 AM
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.
‎2007 May 01 12:06 PM
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
‎2007 May 01 12:20 PM