SAP-ABAP 固定资产原值&净值取值逻辑

本文详细描述了如何在SAP系统中运用计算逻辑,通过整合不同表的数据(如ANLC,ANLA,GT_AFAPOST等)来计算资产原值、历年累计折旧、本年折旧,并最终得出资产净值。主要涉及到了会计折旧方法和数据处理过程。
摘要由CSDN通过智能技术生成

计算逻辑:
**资产原值 = ANLC-ANSWL + ANLC-KANSW
* ANLC-ANSWL 往年累计购置价值
* NNLC-KANSW 本年资产变动价值

**往年累计折旧 = ANLC-KNAFA + ANLC-KSAFA + ANLC-KAAFA + ANLC–NAFAV + ANLC-SAFAV + ANLC-AAFAV + ANLC-NAFAL + ANLC-SAFAL + ANLC-AAFAL
* ANLC-KNAFA 累计普通折旧(以前年)
* ANLC-KSAFA 累计特殊折旧(以前年)
* ANLC-KAAFA 累计计划外折旧(以前年)

* ANLC-NAFAV 比例累计特别折旧
* ANLC-SAFAV 比例累计正常折旧
* ANLC-AAFAV 前年计划外折旧

* ANLC-NAFAL 正常折旧(本年)
* ANLC-SAFAL 特殊折旧(本年)
* ANLC-AAFAL 计划外折旧(本年)

**本年折旧 = NAFAZ + SAFAZ + AAFAZ
* AM_SHOW_POST_DEPR函数计算每月折旧额汇总(查询1月到当前所在月份值汇总)
* NAFAZ 记帐的正常折旧
* SAFAZ 待过帐的特殊折旧
* AAFAZ 待过帐的计划外折旧

**资产净值 = 资产原值 - 往年累计折旧 - 本年折旧

DATA: Z_ZJ        LIKE ANLC-KNAFA.
DATA: GS_ANLC     LIKE  TABLE OF ANLC WITH HEADER LINE.
DATA: GS_ANLA     TYPE ANLA.
DATA: GT_AFAPOST  TYPE TABLE OF FIAA_DPOST.
DATA: GS_AFAPOST  TYPE FIAA_DPOST.
DATA: GT_ANLC     TYPE TABLE OF ANLC.
DATA: GT_ANLB     TYPE TABLE OF ANLB.
DATA: GT_ANEP     TYPE TABLE OF ANEP.
DATA: GT_ANEA     TYPE TABLE OF ANEA.
DATA: GT_ANEK     TYPE TABLE OF ANEK.

CLEAR: GS_ANLC.
REFRESH: GS_ANLC.
SELECT * INTO CORRESPONDING FIELDS OF TABLE GS_ANLC
  FROM ANLC
  WHERE BUKRS = ITAB-BUKRS
    AND ANLN1 = ITAB-ANLN1.
IF SY-SUBRC = 0.
  SORT GS_ANLC BY GJAHR DESCENDING.
  READ TABLE GS_ANLC WITH KEY GJAHR = P_GJAHR.     "按年份取
  IF SY-SUBRC = 0.
**资产原值
    ITAB-YZ = GS_ANLC-KANSW + GS_ANLC-ANSWL.        
**往年累计折旧
    ITAB-PRE_ZJ = GS_ANLC-KNAFA + GS_ANLC-KSAFA + GS_ANLC-KAAFA + GS_ANLC-NAFAV + GS_ANLC-SAFAV + GS_ANLC-AAFAV + GS_ANLC-NAFAL + GS_ANLC-SAFAL + GS_ANLC-AAFAL.
**本年折旧
    CLEAR: GS_ANLA.
    SELECT SINGLE * INTO GS_ANLA
      FROM ANLA
      WHERE BUKRS = ITAB-BUKRS
        AND ANLN1 = ITAB-ANLN1.
    IF SY-SUBRC = 0.
      CALL FUNCTION 'AM_SHOW_POST_DEPR'
        EXPORTING
          I_ANLA    = GS_ANLA
          I_AFABE   = '01'         "账面折旧
          I_GJAHR   = P_GJAHR
        TABLES
          T_DPOST   = GT_AFAPOST[]
          T_ANLB    = GT_ANLB[]
          T_ANLC    = GT_ANLC[]
          T_ANEP    = GT_ANEP[]
          T_ANEA    = GT_ANEA[]
          T_ANEK    = GT_ANEK[]
        EXCEPTIONS
          NOT_FOUND = 1
          OTHERS    = 2.
      CLEAR: Z_ZJ, GS_AFAPOST.
      LOOP AT GT_AFAPOST INTO GS_AFAPOST.
        Z_ZJ = GS_AFAPOST-NAFAZ + GS_AFAPOST-SAFAZ + GS_AFAPOST-AAFAZ.
        ITAB-NOW_ZJ = ITAB-NOW_ZJ + Z_ZJ.
      ENDLOOP.
    ENDIF.
**净值
    ITAB-JZ = ITAB-YZ + ITAB-PRE_ZJ + ITAB-NOW_ZJ.
  ELSE.
    READ TABLE GS_ANLC INDEX 1.                 "取最近的一笔
**资产原值
    ITAB-YZ = GS_ANLC-KANSW + GS_ANLC-ANSWL.        
**往年累计折旧
    ITAB-PRE_ZJ = GS_ANLC-KNAFA + GS_ANLC-KSAFA + GS_ANLC-KAAFA + GS_ANLC-NAFAV + GS_ANLC-SAFAV + GS_ANLC-AAFAV + GS_ANLC-NAFAL + GS_ANLC-SAFAL + GS_ANLC-AAFAL.
**本年折旧
    CLEAR: GS_ANLA.
    SELECT SINGLE * INTO GS_ANLA
      FROM ANLA
      WHERE BUKRS = ITAB-BUKRS
        AND ANLN1 = ITAB-ANLN1.
    IF SY-SUBRC = 0.
      CALL FUNCTION 'AM_SHOW_POST_DEPR'
        EXPORTING
          I_ANLA    = GS_ANLA
          I_AFABE   = '01'         "账面折旧
          I_GJAHR   = GS_ANLC-GJAHR
        TABLES
          T_DPOST   = GT_AFAPOST[]
          T_ANLB    = GT_ANLB[]
          T_ANLC    = GT_ANLC[]
          T_ANEP    = GT_ANEP[]
          T_ANEA    = GT_ANEA[]
          T_ANEK    = GT_ANEK[]
        EXCEPTIONS
          NOT_FOUND = 1
          OTHERS    = 2.
      CLEAR: Z_ZJ, GS_AFAPOST.
      LOOP AT GT_AFAPOST INTO GS_AFAPOST.
        Z_ZJ = GS_AFAPOST-NAFAZ + GS_AFAPOST-SAFAZ + GS_AFAPOST-AAFAZ.
        ITAB-NOW_ZJ = ITAB-NOW_ZJ + Z_ZJ.
      ENDLOOP.
    ENDIF.
**净值
    ITAB-JZ = ITAB-YZ + ITAB-PRE_ZJ + ITAB-NOW_ZJ.
  ENDIF.
ENDIF.

以上~~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值