Skip to Content
0
Former Member
Oct 05, 2009 at 05:14 PM

COLLECT Horrible Performance in Loop

645 Views

This look takes over3 hours with 500k records, how can I make this faster??

SORT i_bw_detail_F   ASCENDING BY   z_belnr z_koart z_shkzg z_buzei.
SORT i_comb          ASCENDING BY   z_belnr z_koart z_shkzg z_buzei.

 LOOP AT i_bw_detail_F ASSIGNING <i_bw_detail_F>.
   READ TABLE i_comb ASSIGNING <i_comb> WITH KEY
                              z_belnr = <i_bw_detail_F>-z_belnr
                              z_koart = <i_bw_detail_F>-z_koart
                              z_shkzg = <i_bw_detail_F>-z_shkzg
                              z_buzei = <i_bw_detail_F>-z_buzei
                              BINARY SEARCH.

*  if we get a hit that matches BW and R/3 key data
   IF sy-subrc = 0.
*    setup the bw field symbol with the entry date / time so the collect will work
     <i_bw_detail_F>-z_entry_date = <i_comb>-z_entry_date.
     <i_bw_detail_F>-z_entry_time = <i_comb>-z_entry_time.

*     load the structure to be collected from BW into i_comb (r/3 data)
      st_i_comb-z_gjahr      =   <i_bw_detail_F>-z_gjahr.
      st_i_comb-z_monat      =   <i_bw_detail_F>-z_monat.
      st_i_comb-z_bukrs      =   <i_bw_detail_F>-z_bukrs.
      st_i_comb-z_belnr      =   <i_bw_detail_F>-z_belnr.
      st_i_comb-z_koart      =   <i_bw_detail_F>-z_koart.
      st_i_comb-z_shkzg      =   <i_bw_detail_F>-z_shkzg.
      st_i_comb-z_buzei      =   <i_bw_detail_F>-z_buzei.
      st_i_comb-z_bw_dmbtr   =   <i_bw_detail_F>-z_bw_dmbtr.
      st_i_comb-z_entry_date =   <i_bw_detail_F>-z_entry_date.
      st_i_comb-z_entry_time =   <i_bw_detail_F>-z_entry_time.

*     merge the bw data with the R/3 data
      COLLECT st_i_comb INTO i_comb.

ENDLOOP.

Moderator message - Moved to the correct forum

Edited by: Rob Burbank on Oct 5, 2009 1:33 PM