ABAP:MIR4采购发票校验增强

采购发票校验增强MIR4:

SE18:

  METHOD if_ex_invoice_update~change_before_update.
*    DATA:i_str TYPE string.
*    DATA:BEGIN OF is_iqc,
*           mblnr      TYPE zwms_sap_iqc-mblnr,
*           po_number  TYPE zwms_sap_iqc-po_number,
*           po_item    TYPE zwms_sap_iqc-po_item,
*           iqc_status TYPE zwms_sap_iqc-iqc_status,
*         END OF is_iqc.
*    DATA:BEGIN OF is_kp,
*           iqc_status TYPE ztfikp-iqc_status,
*           invoice    TYPE ztfikp-invoice,
*         END OF is_kp.
*    CHECK sy-tcode <> 'MIR4'.
*    BREAK-POINT.
*    LOOP AT ti_mrmrseg ASSIGNING FIELD-SYMBOL(<is_rseg>).
*      CLEAR:is_iqc.
*      SELECT SINGLE * INTO CORRESPONDING FIELDS OF is_iqc FROM zwms_sap_iqc
*             WHERE mblnr = <is_rseg>-lfbnr AND
*                   po_number = <is_rseg>-ebeln AND
*                   po_item = <is_rseg>-ebelp.
*      IF sy-subrc = 0 AND is_iqc-iqc_status IS NOT INITIAL.
*        CLEAR:is_kp.
*        SELECT SINGLE * INTO CORRESPONDING FIELDS OF is_kp FROM ztfikp
*                 WHERE iqc_status = is_iqc-iqc_status.
*        IF sy-subrc = 0.
*          IF is_kp-invoice = 'N'.
*            CONCATENATE <is_rseg>-ebeln  '/'   <is_rseg>-ebelp  ',收货凭证:'  <is_rseg>-lfbnr  ',当前状态不允许开票。 状态:'   is_iqc-iqc_status INTO i_str.
*            MESSAGE  i_str TYPE 'E'.
*          ENDIF.
*        ELSE.
*          BREAK-POINT.
*          MESSAGE  e004(zlxbmsg) WITH  '质检状态:' is_iqc-iqc_status  ',未在ZTFIKP表做开票配置'   .
*        ENDIF.
*      ENDIF.
*    ENDLOOP.
**** add by zj 20221026 非源头订单校验增强 start
    DATA:ls_zsdt031 TYPE zsdt031,
         ls_zsdt017 TYPE zsdt017.
    IF sy-tcode = 'MIR4'.
      SELECT SINGLE * FROM zsdt017 INTO ls_zsdt017 WHERE objkey = s_rbkp_old-belnr
                                                     AND gjahr = s_rbkp_old-gjahr
                                                     AND objtype = 'IN'
                                                     AND fksto = ''.
      IF sy-subrc = 0.
        IF ls_zsdt017-canum = '0010'.
          SELECT SINGLE bukrs INTO @DATA(lv_bukrs) FROM rbkp WHERE belnr = @s_rbkp_old-belnr
                                                               AND gjahr = @s_rbkp_old-gjahr.
          IF sy-subrc = 0.
            SELECT SINGLE zbs INTO @DATA(lv_zbs) FROM zsdt031 WHERE bukrs = @lv_bukrs
                                                                AND objtype = 'IN'.
            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 = 'BL'.
              IF sy-subrc = 0 AND lv_zbs = 'Y'.
                MESSAGE '发票是自动创建的,不能修改及过账' TYPE 'E'.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
*      SELECT SINGLE * FROM zsdt031 INTO ls_zsdt031 WHERE bukrs = s_rbkp_old-bukrs
*                                                     AND objtype = 'IN'.
*      IF ls_zsdt031-zbs = 'Y'.
*        SELECT SINGLE * FROM zsdt017 INTO ls_zsdt017 WHERE objkey = s_rbkp_old-belnr
*                                                       AND objtype = 'IN'.
*        IF sy-subrc = 0.
*          MESSAGE '发票是自动创建的,不能修改及过账' TYPE 'E'.
*        ENDIF.
*      ENDIF.
    ENDIF.
**** ADD BY ZJ 20221026 非源头订单校验增强 END
  ENDMETHOD.

 

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