2005 Dec 27 2:26 PM
Hi abapers,
how can i avoid inner loops in performance point of view.
for example my code as follows .. what are the other statements i can use to get more performance.
if not itab_afvc[] is initial.
loop at itab_afvc.
if not itab_afvc-qmnum is initial.
loop at itab_s where
NLMIS_qmnum eq itab_afvc-qmnum
and opno = itab_afvc-vornr.
if sy-subrc eq 0.
itab_afvc-aufnr1 = itab_s-NLMIS_ORDNO.
itab_afvc-vornr = itab_s-vornr.
modify itab_afvc.
endif.
endloop.
endif.
loop at itab_crhd where objid = itab_afvc-arbid.
if sy-subrc eq 0.
itab_afvc-arbpl = itab_crhd-arbpl.
itab_afvc-werks = itab_crhd-werks.
modify itab_afvc.
endif.
endloop.
if not itab_afko[] is initial.
loop at itab_afko where aufpl = itab_afvc-aufpl.
if sy-subrc eq 0.
itab_afvc-qmnum = itab_afko-qmnum.
modify itab_afvc.
endif.
endloop.
endif.
loop at itab_s where qmnum eq itab_afvc-qmnum
and opno eq itab_afvc-opno.
endloop.
endif.
please help me.
2005 Dec 27 2:33 PM
From my understanding you are modifying outer loop internal table so, you can use READ instead of looping the records.
loop at itab_afvc.
if not itab_afvc-qmnum is initial.
Read table itab_s with key
NLMIS_qmnum eq itab_afvc-qmnum
opno = itab_afvc-vornr.
if sy-subrc eq 0.
itab_afvc-aufnr1 = itab_s-NLMIS_ORDNO.
itab_afvc-vornr = itab_s-vornr.
modify itab_afvc.
endif.
endif.
Read table itab_crhd with key objid = itab_afvc-arbid.
if sy-subrc eq 0.
itab_afvc-arbpl = itab_crhd-arbpl.
itab_afvc-werks = itab_crhd-werks.
modify itab_afvc.
endif.
if not itab_afko[] is initial.
read table itab_afko with key aufpl = itab_afvc-aufpl.
if sy-subrc eq 0.
itab_afvc-qmnum = itab_afko-qmnum.
modify itab_afvc.
endif.
endloop.
endif.
endif.
endloop.
May be you can sort all internal tables which are used in READ by the same key and use Binary search.
Hi abapers,
how can i avoid inner loops in performance point of view.
for example my code as follows .. what are the other statements i can use to get more performance.
if not itab_afvc[] is initial.
loop at itab_afvc.
if not itab_afvc-qmnum is initial.
loop at itab_s where
NLMIS_qmnum eq itab_afvc-qmnum
and opno = itab_afvc-vornr.
if sy-subrc eq 0.
itab_afvc-aufnr1 = itab_s-NLMIS_ORDNO.
itab_afvc-vornr = itab_s-vornr.
modify itab_afvc.
endif.
endloop.
endif.
loop at itab_crhd where objid = itab_afvc-arbid.
if sy-subrc eq 0.
itab_afvc-arbpl = itab_crhd-arbpl.
itab_afvc-werks = itab_crhd-werks.
modify itab_afvc.
endif.
endloop.
if not itab_afko[] is initial.
loop at itab_afko where aufpl = itab_afvc-aufpl.
if sy-subrc eq 0.
itab_afvc-qmnum = itab_afko-qmnum.
modify itab_afvc.
endif.
endloop.
endif.
loop at itab_s where qmnum eq itab_afvc-qmnum
and opno eq itab_afvc-opno.
endloop.
endif.
please help me.
2005 Dec 27 2:29 PM
u can use read table by equating the common key instead of loop and endloop
2005 Dec 27 2:30 PM
Hi Ramesh,
You can avoid the inner loops by using the
READ TABLE ITAB WITH KEY.. BINARY SEARCH statement.
Regards,
Suresh Datti
2005 Dec 27 2:33 PM
Hi.
First loop at the internal table. Then read the other table with proper feilds. Try to use Binary search while reading as this improves performance.
Thanks,
Maheshwari.
2005 Dec 27 2:33 PM
From my understanding you are modifying outer loop internal table so, you can use READ instead of looping the records.
loop at itab_afvc.
if not itab_afvc-qmnum is initial.
Read table itab_s with key
NLMIS_qmnum eq itab_afvc-qmnum
opno = itab_afvc-vornr.
if sy-subrc eq 0.
itab_afvc-aufnr1 = itab_s-NLMIS_ORDNO.
itab_afvc-vornr = itab_s-vornr.
modify itab_afvc.
endif.
endif.
Read table itab_crhd with key objid = itab_afvc-arbid.
if sy-subrc eq 0.
itab_afvc-arbpl = itab_crhd-arbpl.
itab_afvc-werks = itab_crhd-werks.
modify itab_afvc.
endif.
if not itab_afko[] is initial.
read table itab_afko with key aufpl = itab_afvc-aufpl.
if sy-subrc eq 0.
itab_afvc-qmnum = itab_afko-qmnum.
modify itab_afvc.
endif.
endloop.
endif.
endif.
endloop.
May be you can sort all internal tables which are used in READ by the same key and use Binary search.
2005 Dec 27 2:35 PM
Hi,
Some more additions.
U need not check for initial if U R looping at
something.(if not itab_afko[] is initial).
Also sy-subrc is not required inside a loop.
(if sy-subrc eq 0.)
Also the last loop is not meaningful.
(loop at itab_s where qmnum eq itab_afvc-qmnum
and opno eq itab_afvc-opno.
endloop.) since UR not doing anything here.
Regards,
GSR.
2005 Dec 27 2:38 PM
Hi
You can't use inner join with LOOP/ENDLOOP statament, you colud improve the performance using SORT TABLE:
DATA: itab_s LIKE SORTED TABLE OF .... with non unique key nlmis_qmnum
opno with header line.
DATA: itab_crhd LIKE SORTED TABLE OF crhd WITH non unique KEY objid
WITH HEADER LINE.
DATA: itab_afko LIKE SORTED TABLE OF afko WITH non unique KEY aufpl
WITH HEADER LINE.
......
LOOP AT itab_afvc.
LOOP AT itab_s WHERE nlmis_qmnum EQ itab_afvc-qmnum
AND opno = itab_afvc-vornr.
itab_afvc-aufnr1 = itab_s-nlmis_ordno.
itab_afvc-vornr = itab_s-vornr.
MODIFY itab_afvc.
ENDLOOP.
LOOP AT itab_crhd WHERE objid = itab_afvc-arbid.
itab_afvc-arbpl = itab_crhd-arbpl.
itab_afvc-werks = itab_crhd-werks.
MODIFY itab_afvc.
ENDLOOP.
LOOP AT itab_afko WHERE aufpl = itab_afvc-aufpl.
itab_afvc-qmnum = itab_afko-qmnum.
MODIFY itab_afvc.
ENDLOOP.
LOOP AT itab_s WHERE qmnum EQ itab_afvc-qmnum
AND opno EQ itab_afvc-opno.
ENDLOOP.
ENDLOOP.
Max
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |