如何优化ABAP程序

news2024/11/20 8:37:40

文章目录

      • 1 Before code
      • 3 After code
      • 3 Performance
      • 4 Summary
        • 4.1 We don' t use nested loop as possible as .
        • 4.2 We use useful data in the program .
        • 4.3 Take care history data .

1 Before code

 DATA:BEGIN OF LW_SZJE,
         ZJN    TYPE P DECIMALS 1, "折旧年
         KANSW  LIKE ANLC-KANSW,  "原值
         LJZJJE LIKE ANLC-KANSW,  "累计折旧
         ZCJZ   LIKE ANLC-KANSW,  "净值
         BNJTZJ LIKE ANLC-KANSW,  "本年计提折旧
         YJTJZ  LIKE ANLC-KANSW,  "已计提减值
         MENGE  LIKE ANLA-MENGE,  "数量/建筑
       END OF LW_SZJE.

  CLEAR:LV_DATUM,LV_LASTDAY.

  CONCATENATE P_GJAHR P_AFBLPE+1(2) '01' INTO LV_DATUM.

  CALL FUNCTION 'BKK_GET_MONTH_LASTDAY'  "获取期间当月最后一天
    EXPORTING
      I_DATE = LV_DATUM
    IMPORTING
      E_DATE = LV_LASTDAY.

  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '020'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '100'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '101'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '105'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '115'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '120'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '130'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '131'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '300'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '310'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '320'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '330'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '341'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '346'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '400'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = 'Z01'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = 'Z02'.
  APPEND S_BWASL.
***20190729 begeing
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '200'.
  APPEND S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '201'.
  APPEND S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '20A'.
  APPEND S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '250'.
  APPEND S_BWASL.
***20190729 ending
  SELECT  ANLA~BUKRS ANLA~ANLN1 ANLA~ANLN2 ANLA~ANLKL ANLA~TXT50 ANLA~AKTIV ANLA~INVNR ANLA~TXA50 ANLA~MENGE ANLA~MEINS ANLA~SERNR
    ANLA~ORD41 ANLA~ORD42 ANLA~ORD43 ANLA~HERST ANLA~DEAKT ANLA~AIBN1 ANLA~AIBDT ANLA~ERDAT
    FROM ANLA
    INNER JOIN ANLZ ON ANLA~BUKRS = ANLZ~BUKRS AND ANLA~ANLN1 = ANLZ~ANLN1 AND ANLA~ANLN2 = ANLZ~ANLN2
    INTO CORRESPONDING FIELDS OF TABLE LT_ANLA
    WHERE ANLA~BUKRS IN S_BUKRS
    AND ANLA~ANLKL IN S_ANLKL
    AND ANLA~ANLN1 IN S_ANLN1
    AND ANLA~ORD41 IN S_ORD41
    AND ANLA~ORD42 IN S_ORD42
    AND ANLA~AKTIV <= LV_LASTDAY
    AND ANLA~AKTIV IN S_AKTIV
    AND ANLA~AKTIV NE '00000000'
    AND ANLZ~KOSTL IN S_KOSTL
    AND ANLZ~BDATU >= LV_DATUM.

  SELECT * FROM T087T INTO CORRESPONDING FIELDS OF TABLE LT_T087T[].

  IF LT_ANLA IS NOT INITIAL.
    SORT LT_ANLA BY BUKRS ANLN1 ANLN2.

    SELECT *
      FROM ANLC
      INTO CORRESPONDING FIELDS OF TABLE LT_ANLC
      FOR ALL ENTRIES IN LT_ANLA
      WHERE BUKRS = LT_ANLA-BUKRS
      AND ANLN1 = LT_ANLA-ANLN1
      AND ANLN2 = LT_ANLA-ANLN2
      AND AFABE = '01'
      AND GJAHR <= P_GJAHR.


    IF LT_ANLC IS NOT INITIAL.
      SORT LT_ANLC BY BUKRS ANLN1 ANLN2.

      SELECT BUKRS
             ANLN1
             ANLN2
             GJAHR
             PERAF
             NAFAZ
             AAFAZ
      FROM ANLP
      INTO CORRESPONDING FIELDS OF TABLE LT_ANLP
      FOR ALL ENTRIES IN LT_ANLC
      WHERE BUKRS = LT_ANLC-BUKRS
      AND ANLN1 = LT_ANLC-ANLN1
      AND ANLN2 = LT_ANLC-ANLN2
      AND GJAHR = LT_ANLC-GJAHR.

      SELECT ANEK~BUKRS
             ANEK~ANLN1
             ANEK~ANLN2
             ANEK~GJAHR
             ANEK~LNRAN
             ANEK~MONAT
             ANEA~NAFAV
             ANEA~NAFAL
      FROM  ANEK INNER JOIN ANEA ON ANEK~BUKRS = ANEA~BUKRS AND ANEK~ANLN1 = ANEA~ANLN1 AND ANEK~ANLN2 = ANEA~ANLN2 AND ANEK~GJAHR = ANEA~GJAHR AND  ANEK~LNRAN = ANEA~LNRAN
      INTO CORRESPONDING FIELDS OF TABLE LT_ANEK
      FOR ALL ENTRIES IN LT_ANLC
      WHERE ANEK~BUKRS = LT_ANLC-BUKRS
      AND ANEK~ANLN1 = LT_ANLC-ANLN1
      AND ANEK~ANLN2 = LT_ANLC-ANLN2
      AND ANEK~GJAHR = LT_ANLC-GJAHR.
    ENDIF.


    SELECT BUKRS
           ANLN1
           ANLN2
           GJAHR
           KNAFA
           KAAFA
    FROM ANLC
    INTO CORRESPONDING FIELDS OF TABLE LT_ANLC_SN
    FOR ALL ENTRIES IN LT_ANLA
    WHERE BUKRS = LT_ANLA-BUKRS
    AND ANLN1 = LT_ANLA-ANLN1
    AND ANLN2 = LT_ANLA-ANLN2
    AND GJAHR <= P_GJAHR.

    SELECT   BUKRS
             ANLN1
             ANLN2
             GJAHR
             BWASL
             ANBTR
             LNRAN
      FROM ANEP
      INTO CORRESPONDING FIELDS OF TABLE LT_ANEP
      FOR ALL ENTRIES IN LT_ANLA
      WHERE BUKRS = LT_ANLA-BUKRS
      AND ANLN1 = LT_ANLA-ANLN1
      AND ANLN2 = LT_ANLA-ANLN2
      AND BZDAT <=  LV_LASTDAY
      AND BWASL IN S_BWASL.


    SELECT * FROM ANLZ INTO CORRESPONDING FIELDS OF TABLE LT_ANLZ
      FOR ALL ENTRIES IN LT_ANLA
      WHERE BUKRS = LT_ANLA-BUKRS
      AND ANLN1 = LT_ANLA-ANLN1
      AND ANLN2 = LT_ANLA-ANLN2
      AND ADATU <= LV_LASTDAY
      AND BDATU >= LV_DATUM.

    IF LT_ANLZ IS NOT INITIAL.
      SORT LT_ANLZ BY WERKS STORT.
      SELECT * FROM T499S INTO CORRESPONDING FIELDS OF TABLE LT_T499S
        FOR ALL ENTRIES IN LT_ANLZ
        WHERE WERKS = LT_ANLZ-WERKS
        AND STAND = LT_ANLZ-STORT.
    ENDIF.

    SELECT * FROM ANLH INTO CORRESPONDING FIELDS OF TABLE LT_ANLH
      FOR ALL ENTRIES IN LT_ANLA
      WHERE BUKRS = LT_ANLA-BUKRS
      AND ANLN1 = LT_ANLA-ANLN1.

    SELECT * FROM ANLB INTO CORRESPONDING FIELDS OF TABLE LT_ANLB
      FOR ALL ENTRIES IN LT_ANLB
      WHERE BUKRS = LT_ANLB-BUKRS
      AND ANLN1 = LT_ANLB-ANLN1
      AND ANLN2 = LT_ANLB-ANLN2.

    SELECT
    ILOA~BUKRS
    ILOA~ANLNR
    ILOA~ANLUN
    ILOA~ILOAN
    EQUZ~EQUNR
    FROM ILOA INNER JOIN EQUZ ON ILOA~ILOAN = EQUZ~ILOAN
    INTO CORRESPONDING FIELDS OF TABLE LT_EQUNR
    FOR ALL ENTRIES IN LT_ANLA
    WHERE  ILOA~BUKRS = LT_ANLA-BUKRS
   AND ILOA~ANLNR = LT_ANLA-ANLN1
   AND ILOA~ANLUN = LT_ANLA-ANLN2
   AND EQUZ~DATAB <= LV_LASTDAY
   AND EQUZ~DATBI >= LV_LASTDAY.

    IF LT_EQUNR IS NOT INITIAL.
      SORT LT_EQUNR BY EQUNR.
      SELECT EQUNR
             EQKTX
       FROM EQKT INTO CORRESPONDING FIELDS OF TABLE LT_EQKT
       FOR ALL ENTRIES IN LT_EQUNR
       WHERE EQUNR = LT_EQUNR-EQUNR
       AND SPRAS = '1'.
    ENDIF.

    SELECT * FROM ANKT INTO CORRESPONDING FIELDS OF TABLE LT_ANKT
      FOR ALL ENTRIES IN LT_ANLA
      WHERE SPRAS = '1'
      AND ANLKL = LT_ANLA-ANLKL.
  ENDIF.

  SORT LT_ANLC BY ANLN1 ANLN2 GJAHR DESCENDING.
  SORT LT_ANLC_SN BY ANLN1 ANLN2 GJAHR DESCENDING.

  LOOP AT  LT_ANLA INTO LS_ANLA.
    CLEAR:LS_ALV,LV_SNZJ,LV_BNZJ,LV_JZJE,LV_GJAHR,LV_AFBLPE,LS_ANLC,LW_SZJE.
    MOVE-CORRESPONDING LS_ANLA TO LS_ALV.
    CALL FUNCTION 'CONVERSION_EXIT_GERNR_OUTPUT'
      EXPORTING
        INPUT  = LS_ALV-SERNR
      IMPORTING
        OUTPUT = LS_ALV-SERNR.

    READ TABLE LT_T087T WITH  KEY ORD4X = LS_ANLA-ORD41  ORDNR = '1'.
    IF SY-SUBRC = 0.
      LS_ALV-ORD41X = LT_T087T-ORDTX.
    ENDIF.
    READ TABLE LT_T087T WITH  KEY ORD4X = LS_ANLA-ORD42  ORDNR = '2'.
    IF SY-SUBRC = 0.
      LS_ALV-ORD42X = LT_T087T-ORDTX.
    ENDIF.
    READ TABLE LT_T087T WITH  KEY ORD4X = LS_ANLA-ORD43  ORDNR = '3'.
    IF SY-SUBRC = 0.
      LS_ALV-ORD43X = LT_T087T-ORDTX.
    ENDIF.

    READ TABLE LT_ANLZ INTO LS_ANLZ WITH KEY BUKRS = LS_ANLA-BUKRS ANLN1 = LS_ANLA-ANLN1 ANLN2 = LS_ANLA-ANLN2.
    IF SY-SUBRC = 0.
      LS_ALV-RAUMN = LS_ANLZ-RAUMN.
      LS_ALV-STORT = LS_ANLZ-STORT.
      LS_ALV-KFZKZ = LS_ANLZ-KFZKZ.
      LS_ALV-KOSTL = LS_ANLZ-KOSTL.

      READ TABLE LT_T499S INTO LS_T499S WITH KEY WERKS = LS_ANLZ-WERKS STAND = LS_ANLZ-STORT.
      IF SY-SUBRC = 0.
        LS_ALV-KTEXT = LS_T499S-KTEXT.
      ENDIF.
    ENDIF.

    READ TABLE LT_ANLH INTO LS_ANLH WITH KEY BUKRS = LS_ANLA-BUKRS ANLN1 = LS_ANLA-ANLN1.
    IF SY-SUBRC = 0.
      LS_ALV-ANLHTXT = LS_ANLH-ANLHTXT.
    ENDIF.

    READ TABLE LT_ANKT INTO LS_ANKT WITH KEY ANLKL = LS_ANLA-ANLKL.
    IF SY-SUBRC = 0.
      LS_ALV-TXK20 = LS_ANKT-TXK20.
    ENDIF.

    IF LS_ANLA-DEAKT IS NOT INITIAL.
      IF LS_ANLA-DEAKT < LV_LASTDAY.
        "已经报废数据
        LV_GJAHR = LS_ANLA-DEAKT+0(4).
      ELSE.
        LV_GJAHR = LV_LASTDAY+0(4).
      ENDIF.
    ELSE.
      LV_GJAHR = P_GJAHR.
    ENDIF.

    READ TABLE LT_ANLC INTO LS_ANLC WITH KEY BUKRS = LS_ANLA-BUKRS  ANLN1 = LS_ANLA-ANLN1 ANLN2 = LS_ANLA-ANLN2 GJAHR = LV_GJAHR.
    IF SY-SUBRC = 0.
      LW_SZJE-KANSW = LS_ANLC-KANSW.

      IF LS_ANLC-GJAHR = P_GJAHR.
        IF LS_ANLC-PSTEND IS INITIAL.
          LV_AFBLPE = P_AFBLPE.
        ELSE.
          IF LS_ANLC-PSTEND <= P_AFBLPE.
            LV_AFBLPE = LS_ANLC-PSTEND.
          ELSE.
            LV_AFBLPE = P_AFBLPE.
          ENDIF.
        ENDIF.
      ELSE.
        LV_AFBLPE = LS_ANLC-PSTEND.
      ENDIF.

      LW_SZJE-ZJN = ( LS_ANLC-NDABJ * 12 + LS_ANLC-NDABP + LV_AFBLPE ) / 12.
      LS_ALV-ZJN = LW_SZJE-ZJN.

      IF LV_AFBLPE = '012'.
