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

Internal table size

Former Member
0 Likes
1,191

In the program, if i execute a report with four sales orgs on selection screen.

while processing one internal table filled with 120 thousand records and processing time its taking

13 hours. if i execute the same report two sales orgs its taking 3 hours and other two sales org 3 hours

which the total 6 hours but not 13 hours.

Here my question is, does internal table size matters for the execution time? i want to execute this

report for all four sales orgs at a time for 6 hours? how can i execute it?

thanks in advance.

vamshi

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,138

It really depends on what your program is doing, I would assume that there may be a problem with the selection of the data from the database. Are you sure that your select statements have been optimized?

Regards,

Rich Heilman

11 REPLIES 11
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,139

It really depends on what your program is doing, I would assume that there may be a problem with the selection of the data from the database. Are you sure that your select statements have been optimized?

Regards,

Rich Heilman

Read only

0 Likes
1,138

Initial selects are exececuting less than 10 mins.

only this loop is taking most time.

I dont have any select statements in that internal table loop.

regards,

vamshi tallada

Read only

0 Likes
1,138

Then check for nested loops. On tables this size, nested loops can slow things down worse than select statements.

Rob

<a href="/people/rob.burbank/blog/2006/02/07/performance-of-nested-loops">This</a> may help.

Message was edited by: Rob Burbank

Read only

Former Member
0 Likes
1,138

Hi,

Performence is not depends on the Number of records in internal table, it depends on the select statment which you have writen to get the data from the Database. so check your select statment, and i assume the you have not writen the loop in side the loop ..

mark all the helpfull answers

Regards

Sudheer

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,138

Can you please post the code?

Regards,

Rich Heilman

Read only

0 Likes
1,138

following is the loop which is taking most time:

follwed with the subroutines i am calling.

LOOP AT it_all_periods.

lw_sytabix = sy-tabix.

it_final-VBELN = it_all_periods-VBELN.

it_final-POSNR = it_all_periods-POSNR.

CLEAR : LW_RDOCC.

IF NOT it_all_periods-BUDAT IS INITIAL.

READ TABLE IT_FPERIOD

WITH KEY FDATE = it_all_periods-BUDAT.

IF SY-SUBRC = 0.

it_final-GJAHR = IT_FPERIOD-GJAHR.

it_final-PERIO = IT_FPERIOD-PERIO.

ELSE.

PERFORM GET_FISCAL_PER USING it_all_periods-BUDAT

CHANGING it_final-GJAHR

it_final-PERIO.

ENDIF.

CONCATENATE it_final-GJAHR it_final-PERIO INTO it_final-BDJPOPER.

ENDIF.

it_final-RDOCC = it_all_periods-WRBTR * -1.

IF it_final-WAERS <> C_USD.

PERFORM CONVERT_CURRENCY USING it_all_periods-BUDAT

it_final-RDOCC

it_final-WAERS

C_USD

CHANGING it_final-RLOCC.

ELSE.

it_final-RLOCC = it_final-RDOCC.

ENDIF.

MODIFY it_final TRANSPORTING RDOCC RLOCC

WHERE VBELN = it_final-VBELN AND

POSNR = it_final-POSNR AND

BDJPOPER = it_final-BDJPOPER AND

WAERS = it_final-WAERS.

delete it_all_periods index lw_sytabix.

endloop.

FORM GET_FISCAL_PER USING P_DATE TYPE SY-DATUM

CHANGING P_YY TYPE N

P_MM TYPE N.

CONSTANTS: LC_CAL TYPE PERIV VALUE 'Z6'.

CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'

EXPORTING

I_DATE = P_DATE

I_PERIV = LC_CAL

IMPORTING

E_BUPER = P_MM

E_GJAHR = P_YY.

IF W_CURYY IS INITIAL.

W_CURYY = P_YY.

W_CURMM = P_MM.

ENDIF.

IF P_YY > W_CURYY.

P_MM = C_01.

ELSEIF P_YY < W_CURYY.

P_MM = C_12.

ENDIF.

IT_FPERIOD-FDATE = P_DATE. " date

IT_FPERIOD-GJAHR = P_YY. " Fiscal Year

IT_FPERIOD-PERIO = P_MM. " Period

APPEND IT_FPERIOD.

