ABAP 设置开票后不允许修改采购订单价格

ABAP 设置开票后不允许修改采购订单价格
增强:MM06E005
EXIT_SAPMM06E_012
INCLUDE ZXM06U43 .

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

***设置开票后不允许修改采购订单价格-公司间PO
DATA:BEGIN OF lt_ekbe OCCURS 0,
ebeln LIKE ekbe-ebeln,
ebelp LIKE ekbe-ebelp,
gjahr LIKE ekbe-gjahr,
belnr LIKE ekbe-belnr,
buzei LIKE ekbe-buzei,
bewtp LIKE ekbe-bewtp,
bwart LIKE ekbe-bwart,
shkzg LIKE ekbe-shkzg,
bamng LIKE ekbe-bamng,
END OF lt_ekbe.

IF sy-tcode = 'ME22N'
  OR sy-tcode = 'ME23N'
  OR sy-tcode = 'ME29N'
  OR sy-tcode = 'ME21N' .

  IF i_ekko-bsart = 'Z005'
    OR i_ekko-bsart = 'Z009'
    OR i_ekko-bsart = 'Z010'.

    LOOP AT tekpo.
      REFRESH lt_ekbe.
      SELECT
        ekbe~ebeln
        ekbe~ebelp
        ekbe~gjahr
        ekbe~belnr
        ekbe~buzei
        ekbe~bwart
        INTO CORRESPONDING FIELDS OF TABLE lt_ekbe
        FROM ekbe
        JOIN rbkp ON ekbe~belnr EQ rbkp~belnr
                 AND ekbe~gjahr EQ rbkp~gjahr
        WHERE ekbe~ebeln EQ tekpo-ebeln
          AND ekbe~ebelp EQ tekpo-ebelp
          AND ekbe~bewtp EQ 'Q'
          AND rbkp~stblg EQ ''
          AND rbkp~rbstat <> '2'.
      IF lt_ekbe[] IS NOT INITIAL.

        SELECT kposn, "项目
               kschl, "条件类型
               kbetr  "价格
          INTO TABLE @DATA(lt_price)
          FROM prcd_elements
          WHERE knumv = @i_ekko-knumv
            AND kposn = @tekpo-ebelp
            AND kinak = ''
            AND kschl = 'P101'.

        READ TABLE lt_price INTO DATA(lv_price1) WITH KEY kposn  = tekpo-ebelp
                                                          kschl  = 'P101'.
        IF sy-subrc = 0.
          READ TABLE tkomv INTO DATA(ls_komv1) WITH KEY kschl = 'P101'
                                                        knumv = i_ekko-knumv
                                                        kposn = tekpo-ebelp.
          IF sy-subrc = 0.
            IF lv_price1-kbetr <> ls_komv1-kbetr.
              MESSAGE e899(mm) WITH tekpo-ebeln tekpo-ebelp '由于已经开票,不允许修改价格。'.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDLOOP.
  ENDIF.
ENDIF.

***设置开票后不允许修改采购订单价格-公司间PO

你可能感兴趣的:(SAP-MM,SAP-ABAP,SAP,ABAP)