*        LOOP AT lt_anlp INTO ls_anlp WHERE bukrs = ls_anla-bukrs AND anln1 = ls_anla-anln1 AND anln2 = ls_anla-anln2 AND gjahr = ls_anlc-gjahr .
        LOOP AT LT_ANLP INTO LS_ANLP WHERE BUKRS = LS_ANLA-BUKRS AND ANLN1 = LS_ANLA-ANLN1 AND ANLN2 = LS_ANLA-ANLN2 AND GJAHR = P_GJAHR .
          LV_BNZJ = LV_BNZJ + LS_ANLP-NAFAZ + LS_ANLP-AAFAZ.
          IF LS_ANLA-DEAKT IS INITIAL OR LS_ANLA-DEAKT(6) GT LV_LASTDAY(6).
            LW_SZJE-BNJTZJ = LW_SZJE-BNJTZJ + LS_ANLP-NAFAZ.
          ENDIF.
          LW_SZJE-YJTJZ = LW_SZJE-YJTJZ + LS_ANLP-AAFAZ.
        ENDLOOP.

*        LOOP AT lt_anek INTO ls_anek WHERE bukrs = ls_anla-bukrs AND anln1 = ls_anla-anln1 AND anln2 = ls_anla-anln2 AND gjahr = ls_anlc-gjahr .
        LOOP AT LT_ANEK INTO LS_ANEK WHERE BUKRS = LS_ANLA-BUKRS AND ANLN1 = LS_ANLA-ANLN1 AND ANLN2 = LS_ANLA-ANLN2 AND GJAHR = P_GJAHR .
          LV_BNZJ = LV_BNZJ + LS_ANEK-NAFAV + LS_ANEK-NAFAL.
        ENDLOOP.
      ELSE.
*        LOOP AT lt_anlp INTO ls_anlp WHERE bukrs = ls_anla-bukrs AND anln1 = ls_anla-anln1 AND anln2 = ls_anla-anln2 AND gjahr = ls_anlc-gjahr  AND peraf <= lv_afblpe.
        LOOP AT LT_ANLP INTO LS_ANLP WHERE BUKRS = LS_ANLA-BUKRS AND ANLN1 = LS_ANLA-ANLN1 AND ANLN2 = LS_ANLA-ANLN2 AND GJAHR = P_GJAHR  AND PERAF <= LV_AFBLPE.
          LV_BNZJ = LV_BNZJ + LS_ANLP-NAFAZ + LS_ANLP-AAFAZ.
          IF LS_ANLA-DEAKT IS INITIAL OR LS_ANLA-DEAKT(6) GT LV_LASTDAY(6).
            LW_SZJE-BNJTZJ = LW_SZJE-BNJTZJ + LS_ANLP-NAFAZ.
          ENDIF.
          LW_SZJE-YJTJZ = LW_SZJE-YJTJZ + LS_ANLP-AAFAZ.
        ENDLOOP.

        CLEAR LV_MONAT.
        LV_MONAT = LV_AFBLPE+1(2).
