Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Help in MSEG select performance.

Hi all, please, help me with this performance.

The coment lines was the original code.

The previous code got time out and the new code is taking long long time. The range r_mblnr has about 1500 records.

MSEG table has more than 1.500.000 records.

Thanks in advance, regards

RP


**      SELECT  mblnr mjahr zeile bwart matnr werks lgort charg
**              insmk lifnr shkzg waers dmbtr bnbtr bualt menge
**              meins erfmg erfme bpmng bprme ebeln ebelp lfbnr
**              bukrs lsmng lsmeh lfbja lfpos xwsbr sjahr smbln
**              smblp
**
**              FROM mseg
**              INTO TABLE t_mseg_cancel
**            FOR ALL ENTRIES IN t_mseg
**            WHERE ( smbln EQ t_mseg-mblnr
**              AND   sjahr EQ t_mseg-mjahr
**              AND   smblp EQ t_mseg-zeile )
**               OR ( lfbnr = t_mseg-mblnr
**              AND   lfbja = t_mseg-mjahr
**              AND   lfpos = t_mseg-zeile ).
**
**
**      SELECT  mblnr mjahr zeile bwart matnr werks lgort charg
**              insmk lifnr shkzg waers dmbtr bnbtr bualt menge
**              meins erfmg erfme bpmng bprme ebeln ebelp lfbnr
**              bukrs lsmng lsmeh lfbja lfpos xwsbr sjahr smbln
**              smblp
**
**              FROM mseg APPENDING TABLE t_mseg_cancel
**              FOR ALL ENTRIES IN t_mseg
**              WHERE   mblnr EQ t_mseg-mblnr
**                AND ( lfbnr NE space
**                 OR   smbln NE space ).

    LOOP AT t_mseg.

      add_range r_mblnr t_mseg-mblnr.
      add_range h_mjahr t_mseg-mjahr.
      add_range r_zeile t_mseg-zeile.

    ENDLOOP.

    SORT: r_mblnr BY low,
          h_mjahr BY low,
          r_zeile BY low.

    DELETE ADJACENT DUPLICATES FROM r_mblnr COMPARING low.
    DELETE ADJACENT DUPLICATES FROM h_mjahr COMPARING low.
    DELETE ADJACENT DUPLICATES FROM r_zeile COMPARING low.


    SELECT  mblnr mjahr zeile bwart matnr werks lgort charg
            insmk lifnr shkzg waers dmbtr bnbtr bualt menge
            meins erfmg erfme bpmng bprme ebeln ebelp lfbnr
            bukrs lsmng lsmeh lfbja lfpos xwsbr sjahr smbln
            smblp
            FROM mseg
            INTO TABLE t_mseg_cancel
            FOR ALL ENTRIES IN r_mblnr
          WHERE ( smbln = r_mblnr-low
            AND   sjahr IN r_mjahr
            AND   smblp IN r_zeile ).

    SELECT  mblnr mjahr zeile bwart matnr werks lgort charg
            insmk lifnr shkzg waers dmbtr bnbtr bualt menge
            meins erfmg erfme bpmng bprme ebeln ebelp lfbnr
            bukrs lsmng lsmeh lfbja lfpos xwsbr sjahr smbln
            smblp
            FROM mseg
            APPENDING TABLE t_mseg_cancel
            FOR ALL ENTRIES IN r_mblnr
          WHERE ( lfbnr = r_mblnr-low
            AND   lfbja IN r_mjahr
            AND   lfpos IN r_zeile ).


    SELECT  mblnr mjahr zeile bwart matnr werks lgort charg
            insmk lifnr shkzg waers dmbtr bnbtr bualt menge
            meins erfmg erfme bpmng bprme ebeln ebelp lfbnr
            bukrs lsmng lsmeh lfbja lfpos xwsbr sjahr smbln
            smblp

            FROM mseg APPENDING TABLE t_mseg_cancel
            FOR ALL ENTRIES IN r_mblnr
            WHERE   mblnr = r_mblnr-low
              AND ( lfbnr NE space
               OR   smbln NE space ).

Not what you were looking for? View more on this topic or Ask a question