本文主要是介绍以前年度资产价值导入以及汇率自动计算解决方案,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
文章目录
- 1 Introduction
- 2 Code
- 3 Summary
1 Introduction
In the example we will finish ABLDT function and modify asset value .
2 Code
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,postedvalues 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,extensionin TYPE STANDARD TABLE OF bapiparex WITH HEADER LINE,lt_investment_support TYPE STANDARD TABLE OF bapi1022_inv_support WITH HEADER LINE.DATA:companycode LIKE bapi1022_1-comp_code,asset LIKE bapi1022_1-assetmaino,subnumber LIKE bapi1022_1-assetsubno.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. "资产分类generaldatax-assetclass = 'X'.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-manufacturer = wa_data-name33. "制造商 原始资产号originx-manufacturer = 'X'. "制造商 原始资产号origin-type_name = wa_data-name28. "类型名 原始购入日期originx-type_name = 'X'.allocations-evalgroup1 = wa_data-name16. "评审小组1使用状态allocationsx-evalgroup1 = 'X'.allocations-evalgroup2 = wa_data-name06. "评审小组2-资产来源 20200301 add by skyyanallocationsx-evalgroup2 = 'X'." add it by sie_jinggl start 20240123IF wa_data-name36 IS NOT INITIAL .CLEAR:depreciationareas ,depreciationareasx , cumulatedvalues,transactions,postedvalues.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. "计划使用期间depreciationareas-odep_start_date = wa_data-name38. "折旧计算开始日期APPEND depreciationareas.depreciationareasx-area = '01'.depreciationareasx-dep_key = 'X'. "折旧码depreciationareasx-ulife_yrs = 'X'. "计划年使用期depreciationareasx-ulife_prds = 'X'. "计划使用期间depreciationareasx-exp_ulife_yrs = 'X'. "原始使用年depreciationareasx-exp_ulife_prds = 'X'. "原始使用期间depreciationareasx-odep_start_date = 'X'. " "APPEND depreciationareasx.CLEAR: cumulatedvalues[].IF wa_data-name10+0(4) < sy-datum+0(4).cumulatedvalues-fisc_year = sy-datum+0(4)."'2020'. "年度cumulatedvalues-area = '01'. "范围cumulatedvalues-acq_value = wa_data-name37. "购置价值cumulatedvalues-ord_dep = 0 - wa_data-name26. "累积普通折旧APPEND cumulatedvalues.ELSE.CLEAR transactions[].IF wa_data-name38 IS NOT INITIAL.transactions-valuedate = wa_data-name38.transactions-current_no = '00001'.transactions-fisc_year = sy-datum+0(4)."'2020'. "会计年transactions-assettrtyp = '100'. "事物类型transactions-area = '01'."wa_data-name33'. "折旧范围transactions-amount = wa_data-name37. "记账金额APPEND transactions.ENDIF.ENDIF.IF wa_data-name27 <> 0.CLEAR postedvalues[].postedvalues-fisc_year = sy-datum+0(4)."'2020'. "年度postedvalues-area = '01'. "范围postedvalues-ord_dep = 0 - wa_data-name27. "一般折旧APPEND postedvalues.ENDIF.
*ENDIF." add it by sie_jinggl start" The function is depreciation Range2 .IF wa_data-name39 IS NOT INITIAL .CLEAR:depreciationareas ,depreciationareasx , cumulatedvalues,transactions,postedvalues.depreciationareas-area = '20'.depreciationareas-dep_key = wa_data-name40. "折旧码depreciationareas-ulife_yrs = wa_data-name41. "计划年使用期depreciationareas-ulife_prds = wa_data-name42. "计划使用期间depreciationareas-odep_start_date = wa_data-name43. "折旧计算开始日期APPEND depreciationareas.depreciationareasx-area = '20'.depreciationareasx-dep_key = 'X'. "折旧码depreciationareasx-ulife_yrs = 'X'. "计划年使用期depreciationareasx-ulife_prds = 'X'. "计划使用期间depreciationareasx-exp_ulife_yrs = 'X'. "原始使用年depreciationareasx-exp_ulife_prds = 'X'. "原始使用期间depreciationareasx-odep_start_date = 'X'. "折旧计算开始日"APPEND depreciationareasx.IF wa_data-name10+0(4) < sy-datum+0(4).cumulatedvalues-fisc_year = sy-datum+0(4)."'2020'. "年度cumulatedvalues-area = '20'. "范围cumulatedvalues-acq_value = wa_data-name44. "购置价值cumulatedvalues-ord_dep = 0 - wa_data-name45. "累积普通折旧* cumulatedvalues-currency = 'USDT'.
* cumulatedvalues-currency_iso = 'USDT' .APPEND cumulatedvalues.ELSE.IF wa_data-name38 IS NOT INITIAL.transactions-valuedate = wa_data-name38.transactions-current_no = '00001'.transactions-fisc_year = sy-datum+0(4)."'2020'. "会计年transactions-assettrtyp = '100'. "事物类型transactions-area = '20'."wa_data-name33'. "折旧范围transactions-amount = wa_data-name44. "记账金额APPEND transactions.ENDIF.ENDIF.
* CLEAR postedvalues[].IF wa_data-name46 <> 0.postedvalues-fisc_year = sy-datum+0(4)."'2020'. "年度postedvalues-area = '20'. "范围postedvalues-ord_dep = 0 - wa_data-name46. "一般折旧
*
* postedvalues-currency = 'USDT'.
* postedvalues-currency_iso = 'USDT'.
* cumulatedvalues-currency_iso = 'TRY' .APPEND postedvalues.ENDIF.ENDIF." The function is depreciation Range3 .IF wa_data-name47 IS NOT INITIAL .CLEAR:depreciationareas ,depreciationareasx , cumulatedvalues,transactions,postedvalues.depreciationareas-area = '06'.depreciationareas-dep_key = wa_data-name48. "折旧码depreciationareas-ulife_yrs = wa_data-name49. "计划年使用期depreciationareas-ulife_prds = wa_data-name50. "计划使用期间depreciationareas-odep_start_date = wa_data-name51. "折旧计算开始日期APPEND depreciationareas.depreciationareasx-area = '06'.depreciationareasx-dep_key = 'X'. "折旧码depreciationareasx-ulife_yrs = 'X'. "计划年使用期depreciationareasx-ulife_prds = 'X'. "计划使用期间depreciationareasx-exp_ulife_yrs = 'X'. "原始使用年depreciationareasx-exp_ulife_prds = 'X'. "原始使用期间depreciationareasx-odep_start_date = 'X'. "折旧计算开始日APPEND depreciationareasx.IF wa_data-name10+0(4) < sy-datum+0(4).cumulatedvalues-fisc_year = sy-datum+0(4)."'2020'. "年度cumulatedvalues-area = '06'. "范围cumulatedvalues-acq_value = wa_data-name52. "购置价值cumulatedvalues-ord_dep = 0 - wa_data-name53. "累积普通折旧APPEND cumulatedvalues.ELSE.IF wa_data-name38 IS NOT INITIAL.transactions-valuedate = wa_data-name38.transactions-current_no = '00001'.transactions-fisc_year = sy-datum+0(4)."'2020'. "会计年transactions-assettrtyp = '100'. "事物类型transactions-area = '06'."wa_data-name33'. "折旧范围transactions-amount = wa_data-name52. "记账金额APPEND transactions.ENDIF.*ENDIF.* CLEAR postedvalues[].IF wa_data-name54 <> 0 .postedvalues-fisc_year = sy-datum+0(4)."'2020'. "年度postedvalues-area = '06'. "范围postedvalues-ord_dep = 0 - wa_data-name54. "一般折旧APPEND postedvalues.ENDIF.ENDIF." The function is depreciation Range4 .IF wa_data-name55 IS NOT INITIAL .CLEAR:depreciationareas ,depreciationareasx , cumulatedvalues,transactions,postedvalues.depreciationareas-area = '30'.depreciationareas-dep_key = wa_data-name56. "折旧码depreciationareas-ulife_yrs = wa_data-name57. "计划年使用期depreciationareas-ulife_prds = wa_data-name58. "计划使用期间depreciationareas-odep_start_date = wa_data-name59. "折旧计算开始日期APPEND depreciationareas.depreciationareasx-area = '30'.depreciationareasx-dep_key = 'X'. "折旧码depreciationareasx-ulife_yrs = 'X'. "计划年使用期depreciationareasx-ulife_prds = 'X'. "计划使用期间depreciationareasx-exp_ulife_yrs = 'X'. "原始使用年depreciationareasx-exp_ulife_prds = 'X'. "原始使用期间depreciationareasx-odep_start_date = 'X'. "折旧计算开始日APPEND depreciationareasx.IF wa_data-name10+0(4) < sy-datum+0(4).cumulatedvalues-fisc_year = sy-datum+0(4)."'2020'. "年度cumulatedvalues-area = '30'. "范围cumulatedvalues-acq_value = wa_data-name60. "购置价值cumulatedvalues-ord_dep = 0 - wa_data-name61. "累积普通折旧
* cumulatedvalues-currency = 'USDT'.
* cumulatedvalues-currency_iso = 'USDT' .APPEND cumulatedvalues.ELSE.IF wa_data-name38 IS NOT INITIAL.transactions-valuedate = wa_data-name38.transactions-current_no = '00001'.transactions-fisc_year = sy-datum+0(4)."'2020'. "会计年transactions-assettrtyp = '100'. "事物类型transactions-area = '01'."wa_data-name33'. "折旧范围transactions-amount = wa_data-name60. "记账金额APPEND transactions.ENDIF.ENDIF.* CLEAR postedvalues[].IF wa_data-name62 <> 0 .postedvalues-fisc_year = sy-datum+0(4)."'2020'. "年度postedvalues-area = '30'. "范围postedvalues-ord_dep = 0 - wa_data-name62. "一般折旧
* postedvalues-currency = 'USDT'.
* postedvalues-currency_iso = 'USDT'.APPEND postedvalues.ENDIF.ENDIF." add it by sie_jinggl end 20240123gv_count = gv_count + 1.gv_prog = '正在处理数据...' && gv_count && '/' && gv_num.PERFORM frm_show_progress USING gv_prog.CALL FUNCTION 'BAPI_FIXEDASSET_OVRTAKE_CREATE'EXPORTINGkey = keygeneraldata = generaldatageneraldatax = generaldatax
* INVENTORY =
* INVENTORYX =postinginformation = postinginformationpostinginformationx = postinginformationxtimedependentdata = timedependentdatatimedependentdatax = timedependentdataxallocations = allocationsallocationsx = allocationsxorigin = originoriginx = originxIMPORTINGcompanycode = companycodeasset = assetsubnumber = subnumberTABLESdepreciationareas = depreciationareasdepreciationareasx = depreciationareasxcumulatedvalues = cumulatedvaluespostedvalues = postedvaluestransactions = transactionsreturn = return.APPEND return.LOOP AT return WHERE type = 'E' OR type = 'A'.ENDLOOP.IF sy-subrc NE 0.CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'EXPORTINGwait = 'X'.wa_data-message = '成功'.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.
3 Summary
Curr1 is local currency .
Curr2 is group currency.
If the system tell us htat we don’t changed it . We will cancel the field for deleting .
When the SAP system gets data by exchange rate and we hope we get value from input the following solution is here .
When I debug it and I find the control point is here (The system get data by exchange rate ).
When the field ‘wrtaft’ is not equal ‘00’ and we don’t get value by exchange rate .
这篇关于以前年度资产价值导入以及汇率自动计算解决方案的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!