We will implement the following fuction for importing asset value .
In the code we introduce that how to transfer value for BAPI.
DATA: key TYPE bapi1022_key,
generaldata TYPE bapi1022_feglg001,
generaldatax TYPE bapi1022_feglg001x,
postinginformation TYPE bapi1022_feglg002,
postinginformationx TYPE bapi1022_feglg002x,
allocations TYPE bapi1022_feglg004,
allocationsx TYPE bapi1022_feglg004x,
timedependentdata TYPE bapi1022_feglg003,
timedependentdatax TYPE bapi1022_feglg003x,
origin TYPE bapi1022_feglg009,
originx TYPE bapi1022_feglg009x,
transactions TYPE STANDARD TABLE OF bapi1022_trtype WITH HEADER LINE,
depreciationareas TYPE STANDARD TABLE OF bapi1022_dep_areas WITH HEADER LINE,
depreciationareasx TYPE STANDARD TABLE OF bapi1022_dep_areasx WITH HEADER LINE,
lt_postval TYPE STANDARD TABLE OF bapi1022_postval WITH HEADER LINE,
cumulatedvalues TYPE STANDARD TABLE OF bapi1022_cumval WITH HEADER LINE,
return TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE,
lt_cumval TYPE STANDARD TABLE OF bapi1022_cumval WITH HEADER LINE,
lt_trtype TYPE STANDARD TABLE OF bapi1022_trtype WITH HEADER LINE.
DATA:companycode LIKE bapi1022_1-comp_code,
asset LIKE bapi1022_1-assetmaino,
subnumber LIKE bapi1022_1-assetsubno.
*IF p_g1 IS NOT INITIAL.
CLEAR:gv_num,gv_count.
gv_num = lines( i_data )."上传条目数
LOOP AT i_data INTO wa_data.
IF wa_data-name06 IS INITIAL.
wa_data-message = TEXT-009.
wa_data-type = 'E'.
APPEND wa_data TO it_data.
CONTINUE.
ENDIF.
key-companycode = wa_data-name02. "公司代码
key-asset = wa_data-name34. "资产
key-subnumber = '0'. "次级编号
generaldata-assetclass = wa_data-name01. "资产分类
generaldata-quantity = wa_data-name08. "数量
generaldatax-quantity = 'X'.
generaldata-base_uom = wa_data-name09. "基本计量单位
generaldatax-base_uom = 'X'.
generaldata-descript = wa_data-name03. "资产描述
generaldatax-descript = 'X'.
generaldata-descript2 = wa_data-name04. "附加资产描述
generaldatax-descript2 = 'X'.
generaldata-main_descript = wa_data-name05. "设备编码
generaldatax-main_descript = 'X'.
generaldata-invent_no = wa_data-name32. "存货号 EAS资产号
generaldatax-invent_no = 'X'.
postinginformation-cap_date = wa_data-name10.
postinginformationx-cap_date = 'X'. "资产资本化日期
timedependentdata-costcenter = wa_data-name11. "成本中心
timedependentdatax-costcenter = 'X'.
timedependentdata-plant = wa_data-name35. "工厂
timedependentdatax-plant = 'X'.
timedependentdata-bus_area = wa_data-name12. "业务范围
timedependentdatax-bus_area = 'X'.
origin-vendor_no = wa_data-name17. "供应商
originx-vendor_no = 'X'. "供应商
origin-type_name = wa_data-name28. "类型名 原始购入日期
originx-type_name = 'X'.
origin-manufacturer = wa_data-name33. "制造商 原始资产号
originx-manufacturer = 'X'. "制造商 原始资产号
allocations-evalgroup1 = wa_data-name16. "评审小组1使用状态
allocationsx-evalgroup1 = 'X'.
allocations-evalgroup2 = wa_data-name06. "评审小组2-资产来源 20200301 add by skyyan
allocationsx-evalgroup2 = 'X'.
" The function is depreciation Range1 .
IF wa_data-name44 IS NOT INITIAL .
CLEAR depreciationareas[].
CLEAR depreciationareasx[].
depreciationareas-area = '01'.
depreciationareas-dep_key = wa_data-name19. "折旧码
depreciationareas-ulife_yrs = wa_data-name20. "计划年使用期
depreciationareas-ulife_prds = wa_data-name21. "计划使用期间
APPEND depreciationareas.
depreciationareasx-area = '01'.
depreciationareasx-dep_key = 'X'. "折旧码
depreciationareasx-ulife_yrs = 'X'. "计划年使用期
depreciationareasx-ulife_prds = 'X'. "计划使用期间
APPEND depreciationareasx.
CLEAR: lt_cumval. "原值
IF wa_data-name10+0(4) < sy-datum+0(4)."SY-DATUM+0(4).
lt_cumval-fisc_year = sy-datum+0(4)."SY-DATUM+0(4) - 1 .
lt_cumval-area = '01' .
lt_cumval-acq_value = wa_data-name31.
lt_cumval-ord_dep = 0 - wa_data-name37.
APPEND lt_cumval .
ELSE.
lt_trtype-fisc_year = sy-datum+0(4)."SY-DATUM+0(4) .
lt_trtype-current_no = sy-tabix .
lt_trtype-area = '01' .
lt_trtype-valuedate = wa_data-name10.
lt_trtype-assettrtyp = '100'.
lt_trtype-amount = wa_data-name31.
APPEND lt_trtype .
ENDIF.
IF wa_data-name37 <> 0.
lt_postval-fisc_year = sy-datum+0(4)."SY-DATUM+0(4)
lt_postval-area = '01' .
lt_postval-ord_dep = 0 - wa_data-name37 .
APPEND lt_postval .
ENDIF.
ENDIF.
" add it by sie_jinggl start
" The function is depreciation Range2 .
IF wa_data-name45 IS NOT INITIAL .
depreciationareas-area = '20'.
depreciationareas-dep_key = wa_data-name36. "折旧码
depreciationareas-ulife_yrs = wa_data-name38. "计划年使用期
depreciationareas-ulife_prds = wa_data-name39. "计划使用期间
APPEND depreciationareas.
depreciationareasx-area = '20'.
depreciationareasx-dep_key = 'X'. "折旧码
depreciationareasx-ulife_yrs = 'X'. "计划年使用期
depreciationareasx-ulife_prds = 'X'. "计划使用期间
APPEND depreciationareasx.
CLEAR: lt_cumval. "原值
IF wa_data-name10+0(4) < sy-datum+0(4)."SY-DATUM+0(4).
lt_cumval-fisc_year = sy-datum+0(4)."SY-DATUM+0(4) - 1 .
lt_cumval-area = '20' .
lt_cumval-acq_value = wa_data-name40.
lt_cumval-ord_dep = 0 - wa_data-name41.
APPEND lt_cumval .
ENDIF.
IF wa_data-name41 <> 0.
lt_postval-fisc_year = sy-datum+0(4)."SY-DATUM+0(4)
lt_postval-area = '20' .
lt_postval-ord_dep = 0 - wa_data-name41 .
APPEND lt_postval .
ENDIF.
ENDIF.
" The function is depreciation Range3 .
IF wa_data-name46 IS NOT INITIAL .
depreciationareas-area = '06'.
depreciationareas-dep_key = wa_data-name47. "折旧码
depreciationareas-ulife_yrs = wa_data-name48. "计划年使用期
depreciationareas-ulife_prds = wa_data-name49. "计划使用期间
APPEND depreciationareas.
depreciationareasx-area = '06'.
depreciationareasx-dep_key = 'X'. "折旧码
depreciationareasx-ulife_yrs = 'X'. "计划年使用期
depreciationareasx-ulife_prds = 'X'. "计划使用期间
APPEND depreciationareasx.
CLEAR: lt_cumval. "原值
IF wa_data-name10+0(4) < sy-datum+0(4)."SY-DATUM+0(4).
lt_cumval-fisc_year = sy-datum+0(4)."SY-DATUM+0(4) - 1 .
lt_cumval-area = '06' .
lt_cumval-acq_value = wa_data-name50.
lt_cumval-ord_dep = 0 - wa_data-name51.
APPEND lt_cumval .
ELSE.
IF wa_data-name51 IS NOT INITIAL.
lt_trtype-fisc_year = sy-datum+0(4)."SY-DATUM+0(4) .
lt_trtype-current_no = sy-tabix .
lt_trtype-area = '06' .
lt_trtype-valuedate = wa_data-name10.
lt_trtype-assettrtyp = '100'.
lt_trtype-amount = wa_data-name50.
APPEND lt_trtype .
ENDIF.
ENDIF.
IF wa_data-name51 <> 0.
lt_postval-fisc_year = sy-datum+0(4)."SY-DATUM+0(4)
lt_postval-area = '06' .
lt_postval-ord_dep = 0 - wa_data-name51 .
APPEND lt_postval .
ENDIF.
ENDIF.
" The function is depreciation Range4 .
IF wa_data-name52 IS NOT INITIAL .
depreciationareas-area = '30'.
depreciationareas-dep_key = wa_data-name53. "折旧码
depreciationareas-ulife_yrs = wa_data-name54. "计划年使用期
depreciationareas-ulife_prds = wa_data-name55. "计划使用期间
APPEND depreciationareas.
depreciationareasx-area = '30'.
depreciationareasx-dep_key = 'X'. "折旧码
depreciationareasx-ulife_yrs = 'X'. "计划年使用期
depreciationareasx-ulife_prds = 'X'. "计划使用期间
APPEND depreciationareasx.
CLEAR: lt_cumval. "原值
IF wa_data-name10+0(4) < sy-datum+0(4)."SY-DATUM+0(4).
lt_cumval-fisc_year = sy-datum+0(4)."SY-DATUM+0(4) - 1 .
lt_cumval-area = '30' .
lt_cumval-acq_value = wa_data-name56.
lt_cumval-ord_dep = 0 - wa_data-name57.
APPEND lt_cumval .
ENDIF.
IF wa_data-name57 <> 0.
lt_postval-fisc_year = sy-datum+0(4)."SY-DATUM+0(4)
lt_postval-area = '30' .
lt_postval-ord_dep = 0 - wa_data-name57 .
APPEND lt_postval .
ENDIF.
ENDIF.
" add it by sie_jinggl 20230120 end
gv_count = gv_count + 1.
gv_prog = '正在处理数据...' && gv_count && '/' && gv_num.
PERFORM frm_show_progress USING gv_prog.
CALL FUNCTION 'BAPI_FIXEDASSET_OVRTAKE_CREATE'
EXPORTING
key = key
generaldata = generaldata
generaldatax = generaldatax
postinginformation = postinginformation
postinginformationx = postinginformationx
timedependentdata = timedependentdata
timedependentdatax = timedependentdatax
allocations = allocations
allocationsx = allocationsx
origin = origin
originx = originx
IMPORTING
companycode = companycode
asset = asset
subnumber = subnumber
TABLES
depreciationareas = depreciationareas
depreciationareasx = depreciationareasx
cumulatedvalues = lt_cumval[]
postedvalues = lt_postval
transactions = lt_trtype
return = return
.
LOOP AT return WHERE type = 'E' OR type = 'A'.
ENDLOOP.
IF sy-subrc NE 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
wa_data-message = TEXT-023.
CONCATENATE asset wa_data-message INTO wa_data-message.
wa_data-type = 'S'.
APPEND wa_data TO it_data.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
wa_data-message = return-message.
wa_data-type = 'E'.
APPEND wa_data TO it_data.
ENDIF.
CLEAR return[].
ENDLOOP.
We do it in front end and implement it by bapi.