‎2007 Jun 14 6:25 AM
Hi,
How to avoid this select statement within loop.
This loop may affect the performance .
loop at idfkkop into waDfkkop.
concatenate waDfkkop-opbel
waDfkkop-opupw
waDfkkop-opupk
waDfkkop-opupz
into w_loobj1.
select single proid lockr from dfkklocks
into (waDfkkop-proid, waDfkkop-spzah)
where loobj1 = w_loobj1
and gpart = waDfkkop-gpart.
if sy-subrc = 0.
modify idfkkop from waDfkkop.
endif.
clear w_loobj1.
endloop.
Thanks
Venkat
‎2007 Jun 14 6:30 AM
You can first loop through the whole table and concatenate fields and put it into other internal table.
Then use FOR ALL ENTRIES clause in the SELECT statement using that new internal table.
‎2007 Jun 14 6:36 AM
Hi,
Try this..
* create a new internal table with the two fields..
data: begin of wa_obj,
loobj1 TYPE dfkklocks-loobj1,
gpart TYPE dfkklocks-gpart,
PROID TYPE dfkklocks-PROID,
LOCKR TYPE dfkklocks-LOCKR,
end of wa_obj.
data: t_obj like table of WA_OBJ.
data: t_obj_1 like table of WA_OBJ.
* process the internal table to prepare the internal table T_OBJ.
loop at idfkkop into waDfkkop.
concatenate waDfkkop-opbel
waDfkkop-opupw
waDfkkop-opupk
waDfkkop-opupz
into w_loobj1.
wa_obj-loobj1 = w_loobj1.
wa_obj-gpart = waDfkkop-gpart.
append wa_obj to t_obj.
ENDLOOP.
if NOT T_OBJ[] Is initial.
* Select the data from the database table.
SELECT PROID LOCKR LOOBJ1 GPART
INTO TABLE T_OBJ_1
FROM dfkklocks
FOR ALL ENTRIES IN T_OBJ
WHERE LOOBJ1 = T_OBJ-LOOBJ1
AND GPART = T_OBJ-GPART.
ENDIF.
loop at idfkkop into waDfkkop.
concatenate waDfkkop-opbel
waDfkkop-opupw
waDfkkop-opupk
waDfkkop-opupz
into w_loobj1.
READ TABLE LT_OBJ_1 INTO WA_OBJ
WITH KEY loobj1 = w_loobj1
gpart = waDfkkop-gpart.
if sy-subrc = 0.* modify idfkkop from waDfkkop.
endif.
clear w_loobj1.
endloop.
Thanks
Naren
‎2007 Jun 14 7:46 AM
hi,
u can avoid select statement in the loop like this,
ex:
select * from kna1 into table itab where kunnr in p_kunnr.
if not itab[] is initial.
select * from ekko into table itab1 for all entries in itab where kunnr = itab-kunnr.
endif.
reward points if helpful.
regards,
seshu.