CLEAR IT_FPERIOD.

ENDFORM. " get_fiscal_per

FORM CONVERT_CURRENCY USING P_BUDAT TYPE D

P_AMTFR TYPE P

P_WAERK TYPE C

P_WAERS TYPE C

CHANGING P_AMTTO TYPE P.

CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'

EXPORTING

DATE = P_BUDAT

FOREIGN_AMOUNT = P_AMTFR

FOREIGN_CURRENCY = P_WAERK

LOCAL_CURRENCY = P_WAERS

IMPORTING

LOCAL_AMOUNT = P_AMTTO

EXCEPTIONS

NO_RATE_FOUND = 1

OVERFLOW = 2

NO_FACTORS_FOUND = 3

NO_SPREAD_FOUND = 4

DERIVED_2_TIMES = 5

OTHERS = 6.

IF SY-SUBRC <> 0.

CLEAR P_AMTTO.

ENDIF.

ENDFORM. " convert_currency

Read only

0 Likes
1,138

Try this:


<b>sort it_fperiod by fdate.</b>
  
LOOP AT it_all_periods.
  lw_sytabix = sy-tabix.
  it_final-vbeln = it_all_periods-vbeln.
  it_final-posnr = it_all_periods-posnr.

  CLEAR : lw_rdocc.
  IF NOT it_all_periods-budat IS INITIAL.
  
    READ TABLE it_fperiod
      WITH KEY fdate = it_all_periods-budat
      <b>binary search.</b>
    
    IF sy-subrc = 0.
      it_final-gjahr = it_fperiod-gjahr.
      it_final-perio = it_fperiod-perio.
    ELSE.
      PERFORM get_fiscal_per USING it_all_periods-budat
      CHANGING it_final-gjahr
      it_final-perio.
    ENDIF.
    CONCATENATE it_final-gjahr it_final-perio INTO it_final-bdjpoper.
  ENDIF.

  it_final-rdocc = it_all_periods-wrbtr * -1.

  IF it_final-waers <> c_usd.
    PERFORM convert_currency USING it_all_periods-budat
    it_final-rdocc
    it_final-waers
    c_usd
    CHANGING it_final-rlocc.
  ELSE.
    it_final-rlocc = it_final-rdocc.
  ENDIF.

  MODIFY it_final TRANSPORTING rdocc rlocc
  WHERE vbeln = it_final-vbeln AND
  posnr = it_final-posnr AND
  bdjpoper = it_final-bdjpoper AND
  waers = it_final-waers.

  DELETE it_all_periods INDEX lw_sytabix.
ENDLOOP.

Read only

0 Likes
1,138

I cannot use binary search for this internal table. since i am adding the records dynamically in the subroutine.

thanks,

vamshi tallada

Read only

0 Likes
1,138

You can sort the table each time a record is added or do as Naren has suggested and use a sorted table.

How many records in each of these tables?

Rob

Read only

Former Member
0 Likes
1,138

Hi,

Try to use binary search if you are using a READ TABLE instead in the loop. Before using the binary search sort the internal table with the corresponding fields..

If you are modifying inside the loop use the TRANSPORTING addition and transport only the fields that you want to change..

If you using LOOP AT ..inside a LOOP ..instead of WHERE use the following technique..

EX..

DATA: BEGIN OF ITAB OCCURS 0,

VBELN TYPE VBELN,

END OF ITAB.

DATA: BEGIN OF ITAB1 OCCURS 0,

VBELN TYPE VBELN,

POSNR TYPE POSNR,

END OF ITAB.

SORT ITAB1 BY VBELN.

DATA: V_TABIX TYPE SYTABIX.

LOOP AT ITAB.

READ TABLE TRANSPORTING NO FIELDS

WITH KEY VBELN = ITAB-VBELN

BINARY SEARCH.

IF SY-SUBRC = 0.

V_TABIX = SY-TABIX.

LOOP AT ITAB1 FROM V_TABIX.

IF ITAB1-VBELN <> ITAB-VBELN.

EXIT.

ENDIF.

  • DO THE PROCESSING...

ENDLOOP.

ENDIF.

ENDLOOP.

Thanks,

Naren

Read only

Former Member
0 Likes
1,138

Hi,

Try to use a sorted internal table or a hashed table..

THanks,

Naren