*        LOOP AT lt_anek INTO ls_anek WHERE bukrs = ls_anla-bukrs AND anln1 = ls_anla-anln1 AND anln2 = ls_anla-anln2 AND gjahr = ls_anlc-gjahr AND monat <= lv_monat .
        LOOP AT LT_ANEK INTO LS_ANEK WHERE BUKRS = LS_ANLA-BUKRS AND ANLN1 = LS_ANLA-ANLN1 AND ANLN2 = LS_ANLA-ANLN2 AND GJAHR = P_GJAHR AND MONAT <= LV_MONAT .
          LV_BNZJ = LV_BNZJ + LS_ANEK-NAFAV + LS_ANEK-NAFAL.
        ENDLOOP.
      ENDIF.
    ENDIF.

*    READ TABLE lt_anlc_sn INTO ls_anlc_sn WITH KEY bukrs = ls_anla-bukrs  anln1 = ls_anla-anln1  anln2 = ls_anla-anln2 gjahr = ls_anlc-gjahr.
    READ TABLE LT_ANLC_SN INTO LS_ANLC_SN WITH KEY BUKRS = LS_ANLA-BUKRS  ANLN1 = LS_ANLA-ANLN1  ANLN2 = LS_ANLA-ANLN2 GJAHR = P_GJAHR.
    IF SY-SUBRC = 0.
      LV_SNZJ =  LS_ANLC_SN-KNAFA + LS_ANLC_SN-KAAFA.
    ENDIF.

    LOOP AT LT_ANEP INTO LS_ANEP WHERE BUKRS = LS_ANLA-BUKRS AND ANLN1 = LS_ANLA-ANLN1 AND ANLN2 = LS_ANLA-ANLN2 AND GJAHR = LS_ANLC-GJAHR .
      LV_JZJE = LV_JZJE + LS_ANEP-ANBTR.
    ENDLOOP.

    LW_SZJE-KANSW = LW_SZJE-KANSW + LV_JZJE.

    LW_SZJE-LJZJJE = LV_BNZJ + LV_SNZJ.

    LW_SZJE-ZCJZ = LW_SZJE-KANSW + LW_SZJE-LJZJJE.
******数字金额字段转换
    LS_ALV-KANSW  = LW_SZJE-KANSW.
    LS_ALV-LJZJJE = LW_SZJE-LJZJJE.
    LS_ALV-ZCJZ   = LW_SZJE-ZCJZ.
    LS_ALV-BNJTZJ = LW_SZJE-BNJTZJ.
    LS_ALV-YJTJZ  = LW_SZJE-YJTJZ.
*    ls_alv-menge  = lw_szje-menge.  "COMMENT BY LW 20191121 这句语句给数量清零了
****
    READ TABLE LT_ANLB INTO LS_ANLB WITH KEY BUKRS = LS_ANLA-BUKRS ANLN1 = LS_ANLA-ANLN1 ANLN2 = LS_ANLA-ANLN2.
    IF SY-SUBRC = 0.
      LS_ALV-AFASL = LS_ANLB-AFASL.
      LS_ALV-NDJAR = LS_ANLB-NDJAR.

      IF LS_ANLA-DEAKT IS NOT INITIAL AND LS_ANLA-DEAKT <= LV_LASTDAY AND LS_ANLB-AFASL = '0000'.
        CONTINUE.
      ENDIF.

*      IF LS_ANLB-SCHRW IS NOT INITIAL.
*        LS_ALV-ZCJZ = LS_ALV-KANSW + LS_ALV-LJZJJE - LS_ANLB-SCHRW.
*      ELSE.
*        IF LS_ANLB-SCHRW_PROZ IS NOT INITIAL.
*          LS_ALV-ZCJZ = LS_ALV-KANSW + LS_ALV-LJZJJE - LS_ANLB-SCHRW_PROZ * LS_ALV-KANSW.
*        ELSE.
*          IF LS_ANLB-AFASL = 'LJ00' OR LS_ANLB-AFASL = 'LJ02'.
*            LS_ALV-ZCJZ = LS_ALV-KANSW + LS_ALV-LJZJJE - ( LS_ALV-KANSW * 5 / 100 ) .
*          ELSE.
*            LS_ALV-ZCJZ = LS_ALV-KANSW + LS_ALV-LJZJJE.
*          ENDIF.
*        ENDIF.
*      ENDIF.
    ENDIF.

    LOOP AT LT_EQUNR INTO LS_EQUNR WHERE BUKRS = LS_ANLA-BUKRS AND ANLNR = LS_ANLA-ANLN1 AND ANLUN = LS_ANLA-ANLN2.
      LS_ALV-EQUNR = LS_EQUNR-EQUNR.
      READ TABLE LT_EQKT INTO LS_EQKT WITH KEY EQUNR = LS_EQUNR-EQUNR.
      IF SY-SUBRC = 0.
        LS_ALV-EQKTX = LS_EQKT-EQKTX.
        SELECT SINGLE TYPBZ INTO  LS_ALV-TXA50 FROM EQUI WHERE EQUNR = LS_EQUNR-EQUNR.
      ENDIF.
******20190729 begning
      PERFORM FRM_CHENGE_DATA CHANGING LS_ALV.
******20190729 ending
      APPEND LS_ALV TO LT_ALV.
    ENDLOOP.

    IF SY-SUBRC <> 0.
      APPEND LS_ALV TO LT_ALV.
    ENDIF.

  ENDLOOP.

  IF LT_ALV IS INITIAL.
    MESSAGE '未找到符合条件的数据,请重新设置您的查询条件' TYPE 'S' DISPLAY LIKE 'E'.
    LEAVE LIST-PROCESSING.
  ENDIF.

3 After code

 DATA:BEGIN OF LW_SZJE,
         ZJN    TYPE P DECIMALS 1, "折旧年
         KANSW  LIKE ANLC-KANSW,  "原值
         LJZJJE LIKE ANLC-KANSW,  "累计折旧
         ZCJZ   LIKE ANLC-KANSW,  "净值
         BNJTZJ LIKE ANLC-KANSW,  "本年计提折旧
         YJTJZ  LIKE ANLC-KANSW,  "已计提减值
         MENGE  LIKE ANLA-MENGE,  "数量/建筑
       END OF LW_SZJE.

  CLEAR:LV_DATUM,LV_LASTDAY.

  CONCATENATE P_GJAHR P_AFBLPE+1(2) '01' INTO LV_DATUM.

  CALL FUNCTION 'BKK_GET_MONTH_LASTDAY'  "获取期间当月最后一天
    EXPORTING
      I_DATE = LV_DATUM
    IMPORTING
      E_DATE = LV_LASTDAY.

  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '020'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '100'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '101'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '105'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '115'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '120'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '130'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '131'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '300'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '310'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '320'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '330'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '341'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '346'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '400'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = 'Z01'.
  APPEND S_BWASL.
  CLEAR S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = 'Z02'.
  APPEND S_BWASL.
***20190729 begeing
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '200'.
  APPEND S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '201'.
  APPEND S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '20A'.
  APPEND S_BWASL.
  S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '250'.
  APPEND S_BWASL.

   S_BWASL-SIGN = 'I'.
  S_BWASL-OPTION = 'EQ'.
  S_BWASL-LOW = '159'.
  APPEND S_BWASL.
