标签:me21nme22nme23n增强me_ abap me21n增强 sap me21n增强 sap me22n增强 sap me23n增强
一、需求背景:采购订单创建、修改时,根据所选订单类型不同,给抬头附加数据里的字段赋默认值。如下图所示:
二、实现方式:实现的方式可以有很多种,这里讲一下用BADI增强ME_PROCESS_PO_CUST实现的方式
第一步:执行事务码se19,在BAdI Name处输入:ME_PROCESS_PO_CUST,然后点“Create Impl”按钮
第二步:在Implementation Name输入ZME_PROCESS_PO_CUST,点OK按钮。
第三步:双击“PROCESS_HEADER”
第四步:在METHOD里编写代码,就可以实现需求的功能了
代码如下:
METHOD IF_EX_ME_PROCESS_PO_CUST~PROCESS_HEADER.
DATA:LT_HEADER TYPE MEPOHEADER,
LV_BSART TYPE EKKO-BSART.
IF SY-TCODE = ‘ME21N‘ OR SY-TCODE = ‘ME22N‘ OR SY-TCODE = ‘ME23N‘.
IF IM_HEADER IS NOT INITIAL.
CALL METHOD IM_HEADER->GET_DATA
RECEIVING
RE_DATA = LT_HEADER.
CLEAR LV_BSART.
SELECT SINGLE
BSART
INTO LV_BSART
FROM EKKO
WHERE EBELN = LT_HEADER-EBELN.
IF LV_BSART <> ‘ZNPI‘ and LV_BSART <> ‘NNPI‘ .
IF LT_HEADER-BSART = ‘ZNPI‘.
LT_HEADER-SUBMI = ‘ZNPI‘.
ELSEIF LT_HEADER-BSART = ‘NNPI‘.
LT_HEADER-SUBMI = ‘ZNPI‘.
ELSE.
LT_HEADER-SUBMI = ‘‘.
ENDIF.
CALL METHOD IM_HEADER->SET_DATA
EXPORTING
IM_DATA = LT_HEADER.
ENDIF.
IF LT_HEADER-SUBMI = ‘ZNPI‘.
CALL METHOD IM_HEADER->GET_DATA
RECEIVING
RE_DATA = LT_HEADER.
LT_HEADER-BEDAT = SY-DATUM.
CALL METHOD IM_HEADER->SET_DATA
EXPORTING
IM_DATA = LT_HEADER.
ENDIF.
ENDIF.
ENDIF.
ENDMETHOD.
ME21N,ME22N,ME23N之BADI增强ME_PROCESS_PO_CUST
标签:me21nme22nme23n增强me_ abap me21n增强 sap me21n增强 sap me22n增强 sap me23n增强
原文地址:http://blog.csdn.net/champaignwolf/article/details/45968871