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 table

Former Member
0 Likes
10,662

Hi Friends,

Their are 3 ways we declare internal table using field string or not using like below.

1)

types: begin of ty_fs,
             a type ztable-a,
             b type ztable-b,
              ------------>
              ------------>
             ------------->
            end of ty_fs.

 data: it_fs type standard table of ty_fs intial size 0.

2)

types: begin of ty_fs.
                 include structure ztable.
     types : end of ty_fs.

data: it_fs type standard table of ty_fs intial size 0.

3)

tables: ztable.
 
 data: it_fs type standard table of ztable intial size 0.

Please suggest which way is better in memory consuming and performance wise.

thanks&regards,

kat.

Edited by: Matt on Apr 14, 2009 10:33 AM - added tags

9 REPLIES 9
Read only

matt
Active Contributor
0 Likes
4,428

Tables will use more memory because you've declared an additional work area. You don't need it for your third option. Otherwise there is no difference.

Defining TYPES and then creating data using those types is better programming.

For this precise definition I'd use

 data: it_fs type standard table of ztable..

( initial size is not necessary ).

But if you want performance, then according to what the requirements are, you'd be better of with SORTED or HASHED tables.

matt

Read only

Former Member
0 Likes
4,428

Hi,

1st method of declaring an internal table is good coding, since u need only certain fields its good coding to declare only those particular fields in the structure instead of INCLUDING the whole structure...

If we want whole structure then u can go for 3rd method instead of the other two...

Regards,.

Pavan

Read only

Former Member
0 Likes
4,428

Here the first way includes all the fields of the table.

Edited by: kat k on Apr 14, 2009 10:41 AM

Read only

0 Likes
4,428

Hi,

Try declaring this way.

Example:

TYPES: BEGIN OF ty_ukmbp,

partner TYPE ukmbp_cms-partner,

check_rule TYPE ukmbp_cms-check_rule,

credit_group TYPE ukmbp_cms-credit_group,

END OF ty_ukmbp.

DATA : t_ukmbp TYPE STANDARD TABLE OF ty_ukmbp.

DATA : wa_ukmbp TYPE ty_ukmbp.

Clear: wa_ukmbp.

Note: Always try to clear the work area after using it.

Thanks,

Babu Kilari

Read only

0 Likes
4,428

Hi Babu,

here i'm just only concerned with the internal table declarations and no other code excluding i mentioned above.

thanks,

kat.

Read only

0 Likes
4,428

Then,

Go for the first option which you have mentioned(Similar to the one that i have mentioned)

Thanks,

Babu Kilari

Read only

Former Member
0 Likes
4,428

Hello,

below process is the best for declaring internal table.


types: begin of ty_fs,
             matnr type matnr,
             werks  type werks_d,
             ..............................
             ..............................
           end of ty_fs.
 
 data:  itab_fs type standard table of ty_fs, " internal table without header lline
           wa_fs type ty_fs. " work area of your internal table.

You can measure runtime analysis in the following path.

SE38>Environment>Examples-->Performance Examples.

Then type your code and execute to meausre comparative runtime.

Regards

Arindam

Read only

Former Member
0 Likes
4,428

First option is good for performance.

Regards,

Joan

Read only

Former Member
0 Likes
4,428

Thank you very much for the support.