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.
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.