‎2008 Jun 24 6:32 AM
Hi,
Kindly help on Performance issue..suggest some changes.
LOOP AT p0001.
MOVE: p0001-pernr TO pernr.
MOVE: p0001-pernr TO wa_data-pernr.
Add name
LOOP AT p0002 WHERE begda LE pn-endda
AND endda GE pn-begda
AND pernr = p0001-pernr.
MOVE: p0002-vorna TO wa_data-vorna.
MOVE: p0002-nachn TO wa_data-nachn.
ENDLOOP.
SELECT SINGLE land1
INTO land1
FROM t001
WHERE bukrs = p0001-bukrs.
SELECT SINGLE molga
INTO user_molga
FROM t500l
WHERE intca = land1.
IF skip = 0.
INSERT wa_data INTO TABLE it_data.
ENDIF.
CLEAR wa_data.
ENDLOOP.
‎2008 Jun 24 6:39 AM
Hi kiran ,
Instead of using two select single statements select the values into an interbal table in the beginning and use READ TABLE statements within the loop. This should make the loop work faster.
‎2008 Jun 24 6:42 AM
Hi,
LOOP AT p0001.
MOVE: p0001-pernr TO pernr.
MOVE: p0001-pernr TO wa_data-pernr.
READ tables pa0002, t001 and t500I here...instead of select stmts.
IF skip = 0.
INSERT wa_data INTO TABLE it_data.
ENDIF.
CLEAR wa_data.
ENDLOOP.
‎2008 Jun 24 6:52 AM
Hi try avoiding the nested loop..try to use for all entries or read statements.
In case, you find it is inevitable to avoid the loops.. use parallel cursor method.
Check out these codes :
Conventional Method
loop at lt_vbpa into wa_vbpa.
loop at lt_kna1 into wa_kna1 where kunnr = wa_vbpa-kunnr.
****** Your Actual logic within inner loop ******
endloop.
endloop.
Parallel Cursor Method
sort: lt_vbpa by kunnr, "Sorting by key is very important
lt_kna1 by kunnr. "Same key which is used for where condition is used here
loop at lt_vbpa into wa_vbpa.
read lt_kna1 into wa_kna1 " This sets the sy-tabix
with key kunnr = wa_vbpa-kunnr
binary search.
if sy-subrc = 0. "Does not enter the inner loop
v_kna1_index = sy-tabix.
loop at lt_kna1 into wa_kna1 from v_kna1_index. "Avoiding Where clause
if wa_kna1-kunnr <> wa_vbpa-kunnr. "This checks whether to exit out of loop
exit.
endif.
****** Your Actual logic within inner loop ******
endloop. "KNA1 Loop
endif.
endloop. " VBPA Loop
Reward if helpful.
Regards.
‎2008 Jun 24 6:53 AM
Hi,
The most performance issue lies in SELECT SINGLE statement...
In substitution of SINGLE use UP TO 1 ROWS before where clause in select statement and also in the inner to get value from internal tables its better you go for READ TABLE with KEY <key name> = <value>
You will have definetly change in the perfomance and the difference would be more...
Mostly never bother about SYSTEM effort,... Mainly think about the interaction with database first and then the system.
As you are interacting with database with select single statment go for the substituion i had stated.
Hope this would be helpful.
please revert back if any suggestions needed.
Regards
Narin Nandivada
‎2008 Jun 24 8:26 AM
hi,
using two select single single statements will give u serious Performance Issues. To make ur code more efficient u should Either fetch the data into an internal table and the process from there. Use a READ statement while working with the Internal Table instead of LOOP AT statement.
Reward points if useful
Sumit Agarwal
‎2008 Jun 24 8:38 AM
I believe that you would be using PNP LDB.
GET PERNR will be bringing in data in P0001 & P0002
For an employee you could not change the company code.
1) So both the SELECT Statmenst for finding out LAND1 and MOLGA will be moved out of the loop.
2) Insted of looping at P0002 - Use provide-endprovide block on P0002.
Loop at p0001.
provide * from p002 between pn-begda and pn-endda.
move...
endprovide.
endloop.