‎2009 May 17 3:36 AM
Hi friends,
what is more performing, a creation of a internal table field one at a time or refer all standard table?
Exemple:
data: begin of ti_mara occurs 0,
matnr type mara-matnr,
mtart type mara-mtart,
seinr type mara-zeinr,
end of ti_mara.
or
data: ti_mara type mara occurs 0.
Well, here i would like use matnr, mtart and seinr... but i used all table on the last command, this cause a bad performance?
thank you for your attention,
Leo
‎2009 May 17 5:43 AM
Ok first thing is OCCURS 0 should not be used to define internal table as it not confirming the Object Oriented ABAP standards. OCCURS 0 is considered an obsolete command extension
So now you have 2 options:
1) DATA:
ti_mara TYPE STANDARD TABLE OF mara.
2) TYPES:
BEGIN OF TYPE i_mara,
matnr type mara-matnr,
mtart type mara-mtart,
seinr type mara-zeinr,
END OF TYPE i_mara.
* This is recommended in your case
DATA i_mara TYPE STANDARD TABLE OF typ_final,
wa_mara TYPE typ_final. "Work area If required
In your case i think you should go for option 2 rather than defining the internal table for Entire table MARA as this will allocate extra memory for the unrequired fields and hence bad performance.
Regards
Shital
‎2009 May 17 7:58 AM
Hi,
Both statements create internal table (reserve appropriate memory area).
In first situation only 3 fields are created, in the latter all fields from mara table are included here.
There is no point to have all the fields (i.e. 20) and use only 3 of them.
In each internal table row we would have 17 fields empty. So our memory here is "licking".
Option 2 would be better if you later in program use select stamenent at MARA table where all the entries be stored internally in program (for further execution) and only if the rest 17 fields are really needed for calculation.
This is case comparable to select statement, where you can choose all fields
select * from ... "bad performance as system has to transport unecessary data from DB
or project them (select particular fields only)
select field1 field2 from...
Alwasy try to consider how much memory will be reserved, how much data will be transported (in select statement) and get rid of unnecessary (not used) declaration. Golden rule: the less, the better
Regards
Marcin
‎2009 May 17 8:57 PM
please reserve the expression 'bad performance* fro something with relevance and not
for effect of 200 microseconds versus 250 microseconds.
Siegfried
‎2009 May 18 5:59 AM
Hi Leo,
There are 2 ways by which u can create an internal table:
1) Internal table with header line
2) Internal tab;e without header line
The one which you have defined are internal table with header line and if you use occurs 0 system by default allocates a memory of 8 kb even though your data is less than that.
Try to create internal tables without header line, where data is passed into work area. Also there is no memory wastage in this case as it will allocated dynamically as an when data is passed into the work area.
When you definining an internal table, pass only those fields that are required to be fetched from the database rather than taking all the fields of that table, this will drastically improve the perfromance, also use Primary index in the where clause.
Hope this might be useful.
Regards,
Prashant Gaikwad
‎2009 May 25 11:18 AM
Hi,
Now a days , we are not supposed to use internal table with header line or internal table without header line.
Always try to use internal table and work area.
Always try to declare the fields in the type declaration, which you want to fetch from the table.
See below a sample code. Always try to use data elements in the declaration (matnr) and not like this (mara-matnr).
**Type declaration
types: begin of ty_mara,
matnt type matnr,
ersda type ersda,
aenam type aenam,
end of ty_mara.
Internal table declaration and work area declaration
data: it_mara type standard table of ty_mara,
wa_mara type ty_mara.
**Fetch data
Select matnr
ersda
aenam
from mara
into table it_mara
where matnr eq -
.
**Read the internal table data through work area or loop the internal table through work area for further processing data
loop at it_mara into wa_mara.
or
read table it_mara into wa_mara.
Hope this will help you and make you clear.
Regards
Ramesh Sundaram