‎2006 Nov 03 4:37 AM
Hi All,
I have a doubt. iam looping at one internal table and in that loop iam reading the other internal table with key and if sy-subrc <> 0 , iam deleting the record from looped table. So my question is will there be any performance issue. Is it good practice ???. One of my senior told that instead of deleting a record to create a internal table and take only those entries which are success.
Please let me know which is the best way.
Also please send me if any one of you have material regarding the performance tuning or good coding standards.
Regards,
Kiran I
‎2006 Nov 03 4:36 PM
‎2006 Nov 03 4:53 AM
Hi krian,
instead of deleting inside the loop u can mark a flg for the record whichu wnt to delte and then delete them after the loop.
Chekc this link
http://www.erpgenie.com/sap/abap/performance.htm
Regards
- Gopi
‎2006 Nov 03 5:26 AM
Hi Gopi,
Will there be any issue if i delete inside loop.
Also insted af deleting can i insert the other records into an other internal table.
Reagrds,
Kiran I
‎2006 Nov 03 5:29 AM
Hi again...
you can delete the records inside the loop if u r not triggering any data base Ztable. if it is internal table i dont think is a problem.
Yes u can even insert the othre records into another internal table using the move and append statements.
Regards
- Gopi
‎2006 Nov 03 5:41 AM
thats rite. it's <b>NOT</b> a good practice to delete records from internal table inside the loop, especially when there is large number of records. instead i will suggest you to the following.
let say you have two internal tables ITAB1 AND ITAB2. now you are looping ITAB1 and reading records from ITAB2 according to some key fields from ITAB1 and if SY-SUBRC <> 0, then you are deleting records from ITAB1. so all you got to do is:
declare field symbol with an identical structure of IATB1.
FIELD-SYMBOLS <FS_ITAB1> TYPE TY_ITAB1.
LOOP AT ITAB1 ASSIGNING <FS_ITAB1>.
READ TABLE ITAB2 TRANSPORTING NO FIELDS
WITH KEY FLD1 = <FS_ITAB1>-FLD1
FLD2 = <FS_ITAB1>-FLD2....
BINARY SEARCH.
**DECLARE YOUR INTERNAL TABLES AS SORTED TABLES**
IF sy-subrc <> 0.
<FS_ITAB1>-flag = 'X'.
**HAVE ONE ADDITIONAL FIELD AS FLAG**
ENDIF.
ENDLOOP.
DELETE ITAB1 WHERE FLAG = 'X'.
this is quite fruitful when original performance is concerned.
shane
‎2006 Nov 03 6:07 AM
Hi Kiran,
what your seniour told is correct insted of deleting that record in the loop before that you delete those records which is unnecessory get the sucess records and read that internal table. iam sending one sample code please go through this. Can i have your email id so that i can send u the code.
Thanks
Vikranth Khimavath
‎2006 Nov 07 4:58 AM
Hi Vikranth,
Sorry for late reply. My Mail id is immadisettygkk@yahoo.com. Please also send me any material on perfomance techniques.
Thanks & Regards,
Kiran I
‎2006 Nov 03 4:36 PM
‎2006 Nov 07 5:10 AM
hi kiran,
kindly chk ur mail.
I send a hands on note of mine.
It might be helpful for u.
regards
Anver
if helped pls mark points
‎2006 Nov 07 6:57 AM
Hi kiran,
kindly chk ur mail.
I send u one excellent OOPS doc.
<b><i>If helped pls mark points.</i></b>
Regards
Anver