Skip to Content

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

code performance

Hi, all !!!

I have problem with this code , because table VBRK is to much big ( 890.000 rec).

and have runtime errorrror, how to improve this code?!

SELECT * FROM mkpf INTO TABLE lt_mkpf

WHERE mjahr = fgodina

AND budat IN budat.

LOOP AT lt_mkpf INTO ls_mkpf.

SELECT * FROM mseg INTO ls_mseg " table lt_mseg

WHERE mblnr = ls_mkpf-mblnr

AND mjahr = ls_mkpf-mjahr

AND werks = plant

AND lgort = stocc.

APPEND ls_mseg TO lt_mseg.

CLEAR ls_mseg.

ENDSELECT.

IF ls_mkpf-xblnr NE ' '.

SELECT * FROM vbrp INTO ls_vbrp

WHERE vgbel = ls_mkpf-xblnr.

APPEND ls_vbrp TO lt_vbrp.

ENDSELECT.

ENDIF.

ENDLOOP.

LOOP AT lt_mseg INTO ls_mseg.

MOVE-CORRESPONDING ls_mseg TO zintrec.

LOOP AT lt_mkpf INTO ls_mkpf

WHERE mblnr = ls_mseg-mblnr

AND mjahr = ls_mseg-mjahr.

MOVE-CORRESPONDING ls_mkpf TO zintrec.

ENDLOOP.

zintrec-status = '5'.

IF l_loc_curr IS INITIAL.

IF ls_mkpf-xblnr <> ' '.

CONCATENATE '0' mseg-zeile '0' INTO xvgpos.

LOOP AT lt_vbrp INTO ls_vbrp

WHERE vgbel = ls_mkpf-xblnr.

  • SELECT * FROM vbrp WHERE vgbel = ls_mkpf-xblnr.

  • AND vgpos = xvgpos.

IF zintrec-charg = ls_vbrp-charg. "

zintrec-vbeln = ls_vbrp-vbeln.

zintrec-netwr = ls_vbrp-netwr.

zintrec-wavwr = ls_vbrp-wavwr.

Tags:
replied

can Improve more..but try like this...

SELECT * FROM mkpf INTO TABLE lt_mkpf
WHERE mjahr = fgodina
AND budat IN budat.


*LOOP AT lt_mkpf INTO ls_mkpf.
*  SELECT * FROM mseg INTO ls_mseg " table lt_mseg
SELECT * FROM mseg INTO TABLE lt_mseg " table lt_mseg
FOR ALL ENTRIES IN lt_mkpf
*  WHERE mblnr = ls_mkpf-mblnr
WHERE mblnr = lt_mkpf-mblnr
AND mjahr = ls_mkpf-mjahr
AND werks = plant
AND lgort = stocc.
*    APPEND ls_mseg TO lt_mseg.
*    CLEAR ls_mseg.
*  ENDSELECT.
*  IF ls_mkpf-xblnr NE ' '.
*    SELECT * FROM vbrp INTO ls_vbrp
SELECT * FROM vbrp INTO lt_vbrp
FOR ALL ENTRIES IN lt_mkpf
WHERE vgbel = lt_mkpf-xblnr.
*      APPEND ls_vbrp TO lt_vbrp.
*    ENDSELECT.
*  ENDIF.
*ENDLOOP.


  LOOP AT lt_mseg INTO ls_mseg.
    MOVE-CORRESPONDING ls_mseg TO zintrec.

*  LOOP AT lt_mkpf INTO ls_mkpf WHERE mblnr = ls_mseg-mblnr
*                               AND   mjahr = ls_mseg-mjahr.
*  MOVE-CORRESPONDING ls_mkpf TO zintrec.
*  ENDLOOP.
    READ TABLE lt_mkpf INTO ls_mkpf WITH KEY mblnr = ls_mseg-mblnr
                                             mjahr = ls_mseg-mjahr.
    CHECK sy-subrc EQ 0.
    MOVE-CORRESPONDING ls_mkpf TO zintrec.

    zintrec-status = '5'.
    IF l_loc_curr IS INITIAL.
      IF ls_mkpf-xblnr ' '.
        CONCATENATE '0' mseg-zeile '0' INTO xvgpos.
        LOOP AT lt_vbrp INTO ls_vbrp
        WHERE vgbel = ls_mkpf-xblnr.


          SELECT * FROM vbrp WHERE vgbel = ls_mkpf-xblnr.
            and vgpos = xvgpos.
            IF zintrec-charg = ls_vbrp-charg. "
              zintrec-vbeln = ls_vbrp-vbeln.
              zintrec-netwr = ls_vbrp-netwr.
              zintrec-wavwr = ls_vbrp-wavwr.

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