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

performance tuning

how do i rewrite the following using "for all entries" to improve performance?

DATA: BEGIN OF I_MARA OCCURS 0,

MATNR LIKE MARA-MATNR,

MTART LIKE MARA-MTART,

END OF I_MARA.

DATA : BEGIN OF I_SER01 OCCURS 0,

LIEF_NR LIKE SER01-LIEF_NR,

OBKNR LIKE SER01-OBKNR,

POSNR LIKE SER01-POSNR,

BWART LIKE SER01-BWART,

END OF I_SER01.

DATA : BEGIN OF I_OBJK OCCURS 0,

OBKNR LIKE OBJK-OBKNR,

SERNR LIKE OBJK-SERNR,

MATNR LIKE OBJK-MATNR,

END OF I_OBJK.

loop at i_ser01.

SELECT bobknr amatnr b~sernr FROM mara AS a INNER JOIN

objk AS b ON bmatnr = amatnr INTO TABLE i_objk FOR ALL ENTRIES IN i_ser01

WHERE b~obknr = i_ser01-obknr

AND b~sernr IN sernr

AND a~mtart = 'FERT'

AND a~matnr IN matnr.

endloop

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

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

    You can use the below code instead of INNER JOIN.

    SELECT obknr

    sernr

    matnr

    INTO t_objk

    FROM objk

    FOR ALL ENTRIES IN i_ser01

    WHERE obknr = i_ser01-obknr

    AND sernr IN sernr

    AND matnr IN matnr.

    SELECT matnr

    INTO t_mara

    FROM mara

    FOR ALL ENTRIES IN t_objk

    WHERE matnr = t_objk-matnr

    AND mtart = 'FERT' .

    LOOP AT t_objk.

    READ TABLE t_mara WITH KEY matnr = t_objk-matnr .

    IF sy-subrc NE 0.

    DELETE t_objk.

    ENDIF .

    ENDLOOP .

    Reward Points to helpful answers.

    Thanks.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 05, 2007 at 09:12 AM
    loop at i_ser01.
    
    SELECT b~obknr a~matnr b~sernr 
                 FROM mara AS a INNER JOIN objk AS b 
                 ON b~matnr = a~matnr 
                 INTO TABLE i_objk 
                 FOR ALL ENTRIES IN i_ser01
                 WHERE b~obknr = i_ser01-obknr
                 AND b~sernr IN sernr
                 AND a~mtart = 'FERT'
                 AND a~matnr IN matnr.
    
    endloop 
    

    Please read the online help again, the FOR ALL ENTRIES does what a loop would do. You can skip the loop ... endloop! otherwise you have a loop in loop!

    Siegfried

    Add a comment
    10|10000 characters needed characters exceeded

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

    hi

    SELECT bobknr amatnr b~sernr

    FROM mara AS a INNER JOIN objk AS b

    ON bmatnr = amatnr

    INTO TABLE i_objk

    FOR ALL ENTRIES IN i_ser01

    WHERE b~obknr = i_ser01-obknr

    AND b~sernr IN sernr

    AND a~mtart = 'FERT'

    AND a~matnr IN matnr.

    Thanks

    Siva Kumar

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2007 at 12:23 PM

    THANK U FOR UR VALUEBLE ANSWERS AND ALL R REWARDED.

    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.