Application Development 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: 

Loop problem urgent (rewards....)

former_member193357
Participant
0 Kudos

Hiii my program is giving a timt out error in the above loop.

LOOP AT IBSID2.(consist of 85000 records)

LOOP AT IBSID1(consist of 85000 records) WHERE KUNNR EQ IBSID2-KUNNR.

V_TABIX2 = SY-TABIX.

IF SY-SUBRC EQ 0.

IBSID2-TOT_30 = IBSID1-AGE30 + IBSID1-AGE30C .

IBSID2-TOT_60 = IBSID1-AGE60 + IBSID1-AGE60C .

IBSID2-TOT_180 = IBSID1-AGE180 + IBSID1-AGE180C .

IBSID2-TOT_360 = IBSID1-AGE360 + IBSID1-AGE360C .

IBSID2-TOT_360M = IBSID1-AGE360M + IBSID1-AGE360MC .

IBSID2-TOT_OUT_INCL = IBSID1-R_DMBTR + IBSID1-SPGLAMT +

IBSID1-SPGLAMTD.

ENDIF.

MODIFY IBSID2 INDEX V_TABIX2 TRANSPORTING TOT_30 TOT_60

TOT_180 TOT_360 TOT_360M TOT_OUT_INCL.

CLEAR IBSID2.

ENDLOOP.

ENDLOOP.

so what is alternate to this problem i tried instead of loop at ibsid1 i tried

read table ibsid1 with key kunnr = ibsid2-kunnr. but some values r not coming properly..

thanking you..

Rewards point for correct ans.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi you can use like following:

data: z_index type i value 1.

sort itab1 by kunnr.

sort itab2 by kunnr.

loop at itab1.

loop at itab2 from z_index.

if itab1-kunnr <> itab2-kunnr.

z_index = sy-tabix.

exit.

else.

******

endif.

endloop.

endloop.

9 REPLIES 9

Former Member
0 Kudos

Hi Hemant,

1. Sort the tables using KUNNR.

2. Copy IBSID2 to another itab and modify that itab.

loop at ibsid2.

LOOP AT IBSID1

endloop.

modify itab....

endloop.

Delete kunnr entry from IBSID2 after each loop end of IBSID1.

Reward if useful!

Former Member
0 Kudos

I Suggest you Do not process large amount of data with Internal table , where you can get timed out like this , Just try to validate the data with where condition , Still you do not want to have any creteria then just run this report on backround mode.

if you have any other key fields on your internal table add those fields additionaly in to your where condition.

One more suggestion : Under At new Kunnr , you can loop the second internal table.

Former Member
0 Kudos

Hi,

declare internal tables....

write select statements using FOR ALL ENTRIES

after that loop at first internal table.

use read statements...

append data to final internal table.

endloop

Regards

Former Member
0 Kudos

Hi,

Try this,

SORT IBSID2 BY kunnr.

LOOP AT IBSID2.

READ TABLE IBSID1WITH KEY kunnr = IBSID2-kunnr

BINARY SEARCH.

V_TABIX2 = SY-TABIX.

IF SY-SUBRC EQ 0.

IBSID2-TOT_30 = IBSID1-AGE30 + IBSID1-AGE30C .

IBSID2-TOT_60 = IBSID1-AGE60 + IBSID1-AGE60C .

IBSID2-TOT_180 = IBSID1-AGE180 + IBSID1-AGE180C .

IBSID2-TOT_360 = IBSID1-AGE360 + IBSID1-AGE360C .

IBSID2-TOT_360M = IBSID1-AGE360M + IBSID1-AGE360MC .

IBSID2-TOT_OUT_INCL = IBSID1-R_DMBTR + IBSID1-SPGLAMT +

IBSID1-SPGLAMTD.

ENDIF.

MODIFY IBSID2 INDEX V_TABIX2 TRANSPORTING TOT_30 TOT_60

TOT_180 TOT_360 TOT_360M TOT_OUT_INCL.

CLEAR IBSID2.

ENDLOOP.

Try to read the internal tables. check the commality in different loops and try to merge the loop.

pls go through the below links:

/people/rob.burbank/blog/2006/02/07/performance-of-nested-loops

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/improvingPerformanceinNestedLoopsforInternal+Tables&

Regards,

Padmam.

Former Member
0 Kudos

call function GUI_PROGRESS_INDICATOR inside your loops to avoid time out error

reward points if helpful

Former Member
0 Kudos

Hi,

Instead of this loop statement:

LOOP AT IBSID1(consist of 85000 records) WHERE KUNNR EQ IBSID2-KUNNR.

V_TABIX2 = SY-TABIX.

try using

SORT IBSID1 BY KUNNR.

READ TABLE IBSID1 WITH KEY KUNNR = IBSID2-KUNNR

V_TABIX2 = SY-TABIX BINARY SEARCH.

Hope this helps.

Reward if helpful.

Regards,

Sipra

Former Member
0 Kudos

create field symbol <ibsid2> like line of IBSID2, <ibsid1> like line of IBSID1.

loop at the internal tables assigning to these field symbols...

do your calculations like

<ibsid2>-TOT_30 = <ibsid1>-AGE30 + <ibsid1>-AGE30C .

using field symbols should improve performance and avoid timeout...

Regards,

Abhijit

/people/mark.finnern/blog/2004/08/10/spread-the-love

former_member235056
Active Contributor
0 Kudos

Hi,

Try to use another table just same as that of ur internal table and copy all contents in that table and then modify the contents of that new table and the main cause of ur error is mainly bcoz every time is calling loops simultaneously ucan avoid this by using sort functions during select statement.

Pls try this and let me know.

Pls reward points if it works.

Regards,

Ameet

Former Member
0 Kudos

hi you can use like following:

data: z_index type i value 1.

sort itab1 by kunnr.

sort itab2 by kunnr.

loop at itab1.

loop at itab2 from z_index.

if itab1-kunnr <> itab2-kunnr.

z_index = sy-tabix.

exit.

else.

******

endif.

endloop.

endloop.