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

declaring internal tables

Former Member
0 Likes
672

why do we declare internal tables in this way

TYPES: BEGIN OF ty_t501t,

..

...

END OF ty_t501t.

DATA: gt_list1 TYPE STANDARD TABLE OF ty_list1,

why not this

DATA: BEGIN OF ITAB OCCURS 0,

....

....

.....

END OF ITAB.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
629

Hi ,

The reason for this being that is it not a good practice to declare internal tables with header lines , as they are not allowed in object oriented concept .

When you declare an internal table with header line it results in the same name for two objects one the internal table and the other the work area , hence the practice to define separate data objects for table and the work area.

Regards,

Arun

4 REPLIES 4
Read only

Former Member
0 Likes
630

Hi ,

The reason for this being that is it not a good practice to declare internal tables with header lines , as they are not allowed in object oriented concept .

When you declare an internal table with header line it results in the same name for two objects one the internal table and the other the work area , hence the practice to define separate data objects for table and the work area.

Regards,

Arun

Read only

former_member156446
Active Contributor
0 Likes
629

if at all if you need any changes if you make changes to Ty... will be enough...

and you can create many internal tables... using that TY with a single line code...

Read only

former_member209217
Active Contributor
0 Likes
629

Hi,

Declaring internal table with a header line decreases performance.

Its better to have internal table without header line and a work area to work with it.

Its improves performance.

Also wen u work with internal table with header line it creates confusion that whether ur working with the header line or body of the internal table.

Also declaring internal table with header line is obsolete one.

LOOP AT ITAB----


>Working with header line.(Confusion whether ur referring header or body of internal table)

LOOP AT ITAB INTO WA------>Working with internal table widout header line and an work area

Regards,

Lakshman.

Edited by: Lakshman N on Aug 14, 2009 7:25 AM

Read only

Former Member
0 Likes
629

When we declare an internal table using DATA statement, it creates an internal table with headerline.

Use of internal tables with header is not recommended. Such internal tables can cause serious bugs

in the code.

So normal we declare a type using TYPE statement and then declare the internal table using the newly declared

type.

In this case we have to create a separate workarea to perform operations on the internal table.

Use of workarea makes our code easy to understand. Also there are less chances of error if we use workareas

rather than internal table with headerline and bebugging becomes simple.