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: 

intenal table with out headerline

Former Member
0 Kudos

hi,

i have a doubt,please clarify.

data:itab like <databse table> occurs 0 with header line.

or

data:itab like <databse table>occurs 0,

wa like line type of itab.

in above two cases , in my view no difference.

in first case there will be one workarea will be created with same name itab,

in second case we are explicitly creating work area.

ok.

here my doubt is in what cases it is madatory to create internal table with explicitly work area?

thanks in advance.

venu

1 ACCEPTED SOLUTION

Former Member
0 Kudos

while using some class method thy only accept table with body.... sooo whn u use with header line thy give error cant convert...

soo better use table with body fill data with help of work area and pass table..

7 REPLIES 7

Former Member
0 Kudos

while using some class method thy only accept table with body.... sooo whn u use with header line thy give error cant convert...

soo better use table with body fill data with help of work area and pass table..

Former Member
0 Kudos

hi,

if u specify without header line:

header for the internal table is not created. in that case, for ex if u r looping, u have to use the work area to process the data.

In this case u have to explicity use work area as the internal table doest have an opp to pass the values to header.

ie:

for an internal table without header:

loop at itab into wa_itab. <-- here work area is mandatory

for an internal table with header

loop at itab. <-- values are populated in the header

loop at itab into wa_itab. <-- this is optional

regards,

madhu

Former Member
0 Kudos

Hi Venugopal..

It is recommended to create the workarea for the internal table explicitly, but it is not mandatory.

If we create a internal table with header line, then we can use the same as the workarea, that is mostly used in loops.

hope this info will clear some of ur doubt.

Reward points if helpful.

Regards

Karan

0 Kudos

Hello.

3 reasons to use explicit work area:

- work areas are faster (check tips&tricks in SE30)

- they will work in methods, and object oriented programs

- internal tables without explicit work area are kind of obsolete and not recomended.

Best regards.

Valter Oliveira.

Former Member
0 Kudos

Hi Venugopal

In the first case, i.e. itab with header line, here itab is used as table as well as work area.

Generally it is not preferred, why since data recurrence will takes place here i.e. ABAP processor will have to hardly process the ABAP statements.

And as u know in the second case, we're defining explicitly another work area, which is more comfortable for the ABAP processor to read.

If u found it useful, reward me plz..

Thanks

Suren

Former Member
0 Kudos

Hi,

You shouldn't use the occurs clause anymore! Like Valter explained, it's obsolete. Instead use as an internal table declaration:

TYPES: BEGIN OF ty_itab,
                 a   type c,
                 b   type d,
                 c   type i,
         END OF ty_itab.

DATA: itab TYPE TABLE OF ty_itab,
         wa_itab type ty_itab.

This concept also works under OO.

Have success,

Heinz

Former Member
0 Kudos

hi,

abap object oriented programming in higher versions doesn't allow internal table with header line, so we can create internal table with out header line.

for that one we follow two approches...

1)

TYPES: BEGIN OF LINE,

COL1 TYPE I,

COL2 TYPE I,

END OF LINE.

DATA : ITAB TYPE STANDARD TABLE OF LINE,

WA TYPE LINE.

2) In second case create line type(structure) and row type by using SE11.

SE11->select DATA ELEMENT object> here select STRUCTURE object and provide required fields>now select ROW TYPE object here provide LINE TYPE( STRCTURE which is created in previous)-> SAVE and activate.

IN the above case STRCTURE acts as WORK-AREA AND ROW TYPE acts as body.

object oriented programming doesn't support to using LIKE key word.

regards,

Ashok