me21n增强BADI:ME_PROCESS_PO_CUST之process_account
当实施ME_PROCESS_PO_CUST这个badi来增强ME21N的时候,用了到方法process_account,既对ME21N的行项目的科目分配做增强。主要用到如下类:
IF_PURCHASE_ORDER_ITEM_MM:获取PO行项目内容
IF_PURCHASE_ORDER_ACCOUNT_MM:PO行项目科目分配相关
- 需求描述:根绝ME21N输入的行项目信息,从自建表ZMMT003中自动带出总帐科目字段
1、实施增强ME_PROCESS_PO_CUST并在方法process_account中定义变量
DATA:lc_account TYPE REF TO if_purchase_order_account_mm,
lc_item TYPE REF TO if_purchase_order_item_mm,
ls_poitem TYPE mepoitem,"po item datas
ls_account TYPE mepoaccounting,"科目分配字段结构
lv_sakto TYPE saknr. "总帐科目编号
lc_item TYPE REF TO if_purchase_order_item_mm,
ls_poitem TYPE mepoitem,"po item datas
ls_account TYPE mepoaccounting,"科目分配字段结构
lv_sakto TYPE saknr. "总帐科目编号
2、取得PO行项目数据
CALL METHOD lc_account->get_item
RECEIVING
re_item = lc_item.
CALL METHOD lc_item->get_data
RECEIVING
re_data = ls_poitem.
RECEIVING
re_item = lc_item.
CALL METHOD lc_item->get_data
RECEIVING
re_data = ls_poitem.
3、根据行项目数据,去自建表ZMMT003取总帐科目放到变量中
SELECT SINGLE saknr
INTO lv_sakto
FROM zmmt003
WHERE werks = ls_poitem-werks
AND knttp = ls_poitem-knttp
AND matkl = ls_poitem-matkl.
INTO lv_sakto
FROM zmmt003
WHERE werks = ls_poitem-werks
AND knttp = ls_poitem-knttp
AND matkl = ls_poitem-matkl.
4、取得科目分配视图下的数据
CALL METHOD lc_account->get_data
RECEIVING
re_data = ls_account.
MOVE: lv_sakto TO ls_account-sakto.
RECEIVING
re_data = ls_account.
MOVE: lv_sakto TO ls_account-sakto.
5、设置科目分配视图中的数据
CALL METHOD lc_account->set_data
EXPORTING
im_data = ls_account.
EXPORTING
im_data = ls_account.
注意:如果第4步没有先获取科目分配视图下的数据,直接进行更新,那么可能会因为传入参数不足,导致报如下错误“没有采用附加业务 ME_PROCESS_PO_CUST 的数据”,消息号为:MEPO151