Page 1 of 1

Internal tables in abap classes

PostPosted: Fri Nov 27, 2015 4:09 am
by halam
Hi all,

I'd like to ask you what is the best practise for internal table definition in ABAP classes in SE24.
Let's say I have 2 methods and each method will read data from MARA table and process this data in different way.
Both methods will read same columns from MARA table so internal table can have same structure.

Where should be the internal table LT_MARA declared?

1. would you declare it 2times, in each method separately like local method variable using
DATA: LT_MARA type table of MARA.

OR

2. would you create an attribute in class with table type MARA?

OR

3. it doesn't matter and I can choose any approach mentioned above?

Could you please explain shortly why you preffer selected solution?

Thank you.

Re: Internal tables in abap classes

PostPosted: Mon Nov 30, 2015 5:40 am
by Gothmog
Is the data used only within each method? If yes, local data.
However, the table type can be defined in the class, and used in both method.