***20190729 ending
  SELECT  ANLA~BUKRS ANLA~ANLN1 ANLA~ANLN2 ANLA~ANLKL ANLA~TXT50 ANLA~AKTIV ANLA~INVNR ANLA~TXA50 ANLA~MENGE ANLA~MEINS ANLA~SERNR
    ANLA~ORD41 ANLA~ORD42 ANLA~ORD43 ANLA~HERST ANLA~DEAKT ANLA~AIBN1 ANLA~AIBDT ANLA~ERDAT
    FROM ANLA
    INNER JOIN ANLZ ON ANLA~BUKRS = ANLZ~BUKRS AND ANLA~ANLN1 = ANLZ~ANLN1 AND ANLA~ANLN2 = ANLZ~ANLN2
    INTO CORRESPONDING FIELDS OF TABLE LT_ANLA
    WHERE ANLA~BUKRS IN S_BUKRS
    AND ANLA~ANLKL IN S_ANLKL
    AND ANLA~ANLN1 IN S_ANLN1
    AND ANLA~ORD41 IN S_ORD41
    AND ANLA~ORD42 IN S_ORD42
    AND ANLA~AKTIV <= LV_LASTDAY
    AND ANLA~AKTIV IN S_AKTIV
    AND ANLA~AKTIV NE '00000000'
    AND ANLZ~KOSTL IN S_KOSTL
    AND ANLZ~BDATU >= LV_DATUM.

  SELECT * FROM T087T INTO CORRESPONDING FIELDS OF TABLE LT_T087T[].

  IF LT_ANLA IS NOT INITIAL.
    SORT LT_ANLA BY BUKRS ANLN1 ANLN2.

    SELECT *
      FROM ANLC
      INTO CORRESPONDING FIELDS OF TABLE LT_ANLC
      FOR ALL ENTRIES IN LT_ANLA
      WHERE BUKRS = LT_ANLA-BUKRS
      AND ANLN1 = LT_ANLA-ANLN1
      AND ANLN2 = LT_ANLA-ANLN2
      AND AFABE = '01'
      AND GJAHR <= P_GJAHR.


    IF LT_ANLC IS NOT INITIAL.
      SORT LT_ANLC BY BUKRS ANLN1 ANLN2.

      SELECT BUKRS
             ANLN1
             ANLN2
             GJAHR
             PERAF
             NAFAZ
             AAFAZ
      FROM ANLP
      INTO CORRESPONDING FIELDS OF TABLE LT_ANLP
      FOR ALL ENTRIES IN LT_ANLC
      WHERE BUKRS = LT_ANLC-BUKRS
      AND ANLN1 = LT_ANLC-ANLN1
      AND  PERAF <=      P_AFBLPE
      AND ANLN2 = LT_ANLC-ANLN2
      AND GJAHR = LT_ANLC-GJAHR.

      SELECT ANEK~BUKRS
             ANEK~ANLN1
             ANEK~ANLN2
             ANEK~GJAHR
             ANEK~LNRAN
             ANEK~MONAT
             ANEA~NAFAV
             ANEA~NAFAL
      FROM  ANEK INNER JOIN ANEA ON ANEK~BUKRS = ANEA~BUKRS AND ANEK~ANLN1 = ANEA~ANLN1 AND ANEK~ANLN2 = ANEA~ANLN2 AND ANEK~GJAHR = ANEA~GJAHR AND  ANEK~LNRAN = ANEA~LNRAN
      INTO CORRESPONDING FIELDS OF TABLE LT_ANEK
      FOR ALL ENTRIES IN LT_ANLC
      WHERE ANEK~BUKRS = LT_ANLC-BUKRS
      AND ANEK~ANLN1 = LT_ANLC-ANLN1
      AND ANEK~ANLN2 = LT_ANLC-ANLN2
      AND ANEK~GJAHR = LT_ANLC-GJAHR.
    ENDIF.


    SELECT BUKRS
           ANLN1
           ANLN2
           GJAHR
           KNAFA
           KAAFA
    FROM ANLC
    INTO CORRESPONDING FIELDS OF TABLE LT_ANLC_SN
    FOR ALL ENTRIES IN LT_ANLA
    WHERE BUKRS = LT_ANLA-BUKRS
    AND ANLN1 = LT_ANLA-ANLN1
    AND ANLN2 = LT_ANLA-ANLN2
    AND GJAHR <= P_GJAHR.

    SELECT   BUKRS
             ANLN1
             ANLN2
             GJAHR
             BWASL
             ANBTR
             LNRAN
      FROM ANEP
      INTO CORRESPONDING FIELDS OF TABLE LT_ANEP
      FOR ALL ENTRIES IN LT_ANLA
      WHERE BUKRS = LT_ANLA-BUKRS
      AND ANLN1 = LT_ANLA-ANLN1
      AND ANLN2 = LT_ANLA-ANLN2
      AND AFABE  = '01'
      AND BZDAT <=  LV_LASTDAY
      AND BWASL IN S_BWASL.


    SELECT * FROM ANLZ INTO CORRESPONDING FIELDS OF TABLE LT_ANLZ
      FOR ALL ENTRIES IN LT_ANLA
      WHERE BUKRS = LT_ANLA-BUKRS
      AND ANLN1 = LT_ANLA-ANLN1
      AND ANLN2 = LT_ANLA-ANLN2
      AND ADATU <= LV_LASTDAY
      AND BDATU >= LV_DATUM.

    IF LT_ANLZ IS NOT INITIAL.
      SORT LT_ANLZ BY WERKS STORT.
      SELECT * FROM T499S INTO CORRESPONDING FIELDS OF TABLE LT_T499S
        FOR ALL ENTRIES IN LT_ANLZ
        WHERE WERKS = LT_ANLZ-WERKS
        AND STAND = LT_ANLZ-STORT.
    ENDIF.

    SELECT * FROM ANLH INTO CORRESPONDING FIELDS OF TABLE LT_ANLH
      FOR ALL ENTRIES IN LT_ANLA
      WHERE BUKRS = LT_ANLA-BUKRS
      AND ANLN1 = LT_ANLA-ANLN1.

    SELECT * FROM ANLB INTO CORRESPONDING FIELDS OF TABLE LT_ANLB
*      FOR ALL ENTRIES IN LT_ANLB
      FOR ALL ENTRIES IN LT_ANLA
      WHERE BUKRS = LT_ANLA-BUKRS
      AND ANLN1 = LT_ANLA-ANLN1
      AND ANLN2 = LT_ANLA-ANLN2.

    SELECT
    ILOA~BUKRS
    ILOA~ANLNR
    ILOA~ANLUN
    ILOA~ILOAN
    EQUZ~EQUNR
    FROM ILOA INNER JOIN EQUZ ON ILOA~ILOAN = EQUZ~ILOAN
    INTO CORRESPONDING FIELDS OF TABLE LT_EQUNR
    FOR ALL ENTRIES IN LT_ANLA
    WHERE  ILOA~BUKRS = LT_ANLA-BUKRS
   AND ILOA~ANLNR = LT_ANLA-ANLN1
   AND ILOA~ANLUN = LT_ANLA-ANLN2
   AND EQUZ~DATAB <= LV_LASTDAY
   AND EQUZ~DATBI >= LV_LASTDAY.

    IF LT_EQUNR IS NOT INITIAL.
      SORT LT_EQUNR BY EQUNR.
      SELECT EQUNR
             EQKTX
       FROM EQKT INTO CORRESPONDING FIELDS OF TABLE LT_EQKT
       FOR ALL ENTRIES IN LT_EQUNR
       WHERE EQUNR = LT_EQUNR-EQUNR
       AND SPRAS = '1'.
    ENDIF.

    SELECT * FROM ANKT INTO CORRESPONDING FIELDS OF TABLE LT_ANKT
      FOR ALL ENTRIES IN LT_ANLA
      WHERE SPRAS = '1'
      AND ANLKL = LT_ANLA-ANLKL.
  ENDIF.

  SORT LT_ANLC BY BUKRS ANLN1 ANLN2 GJAHR DESCENDING .
  DELETE ADJACENT DUPLICATES FROM LT_ANLC COMPARING BUKRS ANLN1 ANLN2 .
  SORT LT_ANLC_SN BY BUKRS ANLN1 ANLN2 GJAHR DESCENDING.

  SORT LT_ANLZ  BY BUKRS ANLN1 ANLN2 .
  SORT LT_ANLH  BY BUKRS ANLN1 .
  SORT LT_ANLB  BY BUKRS  ANLN1 ANLN2 .




    DATA : LT_EQUI  LIKE STANDARD TABLE OF EQUI,
           LW_EQUI LIKE LINE OF LT_EQUI.


    IF LT_EQUNR IS NOT INITIAL.

    SELECT * FROM EQUI INTO  CORRESPONDING FIELDS OF TABLE  LT_EQUI
            FOR ALL ENTRIES IN LT_EQUNR
           WHERE EQUI~EQUNR  =   LT_EQUNR-EQUNR.

     ENDIF.
         SORT LT_EQKT  BY EQUNR.
         SORT LT_EQUI  BY EQUNR.



" START ADD IT BY JINGGL 20230520.

  data : l_dex type sy-tabix.

  LOOP AT LT_ANLC INTO LS_ANLC.

      l_dex  = sy-tabix.

    READ TABLE LT_ANLA INTO LS_ANLA WITH KEY BUKRS = LS_ANLC-BUKRS  ANLN1 = LS_ANLC-ANLN1 ANLN2 = LS_ANLC-ANLN2.
    IF SY-SUBRC = 0.


      IF LS_ANLC-GJAHR = P_GJAHR.
        IF LS_ANLC-PSTEND IS INITIAL.
       LS_ANLC-LV_AFBLPE = P_AFBLPE.
        ELSE.
          IF LS_ANLC-PSTEND <= P_AFBLPE.
            LS_ANLC-LV_AFBLPE = LS_ANLC-PSTEND.
          ELSE.
            LS_ANLC-LV_AFBLPE = P_AFBLPE.
          ENDIF.
        ENDIF.
      ELSE.
        LS_ANLC-LV_AFBLPE = LS_ANLC-PSTEND.
      ENDIF.

     MODIFY  LT_ANLC  INDEX  l_dex  FROM  LS_ANLC  TRANSPORTING  LV_AFBLPE .
    ENDIF.

    CLEAR:LS_ANLC ,LS_ANLA .
  ENDLOOP.



 SORT LT_ANLP  BY BUKRS ANLN1 ANLN2 GJAHR .
 SORT LT_ANLC  BY BUKRS ANLN1 ANLN2 GJAHR .
*
* IF   LV_AFBLPE = '012'.
  LOOP AT LT_ANLP INTO LS_ANLP.


     READ TABLE LT_ANLC INTO LS_ANLC WITH KEY BUKRS = LS_ANLP-BUKRS  ANLN1 = LS_ANLP-ANLN1 ANLN2 = LS_ANLP-ANLN2  BINARY SEARCH  .
     IF SY-SUBRC = 0.
     IF   LS_ANLC-LV_AFBLPE = '012'.
     LS_ANLP_COL-BUKRS =  LS_ANLP-BUKRS.
     LS_ANLP_COL-ANLN1 =  LS_ANLP-ANLN1.
     LS_ANLP_COL-ANLN2 =  LS_ANLP-ANLN2.
     LS_ANLP_COL-GJAHR =  LS_ANLP-GJAHR.
     LS_ANLP-LV_BNZJ =  LS_ANLP-NAFAZ + LS_ANLP-AAFAZ.
     LS_ANLP_COL-LV_BNZJ =  LS_ANLP-LV_BNZJ.
       IF LS_ANLA-DEAKT IS INITIAL OR LS_ANLA-DEAKT(6) GT LV_LASTDAY(6).
           LS_ANLP_COL-NAFAZ = LS_ANLP-NAFAZ.
          ENDIF.
          LS_ANLP_COL-AAFAZ =  LS_ANLP-AAFAZ.

     COLLECT LS_ANLP_COL INTO LT_ANLP_COL.

     ELSE.
     IF   LS_ANLP-PERAF <= LS_ANLC-LV_AFBLPE.

     LS_ANLP_COL_PERAF-BUKRS =  LS_ANLP-BUKRS.
     LS_ANLP_COL_PERAF-ANLN1 =  LS_ANLP-ANLN1.
     LS_ANLP_COL_PERAF-ANLN2 =  LS_ANLP-ANLN2.
     LS_ANLP_COL_PERAF-GJAHR =  LS_ANLP-GJAHR.

     LS_ANLP_COL_PERAF-LV_BNZJ =  LS_ANLP-NAFAZ + LS_ANLP-AAFAZ.
       IF LS_ANLA-DEAKT IS INITIAL OR LS_ANLA-DEAKT(6) GT LV_LASTDAY(6).
           LS_ANLP_COL_PERAF-NAFAZ = LS_ANLP-NAFAZ.
          ENDIF.
          LS_ANLP_COL_PERAF-AAFAZ =  LS_ANLP-AAFAZ.

     COLLECT LS_ANLP_COL_PERAF INTO LT_ANLP_COL_PERAF.

      ENDIF.

      ENDIF.
      ENDIF.
     CLEAR:LS_ANLP,LS_ANLP_COL, LS_ANLP_COL_PERAF ,LS_ANLC .

 ENDLOOP.

 SORT LT_ANEK BY BUKRS ANLN1 ANLN2  GJAHR.




  LOOP AT LT_ANEK INTO LS_ANEK.
    READ TABLE LT_ANLC INTO LS_ANLC WITH KEY BUKRS = LS_ANEK-BUKRS  ANLN1 = LS_ANEK-ANLN1 ANLN2 = LS_ANEK-ANLN2  BINARY SEARCH  .
     IF SY-SUBRC = 0.

          CLEAR LV_MONAT.
        LV_MONAT = LS_ANLC-LV_AFBLPE+1(2).

    IF   LV_AFBLPE = '012'.
     LS_ANEK_COL-BUKRS =  LS_ANEK-BUKRS.
     LS_ANEK_COL-ANLN1 = LS_ANEK-ANLN1.
     LS_ANEK_COL-ANLN2 = LS_ANEK-ANLN2.
     LS_ANEK_COL-GJAHR = LS_ANEK-GJAHR.
     LS_ANEK-LV_BNZJ =  LS_ANEK-NAFAV + LS_ANEK-NAFAL.
     LS_ANEK_COL-LV_BNZJ  =    LS_ANEK-LV_BNZJ.
     COLLECT LS_ANEK_COL  INTO LT_ANEK_COL.

     ELSE.
     IF LS_ANEK-MONAT <= LV_MONAT.

      LS_ANEK_COL_MONAT-BUKRS =  LS_ANEK-BUKRS.
     LS_ANEK_COL_MONAT-ANLN1 = LS_ANEK-ANLN1.
     LS_ANEK_COL_MONAT-ANLN2 = LS_ANEK-ANLN2.
     LS_ANEK_COL_MONAT-GJAHR = LS_ANEK-GJAHR.
     LS_ANEK-LV_BNZJ =  LS_ANEK-NAFAV + LS_ANEK-NAFAL.
     LS_ANEK_COL_MONAT-LV_BNZJ  =    LS_ANEK-LV_BNZJ.
     COLLECT LS_ANEK_COL_MONAT  INTO LT_ANEK_COL_MONAT.

     ENDIF.
      ENDIF.
      ENDIF.
     CLEAR: LS_ANEK_COL, LS_ANEK, LS_ANEK_COL_MONAT,LS_ANLC.

   ENDLOOP.
