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

Data declaration

Former Member
0 Likes
1,583

Hi Guru's,

Please advice which is da best amoung the below said.

Normally I feel more comfortable using the second one is there any problem using the second one??

Please let me know..

1.

TYPES: BEGIN OF typ_item,
matnr TYPE matnr,
werks TYPE werks_d,
END OF typ_item.
DATA: gt_item TYPE TABLE OF typ_item,
gs_item TYPE typ_item,
gt_where TYPE TABLE OF string.

2.

DATA: begin of itab occurs 0,
             matnr like mara-matnr,
             werks like marc-werks,
          end of itab.

3.

TYPES : BEGIN OF typ_mara,
                 matnr type mara-matnr,
                werks type marc-werks,
            end of typ_mara.
data: typ_mara type table of mara with header line.

Thanks

Raj

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,545

Hi Raj,

The data decalration preferably should be like:



Types: Begin of t_tab,
             field1 type c,
             field2 type c,
            End of t_tab.

Data: It_tab type standard table of t_tab,
         wa_tab type t_tab.

Then for fetching the data you can do like:

Loop at it_tab into wa_tab.

Endloop.

Hope it helps

Regards

Mansi

15 REPLIES 15
Read only

Former Member
0 Likes
1,545

1st one is the best...

Read only

GauthamV
Active Contributor
0 Likes
1,545

If you look it from performance point of view First one is the better option.

You can check the same from SE30 - tips and tricks in application toolbar.

Read only

Former Member
0 Likes
1,545

Hi,

Methods 2 and 3 are obsolete statements which make use of internal tables with header line concept and are only for demo purposes.

Method 1 is latest way and can be implemented.

Methods 2 and 3 usage will give u Extended program check error in obsolete statements.

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,545

Hi,

First one is the best approach.

Declare a type first.

Create an internal table without header line.

Instead of header line create a work area.

And use loop from internal table into work area.

Regards,

Tarun

Read only

former_member209217
Active Contributor
0 Likes
1,545

Hi Raj,

The first one will give better performance than the remaining ones.

It will be performance drain if we work with internal tables having header lines.It will be better if we create one work area for that internal table and use that.

Also occurs 0 and header line statements may become obsolete in the upcoming versions.

Hope it will be useful.

Regards,

Lakshman

Read only

Former Member
0 Likes
1,546

Hi Raj,

The data decalration preferably should be like:



Types: Begin of t_tab,
             field1 type c,
             field2 type c,
            End of t_tab.

Data: It_tab type standard table of t_tab,
         wa_tab type t_tab.

Then for fetching the data you can do like:

Loop at it_tab into wa_tab.

Endloop.

Hope it helps

Regards

Mansi

Read only

0 Likes
1,545

Hi,

Thank you for your advice !!

But normally I use the second one and I feel more comfortable in it but now I would like to

change to first one. When I use like I fetch the records by using ALL ENTRIES ,

APPENDING SECOND ITAB TO FIRST ITAB , SELECT SINGLE etc ....

my question is if Iam changing to second one will there be change in logical flow ?

Also please advice purpose of gt_where TYPE TABLE OF string in the below said.

also advice me where is da headerline and pupose of declaring it seperately..

TYPES: BEGIN OF typ_item,
matnr TYPE matnr,
werks TYPE werks_d,
END OF typ_item.

DATA: gt_item TYPE TABLE OF typ_item,
gs_item TYPE typ_item,
gt_where TYPE TABLE OF string.

Thanks

Raj

Edited by: Raj rockss on Mar 26, 2009 7:58 AM

Read only

0 Likes
1,545

Hi Raj,

The second method is not preferable in the new version 6.0,

In the second option it will create you an internal table with header line,

so you while looping it you are not required to write:

loop at itab into wa,

you can only write:



Your select query into itab.
 loop at itab.

Append second itab from first itab on some condition.

Endloop

And gt_where type table of string will make

you an internal table gt_where without header line.

Hope it helps

Regards

Mansi

Read only

0 Likes
1,545

Hi ,

Thank you !!

Read only

Former Member
0 Likes
1,545

Hi:

1st is the best option, since this is the way to declare the internal table as a local object, which further effects the performanance.

So use 1st only.

Regards

Shashi

Read only

0 Likes
1,545

first one is the best one

and also if u use the internal table with header line u vll face some problems and lots of confusion

table and work area are shud be different to make it clear an easy to understand.

second and third are obsolete now and can be used gives no performance issue.

its like goto wich is obsolete hope u got it.

Read only

Former Member
0 Likes
1,545

First one is the best approach as we should always prefer TYPE declaration instead of LIKE.

Read only

Former Member
0 Likes
1,545

Hello,

The first one is the best approach.

The other two appraches should not be used as they have become obsolete.

Read only

Former Member
0 Likes
1,545

U should not use 2 nd and 3 rd one it is old now.

use this

Types: Begin of ls_tab,

matnr type mara-matnr,

mtart type mara-mtart,

End of ls_tab.

Data: It_tab type standard table of ls_tab,

wa_tab type ls_tab.

then for processing use like

Loop at lt_tab into wa_tab.

logic

Endloop.

Regards

Read only

Former Member
0 Likes
1,545

Hi All,

Thanks a lot !!

miles to go before u sleep***

Raj ***