PO 增强校验

场景:修改PO 时 ,? item 已标记的删除标记 不允许修改,并报错

找到增强exit或者badi

ME_PROCESS_PO_CUST

?

这里要求的是点击解锁的按钮 时,删除的标记不能在修改回未删除

?在BADI的 process_item中写入代码

  DATA: ls_mepoitem TYPE mepoitem,
        ls_customer TYPE mepo_badi_exampl,
        ls_tbsg     TYPE tbsg,
        lv_dummy    TYPE c LENGTH 128,
        im_header  TYPE REF TO if_purchase_order_mm,
        head TYPE  mepoheader.

  INCLUDE mm_messages_mac. "useful macros for message handling

*---------------------------------------------------------------------*
* here we check customers data
*---------------------------------------------------------------------*

  im_header = im_item->get_header( ).
  head = im_header->get_data( ).
  ls_mepoitem = im_item->get_data( ).
  DATA:o_mepoitem TYPE mepoitem.

  IF ( sy-tcode = 'ME22N' OR sy-tcode = 'ME23N') AND head-bsart = 'Z002'.
    CALL METHOD im_item->get_previous_data  "取出修改前的ITEM的数据
      IMPORTING
        ex_data = o_mepoitem
      EXCEPTIONS
        no_data = 1
        OTHERS  = 2.
    IF sy-subrc = 0.
      IF o_mepoitem-loekz = 'L' AND ls_mepoitem-loekz IS INITIAL.  "修改前的删除标记为L ,则不可修改回正常单
        
          MESSAGE e899(mm) WITH ls_mepoitem-ebeln ls_mepoitem-ebelp '已删除的行项目不能被恢复'.
       

      ENDIF.
    ENDIF.
  ENDIF.

点击 检查的按钮的时候也可以实现,但是在check的方法中,好像不能获取修改前的数据,这时,需要取到DBTable的数据,来和当前mepotiem的数据比较来判断

原文链接:加载失败,请重新获取