Skip to Content

help : performance of a loop

Hello All,

Please help me improve the performance of this loop

LOOP AT lt_j_3abdbs.

UNPACK lt_j_3abdbs-aufnr TO lt_temp.

SELECT * FROM ltak

INTO CORRESPONDING FIELDS OF TABLE lt_ltak_temp

WHERE benum = lt_temp.

CHECK sy-subrc = 0.

INSERT LINES OF lt_ltak_temp INTO TABLE lt_ltak.

ENDLOOP.

Thanks in advance

Sudha

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2007 at 06:37 AM

    Try this one..

    SELECT * FROM ltak

    INTO TABLE lt_ltak_temp

    for all entries in lt_j_3abdbs

    WHERE benum = lt_j_3abdbs-aufnr .

    SORT ITAK by AUFNR.

    LOOP AT lt_j_3abdbs.

    READ TABLE ITAK WITH KEY AUFNR = lt_j_3abdbs-aufnr BINARY SEARCH.

    CHECK sy-subrc = 0.

    INSERT LINES OF lt_ltak_temp INTO TABLE lt_ltak where aufnr eq lt_j_3abdbs-aufnr .

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2007 at 06:33 AM

    use 'FOR ALL ENTRIES' in your select statement....

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Sudha Surendran

      You can solve in two ways:

      1. Loop the internal table & store the aufnr into benum type inside the loop. At the end of loop use select for all entries for aufnr which is of type benum type.

      2. Simplier way would be declare the auftr as 10 for lt_j_3abdbs-aufnr. As it is comparing with benum, I guess it should always have value less than of 10 characters

  • Posted on Dec 05, 2007 at 06:34 AM

    Hi,

    Dont use select statement within loop.

    Regards,

    Prashant

    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.