Skip to Content
0
Former Member
Dec 13, 2007 at 04:44 PM

Header Text selection Option

20 Views

Hi,

I have developed a report which include a number of fields that come from the header text of the document. Besides, those fields are also used as the selection options. So, I use the function module READ_TEXT to retrieve it and compare it. The problem is the performance of the report is very bad. It takes 3 mins to get 3 records. Is there any way to resolve this??

 SELECT-OPTIONS: S_WADAT FOR LIKP-WADAT_IST.
  PARAMETERS: P_MAWB LIKE WA_REPORT-KZABE.
  PARAMETERS: P_HAWB LIKE LIKP-BOLNR.
  PARAMETERS: P_MATNR LIKE LIPS-MATNR.
  PARAMETERS: P_LOT(20) TYPE C.

  CLEAR: I_REPORT,I_DELIVERY,I_DELIVERY_INFO.
  REFRESH: I_REPORT,I_DELIVERY,I_DELIVERY_INFO.

  DATA WHERE_TAB(80) OCCURS 10 WITH HEADER LINE.

  DATA: BEGIN OF LTEXT OCCURS 50.
          INCLUDE STRUCTURE TLINE.
  DATA: END OF LTEXT.

  IF NOT P_HAWB IS INITIAL.
    CONCATENATE ' BOLNR = ' WHERE_TAB INTO WHERE_TAB.
    CONCATENATE WHERE_TAB '''' INTO WHERE_TAB.
    CONCATENATE WHERE_TAB P_HAWB INTO WHERE_TAB.
    CONCATENATE  WHERE_TAB '''' INTO WHERE_TAB.
    APPEND WHERE_TAB.
  ENDIF.

  IF NOT P_MATNR IS INITIAL.
    IF NOT WHERE_TAB IS INITIAL.
      CONCATENATE ' AND MATNR = ' WHERE_TAB INTO WHERE_TAB.
    ELSE.
      CONCATENATE ' MATNR = ' WHERE_TAB INTO WHERE_TAB.
    ENDIF.
    CONCATENATE WHERE_TAB '''' INTO WHERE_TAB.
    CONCATENATE WHERE_TAB P_MATNR INTO WHERE_TAB.
    CONCATENATE  WHERE_TAB '''' INTO WHERE_TAB.
    APPEND WHERE_TAB.
  ENDIF.

  SELECT A1~VBELN
         WADAT_IST
         BOLNR
         C1~LIFNR
         B1~MATNR
         LFIMG
         BTGEW
         B1~CHARG
    INTO CORRESPONDING FIELDS OF TABLE TMP_REPORT
    FROM LIKP AS A1 JOIN LIPS AS B1 ON A1~VBELN = B1~VBELN
        JOIN MCHA AS C1 ON B1~MATNR = C1~MATNR
                           AND
                           B1~WERKS = C1~WERKS
                           AND
                           B1~CHARG = C1~CHARG
     WHERE LFART = 'EL'
           AND
           WADAT_IST IN S_WADAT
           AND
           B1~CHARG NE ''
           AND
           B1~WERKS = 'ABC'
           AND
           (WHERE_TAB)
           .


  SORT TMP_REPORT BY VBELN.

  DATA: V_FLAG TYPE I,
        V_EXCLUDE TYPE I,
        V_LOT_EXCLUDE TYPE I.

  V_FLAG = 0.
  V_EXCLUDE = 0.
  V_LOT_EXCLUDE = 0.

  IF SY-SUBRC = 0.

* trim the parameter space
    SHIFT P_MAWB RIGHT DELETING TRAILING SPACE.
    SHIFT P_MAWB LEFT DELETING LEADING SPACE.

    SHIFT P_LOT RIGHT DELETING TRAILING SPACE.
    SHIFT P_LOT LEFT DELETING LEADING SPACE.

    LOOP AT TMP_REPORT.

      AT NEW VBELN.
        V_FLAG = 1.
        V_EXCLUDE = 0.
      ENDAT.

      IF V_FLAG = 1.
        PERFORM GET_HEADER_TEXT
              TABLES
                   LTEXT
              USING
                   'Z3IH'
                    TMP_REPORT-VBELN
                              .

        READ TABLE LTEXT INDEX 1.
        SPLIT LTEXT-TDLINE AT ':' INTO
        TMP_REPORT-VERUR TMP_REPORT-VERUR.
        READ TABLE LTEXT INDEX 2.
        SPLIT LTEXT-TDLINE AT ':' INTO
        TMP_REPORT-KZGBE TMP_REPORT-KZGBE.
        READ TABLE LTEXT INDEX 3.
        SPLIT LTEXT-TDLINE AT ':' INTO
        TMP_REPORT-KZABE TMP_REPORT-KZABE.
        READ TABLE LTEXT INDEX 4.
        SPLIT LTEXT-TDLINE AT ':' INTO
        TMP_REPORT-STABE TMP_REPORT-STABE.
        READ TABLE LTEXT INDEX 5.
        SPLIT LTEXT-TDLINE AT ':' INTO
        TMP_REPORT-PRONU TMP_REPORT-PRONU.
        READ TABLE LTEXT INDEX 6.
        SPLIT LTEXT-TDLINE AT ':' INTO
        TMP_REPORT-LADEL TMP_REPORT-LADEL.

        SHIFT TMP_REPORT-KZABE RIGHT DELETING TRAILING SPACE.
        SHIFT TMP_REPORT-KZABE LEFT DELETING LEADING SPACE.

        MOVE-CORRESPONDING TMP_REPORT TO WA_REPORT.
        MOVE-CORRESPONDING TMP_REPORT TO WA_TMPREPORT.

        V_FLAG = 0.
      ELSE.
        MOVE TMP_REPORT-VBELN TO WA_REPORT-VBELN.
        MOVE TMP_REPORT-LIFNR TO WA_REPORT-LIFNR.
        MOVE TMP_REPORT-MATNR TO WA_REPORT-MATNR.
        MOVE TMP_REPORT-LFIMG TO WA_REPORT-LFIMG.
      ENDIF.

      PERFORM GET_LOT_CODE USING
                                 WA_REPORT-MATNR
                                 '3LTU'
                                 WA_TMPREPORT-CHARG
                                 WA_REPORT-LOT.

      IF V_EXCLUDE <> 1 AND P_MAWB NE ''
        AND WA_TMPREPORT-KZABE NE P_MAWB .
        V_EXCLUDE = 1.
      ENDIF.

      SHIFT WA_REPORT-LOT RIGHT DELETING TRAILING SPACE.
      SHIFT WA_REPORT-LOT LEFT DELETING LEADING SPACE.

      IF P_LOT NE '' AND P_LOT NE WA_REPORT-LOT.
        V_LOT_EXCLUDE = 1.
      ELSE.
        V_LOT_EXCLUDE = 0.
      ENDIF.


      IF V_EXCLUDE <> 1 AND V_LOT_EXCLUDE <> 1.
        APPEND WA_REPORT TO I_REPORT.
        CLEAR WA_REPORT.
        CLEAR TMP_REPORT.
      ENDIF.

    ENDLOOP.

Regards,

Kit