‎2010 Jun 28 12:09 PM
Dear Friends,
In my report we used loop inside the loop so the performance is affecting much worse. so Kindly help me to resolve this issue.
{LOOP AT it_part.
IF it_part-belnr NE it_part-rebzg AND it_part-augbl EQ ' '.
CLEAR w_count.
LOOP AT it_pos WHERE belnr = it_part-rebzg and konto = it_part-konto. " and blart = 'DZ' and blart = 'AB'.
it_part-dmshb = it_part-dmshb * -1.
it_pos-dmshb = it_pos-dmshb - it_part-dmshb.
MODIFY it_pos.
w_count = w_count + 1.
ENDLOOP.
IF w_count EQ 0.
APPEND it_part TO it_pos.
ENDIF.
ENDIF.
IF it_part-belnr EQ it_part-rebzg AND it_part-augbl NE ' '.
APPEND it_part TO it_part_filter.
ENDIF.
IF it_part-belnr EQ it_part-rebzg AND it_part-augbl EQ ' '.
CLEAR w_on_acc_total.
wa_on_acc-konto = it_part-konto.
wa_on_acc-dmshb = it_part-dmshb.
APPEND wa_on_acc TO it_on_acc.
ENDIF.}
Thanks and regards,
Karthik
Edited by: karthikani on Jun 28, 2010 4:39 PM
‎2010 Jun 28 12:12 PM
Hey,
use read instead of inner loop.
LOOP AT it_part.
read it_pos with belnr = it_part-rebzg and konto = it_part-konto. " and blart = 'DZ' and blart = 'AB'.
if sy-subrc = 0.
ur code
endif.
endloop.
Hope this will help you.
Regards,
Uma Dave
‎2010 Jun 28 12:12 PM
Hey,
use read instead of inner loop.
LOOP AT it_part.
read it_pos with belnr = it_part-rebzg and konto = it_part-konto. " and blart = 'DZ' and blart = 'AB'.
if sy-subrc = 0.
ur code
endif.
endloop.
Hope this will help you.
Regards,
Uma Dave
‎2010 Jun 28 12:20 PM
Hi Friend,
Itz really been very much thankful for your reply. But would you plz mention wer shud i make the changes.
Thanks and Regards,
Karthik
‎2010 Jun 28 12:34 PM
Hi,
Use the following logic.
{LOOP AT it_part.
IF it_part-belnr NE it_part-rebzg AND it_part-augbl EQ ' '.
CLEAR w_count.
read table it_pos with key belnr = it_part-rebzg
konto = it_part-konto.
it_part-dmshb = it_part-dmshb * -1.
it_pos-dmshb = it_pos-dmshb - it_part-dmshb.
MODIFY it_pos.
w_count = w_count + 1.
IF w_count EQ 0.
APPEND it_part TO it_pos.
ENDIF.
ENDIF.
IF it_part-belnr EQ it_part-rebzg AND it_part-augbl NE ' '.
APPEND it_part TO it_part_filter.
ENDIF.
IF it_part-belnr EQ it_part-rebzg AND it_part-augbl EQ ' '.
CLEAR w_on_acc_total.
wa_on_acc-konto = it_part-konto.
wa_on_acc-dmshb = it_part-dmshb.
APPEND wa_on_acc TO it_on_acc.
ENDIF.}
Regards,
Preetham
‎2010 Jun 28 12:39 PM
Hi friend preetham and dave,
Your both answer worked. But wen i checked in se30(runtime analysis) the performance criteria was still little bit high. Is anyother solution which should increase more.
If you find any plz let me know.\
Thanka and regards,
Karthik
‎2010 Jun 28 12:43 PM
Hi,
Check whether have you sorted the internal tables with key fields.
Regards,
Preetham
‎2010 Jun 28 12:14 PM
The LOOP where can only be optimized with an internal table of type SORTED, if the criteria of the WHERE are the keys of the table. (ref: [WHERE log_exp|http://help.sap.com/abapdocu_70/en/ABAPLOOP_AT_ITAB_COND.htm#!ABAP_ADDITION_3@3@])
If you dont want or cannot use such a type, you can use a SORT statement before the external loop, insure that the table stay sorted when you insert/update record, and replace the LOOP with a READ TABLE statement, and reading next records incrementing index, checking that the criteria is valid.
Regards,
Raymond
‎2010 Jun 28 12:48 PM
Hi karthik,
Observe the changes in your code.
I am using parallel cursor approach to improve the performance of nested loop.
{LOOP AT it_part.
IF it_part-belnr NE it_part-rebzg AND it_part-augbl EQ ' '.
CLEAR w_count.
read table it_pos with key belnr = it_part-rebzg and konto = it_part-konto
IF sy-subrc = 0.
LOOP AT it_pos FROM sy-tabix. " and blart = 'DZ' and blart = 'AB'.
it_part-dmshb = it_part-dmshb * -1.
it_pos-dmshb = it_pos-dmshb - it_part-dmshb.
MODIFY it_pos.
w_count = w_count + 1.
ENDLOOP.
endif.
IF w_count EQ 0.
APPEND it_part TO it_pos.
ENDIF.
ENDIF.
IF it_part-belnr EQ it_part-rebzg AND it_part-augbl NE ' '.
APPEND it_part TO it_part_filter.
ENDIF.
IF it_part-belnr EQ it_part-rebzg AND it_part-augbl EQ ' '.
CLEAR w_on_acc_total.
wa_on_acc-konto = it_part-konto.
wa_on_acc-dmshb = it_part-dmshb.
APPEND wa_on_acc TO it_on_acc.
ENDIF.}
Regards,
Vinod