2007 Aug 06 1:13 PM
Hi,
I am having an internal table with large volume (around 10 Lacs ) of records. Right now it has been sorted with required fields and using the same fileds in the where condtion of loop. But it is taking lot of time to read the records while loop the internal table.
Could you please suggest the best way to read the internal table so that read time should be reduced.
Points will be assinged for the better soultions.
Thanks in Advance,
Chandra Mohan Vempati
2007 Aug 06 1:17 PM
Hi
first SORT the ITAB with Key fields
And READ the ITAB with the key fields using BINARY SEARCH
<b>Reward points for useful Answers</b>
Regards
Anji
Hi,
I am having an internal table with large volume (around 10 Lacs ) of records. Right now it has been sorted with required fields and using the same fileds in the where condtion of loop. But it is taking lot of time to read the records while loop the internal table.
Could you please suggest the best way to read the internal table so that read time should be reduced.
Points will be assinged for the better soultions.
Thanks in Advance,
Chandra Mohan Vempati
2007 Aug 06 1:15 PM
HI,
use read statement
for example
READ TABLE <itab> INTO <wa> WITH KEY field = <value> using binary search.
rgds,
bharat.
2007 Aug 06 1:17 PM
Hi
first SORT the ITAB with Key fields
And READ the ITAB with the key fields using BINARY SEARCH
<b>Reward points for useful Answers</b>
Regards
Anji
2007 Aug 06 1:18 PM
Hi Chandra,
I think u r executing loop in a loop and using where condition.
if it is really not needed ten use
: Read.....with binary search statement.
it will increase the performance of program.
Regards,
Krishnendu
2007 Aug 06 1:18 PM
Hi
1. sort the internal table
2. delete the adjacent records with same name (if you don't want only )
3. after that loop at internal table
4. read the table based on the condition
so it will execute so easyly
reward if usefull
regards
naresh
2007 Aug 06 1:20 PM
Hi Chandra Vempati,
1. Try to give where condition in the same order where the fields available in table.
2. Try to give more selection condition if available / possible.
3. try to give where condition while looping.
ex : loop at table where <condition>
endloop.
4. Try to use secondary indexes.
5. inside the loop use READ with binary searches.
6. Sort before using the binary search.
Hope this will help u.
Reward points if useful.
with regards,
Murugan Arumugam.
2007 Aug 06 1:34 PM
Hi,
First sort the internal table.
Try to read with more conditions + Binary search.
With Regards,Jaheer.
2007 Aug 06 1:47 PM
Hi..
When you execute a LOOP using WHERE condition, it will actually process all the rows from first row to Last row.
To Avoid this we have to use LOOP AT IT_VBAK from <row> .
Try this code .. it will surely improve the performance.
For eg IT_VBAK is my internal table with 10 lacks records .
But i want to process only records with KUNNR = 1000.
DATA: V_START TYPE I.
DATA : V_KUNNR TYPE VBAK-KUNNR.
SORT IT_VBAK BY KUNNR.
READ TABLE IT_VBAK INTO WA_VBAK
with KEY KUNNR = '0000001000'
TRANPORTING NO FIELDS
BINARY SEARCH.
IF SY-SUBRC = 0.
V_START = SY-TABIX. "Capture the row position of first row
V_KUNNR = WA_VBAK-KUNNR.
LOOP AT IT_VBAK INTO WA_VBAK
From V_START.
**Terminate the loop after the completion of the records for the KUNNR
IF WA_VBAK-KUNNR <> V_KUNNR.
EXIT.
ENDIF.
**Process the records here
WRITE:/ WA_VBAK-VBELN,
WA_VBAK-VKORG.
ENDLOOP.
ENDLOOP.
<b>Reward if Helpful</b>
2007 Aug 06 1:54 PM
please read my comments on nested loops in the performance forum.
A standard table is slow if used with loop at where, it does not matter whether it is sorted or not.
Either you specify a sorted table, which is recommended, Or you use the binary search, index, loop from index, exit condition as explained also in the comment above.
Siegfried
P.S.: what is 10 Lacs? I know that it is a number, but don't remember how much it is.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |