‎2008 Jan 11 1:49 PM
hi all,
i am facing a with a performance issue with below logic.
LOOP AT tcust.
SELECT SINGLE * FROM kna1
WHERE kunnr EQ tcust-kunnr.
LOOP AT t_materials.
PERFORM f1000_get_price.
ENDLOOP.
ENDLOOP.
here tcust having one row & t_materials is having 250 rows so that perform is calling 250- times can u pls help me out in this issue.
‎2008 Jan 11 2:06 PM
‎2008 Jan 11 2:09 PM
Hi,
You can change the code as below :
Instead using the code below :
LOOP AT tcust.
SELECT SINGLE * FROM kna1
WHERE kunnr EQ tcust-kunnr.
You can use as
select <fieldanames> from kna1 into ito tbale itab for all entries of tcust.
Now you will have the itab with data(250) line items.
Loop at itab.
PERFORM f1000_get_price.
endloop.
Now also it has to go for 250 iterations. We cannot avoid this.
Thanks,
Sriram POnna.
‎2008 Jan 11 2:47 PM
Krishna,
If you want to get the price for 250 materials for each of the customers in TCUST, then the code is doing what it is supposed to.
The only thing you can improve is to change the subroutine f1000_get_price so that it can take a table as input (T_MATERIALS), and process them all in one shot. This involves significant changes to the subroutine.
Another thing you can improve upon is to replace LOOP and SELECT SINGLE * with FOR ALL ENTRIES option. Again, this will also involve significant changes to the code and it looks like you are new to ABAP.