‎2007 Nov 03 12:06 PM
What is worng with this code. it's giving error internal table with no header line
tables: spfli.
types: begin of it_line,
carrid type s_carrid,
connid type s_conn_id,
end of it_line.
types: it_tt type standard table of it_line with default key.
data: it type it_line.
select * from spfli into corresponding fields of table it.
loop at it.
write it-carrid, it-connid.
endloop.
‎2007 Nov 03 12:10 PM
Replace the "data: it type it_line."
With
data : it like it_line occurs 0 with header line.
‎2007 Nov 03 12:15 PM
use this code it wil b helpful
REPORT zmftest2.
tables: spfli.
types: begin of it_line,
carrid type s_carrid,
connid type s_conn_id,
end of it_line.
types: it_tt type standard table of it_line with default key initial size 0.
data: it type it_tt with header line.
select carrid from spfli into table it.
loop at it.
write: it-carrid.
endloop.
‎2007 Nov 03 12:22 PM
Thanks, your answers are helpful. but could you please clarfy few more doubts in this program.
1. what is the difference between occurs and intial size.
2.what is the need of header line as we have line type
3. what are the different ways to define it with header line
points for sure
‎2007 Nov 03 12:31 PM
Hi Ajay,
Here some examples on iternal table declarations..
REPORT ZTYPES .
* Table declaration (old method)
DATA: BEGIN OF tab_ekpo OCCURS 0, "itab with header line
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
END OF tab_ekpo.
*Table declaration (new method) "USE THIS WAY!!!
TYPES: BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
END OF t_ekpo.
DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0, "itab
wa_ekpo TYPE t_ekpo. "work area (header line)
* Build internal table and work area from existing internal table
DATA: it_datatab LIKE tab_ekpo OCCURS 0, "old method
wa_datatab LIKE LINE OF tab_ekpo.
* Build internal table and work area from existing internal table,
* adding additional fields
TYPES: BEGIN OF t_repdata.
INCLUDE STRUCTURE tab_ekpo. "could include EKKO table itself!!
TYPES: bukrs TYPE ekpo-werks,
bstyp TYPE ekpo-bukrs.
TYPES: END OF t_repdata.
DATA: it_repdata TYPE STANDARD TABLE OF t_repdata INITIAL SIZE 0, "itab
wa_repdata TYPE t_repdata. "work area (header line)
‎2007 Nov 03 4:59 PM
Hi,
Declare your internal table as below :
tables: spfli.
types: begin of it_line,
carrid type s_carrid,
connid type s_conn_id,
end of it_line.
data : it_tt type like it_line occurs 0 with header line.Thanks,
Sriram Ponna.
‎2007 Nov 03 7:29 PM
tables: spfli.
types: begin of it_line,
carrid type s_carrid,
connid type s_conn_id,
end of it_line.
types: it_tt type standard table of it_line with default key.
data: it type it_line.
select * from spfli into corresponding fields of table <b>it_tt.</b>
loop at <b>it_tt into it</b>.
write it-carrid, it-connid.
endloop.
‎2007 Nov 03 8:59 PM
tables: spfli.
types: begin of it_line,
carrid type s_carrid,
connid type s_conn_id,
end of it_line.
types: it_tt type standard table of it_line with default key.
data: it type it_line <b>occurs 0 with header line. " this you want to correct</b>
select * from spfli into corresponding fields of table it.
loop at it.
write it-carrid, it-connid.
endloop.