ABAP:VF02/VF03销售发票保存前增强

VF02/VF03销售发票保存前增强

SE38:RV60AFZZ

 

 

 

 创建实施

ENHANCEMENT 1  ZCD_BL_SAVE_CHECK.    "active version
  DATA:lv_flag TYPE char1.
  DATA:ls_zsdt031 TYPE zsdt031,
       ls_zsdt017 TYPE zsdt017.
  CLEAR:ls_zsdt031,ls_zsdt017.
  IMPORT lv_flag FROM MEMORY ID 'ZSDU003'.
  FREE MEMORY ID 'ZSDU003'.
  IF ( sy-tcode = 'VF02' OR sy-tcode = 'VF03' ) AND lv_flag NE 'X'.
    SELECT SINGLE * FROM zsdt017 INTO ls_zsdt017 WHERE objkey = vbrk-vbeln
                                                   AND objtype = 'BL'
                                                   AND fksto = ''.
    IF sy-subrc = 0.
      IF ls_zsdt017-canum = '0010'.
        SELECT SINGLE zbs INTO @DATA(lv_zbs) FROM zsdt031 WHERE bukrs = @vbrk-vkorg
                                                            AND objtype = 'BL'.
        IF lv_zbs = 'Y'.
          MESSAGE '发票是自动创建的,不能修改及过账' TYPE 'E'.
        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 bukrs INTO @DATA(lv_bukrs) FROM rbkp WHERE belnr = @ls_zsdt017_2-objkey
                                                               AND gjahr = @ls_zsdt017_2-gjahr.
          IF sy-subrc = 0.
            SELECT SINGLE zbs INTO lv_zbs FROM zsdt031 WHERE bukrs = lv_bukrs
                                                         AND objtype = 'IN'.
            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 = vbrk-vkorg
*                                                   AND objtype = 'BL'.
*    IF ls_zsdt031-zbs = 'Y'.
*      SELECT SINGLE * FROM zsdt017 INTO ls_zsdt017 WHERE objkey = vbrk-vbeln
*                                                     AND objtype = 'BL'.
*      IF sy-subrc = 0.
*        MESSAGE '发票是自动创建的,不能修改及过账' TYPE 'E'.
*      ENDIF.
*    ENDIF.
  ENDIF.

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