SAP FICO 固定资产批导

13 篇文章 9 订阅

AS01对应的BAPI:BAPI_FIXEDASSET_CREATE

AS91对应的BAPI:BAPI_FIXEDASSET_OVRTAKE_CREATE

AS01的固定资产的导入和AS91的区别是后者可输入资本化日期,即可以导入之前资本化的资产并进行折旧。

 DATA:  ls_key                 TYPE bapi1022_key,
        ls_generaldata         TYPE bapi1022_feglg001,
        ls_generaldatax        TYPE bapi1022_feglg001x,
        ls_timedependentdata   TYPE bapi1022_feglg003,
        ls_timedependentdatax  TYPE bapi1022_feglg003x,
        ls_postinginformation  TYPE bapi1022_feglg002,
        ls_postinginformationx TYPE bapi1022_feglg002x,
        ls_allocations         TYPE bapi1022_feglg004,
        ls_allocationsx        TYPE bapi1022_feglg004x,
        ls_networthvaluation   TYPE bapi1022_feglg006,
        ls_networthvaluationx  TYPE bapi1022_feglg006x,
        ls_origin              TYPE bapi1022_feglg009,
        ls_originx              TYPE bapi1022_feglg009x,
        lt_depreciationareas   TYPE STANDARD TABLE OF bapi1022_dep_areas,
        lt_depreciationareasx  TYPE STANDARD TABLE OF bapi1022_dep_areasx,
        lt_cumulatedvalues     TYPE STANDARD TABLE OF bapi1022_cumval,
        lt_postedvalues        TYPE STANDARD TABLE OF bapi1022_postval,
        lt_transactions        TYPE STANDARD TABLE OF bapi1022_trtype,
        lt_extensionin         TYPE TABLE OF bapiparex,
        ls_extensionin         TYPE bapiparex,
        ls_assetcreated        TYPE bapi1022_reference,
        lt_return              TYPE STANDARD TABLE OF bapiret2,
        ls_return1             TYPE bapiret2.
  DATA: ls_output TYPE ty_output.
  DATA: ls_inventory  TYPE  bapi1022_feglg011,
        ls_inventoryx TYPE  bapi1022_feglg011x.


处理关键值数据
    ls_key-companycode = ls_input-companycode.               "公司代码

*   处理一般数据
    ls_generaldata-assetclass = ls_input-assetclass.         "资产分类
    IF ls_input-assetclass IS NOT INITIAL.
      ls_generaldatax-assetclass = abap_true.
    ENDIF.
    ls_generaldata-descript = ls_input-descript.             "资产描述
    IF ls_input-descript IS NOT INITIAL.
      ls_generaldatax-descript = abap_true.
    ENDIF.
    ls_generaldata-descript2 = ls_input-descript2.           "描述2
    IF ls_input-descript2 IS NOT INITIAL.
      ls_generaldatax-descript2 = abap_true.
    ENDIF.
    ls_generaldata-main_descript = ls_input-main_descript.   "资产主号文本
    IF ls_input-main_descript IS NOT INITIAL.
      ls_generaldatax-main_descript = abap_true.
    ENDIF.
    ls_generaldata-quantity  = ls_input-quantity.            "数量
    IF ls_generaldata-quantity IS NOT INITIAL.
      ls_generaldatax-quantity = abap_true.
    ENDIF.
    ls_generaldata-base_uom   = ls_input-base_uom.           "单位
    IF ls_generaldata-base_uom IS NOT INITIAL.
      ls_generaldatax-base_uom = abap_true.
    ENDIF.
    ls_generaldata-serial_no = ls_input-serial_no.           "序列号
    IF ls_input-serial_no IS NOT INITIAL.
      ls_generaldatax-serial_no = abap_true.
    ENDIF.
    ls_generaldata-invent_no = ls_input-invent_no.           "型号
    IF ls_input-invent_no IS NOT INITIAL.
      ls_generaldatax-invent_no = abap_true.
    ENDIF.
*   库存
    ls_inventory-note = ls_input-invzu.                      "历史资产号
    IF ls_input-invzu IS NOT INITIAL.
      ls_inventoryx-note = abap_true.
    ENDIF.

*   处理过帐数据
    ls_postinginformation-cap_date = ls_input-cap_date.
    IF ls_input-cap_date IS NOT INITIAL.
      ls_postinginformationx-cap_date = abap_true.
    ENDIF.

*   成本中心数据
    ls_timedependentdata-costcenter = ls_input-costcenter.   "成本中心
    IF ls_input-costcenter IS NOT INITIAL.
      ls_timedependentdatax-costcenter = abap_true.
    ENDIF.
    ls_timedependentdata-location = ls_input-location.       "位置
    IF ls_input-location IS NOT INITIAL.
      ls_timedependentdatax-location   = abap_true.
    ENDIF.
    ls_timedependentdata-person_no  = ls_input-person_no.    "使用人
    IF ls_timedependentdata-person_no IS NOT INITIAL.
      ls_timedependentdatax-person_no = abap_true.
    ENDIF.
    ls_timedependentdata-plate_no  = ls_input-plate_no.      "车牌号
    IF ls_timedependentdata-plate_no IS NOT INITIAL.
      ls_timedependentdatax-license_plate_no = abap_true.
    ENDIF.

