2006 Sep 16 1:39 AM
LOOP AT gt_bsak. " INTO wa_bsak.
SELECT SINGLE lifnr FROM lfb1
INTO wa_lifnr
WHERE lifnr = gt_bsak-lifnr
AND bukrs = gt_bsak-bukrs
AND uzawe EQ 'ZN'
.
IF sy-subrc = 0.
DELETE TABLE gt_bsak. "FROM wa_bsak.
EXIT.
ENDIF.
Checking document header text,.
SELECT SINGLE bktxt FROM bkpf
INTO wa_bktxt
WHERE bukrs = gt_bsak-bukrs
AND belnr = gt_bsak-belnr
AND gjahr = gt_bsak-gjahr.
IF wa_bktxt+0(5) = 'OTPY:' OR
wa_bktxt+0(5) = 'OTPN:'.
DELETE TABLE gt_bsak. " FROM wa_bsak.
EXIT.
ENDIF.
ENDLOOP.
Is the above loop is ok ..performance point of view ? out of select single and SELECT up to 1 rows which one is the better ?
2006 Sep 16 1:46 AM
Hi Sam,
Avoding a select is always better inside a loop. Whether it is select single or select up to one rows its always better to avoid.
But if the situation is such that you cannot avoid select within a loop then better to use SELECT SINGLE with all KEY FIELDS.
You can also use Field symbols with LOOP as described in the weblog by rich
/people/rich.heilman2/blog/2006/03/07/using-field-symbols-in-loop-statements--performance-boost
Cheers
VJ
Message was edited by: Vijayendra Rao
LOOP AT gt_bsak. " INTO wa_bsak.
SELECT SINGLE lifnr FROM lfb1
INTO wa_lifnr
WHERE lifnr = gt_bsak-lifnr
AND bukrs = gt_bsak-bukrs
AND uzawe EQ 'ZN'
.
IF sy-subrc = 0.
DELETE TABLE gt_bsak. "FROM wa_bsak.
EXIT.
ENDIF.
Checking document header text,.
SELECT SINGLE bktxt FROM bkpf
INTO wa_bktxt
WHERE bukrs = gt_bsak-bukrs
AND belnr = gt_bsak-belnr
AND gjahr = gt_bsak-gjahr.
IF wa_bktxt+0(5) = 'OTPY:' OR
wa_bktxt+0(5) = 'OTPN:'.
DELETE TABLE gt_bsak. " FROM wa_bsak.
EXIT.
ENDIF.
ENDLOOP.
Is the above loop is ok ..performance point of view ? out of select single and SELECT up to 1 rows which one is the better ?
2006 Sep 16 1:46 AM
Hi Sam,
Avoding a select is always better inside a loop. Whether it is select single or select up to one rows its always better to avoid.
But if the situation is such that you cannot avoid select within a loop then better to use SELECT SINGLE with all KEY FIELDS.
You can also use Field symbols with LOOP as described in the weblog by rich
/people/rich.heilman2/blog/2006/03/07/using-field-symbols-in-loop-statements--performance-boost
Cheers
VJ
Message was edited by: Vijayendra Rao
2006 Sep 16 4:20 AM
I think logic may be more of a problem here than performance. Do you want to <b>EXIT</b> out of the loop or <b>CONTINUE</b> withe the next loop pass?
Rob
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |