前台通过tcode ABAVN报废固定资产,这个tcode对应的bapi是BAPI_ASSET_RETIREMENT_POST。
参数的详细信息可以在SE37中查看到,这个BAPI使用起来不麻烦,字段也不是很多,基本上都能对出来。。
例子代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
FORM frm_asset_retire CHANGING c_alv TYPE gty_alv. DATA: ls_generalpostingdata TYPE bapifapo_gen_info, ls_retirementdata TYPE bapifapo_ret, ls_doc TYPE bapifapo_doc_ref, ls_return TYPE bapiret2, ls_furtherpostingdata TYPE bapifapo_add_info. ls_generalpostingdata-username = sy-uname. ls_generalpostingdata-doc_date = c_alv-bldat."凭证中的凭证日期 ls_generalpostingdata-pstng_date = c_alv-budat."凭证中的过账日期 ls_generalpostingdata-fis_period = c_alv-budat+4(2)."会计期间 ls_generalpostingdata-trans_date = c_alv-budat. "换算日期 ls_generalpostingdata-comp_code = c_alv-bukrs. "公司代码 ls_generalpostingdata-assetmaino = c_alv-anln1. "主资产号 ls_generalpostingdata-assetsubno = '0000'. IF c_alv-zujhr = sy-datum+0(4)."当年的用250 ls_generalpostingdata-assettrtyp = '250'. ELSE. ls_generalpostingdata-assettrtyp = '200'."往年的用200 ENDIF. ls_retirementdata-quantity = c_alv-menge. "数量 ls_retirementdata-valuedate = c_alv-aktiv."参考日期 ls_retirementdata-compl_ret = 'X'."标志: 记帐全部报废 ls_retirementdata-base_uom = c_alv-meins."单位 ls_furtherpostingdata-header_txt = c_alv-sgtxt."将文本写入报废会计凭证的抬头文本 CALL FUNCTION 'BAPI_ASSET_RETIREMENT_POST' EXPORTING generalpostingdata = ls_generalpostingdata retirementdata = ls_retirementdata furtherpostingdata = ls_furtherpostingdata IMPORTING documentreference = ls_doc return = ls_return. IF ls_return-type = 'S'. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. IF ls_return-number = '374' AND ls_return-id = 'AA'. c_alv-xblnr = ls_return-message_v2."报废会计凭证号 c_alv-done = 'X'. ENDIF. c_alv-light = icon_green_light. c_alv-msg = ls_return-message. ELSE. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. c_alv-light = icon_red_light. c_alv-msg = ls_return-message. ENDIF. ENDFORM. |
以上。
发表评论