*   ENDIF.

  SORT LT_ANEP BY BUKRS ANLN1 ANLN2 GJAHR.

  LOOP AT LT_ANEP INTO LS_ANEP .
        LS_ANEP_COL-BUKRS =   LS_ANEP-BUKRS .
        LS_ANEP_COL-ANLN1 =   LS_ANEP-ANLN1 .
        LS_ANEP_COL-ANLN2 =   LS_ANEP-ANLN2 .
        LS_ANEP_COL-GJAHR =   LS_ANEP-GJAHR .
        LS_ANEP_COL-ANBTR =   LS_ANEP-ANBTR .
        COLLECT LS_ANEP_COL INTO LT_ANEP_COL .

        CLEAR:LS_ANEP,LS_ANEP_COL.
    ENDLOOP.

   CLEAR:LV_AFBLPE,LV_MONAT.

  SORT LT_ANLP_COL  BY BUKRS  ANLN1  ANLN2  GJAHR.
  SORT LT_ANLP_COL_PERAF  BY BUKRS  ANLN1  ANLN2  GJAHR.
  SORT   LT_ANEK_COL  BY BUKRS ANLN1 ANLN2 GJAHR .
  SORT LT_ANEK_COL_MONAT  BY BUKRS ANLN1 ANLN2 GJAHR .
  SORT  LT_ANEP_COL   BY BUKRS ANLN1 ANLN2 GJAHR .


 " END ADD IT BY JINGGL 20230520



  LOOP AT  LT_ANLA INTO LS_ANLA.
    CLEAR:LS_ALV,LV_SNZJ,LV_BNZJ,LV_JZJE,LV_GJAHR,LV_AFBLPE,LS_ANLC,LW_SZJE.
    MOVE-CORRESPONDING LS_ANLA TO LS_ALV.
    CALL FUNCTION 'CONVERSION_EXIT_GERNR_OUTPUT'
      EXPORTING
        INPUT  = LS_ALV-SERNR
      IMPORTING
        OUTPUT = LS_ALV-SERNR.

    READ TABLE LT_T087T WITH  KEY ORD4X = LS_ANLA-ORD41  ORDNR = '1'.
    IF SY-SUBRC = 0.
      LS_ALV-ORD41X = LT_T087T-ORDTX.
    ENDIF.
    READ TABLE LT_T087T WITH  KEY ORD4X = LS_ANLA-ORD42  ORDNR = '2'.
    IF SY-SUBRC = 0.
      LS_ALV-ORD42X = LT_T087T-ORDTX.
    ENDIF.
    READ TABLE LT_T087T WITH  KEY ORD4X = LS_ANLA-ORD43  ORDNR = '3'.
    IF SY-SUBRC = 0.
      LS_ALV-ORD43X = LT_T087T-ORDTX.
    ENDIF.

    READ TABLE LT_ANLZ INTO LS_ANLZ WITH KEY BUKRS = LS_ANLA-BUKRS ANLN1 = LS_ANLA-ANLN1 ANLN2 = LS_ANLA-ANLN2 BINARY SEARCH.
    IF SY-SUBRC = 0.
      LS_ALV-RAUMN = LS_ANLZ-RAUMN.
      LS_ALV-STORT = LS_ANLZ-STORT.
      LS_ALV-KFZKZ = LS_ANLZ-KFZKZ.
      LS_ALV-KOSTL = LS_ANLZ-KOSTL.

      READ TABLE LT_T499S INTO LS_T499S WITH KEY WERKS = LS_ANLZ-WERKS STAND = LS_ANLZ-STORT.
      IF SY-SUBRC = 0.
        LS_ALV-KTEXT = LS_T499S-KTEXT.
      ENDIF.
    ENDIF.

    READ TABLE LT_ANLH INTO LS_ANLH WITH KEY BUKRS = LS_ANLA-BUKRS ANLN1 = LS_ANLA-ANLN1 BINARY SEARCH.
    IF SY-SUBRC = 0.
      LS_ALV-ANLHTXT = LS_ANLH-ANLHTXT.
    ENDIF.

    READ TABLE LT_ANKT INTO LS_ANKT WITH KEY ANLKL = LS_ANLA-ANLKL.
    IF SY-SUBRC = 0.
      LS_ALV-TXK20 = LS_ANKT-TXK20.
    ENDIF.

    IF LS_ANLA-DEAKT IS NOT INITIAL.
      IF LS_ANLA-DEAKT < LV_LASTDAY.
        "已经报废数据
        LV_GJAHR = LS_ANLA-DEAKT+0(4).
      ELSE.
        LV_GJAHR = LV_LASTDAY+0(4).
      ENDIF.
    ELSE.
      LV_GJAHR = P_GJAHR.
    ENDIF.

    READ TABLE LT_ANLC INTO LS_ANLC WITH KEY BUKRS = LS_ANLA-BUKRS  ANLN1 = LS_ANLA-ANLN1 ANLN2 = LS_ANLA-ANLN2 GJAHR = LV_GJAHR  BINARY SEARCH .
    IF SY-SUBRC = 0.
      LW_SZJE-KANSW = LS_ANLC-KANSW.

*      IF LS_ANLC-GJAHR = P_GJAHR.
*        IF LS_ANLC-PSTEND IS INITIAL.
*          LV_AFBLPE = P_AFBLPE.
*        ELSE.
*          IF LS_ANLC-PSTEND <= P_AFBLPE.
*            LV_AFBLPE = LS_ANLC-PSTEND.
*          ELSE.
*            LV_AFBLPE = P_AFBLPE.
*          ENDIF.
*        ENDIF.
*      ELSE.
        LV_AFBLPE = LS_ANLC-LV_AFBLPE.
*      ENDIF.

      LW_SZJE-ZJN = ( LS_ANLC-NDABJ * 12 + LS_ANLC-NDABP + LV_AFBLPE ) / 12.
      LS_ALV-ZJN = LW_SZJE-ZJN.

      IF LV_AFBLPE = '012'.
*        LOOP AT lt_anlp INTO ls_anlp WHERE bukrs = ls_anla-bukrs AND anln1 = ls_anla-anln1 AND anln2 = ls_anla-anln2 AND gjahr = ls_anlc-gjahr .


        READ TABLE LT_ANLP_COL INTO LS_ANLP_COL WITH KEY BUKRS =  LS_ANLA-BUKRS  ANLN1 = LS_ANLA-ANLN1  ANLN2 = LS_ANLA-ANLN2  GJAHR = P_GJAHR  BINARY SEARCH.

         IF SY-SUBRC  = 0.
           LV_BNZJ = LS_ANLP_COL-LV_BNZJ.
            LW_SZJE-BNJTZJ =  LS_ANLP_COL-NAFAZ.
           LW_SZJE-YJTJZ = LS_ANLP_COL-AAFAZ.
          ENDIF.
          CLEAR:LS_ANLP_COL.


*        LOOP AT LT_ANLP INTO LS_ANLP WHERE BUKRS = LS_ANLA-BUKRS AND ANLN1 = LS_ANLA-ANLN1 AND ANLN2 = LS_ANLA-ANLN2 AND GJAHR = P_GJAHR .
*          LV_BNZJ = LV_BNZJ + LS_ANLP-NAFAZ + LS_ANLP-AAFAZ.
*          IF LS_ANLA-DEAKT IS INITIAL OR LS_ANLA-DEAKT(6) GT LV_LASTDAY(6).
*            LW_SZJE-BNJTZJ = LW_SZJE-BNJTZJ + LS_ANLP-NAFAZ.
*          ENDIF.
*          LW_SZJE-YJTJZ = LW_SZJE-YJTJZ + LS_ANLP-AAFAZ.
*        ENDLOOP.

*        LOOP AT lt_anek INTO ls_anek WHERE bukrs = ls_anla-bukrs AND anln1 = ls_anla-anln1 AND anln2 = ls_anla-anln2 AND gjahr = ls_anlc-gjahr .

          READ TABLE  LT_ANEK_col INTO LS_ANEK_col WITH key   BUKRS = LS_ANLA-BUKRS  ANLN1 = LS_ANLA-ANLN1  ANLN2 = LS_ANLA-ANLN2  GJAHR = P_GJAHR BINARY SEARCH .
          if sy-subrc = 0.
            LV_BNZJ = LS_ANEK_col-LV_BNZJ .

          ENDif.
          CLEAR: LS_ANEK_col.

*        LOOP AT LT_ANEK INTO LS_ANEK WHERE BUKRS = LS_ANLA-BUKRS AND ANLN1 = LS_ANLA-ANLN1 AND ANLN2 = LS_ANLA-ANLN2 AND GJAHR = P_GJAHR .
*          LV_BNZJ = LV_BNZJ + LS_ANEK-NAFAV + LS_ANEK-NAFAL.
*        ENDLOOP.
      ELSE.
*        LOOP AT lt_anlp INTO ls_anlp WHERE bukrs = ls_anla-bukrs AND anln1 = ls_anla-anln1 AND anln2 = ls_anla-anln2 AND gjahr = ls_anlc-gjahr  AND peraf <= lv_afblpe.

          READ TABLE LT_ANLP_COL_PERAF INTO LS_ANLP_COL_PERAF WITH KEY BUKRS = LS_ANLA-BUKRS  ANLN1 = LS_ANLA-ANLN1  ANLN2 = LS_ANLA-ANLN2  GJAHR = P_GJAHR  BINARY SEARCH  .

           IF SY-SUBRC = 0.
             LV_BNZJ =  LS_ANLP_COL_PERAF-LV_BNZJ.
             LW_SZJE-BNJTZJ =  LS_ANLP_COL_PERAF-NAFAZ.
             LW_SZJE-YJTJZ  =  LS_ANLP_COL_PERAF-AAFAZ.

           ENDIF.
            CLEAR:LS_ANLP_COL_PERAF.

