ABAP:MR8M冲销采购预制发票增强

MR8M冲销采购预制发票增强

SMOD:LMR1M001

 

 

****ADD BY ZJ 20221026 冲销采购预制发票校验 START
IF sy-tcode = 'MR8M'.
  DATA:ls_zsdt031 TYPE zsdt031,
       ls_zsdt017 TYPE zsdt017,
       lv_bukrs   TYPE bukrs.
  SELECT SINGLE * FROM zsdt017 INTO ls_zsdt017 WHERE objkey = e_trbkpv-stblg
                                                 AND gjahr = e_trbkpv-stjah
                                                 AND objtype = 'IN'
                                                 AND fksto = ''.
  IF sy-subrc = 0.
    IF ls_zsdt017-canum = '0010'.
      SELECT SINGLE bukrs INTO lv_bukrs FROM rbkp WHERE belnr = e_trbkpv-stblg
                                                    AND gjahr = e_trbkpv-stjah.
      IF sy-subrc = 0.
        SELECT SINGLE zbs INTO @DATA(lv_zbs) FROM zsdt031 WHERE bukrs = @lv_bukrs
                                                            AND objtype = 'IS'.
        IF sy-subrc = 0 AND lv_zbs = 'Y'.
          MESSAGE '发票是自动创建的,不能修改/及过账' TYPE 'E'.
        ENDIF.
      ENDIF.
    ELSE.
      SELECT SINGLE * FROM zsdt017 INTO @DATA(ls_zsdt017_2) WHERE zrfc_logid = @ls_zsdt017-zrfc_logid
                                                              AND canum = '0010'.
      IF sy-subrc = 0.
        SELECT SINGLE vkorg INTO @DATA(lv_vkorg) FROM vbrk WHERE vbeln = @ls_zsdt017_2-objkey.

        IF sy-subrc = 0.
          SELECT SINGLE zbs INTO lv_zbs FROM zsdt031 WHERE bukrs = lv_vkorg
                                                       AND objtype = 'BS'.
          IF sy-subrc = 0 AND lv_zbs = 'Y'.
            MESSAGE '发票是自动创建的,不能修改/及过账' TYPE 'E'.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDIF.
  ENDIF.
*  SELECT SINGLE bukrs FROM rbkp INTO lv_bukrs WHERE belnr = e_trbkpv-stblg
*                                                AND gjahr = e_trbkpv-stjah.
*  IF sy-subrc = 0.
*    SELECT SINGLE * FROM zsdt031 INTO lS_zsdt031 WHERE bukrs = lv_bukrs
*                                                   AND objtype = 'IS'.
*    IF ls_zsdt031-zbs = 'Y'.
*      SELECT SINGLE * FROM zsdt017 INTO ls_zsdt017 WHERE objkey = e_trbkpv-stblg
*                                                     AND objtype = 'IS'.
*      IF sy-subrc = 0.
*        MESSAGE '发票是自动创建的,不能修改/及过账' TYPE 'E'.
*      ENDIF.
*    ENDIF.
*  ENDIF.
ENDIF.
****ADD BY ZJ 20221026 冲销采购预制发票校验 END

CMOD:

 

 全部激活!!

 

posted @ 2022-12-19 12:11  阿胖的阿多  阅读(415)  评论(0编辑  收藏  举报