Skip to Content
author's profile photo Former Member
Former Member

Performance Issue in modifying a ITAB

Hi SDNs.,

performance issue in modifying a internal table : code :

*-Modify LT_DOC with Object list number(OBKNR) from SER03

LOOP AT LT_SER03_HASH INTO LW_SER03.

IF ( LW_SER03-OBKNR IS NOT INITIAL ).

READ TABLE LT_DOC INTO LW_DOC WITH KEY MBLNR = LW_SER03-MBLNR

MJAHR = LW_SER03-MJAHR

ZEILE = LW_SER03-ZEILE BINARY SEARCH.

IF ( SY-SUBRC = 0 ). " AND ( LW_SER03-OBKNR IS NOT INITIAL ).

LW_DOC-OBKNR = LW_SER03-OBKNR.

LW_DOC-DATUM = LW_SER03-DATUM.

LW_DOC-UZEIT = LW_SER03-UZEIT.

MODIFY LT_DOC FROM LW_DOC INDEX SY-INDEX TRANSPORTING OBKNR DATUM UZEIT WHERE MBLNR = LW_SER03-MBLNR AND

MJAHR = LW_SER03-MJAHR AND

ZEILE = LW_SER03-ZEILE .

ENDIF.

ENDIF.

CLEAR: LW_DOC, LW_SER03.

ENDLOOP.

<b>could any one help me out in tuning this code...</b>

Thank you

RK S

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Posted on Jan 09, 2007 at 01:58 PM

    Hi!

    I don't know, if the binary search could be faster - looks like it's already like a full (binary) key access. But for the rest: use field-symbols as work-area!

    field-symbols: <ser03> type ..."like line of lt_ser03
                         <doc>    type .... "like line of lt_doc.
    LOOP AT LT_SER03_HASH assinging <ser03>.
      IF ( <SER03>-OBKNR IS NOT INITIAL ).
        READ TABLE LT_DOC assigning <doc> WITH KEY MBLNR = <SER03>-MBLNR
                                                 MJAHR =<SER03>-MJAHR
                                                 ZEILE = <SER03>-ZEILE BINARY SEARCH.
    
    IF SY-SUBRC = 0 . " AND ( LW_SER03-OBKNR IS NOT INITIAL ).
    <DOC>-OBKNR = <SER03>-OBKNR.
    <DOC>-DATUM = <SER03>-DATUM.
    <DOC>-UZEIT = <SER03>-UZEIT.
    ENDIF.
    ENDIF.
    ENDLOOP.

    You don't need a modify any longer.

    Regards,

    Christian

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi RKS!

      Thanks for listening to the best solution 😉

      It wasn't easy to understand the coding without explanation, but so far I got:

      you are making a fast version of a loop at lt_final where sernr = lt_final_hash1-sernr.

      Your modify was changing all lines of the corresponding sernr - now you need to 'loop' some lines with the while-loop - this solution will be faster for standard tables, that's good.

      You just loose the budat mblnr values. The field symbol is pointing to lines of the table body: the read table at the end of the while loop (index +1) is pointing to new budat / mblnr values, you don't have the values from previous loop any longer. You just assign two fields from one table line (ag_date = budat...).

      I guess, you want to move budat from the first line of this sernr to all ag_date of this sernr. Then just make two local variables for budat, mblnr. Maybe fill this before the loop (if sy-subrc eq 0. filling... endif), at least be sure to do it only once. These fields you can use to fill ag_date and ag_mblnr of all lines inside the while-loop.

      If this is what you want to do, then it should work - otherwise describe more detailed what is going wrong and what you would like to do.

      Regards,

      Christian

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2007 at 02:11 PM

    I don't know if it makes sense to:

    MODIFY LT_DOC FROM LW_DOC

    <b>INDEX SY-INDEX</b>

    TRANSPORTING OBKNR DATUM UZEIT

    <b>WHERE</b> MBLNR = LW_SER03-MBLNR AND

    MJAHR = LW_SER03-MJAHR AND

    ZEILE = LW_SER03-ZEILE .

    I think the WHERE will cause a full table scan.

    Rob

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2007 at 03:17 PM

    MODIFY LT_DOC FROM LW_DOC <b>INDEX SY-INDEX</b> TRANSPORTING OBKNR DATUM UZEIT WHERE MBLNR = LW_SER03-MBLNR AND

    MJAHR = LW_SER03-MJAHR AND

    ZEILE = LW_SER03-ZEILE .

    I feel, It's more appropriate to use sy-tabix instead of sy-index.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2007 at 03:30 PM

    LOOP AT LT_SER03_HASH.

    IF ( LT_SER03-OBKNR IS NOT INITIAL ).

    READ TABLE LT_DOC WITH KEY MBLNR = LT_SER03-MBLNR

    MJAHR = LT_SER03-MJAHR

    ZEILE = LT_SER03-ZEILE

    BINARY SEARCH.

    IF SY-SUBRC = 0.

    LT_DOC-OBKNR = LW_SER03-OBKNR.

    LT_DOC-DATUM = LW_SER03-DATUM.

    LT_DOC-UZEIT = LW_SER03-UZEIT.

    MODIFY LT_DOC INDEX SY-TABIX.

    ENDIF.

    ENDIF.

    CLEAR: LW_DOC, LW_SER03.

    ENDLOOP.

    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.