Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Performance Issue

Former Member
0 Likes
852

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
824

Kiran,

Check the below link for my post in that link.

It just reiterates what the others replied. Just has additional info as to why.

Regards,

-Ramesh

9 REPLIES 9
Read only

gopi_narendra
Active Contributor
0 Likes
824

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

Read only

0 Likes
824

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

Read only

0 Likes
824

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

Read only

Former Member
0 Likes
824

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

Read only

Former Member
0 Likes
824

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

Read only

0 Likes
824

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

Read only

Former Member
0 Likes
825

Kiran,

Check the below link for my post in that link.

It just reiterates what the others replied. Just has additional info as to why.

Regards,

-Ramesh

Read only

anversha_s
Active Contributor
0 Likes
824

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

Read only

0 Likes
824

Hi kiran,

kindly chk ur mail.

I send u one excellent OOPS doc.

<b><i>If helped pls mark points.</i></b>

Regards

Anver