*   处理供应商数据
    ls_origin-vendor_no = ls_input-vendor_no.                "供应商
    IF ls_origin-vendor_no IS NOT INITIAL.
      ls_originx-vendor_no   = abap_true.
    ENDIF.
    ls_origin-manufacturer  = ls_input-manufacturer .        "制造商
    IF ls_origin-manufacturer IS NOT INITIAL.
      ls_originx-manufacturer  = abap_true.
    ENDIF.

*   增加折旧范围数据
    lt_depreciationareas = VALUE #( ( area             = p_area                     "实际折旧范围
                                      dep_key          = ls_input-dep_key           "折旧码
                                      ulife_yrs        = ls_input-ulife_yrs         "使用年
                                      ulife_prds       = ls_input-ulife_prds        "使用月
                                      scrapvalue_prctg = ls_input-scrapvalue_prctg  "残值率
                                    ) ).
    lt_depreciationareasx = VALUE #( ( area             = p_area
                                       dep_key          = COND #( WHEN ls_input-dep_key          IS NOT INITIAL THEN abap_true )
                                       ulife_yrs        = COND #( WHEN ls_input-ulife_yrs        IS NOT INITIAL THEN abap_true )
                                       ulife_prds       = COND #( WHEN ls_input-ulife_prds       IS NOT INITIAL THEN abap_true )
                                       scrapvalue_prctg = COND #( WHEN ls_input-scrapvalue_prctg IS NOT INITIAL THEN abap_true )
                                       ) ).

*   增加累计折旧
    IF ls_input-cap_date+0(4) < p_year.
      lt_cumulatedvalues = VALUE #( ( area        = p_area               "实际折旧范围
                                      fisc_year   = p_year               "会计年度
                                      acq_value   = ls_input-kansw       "累积购置价值
                                      ord_dep     = ls_input-ord_dep     "累积普通折旧
                                      ) ).
    ELSE.
*     增加购置价值
      lt_transactions = VALUE #( ( fisc_year  = p_year              "会计年度
                                   area       = p_area              "实际折旧范围
                                   current_no = '00001'             "会计年资产行项目的序号
                                   assettrtyp = ls_input-assettrtyp "资产交易类型
                                   valuedate  = ls_input-cap_date   "资产资本化日期
*                                   amount     = ls_input-anbtr      "当前年度购置金额
                                   amount     = ls_input-kansw       "累积购置价值
                                  ) ).
    ENDIF.
    IF ls_input-nafag IS NOT INITIAL.
*     已过帐的传输值
      lt_postedvalues = VALUE #( ( area      = p_area
                                   fisc_year = p_year
                                   ord_dep   = ls_input-nafag    "2022年11月总折旧额
                                  ) ).
    ENDIF.
    DATA(ls_anlu) = VALUE bapi_te_anlu( comp_code = ls_input-companycode ).
    ls_extensionin-structure = 'BAPI_TE_ANLU'.
    ls_extensionin+30(960)  = ls_anlu.
    APPEND ls_extensionin TO lt_extensionin.
    CLEAR:ls_extensionin,ls_anlu.
*   固定资产期初导入
    IF p_gdqc = 'X'.

      CALL FUNCTION 'BAPI_FIXEDASSET_OVRTAKE_CREATE'
        EXPORTING
          key                 = ls_key
          testrun             = p_test
          generaldata         = ls_generaldata
          generaldatax        = ls_generaldatax
          postinginformation  = ls_postinginformation
          postinginformationx = ls_postinginformationx
          timedependentdata   = ls_timedependentdata
          timedependentdatax  = ls_timedependentdatax
          allocations         = ls_allocations
          allocationsx        = ls_allocationsx
*          networthvaluation   = ls_networthvaluation
*          networthvaluationx  = ls_networthvaluationx
          inventory           = ls_inventory
          inventoryx          = ls_inventoryx
        IMPORTING
          assetcreated        = ls_assetcreated
        TABLES
          depreciationareas   = lt_depreciationareas
          depreciationareasx  = lt_depreciationareasx
          cumulatedvalues     = lt_cumulatedvalues
          postedvalues        = lt_postedvalues
          transactions        = lt_transactions
          extensionin         = lt_extensionin
          return              = lt_return.

*   固定资产导入
    ELSE.

      CLEAR: ls_postinginformation-cap_date,ls_postinginformationx-cap_date.

      CALL FUNCTION 'BAPI_FIXEDASSET_CREATE'
        EXPORTING
          companycode         = ls_key-companycode
          asset               = ls_key-asset
          subnumber           = ls_key-subnumber
          generaldata         = ls_generaldata
          generaldatax        = ls_generaldatax
          inventory           = ls_inventory
          inventoryx          = ls_inventoryx
          postinginformation  = ls_postinginformation
          postinginformationx = ls_postinginformationx
          timedependentdata   = ls_timedependentdata
          timedependentdatax  = ls_timedependentdatax
          allocations         = ls_allocations
          allocationsx        = ls_allocationsx
          origin              = ls_origin
          originx             = ls_originx
*          networthvaluation   = ls_networthvaluation
*          networthvaluationx  = ls_networthvaluationx
        IMPORTING
          assetcreated        = ls_assetcreated
          return              = ls_return1
        TABLES
          depreciationareas   = lt_depreciationareas
          depreciationareasx  = lt_depreciationareasx
          extensionin         = lt_extensionin.


    ENDIF.

问题1:

报错:在折旧范围01中正常折旧的增值超过了累计折旧

解决方法:

 

 

 

 

如图配置中的设置无法输入正值。改为0或者负值即可

问题2:字段 资本化日期未准备好输入

AS01的BAPI的参数需要将资本化日期清空。

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值