此文单纯用于校验采购订单屏幕界面数据。
首先使用SE18-badi增强
怎么使用实施类,自行百度。
2、双击上图框出,进入代码编辑
比如我要校验输入的物料编码有没有发布标准成本。代码如下。
METHOD IF_EX_ME_PROCESS_PO_CUST~PROCESS_ITEM. DATA: IT_HEADER TYPE REF TO IF_PURCHASE_ORDER_MM, IT_HEADER1 TYPE MEPOHEADER, IT_ITEM TYPE MEPOITEM, IT_EKPV TYPE EKPV, L_MATNR TYPE EKPO-MATNR. IF SY-TCODE NE 'ME23N'. IF IM_ITEM IS NOT INITIAL. CLEAR: IT_HEADER,IT_HEADER1,IT_ITEM,IT_EKPV,L_MATNR. CALL METHOD IM_ITEM->GET_HEADER RECEIVING RE_HEADER = IT_HEADER. CALL METHOD IT_HEADER->GET_DATA RECEIVING RE_DATA = IT_HEADER1. CALL METHOD IM_ITEM->GET_DATA RECEIVING RE_DATA = IT_ITEM. IF IT_ITEM-MATNR IS NOT INITIAL. SELECT SINGLE STPRS INTO @DATA(LS_STPRS) FROM MBEW WHERE MATNR = @IT_ITEM-MATNR AND VPRSV = 'S' AND BWKEY = @IT_ITEM-WERKS AND LFGJA = @IT_HEADER1-AEDAT+0(4) AND LFMON = @IT_HEADER1-AEDAT+4(2). IF SY-SUBRC NE 0 OR LS_STPRS IS INITIAL. MESSAGE '该物料标准成本没有发布,请联系财务成本组进行维护!' TYPE 'E'. ENDIF. ENDIF. ENDIF. ENDIF. ENDMETHOD.