title: Speedup long running loop in ABAP
body: <p>When analysing a performance issue in an SAP export script (SAP R/3, 4.06b) I found the following code which runs about 10 minutes in the test system. Might be a bit faster in production but I can not test it there.</p>
  
  <pre><code>LOOP AT ZMARD.
    LOOP AT ZCOMB.
         IF ZCOMB-MATNR = ZMARD-MATNR.
            IF ZCOMB-LGORT = ZMARD-LGORT.
             IF ZCOMB-IND = ' '.
               IF ZCOMB-PLUMI = '+'.
                  ZMARD-LABST = ZMARD-LABST + ZCOMB-MNG01.
               ELSEIF ZCOMB-PLUMI = '-'.
                  ZMARD-LABST = ZMARD-LABST - ZCOMB-MNG01.
               ENDIF.                          "PLUMI
            ENDIF.                             "IND
          ENDIF.                               "LGORT
        ENDIF.                                 "MATNR
    ENDLOOP.
    IF ZMARD-LABST &lt; 0.
       ZMARD-LABST = 0.
    ENDIF.
    WRITE ZMARD-LABST DECIMALS 0 TO ZMARD-ZLABST.
    MODIFY ZMARD.
  ENDLOOP.
  </code></pre>
  
  <p>Do you have any advice on how this loops can be optimized / put together into one single loop?</p>