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

internal table with header line

Former Member
0 Likes
3,455

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.

7 REPLIES 7
Read only

Former Member
0 Likes
1,024

Replace the "data: it type it_line."

With

data : it like it_line occurs 0 with header line.

Read only

0 Likes
1,024

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.

Read only

0 Likes
1,024

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

Read only

0 Likes
1,024

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)

Read only

Former Member
0 Likes
1,024

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.

Read only

rainer_hbenthal
Active Contributor
0 Likes
1,024

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.

Read only

Former Member
0 Likes
1,024

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.