SAP採購訂單入庫後不容許修改單價加強

需求:S4在根據採購訂單作了入庫憑證以後,若是用戶反審批採購訂單去修改單價,系統提示‘已收貨,不容許修改單價’。微信

判斷流程:是否有入庫憑證oop

     若是採購訂單條件按採購信息記錄訂價,這個價格原本就不能修改,只能新增一條PBXX的條件,這裏判斷時spa

             還要判斷有沒有PBXX或者只有PB00.code

找加強的位置SMOD,而後搜索包ME包含的加強點,這個加強的位置就在視頻

 

 

 

CMOD建立一個項目,填入加強點用於管理。雙擊ZXM06U43建立就行,直接在這裏寫代碼。blog

 

 

 最後附上代碼element

注意:使用的是S4環境,獲取採購訂單條件的表不同,S4的是PRCD_ELEMENTS,ecc的好像是KONV.get

*&---------------------------------------------------------------------*
*& 包含               ZXM06U43
*&---------------------------------------------------------------------*

data: sum_menge type ekbe-menge.

if sy-tcode = 'ME22N' or sy-tcode = 'ME22'.

  loop at tekpo.

    "判斷是否有入庫記錄
    select menge,shkzg into table @data(lt_ekbe)
      from ekbe
      where ebeln = @tekpo-ebeln
        and ebelp = @tekpo-ebelp
        and bewtp = 'E'.

    loop at lt_ekbe assigning field-symbol(<ls_ekbe>).
      if <ls_ekbe>-shkzg = 'S'.
        sum_menge = sum_menge + <ls_ekbe>-menge.
      else.
        sum_menge = sum_menge - <ls_ekbe>-menge.
      endif.
    endloop.

    check sum_menge > 0."有入庫記錄
    sum_menge = 0.

    select kposn, "項目
           kschl, "條件類型
           kbetr  "價格
      into table @data(lt_price)
      from prcd_elements
      where knumv = @i_ekko-knumv
        and kposn = @tekpo-ebelp.

    read table lt_price assigning field-symbol(<ls_price>) with key kposn  = tekpo-ebelp "是否有新增條件
                                                                    kschl  = 'PBXX'.
    if sy-subrc = 0.

      read table tkomv assigning field-symbol(<ls_komv>) with key kschl = 'PBXX'.
      if sy-subrc = 0.
        if <ls_price>-kbetr <> <ls_komv>-kbetr.                                           "修改了價格
          message e899(mm) with tekpo-ebeln tekpo-ebelp '因爲已經收貨,不容許修改價格。'.
        endif.

      else.                                                                               "刪除了價格
        message e899(mm) with tekpo-ebeln tekpo-ebelp '因爲已經收貨,不容許修改價格。'.
      endif.

    else."原po沒有新增條件價格,

      read table tkomv with key kschl = 'PBXX' transporting no fields.
      if sy-subrc = 0.                                                                    "新增了價格
        message e899(mm) with tekpo-ebeln tekpo-ebelp '因爲已經收貨,不容許修改價格。'.
      endif.
    endif.
  endloop.

endif.

在CMOD激活這個加強就好了。博客

 

 

 

做者:明光爍亮
出處:http://www.cnblogs.com/hezhongxun/
微信號:HEme922 歡迎加好友一塊兒交流SAP! 視頻資料共享。
本文版權歸做者和博客園共有,歡迎轉載,但未經做者贊成必須保留此段聲明,且在文章頁面明顯位置給出原文鏈接,不然保留追究法律責任的權利。it