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 in internal tables

Former Member
0 Likes
1,466

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,268

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

8 REPLIES 8
Read only

Former Member
0 Likes
1,268

HI,

use read statement

for example

READ TABLE <itab> INTO <wa> WITH KEY field = <value> using binary search.

rgds,

bharat.

Read only

Former Member
0 Likes
1,269

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

Read only

Former Member
0 Likes
1,268

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

Read only

Former Member
0 Likes
1,268

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

Read only

Former Member
0 Likes
1,268

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.

Read only

jaheer_hussain
Active Contributor
0 Likes
1,268

Hi,

First sort the internal table.

Try to read with more conditions + Binary search.

With Regards,Jaheer.

Read only

varma_narayana
Active Contributor
0 Likes
1,268

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>

Read only

Former Member
0 Likes
1,268

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.