SAP 采购订单税码增强检查

原文地址:http://fengan321.blog.163.com/blog/static/61762371201212911542414/

1、SE18查看ME_PROCESS_PO_CUST相关信息
 
2、SE19创建ME_PROCESS_PO_CUST的BADI实现类
 
注意类名称定义是按照以下规则:
ZCL_IM_ + BADI
其中CL表示CLASS类的意思,
IM表示Implement实现的意思;
3、SE24实现ZCL_IM_ME_PROCESS_PO_CUST

4、实现PROCESS_ITEM代码:
METHOD IF_EX_ME_PROCESS_PO_CUST~PROCESS_ITEM.

*&==========================================================
*& 对采购订单行项目增加是否有选择税码检查
*& Added by liangqh 2010-07-28
*&==========================================================

  INCLUDE MM_MESSAGES_MAC.

  DATA:
    L_ITEM TYPE MEPOITEM.            "采购订单行项目

*--> 取得采购订单行项目数据
  L_ITEM =  IM_ITEM->GET_DATA( ).

*--> 判断行项目税率是否为空
  IF L_ITEM-MWSKZ = '' OR L_ITEM-MWSKZ IS INITIAL.
    MMPUR_MESSAGE 'E' 'ZMM01' '002' L_ITEM-EBELN L_ITEM-EBELP '' ''.
  ENDIF.

ENDMETHOD.


METHOD IF_EX_ME_PROCESS_PO_CUST~CHECK.
*&==========================================================
*& 对采购订单行项目增加是否有选择税码检查
*& Added by liangqh 2010-07-28
*&==========================================================

  INCLUDE MM_MESSAGES_MAC.

  DATA:
    OBJ_ITEMS TYPE PURCHASE_ORDER_ITEMS,
    OBJ_ITEM TYPE PURCHASE_ORDER_ITEM,
    LW_HEADER TYPE MEPOHEADER,
    LW_ITEM TYPE MEPOITEM.

*-->取得订单抬头信息及明细数据
  LW_HEADER = IM_HEADER->GET_DATA( ).
  OBJ_ITEMS  = IM_HEADER->GET_ITEMS( ).

  LOOP AT OBJ_ITEMS INTO OBJ_ITEM.

    LW_ITEM = OBJ_ITEM-ITEM->GET_DATA( ).

*--> 判断行项目税率是否为空
    IF LW_ITEM-MWSKZ = '' OR LW_ITEM-MWSKZ IS INITIAL.
      MMPUR_MESSAGE 'E' 'ZMM01' '002' LW_ITEM-EBELN LW_ITEM-EBELP '' ''.
    ENDIF.

  ENDLOOP.

ENDMETHOD.



method IF_EX_ME_PROCESS_PO_CUST~POST.
*&==========================================================
*& 对采购订单行项目增加是否有选择税码检查
*& Added by liangqh 2010-07-28
*&==========================================================

  INCLUDE MM_MESSAGES_MAC.

  DATA:
    OBJ_ITEMS TYPE PURCHASE_ORDER_ITEMS,
    OBJ_ITEM TYPE PURCHASE_ORDER_ITEM,
    LW_HEADER TYPE MEPOHEADER,
    LW_ITEM TYPE MEPOITEM.

*-->取得订单抬头信息及明细数据
  LW_HEADER = IM_HEADER->GET_DATA( ).
  OBJ_ITEMS  = IM_HEADER->GET_ITEMS( ).

  LOOP AT OBJ_ITEMS INTO OBJ_ITEM.

    LW_ITEM = OBJ_ITEM-ITEM->GET_DATA( ).

*--> 判断行项目税率是否为空
    IF LW_ITEM-MWSKZ = '' OR LW_ITEM-MWSKZ IS INITIAL.
      MMPUR_MESSAGE 'E' 'ZMM01' '002' LW_ITEM-EBELN LW_ITEM-EBELP '' ''.
    ENDIF.

  ENDLOOP.

endmethod.


*********************************************************************************
Add by Andrew :
在采购订单增强中报消息信息的方法:
1.
     INCLUDE MM_MESSAGES_MAC.
     MMPUR_MESSAGE 'W' 'ZMM01' '002' ls_mepoitem-EBEln ls_mepoitem-EBELP ls_mepoitem-reslo '' .
2.
   sy-msgid 'ZMM01'.
    sy-msgty 'W'.
    sy-msgno 003.
    message id sy-msgid type sy-msgty number sy-msgno WITH ls_mepoitem-EBEln  ls_mepoitem-EBELP ls_mepoitem-reslo .
    set extended check off.
    call method cl_message_mm=>create
      EXPORTING
        im_msgid         sy-msgid
        im_msgty         sy-msgty
        im_msgno         sy-msgno
        im_msgv1         sy-msgv1
        im_msgv2         sy-msgv2
        im_msgv3         sy-msgv3
        im_msgv4         sy-msgv4
        im_force_collect mmpur_yes
      EXCEPTIONS
        failure          01
        dialog           02.
    set extended check off.
这两个方法实现方法是一样的,只是第一种是SAP 公司已经实现了,包含在include  MM_MESSAGES_MAC中,所以直接引用。
消息类:SE91
建立消息类:ZMM01
Message : 002 Item &1 &2 The default issuing storage location is &3.
Message : 003 Item &1 &2 The default issuing storage location is &3.

你可能感兴趣的:(header,SAP,dialog,include,IM,2010)