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

itab header line problem

Former Member
0 Likes
834

hello abap gurus,

i was trying to create an internal table of type of my ztable. and when i was trying to execute my program , it was giving error, as " table type does not have header line.

DATA: ITAB type ZTABLE with header line.

what is wrong in this, can some one help me with this.

thanks

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
727

Hello Saritha

The correct statement would be:

DATA:
  itab   TYPE ztable OCCURS 0 WITH HEADER LINE.

However, using header lines is a sign of ppor ABAP programming. Do no use them anymore, they mess up any program.

Instead, use table types and work area as shown below:

DATA:
  gt_itab     TYPE STANDARD TABLE OF ztable,  " table type
  gs_line     TYPE ZTABLE.                                 " work area

  LOOP AT gt_itab INTO gs_line.
  ...
  ENDLOOP.

Regards

Uwe

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
727

Try this.

DATA: ITAB type <b>TABLE OF</b> ZTABLE with header line.

Regards,

RIch Heilman

Read only

uwe_schieferstein
Active Contributor
0 Likes
728

Hello Saritha

The correct statement would be:

DATA:
  itab   TYPE ztable OCCURS 0 WITH HEADER LINE.

However, using header lines is a sign of ppor ABAP programming. Do no use them anymore, they mess up any program.

Instead, use table types and work area as shown below:

DATA:
  gt_itab     TYPE STANDARD TABLE OF ztable,  " table type
  gs_line     TYPE ZTABLE.                                 " work area

  LOOP AT gt_itab INTO gs_line.
  ...
  ENDLOOP.

Regards

Uwe

Read only

Former Member
0 Likes
727

thank you very much uwe and riche

Read only

Former Member
0 Likes
727

For Better coding Standard :

<b>Internal table with header line :</b>

data : begin of itab occurs 0,

fld1 type c,

fld2 type c,

end of itab.

<b>Internal table without header line :</b>

  • Declare Structure

types : begin of ty_itab,

fld1 type c,

fld2 type i,

end of ty_itab

  • Internal table without header line

data i_itab type standard table of ty_itab

  • Work area

data wa_itab like line of i_itab.

Try to use always Internal table without header line.

Hope you got my point and please let me know if you have any question

Thanks

Seshu