Application Development 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: 

good practices for ECC 6.0 wr.t. internal tables..

Former Member
0 Kudos
104

hi,

i am told that when defining internal tables in ecc 6.0, we shud avoid using OCCURS and WITH HEADER LINE. and always use work areas..

is this right ? is this a good practice or a must ?

i followed this and created an internal table without a header line .then i am using a collect statement in my programn which fails and says that IT is not with header line !!

COLLECT ITT.

what to do ?

thks

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
60

Yes, that is correct. SAP is pushing the use of ABAP Objects and you can not use OCCURS or HEADER LINEs in the ABAP OO context. You should always defined explicitly and a work area.

Data: itab type table of mara.
Data: wa like line of itab.

So then you must keep this in mind when doing any operations on internal tables, like in the case of the COLLECT statement, the syntax would be.



wa-field1 = '1'.
wa-field2 = '2'.
Collect wa into itab.

Regards,

Rich Heilman

2 REPLIES 2

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
61

Yes, that is correct. SAP is pushing the use of ABAP Objects and you can not use OCCURS or HEADER LINEs in the ABAP OO context. You should always defined explicitly and a work area.

Data: itab type table of mara.
Data: wa like line of itab.

So then you must keep this in mind when doing any operations on internal tables, like in the case of the COLLECT statement, the syntax would be.



wa-field1 = '1'.
wa-field2 = '2'.
Collect wa into itab.

Regards,

Rich Heilman

matt
Active Contributor
0 Kudos
60

Whether you're using ABAP Objects or not, you should still not use tables with header lines. When you refer to ITAB, you don't know whether it is the table or the header line. This is bad. A specific work-area is good.