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: 

Performace Which is better ? : Bapi inside a loop OR Select from Tables

Former Member
0 Kudos

Hi Gurus,

I have a report which displays purchase info records.

If I am selecting from tables i need to use EINA, EINE, EORD and some other tables.

There is a BAPI which gets all purchase info records specific to a vendor , material , purchasing organisation.

QUESTION: Performace wise which is the better Approach, either selecting from tables or BAPI for Purchase info records

Regards

Avi.

1 ACCEPTED SOLUTION

GauthamV
Active Contributor
0 Kudos

If you are able to get all the details from 1 bapi then you can go with

that option instead of using select on multiple tables.

You can also check the trace difference between both using SM30 transaction.

6 REPLIES 6

GauthamV
Active Contributor
0 Kudos

If you are able to get all the details from 1 bapi then you can go with

that option instead of using select on multiple tables.

You can also check the trace difference between both using SM30 transaction.

Former Member
0 Kudos

Hi Gautam,

If I am using BAPI i need to use it inside a LOOP, so is it advicable?

Regards

Avi

0 Kudos

Whether it using BAPI or select. you need to check the performance. If you have full key for these tables EINA, EINE, EORD then mak a select outside of the loop and within loop use READ TABLE statement with binary search. of if you want multiple records within loop then use loop insdie loop.

Your final objective is to minimise the database hits . If you use bapi inside loop then your database hits will be more


select from EINA
select from EINE
select from EORD
loop at itab,
  read table EINA
  read table EINE
  read table EORD
endloop

0 Kudos

Hi,

Check the run time analysis for both cases. You are saying that you need to pick up data from 4 tables. Hence, you should be able to write a better select query using JOINs which should not cause much performance drain.Instead of picking data from the tables each time in a loop , i feel its better to fetch the data from the tables at one go using SELECT.Run SM30 and check Database time.

Regards,

Lakshman.

Former Member
0 Kudos

hi,

yes you can use BAPI inside a loop..

and its give u better performance then a select statement ..

regards

RItesh

anup_deshmukh4
Active Contributor
0 Kudos

Dependent's on you requirement again..coz if you want only selected data in report the BAPI will fetch unnecessery data also and you also can check if the BAPI has parameter for fetching Specific data if it suffice your requirement ..but again you can filter the data if you directly access table s by having a strong selection criteria ..!

you can very well try using in SE30

Edited by: Anup Deshmukh on Mar 30, 2010 6:51 AM