‎2010 Sep 28 10:43 AM
Hi experts,
Pls suggest to remove the select inside loop.
LOOP AT lt_likp INTO lwa_likp.
IF lwa_likp-lgtor <> zgwm_shp_ctrl-lgtor OR
lwa_likp-lgbzo <> zgwm_shp_ctrl-lgbzo.
SELECT SINGLE * FROM likp
INTO lwa_likp
WHERE vbeln = lwa_likp-vbeln.
UPDATE likp
SET lgtor = zgwm_shp_ctrl-lgtor
lgbzo = zgwm_shp_ctrl-lgbzo
WHERE vbeln = lwa_likp-vbeln.
ENDIF.
ENDLOOP.
‎2010 Sep 28 12:00 PM
Hi Madan,
Use the below code which removes the select statement outside the loop :-
if not lt_likp[] is initial.
sort lt_likp.
SELECT * FROM likp
INTO lt_likp1
for all entries in lt_likp
WHERE vbeln = likp-vbeln
endif.
LOOP AT lt_likp INTO lwa_likp.
IF lwa_likp-lgtor zgwm_shp_ctrl-lgtor OR
lwa_likp-lgbzo zgwm_shp_ctrl-lgbzo.
read table lt_likp1 with key vbeln = lwa_likp-vbeln binary search.
if sy-subrc eq 0.
UPDATE likp
SET lgtor = zgwm_shp_ctrl-lgtor
lgbzo = zgwm_shp_ctrl-lgbzo
WHERE vbeln = lwa_likp-vbeln.
endif.
ENDIF.
ENDLOOP.
Regards,
Md Ziauddin.
‎2010 Sep 28 10:48 AM
Hi,
try this,
it wiont effect if you write the select single inside the loop because the field uding in the sekect is a key field.
you can try for all enries and sort table using vbeln and use binary search inside the loop.
after the loop or Update commabnd use the commit work or roll back work when u r doing operation on databases.
Prabhudas
‎2010 Sep 28 12:00 PM
Hi Madan,
Use the below code which removes the select statement outside the loop :-
if not lt_likp[] is initial.
sort lt_likp.
SELECT * FROM likp
INTO lt_likp1
for all entries in lt_likp
WHERE vbeln = likp-vbeln
endif.
LOOP AT lt_likp INTO lwa_likp.
IF lwa_likp-lgtor zgwm_shp_ctrl-lgtor OR
lwa_likp-lgbzo zgwm_shp_ctrl-lgbzo.
read table lt_likp1 with key vbeln = lwa_likp-vbeln binary search.
if sy-subrc eq 0.
UPDATE likp
SET lgtor = zgwm_shp_ctrl-lgtor
lgbzo = zgwm_shp_ctrl-lgbzo
WHERE vbeln = lwa_likp-vbeln.
endif.
ENDIF.
ENDLOOP.
Regards,
Md Ziauddin.
‎2010 Sep 28 1:41 PM
Please note that your code example is nonsense! Maybe you missed something!
>SELECT SINGLE * FROM likp
>INTO lwa_likp
>WHERE vbeln = lwa_likp-vbeln.
This SELECT SINGLE does nothing, you know everything already.
Just do the UPDATE directly and forget the SELECT SINGLE!
Forget also the FOR ALL ENTRIES proposed solution!
Edited by: Siegfried Boes on Sep 28, 2010 2:41 PM
‎2010 Sep 28 2:49 PM