zoukankan      html  css  js  c++  java
  • Efficiency optimizing

    *low efficiency
       l_it_alv_stpox[] = g_it_alv_stpox[].
      SORT l_it_alv_stpox BY zz_matnr idnrk.
      LOOP AT g_it_alv_stpox ASSIGNING <l_wa_alv>.
        LOOP AT l_it_alv_stpox WHERE ( zz_matnr NE <l_wa_alv>-zz_matnr )
                                 AND ( idnrk EQ <l_wa_alv>-idnrk )
                                 AND ( zz_bunit IS NOT INITIAL )
                                 AND ( zz_bunit NE <l_wa_alv>-zz_bunit ).
          <l_wa_alv>-zz_bunit = 'Common'.
          EXIT.
        ENDLOOP.
        UPDATE marc SET zz_bunit = <l_wa_alv>-zz_bunit WHERE werks = <l_wa_alv>-werks
                                                         AND matnr = <l_wa_alv>-idnrk                                                    .
        IF sy-subrc EQ 0.
          COMMIT WORK.
          <l_wa_alv>-zz_message  = l_message_s.
        ELSE.
          ROLLBACK WORK.
          <l_wa_alv>-zz_message  = l_message_f.
        ENDIF.
      ENDLOOP.
    

    ***大内表LOOP嵌套LOOP,速度太慢,转化成以下逻辑 ***

     delete adjacent duplicates from g_it_alv_stpox comparing zz_matnr idnrk.  
      l_it_idnrk_stpox[] = g_it_alv_stpox[].
      sort l_it_idnrk_stpox by idnrk.
      delete adjacent duplicates from l_it_idnrk_stpox comparing idnrk.
    
       l_it_both_stpox[] = l_it_idnrk_stpox[].
    
    
      loop at l_it_idnrk_stpox into l_wa_idnrk_stpox.
        l_it_stpox_in_loop[] = l_it_both_stpox[].
        delete l_it_stpox_in_loop where idnrk ne l_wa_idnrk_stpox-idnrk.
        delete l_it_both_stpox where idnrk eq l_wa_idnrk_stpox-idnrk.
        describe table l_it_stpox_in_loop lines l_lines.
        if l_lines gt 1.
          l_wa_idnrk_stpox-zz_bunit = 'Common'.
        endif.
        clear l_lines.
        update marc set zz_bunit = l_wa_idnrk_stpox-zz_bunit where werks = l_wa_idnrk_stpox-werks
                                                         and matnr = l_wa_idnrk_stpox-idnrk.
        if sy-subrc eq 0.
          commit work.
          l_wa_idnrk_stpox-zz_message  = l_message_s.
        else.
          rollback work.
          l_wa_idnrk_stpox-zz_message  = l_message_f.
        endif.
    
        modify g_it_alv_stpox from l_wa_idnrk_stpox transporting zz_bunit zz_message
        where werks = l_wa_idnrk_stpox-werks and idnrk = l_wa_idnrk_stpox-idnrk.
      endloop.
      clear:l_wa_idnrk_stpox.
    

    ***上面一段有误,改成以下 ***

    sort lt_stpox by idnrk zz_bunit.
        delete adjacent duplicates from lt_stpox comparing idnrk zz_bunit.
        describe table lt_stpox lines l_lines.
      endif.
    *  PERFORM frm_check_users.
      write: 'LT_STPOX lines:' , l_lines.
    
      lt_mara[] = lt_stpox[].
      sort: lt_mara by idnrk.
      delete adjacent duplicates from lt_mara comparing idnrk .
    
      sort:  lt_stpox  by idnrk.
    
      describe table lt_mara lines l_lines.
      write: 'LT_MARA:' , l_lines.
    
      loop at lt_mara into ls_mara.
        l_maraindex = sy-tabix.
        read table lt_stpox into ls_stpox with key idnrk = ls_mara-idnrk binary search.
        if sy-subrc = 0.
          l_index = sy-tabix.
          loop at lt_stpox into ls_stpox from l_index.
            if ls_stpox-idnrk ne ls_mara-idnrk.
              exit.
            endif.
            if ls_stpox-zz_bunit ne ls_mara-zz_bunit.
              ls_mara-zz_bunit = 'Common'.
              exit.
            endif.
    
          endloop.
    
          update marc set zz_bunit = ls_mara-zz_bunit where werks = p_werks
                                                             and matnr = ls_mara-idnrk.
          if sy-subrc eq 0.
            commit work.
          else.
            rollback work.
          endif.
          write: /.
          write:l_maraindex, ls_mara-idnrk, ls_mara-zz_bunit.
    
        endif.
      endloop.
    
  • 相关阅读:
    nginx php-fpm 输出php错误日志
    图解phpstorm常用快捷键
    Mysq性能分析 —— Genral log(普通日志)与 Slow log(慢速日式)
    Mac Terminal
    Git安装与配置
    Linux ulimit
    tcpdump
    Linux 基础
    TCP
    HTTP
  • 原文地址:https://www.cnblogs.com/aurora-cj/p/9632655.html
Copyright © 2011-2022 走看看