*        LOOP AT LT_ANLP INTO LS_ANLP WHERE BUKRS = LS_ANLA-BUKRS AND ANLN1 = LS_ANLA-ANLN1 AND ANLN2 = LS_ANLA-ANLN2 AND GJAHR = P_GJAHR  AND PERAF <= LV_AFBLPE.
*          LV_BNZJ = LV_BNZJ + LS_ANLP-NAFAZ + LS_ANLP-AAFAZ.
*          IF LS_ANLA-DEAKT IS INITIAL OR LS_ANLA-DEAKT(6) GT LV_LASTDAY(6).
*            LW_SZJE-BNJTZJ = LW_SZJE-BNJTZJ + LS_ANLP-NAFAZ.
*          ENDIF.
*          LW_SZJE-YJTJZ = LW_SZJE-YJTJZ + LS_ANLP-AAFAZ.
*        ENDLOOP.

        CLEAR LV_MONAT.
        LV_MONAT = LV_AFBLPE+1(2).
*        LOOP AT lt_anek INTO ls_anek WHERE bukrs = ls_anla-bukrs AND anln1 = ls_anla-anln1 AND anln2 = ls_anla-anln2 AND gjahr = ls_anlc-gjahr AND monat <= lv_monat .
        READ TABLE LT_ANEK_COL_MONAT INTO LS_ANEK_COL_MONAT  WITH KEY BUKRS = LS_ANLA-BUKRS  ANLN1 = LS_ANLA-ANLN1  ANLN2 = LS_ANLA-ANLN2  GJAHR = P_GJAHR BINARY SEARCH .

         IF SY-SUBRC  = 0 .
           LV_BNZJ = LS_ANEK_COL_MONAT-LV_BNZJ .


          ENDIF.

         CLEAR:LS_ANEK_COL_MONAT .
*
*        LOOP AT LT_ANEK INTO LS_ANEK WHERE BUKRS = LS_ANLA-BUKRS AND ANLN1 = LS_ANLA-ANLN1 AND ANLN2 = LS_ANLA-ANLN2 AND GJAHR = P_GJAHR AND MONAT <= LV_MONAT .
*          LV_BNZJ = LV_BNZJ + LS_ANEK-NAFAV + LS_ANEK-NAFAL.
*        ENDLOOP.
      ENDIF.
    ENDIF.

*    READ TABLE lt_anlc_sn INTO ls_anlc_sn WITH KEY bukrs = ls_anla-bukrs  anln1 = ls_anla-anln1  anln2 = ls_anla-anln2 gjahr = ls_anlc-gjahr.
    READ TABLE LT_ANLC_SN INTO LS_ANLC_SN WITH KEY BUKRS = LS_ANLA-BUKRS  ANLN1 = LS_ANLA-ANLN1  ANLN2 = LS_ANLA-ANLN2 GJAHR = P_GJAHR  .
    IF SY-SUBRC = 0.
      LV_SNZJ =  LS_ANLC_SN-KNAFA + LS_ANLC_SN-KAAFA.
    ENDIF.

   READ TABLE LT_ANEP_COL INTO LS_ANEP_COL WITH KEY BUKRS = LS_ANLA-BUKRS  ANLN1 = LS_ANLA-ANLN1  ANLN2 = LS_ANLA-ANLN2  GJAHR = LS_ANLC-GJAHR  BINARY SEARCH.
    IF SY-SUBRC = 0.
      LV_JZJE  =   LS_ANEP_COL-ANBTR.
    ENDIF.

    CLEAR:LS_ANEP_COL .
*    LOOP AT LT_ANEP INTO LS_ANEP WHERE BUKRS = LS_ANLA-BUKRS AND ANLN1 = LS_ANLA-ANLN1 AND ANLN2 = LS_ANLA-ANLN2 AND GJAHR = LS_ANLC-GJAHR .
*      LV_JZJE = LV_JZJE + LS_ANEP-ANBTR.
*    ENDLOOP.

    LW_SZJE-KANSW = LW_SZJE-KANSW + LV_JZJE.

    LW_SZJE-LJZJJE = LV_BNZJ + LV_SNZJ.

    LW_SZJE-ZCJZ = LW_SZJE-KANSW + LW_SZJE-LJZJJE.
******数字金额字段转换
    LS_ALV-KANSW  = LW_SZJE-KANSW.
    LS_ALV-LJZJJE = LW_SZJE-LJZJJE.
    LS_ALV-ZCJZ   = LW_SZJE-ZCJZ.
    LS_ALV-BNJTZJ = LW_SZJE-BNJTZJ.
    LS_ALV-YJTJZ  = LW_SZJE-YJTJZ.
*    ls_alv-menge  = lw_szje-menge.  "COMMENT BY LW 20191121 这句语句给数量清零了
****
    READ TABLE LT_ANLB INTO LS_ANLB WITH KEY BUKRS = LS_ANLA-BUKRS ANLN1 = LS_ANLA-ANLN1 ANLN2 = LS_ANLA-ANLN2 BINARY SEARCH.
    IF SY-SUBRC = 0.
      LS_ALV-AFASL = LS_ANLB-AFASL.
      LS_ALV-NDJAR = LS_ANLB-NDJAR.

      IF LS_ANLA-DEAKT IS NOT INITIAL AND LS_ANLA-DEAKT <= LV_LASTDAY AND LS_ANLB-AFASL = '0000'.
        CONTINUE.
      ENDIF.

*      IF LS_ANLB-SCHRW IS NOT INITIAL.
*        LS_ALV-ZCJZ = LS_ALV-KANSW + LS_ALV-LJZJJE - LS_ANLB-SCHRW.
*      ELSE.
*        IF LS_ANLB-SCHRW_PROZ IS NOT INITIAL.
*          LS_ALV-ZCJZ = LS_ALV-KANSW + LS_ALV-LJZJJE - LS_ANLB-SCHRW_PROZ * LS_ALV-KANSW.
*        ELSE.
*          IF LS_ANLB-AFASL = 'LJ00' OR LS_ANLB-AFASL = 'LJ02'.
*            LS_ALV-ZCJZ = LS_ALV-KANSW + LS_ALV-LJZJJE - ( LS_ALV-KANSW * 5 / 100 ) .
*          ELSE.
*            LS_ALV-ZCJZ = LS_ALV-KANSW + LS_ALV-LJZJJE.
*          ENDIF.
*        ENDIF.
*      ENDIF.
    ENDIF.





    LOOP AT LT_EQUNR INTO LS_EQUNR WHERE BUKRS = LS_ANLA-BUKRS AND ANLNR = LS_ANLA-ANLN1 AND ANLUN = LS_ANLA-ANLN2.
      LS_ALV-EQUNR = LS_EQUNR-EQUNR.
      READ TABLE LT_EQKT INTO LS_EQKT WITH KEY EQUNR = LS_EQUNR-EQUNR BINARY SEARCH.
      IF SY-SUBRC = 0.
        LS_ALV-EQKTX = LS_EQKT-EQKTX.

        READ TABLE LT_EQUI INTO LW_EQUI WITH KEY EQUNR = LS_EQUNR-EQUNR BINARY SEARCH.
         IF SY-SUBRC = 0.
           LS_ALV-TXA50  =  LW_EQUI-TYPBZ.


         ENDIF.
       CLEAR: LW_EQUI.
*        SELECT SINGLE TYPBZ INTO  LS_ALV-TXA50 FROM EQUI WHERE EQUNR = LS_EQUNR-EQUNR.
      ENDIF.
******20190729 begning
      PERFORM FRM_CHENGE_DATA CHANGING LS_ALV.
