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

Performance in Declaring Internal table

Former Member
0 Likes
950

Hi ,

Hope this query might seem very simple but I wanted to make it clear. I want to declare an itab with all the fields of the database table. There are many fields in db table.

Should I go for TYPES or DATA statement?

If I define with DATA , Is it "with occurs 0 with header line" or use separate work area. Pls suggest.

Thanks,

Rajani.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
815

HI,

You can use both the TYPES and DATA no problem..

but it is always advisable that use separate work area just like this..

data:

begin of fs_structure,

f1 type xyz,

f2 type abc,

end of fs_structure.

data:

t_table like standard table of fs_structure.

it will be more efficient..

6 REPLIES 6
Read only

Former Member
0 Likes
815

hiii,

if you want to use all the fields for internal table from DB table then you can use like below

DATA:
   lt_files     LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE.

it will make your internal table with header line with all the fields.

for without header line table you need to define separate work area for it.like below.

DATA:
  ls_excel       TYPE alsmex_tabline.
                                       " Work Area to hold Rows for Table

*"--------------------------------------------------------------------*
* Internal table to hold Rows for Table with Excel Data.              *
*"--------------------------------------------------------------------*
DATA:
  it_excel      TYPE TABLE OF alsmex_tabline.

performance will be same if you use with or without header line internal table.

thx

twinkal.

Read only

Former Member
0 Likes
815

Hi,

You can declare a internal table either using data or types.

If you want to use data statement you need to use occurs 0 with header line. Or if you want to use types you need to declare internal table with or without header line and a work area.

Thanks,

Sriram Ponna.

Read only

valter_oliveira
Active Contributor
0 Likes
815

Hello.

1 - If possible use types. If you have more than one internal tables of same type, if you want to change the type, with types, only one change that affects all tables.


TYPES: BEGIN OF ty_out,
         field1 TYPE x,
         field2 TYPE y,
       END OF ty_out.
DATA: it_out TYPE STANDARD TABLE OF ty_out,
      wa_out TYPE ty_out.

2 - Always use work area (instead of OCCURS 0). Work areas are faster (check Se30, tips&tricks), work in OO programing and OCCURS is an obsolete statement.

Regards.

Valter Oliveira.

Read only

Former Member
0 Likes
815

Hi,

Create Structure if u want to use all the data of the table using DATA with OCCURS 0.

Regards,

Amit G.

Read only

Former Member
0 Likes
816

HI,

You can use both the TYPES and DATA no problem..

but it is always advisable that use separate work area just like this..

data:

begin of fs_structure,

f1 type xyz,

f2 type abc,

end of fs_structure.

data:

t_table like standard table of fs_structure.

it will be more efficient..

Read only

Former Member
0 Likes
815

Hi ,

This is also one of the best way to declare internal table for performance.

TYPES : BEGIN OF typ_itab,

f1,

f2,

,

fn,

END OF typ_itab.

DATA : it_itab TYPE STANDARD TABLE OF typ_itab INITIAL SIZE 1,

wa_itab TYPE typ_itab.

Regards,

Vishvesh