Skip to Content

Better performance for program

Hi

I have a program which its execution is 'ok' if there are few record (for example 250), otherwise, system show a message of time out.

In this case, what I should do to get better performance for program?

These are code lines for data selection

SELECT ZLOTE BUKRS ANLN1 INVNR ORD41 ORD42 ORD43 ORD44 FROM zanla1
         INTO TABLE ti_zanla1
         WHERE INVNR IN p_invnr.

 SORT ti_zanla1 BY INVNR.

  LOOP AT ti_zanla1 INTO wa_zanla1.

    READ TABLE ti_zinvnr WITH KEY BUKRS = wa_zanla1-bukrs
                                   INVNR = wa_zanla1-invnr
                          ASSIGNING <zinvnr>.

    IF SY-SUBRC = 0.

      READ TABLE it_invnr_control WITH KEY ZLOTE = <zinvnr>-ZLOTE ASSIGNING <zcontrol_serial>.
      IF sy-subrc = 0.
        it_output-ZFECHAEC  = <zcontrol_serial>-ZFECHAEC.
        it_output-ZHORAEC   = <zcontrol_serial>-ZHORAEC.
      ENDIF.

      it_output-EBELN    = <zinvnr>-EBELN.
      it_output-BISMT    = <zinvnr>-BISMT.

      READ TABLE ti_zcontrol_anla1 WITH KEY ZLOTE = wa_zanla1-ZLOTE ASSIGNING <zcontrol_anla1>.
      IF sy-subrc = 0.
        it_output-FECHAREC = <zcontrol_anla1>-ZFECHAEC.
      ENDIF.

      it_output-ZLOTE   = wa_zanla1-ZLOTE.
*        it_output-BUKRS   = wa_zanla1-BUKRS.
      it_output-ANLN1   = wa_zanla1-ANLN1.
      it_output-INVNR   = wa_zanla1-INVNR.

      IF wa_zanla1-INVNR = ZINVNR.
        it_output-TOTIN01 = 0.
      ELSE.
        it_output-TOTIN01 = 1.
      ENDIF.


      it_output-ORD41   = wa_zanla1-ORD41.

      READ TABLE ti_t087t WITH KEY ordnr = '1' ord4x = ti_salida-ord41.
      it_output-T_ORD41 = ti_t087t-ordtx.

      it_output-ORD42   = wa_zanla1-ORD42.
      READ TABLE ti_t087t WITH KEY ordnr = '2' ord4x = ti_salida-ord42.
      it_output-T_ORD42 = ti_t087t-ordtx.

      it_output-ORD43   = wa_zanla1-ORD43.
      READ TABLE ti_t087t WITH KEY ordnr = '3' ord4x = ti_salida-ord43.
      it_output-T_ORD43 = ti_t087t-ordtx.

      it_output-ORD44   = wa_zanla1-ORD44.
      READ TABLE ti_t087t WITH KEY ordnr = '4' ord4x = ti_salida-ord44.
      it_output-T_ORD44 =  ti_t087t-ordtx.
*        it_output-STATUS  = wa_zanla1-STATUS.
      APPEND it_output.
      CLEAR it_output.
    ENDIF.  

  ENDLOOP.

Thanks in advance.

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 03:53 PM

    Sort the internal tables and then use the BINARY SEARCH option of the READ statement.

    Rob

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 17, 2008 at 03:59 PM

    How large is table zanla1?

    Is INVNR the primary or a secondary key of that table?

    Thomas

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 18, 2008 at 09:04 AM
    SORT ti_zanla1 BY INVNR.
     
      LOOP AT ti_zanla1 INTO wa_zanla1.
     
        READ TABLE ti_zinvnr WITH KEY BUKRS = wa_zanla1-bukrs
                                       INVNR = wa_zanla1-invnr
                              ASSIGNING <zinvnr>.
    

    I would recommend you to use Sorted tables for all tables which are used with the READs inside the LOOP.

    If this is not possible, then sort the standard table before the LOOP starts and use BINARY SEARCH.

    There is no real advantage that the large table ti_zanla1 is sorted, the LOOP processes anyway the complete LOOP.

    Maybe there is some other logic, which profits of the sort. The APPEND could be such a logic, if the result-table should also be sorted then it makes sense to have

    the sort on the LOOP-table.

    Siegfried

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.