06-03-2008 10:09 AM
Greetings Abapers
I keep getting a runtime error where the system tells me that my program has terminated because it has exceeded the runtime limit. I suspect this is because i have a loop within another loop and they both take a while to execute. I was wondering if you could suggest how i can improve my code. Currently what i want to do is
Get all active sales codes and assign them to a table
Read org relationships for all BP's linked to Salescodes for all date ranges
The code is :
loop at lt_/ccdev01/a2scode.
Read all organisational relationships for all business partneru2019s linked to sales codes for all date ranges
select * from hrp1001 into table lt_hrp1001
where plvar = '01'
and relat = 'Z40'
or relat = '008'.
loop at lt_hrp1001.
.........
endloop.
endloop.
06-03-2008 10:13 AM
Hi try this!
sort lt_/ccdev01/a2scode by <keyfield>.
sort hrp1001 by <key field..
loop at lt_/ccdev01/a2scode.
Read all organisational relationships for all business partneru2019s linked to sales codes for all date ranges
select * from hrp1001 into table lt_hrp1001
where plvar = '01'
and relat = 'Z40'
or relat = '008'.
read table hrp1001 into wa_hrp1001 with key = lt_/ccdev01/a2scode-<key>.
endloop.
06-03-2008 10:14 AM
If your select statement is doing the same work in every loop, better place it outside the loop. And then do a loop within the loop. Just try if it helps.
Regards,
Yogesh Bhatia
06-03-2008 10:19 AM
Hrp1001 has huge data and that too UR executing this table
without proper key .. and in loop .. endloop.
Select data only once from HRP1001 ..
select * from hrp1001 into table lt_hrp1001
where plvar = '01'
and relat = 'Z40'
or relat = '008'.
loop at lt_/ccdev01/a2scode.
loop at lt_hrp1001.
.........
endloop.
endloop.
06-03-2008 10:19 AM
Hi,
try this:
...
select * from hrp1001 into table lt_hrp1001
where plvar = '01'
and relat = 'Z40'
or relat = '008'.
LOOP AT lt_/ccdev01/a2scode ASSIGNING <FS1>.
LOOP AT LT_HRP1001 ASSIGNING <FS2>.
ENDLOOP.
ENDLOOP.
...
Futher tipps:
TABLE LT_HRP1001: Sorted or Hashed table
06-03-2008 10:21 AM
write:
select * from hrp1001 into table lt_hrp1001
where plvar = '01'
and relat IN ('Z40','008').