******20190729 ending
      APPEND LS_ALV TO LT_ALV.
    ENDLOOP.

    IF SY-SUBRC <> 0.
      APPEND LS_ALV TO LT_ALV.
    ENDIF.

  ENDLOOP.

  IF LT_ALV IS INITIAL.
    MESSAGE '未找到符合条件的数据,请重新设置您的查询条件' TYPE 'S' DISPLAY LIKE 'E'.
    LEAVE LIST-PROCESSING.
  ENDIF.

3 Performance

在这里插入图片描述

4 Summary

4.1 We don’ t use nested loop as possible as .

4.2 We use useful data in the program .

4.3 Take care history data .

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/641008.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

从零玩转系列之微信支付实战PC端接口搭建

一、前言 halo各位大佬很久没更新了最近在搞微信支付,因商户号审核了我半个月和小程序认证也找了资料并且将商户号和小程序进行关联,至此微信支付Native支付完成.此篇文章过长我将分几个阶段的文章发布(项目源码都有,小程序和PC端) 在此之前已经更新了微信支付开篇、微信支付安…

阿里云+Nginx Proxy Manager 设置二级域名

这里我们以购买阿里云的域名为例 有域名的作用&#xff1a;当我们在浏览器上面访问主机的某一个端口时&#xff0c;必须输入主机ip端口号&#xff0c;这就会非常的麻烦&#xff0c;而且也会暴露出我们的主机名&#xff0c;很不安全&#xff0c;因此域名的好处就是可以将我们的主…

开关电源-FPC入门知识

01功率因数补偿和功率因数校正 功率因数补偿&#xff1a;在上世纪五十年代&#xff0c;已经针对具有感性负载的交流用电器具的电压和电流不同相&#xff08;图1&#xff09;从而引起的供电效率低下提出了改进方法&#xff08;由于感性负载的电流滞后所加电压&#xff0c;由于电…

JavaWeb笔记(二)

数据库基础 数据库是学习JavaWeb的一个前置&#xff0c;只有了解了数据库的操作和使用&#xff0c;我们才能更好地组织和管理网站应用产生的数据。 [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-IJ1neG69-1686619058026)(null)] 什么是数据库 数…

2023中国纸业碳中和与可持续峰会,九月来袭!

制浆与造纸是资源密集型产业&#xff0c;具有高污染、高能耗的特点。“双碳”目标提出后&#xff0c;造纸行业同时面临需求和产能增长的生产现状与实现“双碳”目标的考验。如何在未来保证产量增长&#xff0c;还能实现节能减排和降耗&#xff0c;成为了所有制浆造纸及上下游产…

docker容器启动的问题 - docker容器和虚拟机的比较 - docker的底层隔离机制

目录 一、docker容器启动的问题&#xff1f; 二、什么是docker仓库&#xff1f; 三、虚拟机和docker容器的区别&#xff1a; docker的优势&#xff1a; docker的缺点&#xff1a; 对比&#xff1a; 四、docker的底层隔离机制 参考文献&#xff1a;LXC linux容器简介——…

前端项目架构怎么搭

前端项目架构 文章目录 **前端项目架构** **框架选型标准****异常处理****自动化构建** **&#xff08;打包&#xff09;****基础组件****公共方法封装****目录结构分配原则** 框架选型标准 ​ 框架的选型需要考虑很多因素&#xff0c;如该技术能否可以满足业务需求、浏览器支…

《大卫科波菲尔》社会网络分析

《大卫科波菲尔》社会网络分析 1.简介1.1数据集介绍1.2社会网络分析简介1.3《大卫科波菲尔》介绍 2.描述性统计3.网络概述4.社区发现5.好句摘抄6.总结和不足 1.简介 1.1数据集介绍 Newman教授的个人数据网站 网址&#xff1a;http://www-personal.umich.edu/~mejn/netdata/ 从…

网络设备容量测试该如何进行?

网络设备容量测试该如何进行? 网络设备容量测试是现代IT运维管理中的重要内容之一。随着企业对网络带宽需求的不断增加&#xff0c;为了更好地满足用户需求和提升网络性能&#xff0c;进行网络设备容量测试显得尤为重要。那么&#xff0c;网络设备容量测试该如何进行呢? 首先…

转行大数据该怎么学

大数据分析主要面向于离线计算。负责数据分析、报表统计等工作&#xff0c;重于数据价值的体现&#xff1b;数据的ETL调度&#xff0c;即E抽取、T转换、L加载&#xff0c;着重于离线数据的流转。虽然工作形式比较单一&#xff0c;但日常需求比较多&#xff0c;尤其是节假日的数…

UE特效案例 —— 武器附魔

一&#xff0c;环境配置 创建默认地形Landscape&#xff0c;如给地形上材质需确定比例&#xff1b;添加环境主光源DirectionalLight&#xff0c;设置相应的强度和颜色&#xff1b;PostProcessVolume设置曝光&#xff0c;设置Min/Max Brightness为1&#xff1b; 与关闭Game Sett…

从数据中台实践,浅谈数据质量管理

时代背景 近20年来&#xff0c;我国的科学技术发展日新月异&#xff0c;各种新兴技术层出不穷&#xff0c;深刻的改变着各行各业&#xff0c;也改变着我们的生活。大数据、云计算、人工智能的出现更是将技术革命推向了高潮。在这种背景下&#xff0c;继农业经济、工业经济之后&…

NSS周常刷密码(3)

[LitCTF 2023]md5的破解 from hashlib import md5 from string import ascii_lowercase,digits import itertools f1 LitCTF{md5can3derypt213thoughcrsh} for i in itertools.product(ascii_lowercasedigits, repeat4):t .join(i)flag f1[:13] t[:2] f1[13:16] t[2] f…

d2l_第四章学习_Classification/Softmax Regression

x.1 Classification 分类问题理论 x.1.1 Classification和Regression的区别 注意&#xff0c;广义上来讲&#xff0c;Classification/Softmax Regression 和 Linear Regression 都属于线性模型。但人们口语上更习惯用Classification表示Softmax Regression&#xff0c;而用Re…

13. ReentrantLock、ReentrantReadWriteLock、StampedLock讲解

13.1 关于锁的面试题 ● 你知道Java里面有那些锁 ● 你说说你用过的锁&#xff0c;锁饥饿问题是什么&#xff1f; ● 有没有比读写锁更快的锁 ● StampedLock知道吗&#xff1f;&#xff08;邮戳锁/票据锁&#xff09; ● ReentrantReadWriteLock有锁降级机制&#xff0c;你知道…

linux实验四 vi编辑器及用户管理

1、vi编辑器的详细使用 &#xff08;1&#xff09;在用户主目录下建一个名为vi的目录。 &#xff08;2&#xff09;进入vi目录。 &#xff08;3&#xff09;将文件/etc/man_db.conf复制到当前目录下&#xff0c;并用命令sudo修改man_db.conf的属性为所有用户可以读写。 &am…

华为OD机试真题 JavaScript 实现【贪心的商人】【2023Q1 100分】

一、题目描述 商人经营一家店铺&#xff0c;有number种商品&#xff0c;由于仓库限制每件商品的最大持有数量是item[index]&#xff0c;每种商品的价格在每天是item_price[item_index][day]&#xff0c;通过对商品的买进和卖出获取利润&#xff0c;请给出商人在days天内能获取…

SQL高级之order by优化

简介 MySQL支持两种方式的排序&#xff0c;FileSort和Index&#xff0c;其中Index的效率较高他是指MySQL扫描索引本身完成排序。FileSort方式效率较低 使用Index 一般情况下ORDER BY满足两种情况会使用索引排序 ORDER BY语句使用索引最左前列使用where子句与order by 子句条…

复习之linux虚拟化的介绍

一、虚拟化客户端及工具的安装 1.在虚拟机westos中列出&#xff1a; ps:虚拟机中安装虚拟机无意义&#xff0c;这里指是做实验看清楚虚拟机的创建&#xff01; # dnf group list --hidden irtualization Client &#xff1a;虚拟化客户端 Virtualization Tools &…

稳定性治理二,稳定性分析

目录 重新认识系统稳定性&#xff08;SLA与系分&#xff09;稳定性分析&#xff08;单点&#xff0c;容量和性能&#xff0c;依赖&#xff0c;数据保护&#xff0c;安全&#xff0c;资损&#xff0c;弹性能力&#xff0c;业务连续性&#xff0c;变更控制&#xff09;压测方案&a…