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: 

Better way of declaring internal table for Large Number of Records.

Former Member
0 Kudos
223

Hi,

I am declaring an internal table which is supposed to hold more than 50,000 records.

I am confused between both the declarations below.

I understand that second one is standard one, but first one gives the flexibility to mention the size.

Will the second way of declaring give me run time errors due to space when more than 50k records are stored in this itab.

Any suggestions are appreciated.

1)


DATA: BEGIN OF it_tab1 OCCURS 10000,
       matnr LIKE marc-matnr,
       werks LIKE marc-werks,
      END OF it_tab1.
DATA: wa_itab1 LIKE it_itab1.

2)


TYPES: BEGIN OF ty_tab1,
       matnr LIKE marc-matnr,
       werks LIKE marc-werks,
      END OF ty_tab1.
DATA: it_tab1 TYPE STANDARD TABLE OF ty_tab1.
DATA: wa_itab1 TYPE ty_tab1.

Thanks.

6 REPLIES 6

former_member217316
Contributor
0 Kudos
145

Hi Vinay

You can choose option 1 for your declaration.

As far as option 2 is concerned, try someting like this after TYPES declaration:

DATA: it_tab1 TYPE TABLE OF ty_tab1,
           wa_itab1 LIKE LINE OF it_tab1.

Hope this helps.

Harsh

Former Member
0 Kudos
145

hi ,

I dont think so the second declaration will give any problem or error.Just go for the second option,its the best and standard one , as per the performance part is concerned.

Former Member
0 Kudos
145

HI Vinay

I beleive you should use the second method to declare your internal table. This is the standard one and will use less meemory for your internal table.

whereas in second case it will create an internal table with 10,000 line of body. Let assume you have 51,000 records till your 50,000 records the body of the internal table will be filled, but as soon as you will fetch the next record it will create an internal table's body with another 10,000 lines, which will lead to extra memory.

so its always better to create a structure and then define opur internal table and separate work area.

the separate work area will help us to indentify that we are addressing our internal table ot work area.

In first case it will not be easy to identify that when your are addressing your internal table and when to your work area.

I hope this will work for you.

<removed by moderator>

thanks

Lalit Gupta

Edited by: Thomas Zloch on Jun 30, 2010 12:32 PM - do not ask for points

Former Member
0 Kudos
145

Hi,

One important point is that OCCURS is simply not allowed in the OO(object oriented) context, and neither are header lines.

So you should always use TYPE TABLE OF and explicit work areas instead of header lines.

We need to create a work area like line of internal table.

TYPES: BEGIN OF ty_itab,
category_id TYPE comt_category_id,
category_text TYPE comt_category_text,
hierarchy_guid TYPE comt_hierarchy_guid,
non_assignable TYPE comt_non_assignable_category,
END OF ty_itab,
ty_t_itab TYPE TABLE OF ty_itab.
DATA: lt_itab TYPE ty_t_itab WITH HEADER LINE.

OR

DATA: lt_itab TYPE STANDARD TABLE OF ty_t_itab,
wa_itab like line of lt_itab.

May it helps you.

Regards.

Deepak Sharma

Former Member
0 Kudos
145

Hi

Use the second option for declaring internal table and in your select query you can use packet size option to optimize the performance.

Regards,

Vinod

ThomasZloch
Active Contributor
0 Kudos
145

Please inform yourself before posting, e.g. press F1 for OCCURS.

Thread locked.

Thomas