Skip to Content
0
Former Member
Apr 02, 2008 at 06:48 PM

Wanted to increase performance

14 Views

Hi,

I had a report which is displaying the correct data but i execute on PRD Server,it gets Request Time Out.So i want to increase the performance of it.Plzz help me out in doing this.

REPORT  ZWIP_STOCK NO STANDARD PAGE HEADING LINE-SIZE 150.

TABLES: AFPO, AFRU, MARA, MAKT.

DATA: BEGIN OF ITAB OCCURS 0,
      AUFNR LIKE AFPO-AUFNR,
      MATNR LIKE AFPO-MATNR,
      LGORT LIKE AFPO-LGORT,
      MEINS LIKE MARA-MEINS,
      NTGEW LIKE MARA-NTGEW,
      MTART LIKE MARA-MTART,
      STOCK TYPE P LENGTH 10 DECIMALS 3,
      END OF ITAB.

DATA : ITAB2 LIKE ITAB OCCURS 0 WITH HEADER LINE.

DATA : DESC LIKE MAKT-MAKTX.

SELECT-OPTIONS : MAT_TYPE FOR MARA-MTART.
SELECT-OPTIONS : P_MATNR FOR AFPO-MATNR.

DATA : V_MINOPR LIKE AFRU-VORNR,
       V_MAXOPR LIKE AFRU-VORNR,
       V_QTYMIN LIKE AFRU-GMNGA,
       V_QTYMAX LIKE AFRU-GMNGA,
       V_QTY TYPE P LENGTH 10 DECIMALS 3.

        SELECT A~AUFNR A~MATNR A~LGORT B~MEINS B~NTGEW B~MTART FROM AFPO AS A
          INNER JOIN MARA AS B ON A~MATNR = B~MATNR
            INTO TABLE ITAB WHERE ELIKZ <> 'X' AND MTART IN MAT_TYPE AND A~MATNR IN P_MATNR.


    ITAB2[] = ITAB[].

    SORT ITAB2 BY MATNR MEINS MTART NTGEW.
    DELETE ADJACENT DUPLICATES FROM ITAB2 COMPARING MATNR MEINS MTART NTGEW.

   LOOP AT ITAB2.

    V_QTY = 0.

      LOOP AT ITAB WHERE MATNR = ITAB2-MATNR.

        SELECT MIN( VORNR ) INTO V_MINOPR FROM AFRU WHERE AUFNR = ITAB-AUFNR.
        SELECT MAX( VORNR ) INTO V_MAXOPR FROM AFRU WHERE AUFNR = ITAB-AUFNR.


        SELECT SUM( GMNGA ) INTO V_QTYMIN FROM AFRU WHERE AUFNR = ITAB-AUFNR AND VORNR =  V_MINOPR.
        SELECT SUM( GMNGA ) INTO V_QTYMAX FROM AFRU WHERE AUFNR = ITAB-AUFNR AND VORNR =  V_MAXOPR.

        V_QTY = V_QTY + V_QTYMIN - V_QTYMAX.

      ENDLOOP.

      ITAB2-STOCK = V_QTY.
      MODIFY ITAB2.

    ENDLOOP.

    LOOP AT ITAB2.
          WRITE:/ ITAB2-MATNR,ITAB2-STOCK.
    ENDLOOP.

Edited by: Alvaro Tejada Galindo on Apr 2, 2008 3:14 PM