Application Development 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: 

performance tunning

Former Member
0 Kudos
156

hi sap guru's,

please help me regarding performance tunning.

loop at itab

select matnr maktx from mara into jtab where matnr = itab-matnr.

append jtab.

endloop.

loop statement will work in application server,

and select query fires in database server.

now if i want to tune performance ,

which statement i need to tune,

please forward any document with is releated to performance tunning , that really helps me.

thanks & regards

prasad

1 ACCEPTED SOLUTION

bpawanchand
Active Contributor
0 Kudos
121

Hi

Its not a good idea to write a SELECt statement inside a LOOP and ENDLOOP .

loop at itab

select matnr maktx from mara into jtab where matnr = itab-matnr.

append jtab.

endloop.

First you read all teh data into ITAb and then its better to use

FOR ALL ENTRIES

example

SELECT *

FROM <TAB>

INTO <itab>

SELECT *

FROM <tab2>

INTO <jtab>

FOR ALL ENTRIES IN TABLE <itab>

WHERE MATNR EQ = ITAB-MATNR.

I hope this helps you

Regards

Pavan

7 REPLIES 7

bpawanchand
Active Contributor
0 Kudos
122

Hi

Its not a good idea to write a SELECt statement inside a LOOP and ENDLOOP .

loop at itab

select matnr maktx from mara into jtab where matnr = itab-matnr.

append jtab.

endloop.

First you read all teh data into ITAb and then its better to use

FOR ALL ENTRIES

example

SELECT *

FROM <TAB>

INTO <itab>

SELECT *

FROM <tab2>

INTO <jtab>

FOR ALL ENTRIES IN TABLE <itab>

WHERE MATNR EQ = ITAB-MATNR.

I hope this helps you

Regards

Pavan

Former Member
0 Kudos
121

hi,

Remove select statement from loop and endloop and do this way ...


if not itab[] is initial.
select matnr maktx from mara into table jtab 
for all entries in itab
where matnr = itab-matnr.
if sy-subrc = 0.
endif.
endif.

Check out the below related thread ...

Former Member
0 Kudos
121

Hi Prasad,

Please check this link

SELECT statement hit the database. If we write select statement in side the loop , then every time it hits the database.

For every record it hits the database and fetches the data. It better to get all the data from the database into a internal table and the process the data accordingly.

Best regards,

raam

Former Member
0 Kudos
121

Hi

try for this code

if there is a relation between itab and jtab

then

select * from mara into corresponding feilds of table itab

for all entries in jtab.

where matnr = jtab-matnr.

replace this code lie this

thanks

Sachhidananda

Edited by: sachhidananda tripathy on Jul 30, 2008 7:31 AM

Former Member
0 Kudos
121

dont use select inside loop, so its better go for all entries

select matnr maktx

from mara

into jtab

for all entiries in itab

where matnr = itab-matnr.

With luck,

pritam.

Former Member
0 Kudos
121

Hi kantu ,

Never used select inside a loop its blunder mistake but in some exceptional cases you can do with the approval from the quality team . better use for all entries like example

select matnr

maktx

from mara

into jtab

for all entiries in itab

where matnr = itab-matnr.

regards

fareed

Former Member
0 Kudos
121

Hi,

Do not use select statements inside a loop. You can use for all entries.


select matnr maktx from mara into table j1tab for all entries in itab where matnr = itab-matnr.
loop at itab
read table j1tab with key matnr = itab-matnr.
if sy-subrc = 0.
     move  j1tab to jtab.
     append jtab.
endif.
endloop.

Regards

Samson.