二维码

[BAPI] MIRO过账采购订单发票BAPI_INCOMINGINVOICE_POST

Twilight发表于 2019-08-02 18:40Twilight 最后回复于 2019-08-02 18:40 [复制链接] 5790 0

MIRO修改参考和抬头文本并过账
  1. FUNCTION zpufm020.
  2. *"----------------------------------------------------------------------
  3. *"*"本地接口
  4. *"  IMPORTING
  5. *"     VALUE(I_BELNR) TYPE  RE_BELNR
  6. *"     VALUE(I_GJAHR) TYPE  GJAHR
  7. *"     VALUE(I_XBLNR) TYPE  XBLNR1 OPTIONAL
  8. *"     VALUE(I_BKTXT) TYPE  BKTXT OPTIONAL
  9. *"  EXPORTING
  10. *"     VALUE(E_MESSAGE) TYPE  ZOTS001
  11. *"----------------------------------------------------------------------
  12.   DATA:lt_return TYPE TABLE OF bapiret2 WITH HEADER LINE.
  13.   DATA:ls_headerdata_change  TYPE bapi_incinv_chng_header.
  14.   DATA:ls_headerdata_changex TYPE bapi_incinv_chng_headerx.
  15.   DATA:ls_rbkp  TYPE rbkp.

  16.   PERFORM frm_re_belnr_input CHANGING i_belnr.

  17.   SELECT SINGLE * INTO ls_rbkp FROM rbkp WHERE belnr = i_belnr AND gjahr = i_gjahr.
  18.   IF sy-subrc = 0.
  19.     IF ls_rbkp-rbstat = '5'.  "5  已过账
  20.       e_message-type    = 'S'.
  21.       e_message-message = 'PO预制发票已经过账!'.
  22.       EXIT.
  23.     ENDIF.
  24.   ELSE.
  25.     e_message-type    = 'E'.
  26.     e_message-message = 'PO预制发票不存在!'.
  27.     EXIT.
  28.   ENDIF.

  29. *-->BAPI_INCOMINGINVOICE_CHANGE
  30.   ls_headerdata_change-ref_doc_no = '00100653'.
  31.   ls_headerdata_change-header_txt = '确认发票自动生成的过账凭证'.

  32.   ls_headerdata_changex-ref_doc_no = 'X'.
  33.   ls_headerdata_changex-header_txt = 'X'.

  34.   CALL FUNCTION 'BAPI_INCOMINGINVOICE_CHANGE'
  35.     EXPORTING
  36.       invoicedocnumber   = i_belnr
  37.       fiscalyear         = i_gjahr
  38.       headerdata_change  = ls_headerdata_change
  39.       headerdata_changex = ls_headerdata_changex
  40.     TABLES
  41.       return             = lt_return.

  42.   LOOP AT lt_return WHERE type CA 'AEX'.
  43.     IF e_message-message IS INITIAL.
  44.       e_message-message   = lt_return-message.
  45.     ELSE.
  46.       CONCATENATE e_message-message lt_return-message INTO e_message-message SEPARATED BY '/'.
  47.     ENDIF.
  48.   ENDLOOP.
  49.   IF sy-subrc = 0.
  50.     CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
  51.     e_message-type   = 'E'.
  52.     EXIT.
  53.   ELSE.
  54.     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
  55.       EXPORTING
  56.         wait = 'X'.
  57. *-->BAPI_INCOMINGINVOICE_POST
  58.     CLEAR:lt_return[].
  59.     CALL FUNCTION 'BAPI_INCOMINGINVOICE_POST'
  60.       EXPORTING
  61.         invoicedocnumber = i_belnr
  62.         fiscalyear       = i_gjahr
  63.       TABLES
  64.         return           = lt_return.

  65.     LOOP AT lt_return WHERE type CA 'AEX'.
  66.       IF e_message-message IS INITIAL.
  67.         e_message-message   = lt_return-message.
  68.       ELSE.
  69.         CONCATENATE e_message-message lt_return-message INTO e_message-message SEPARATED BY '/'.
  70.       ENDIF.
  71.     ENDLOOP.
  72.     IF sy-subrc = 0.
  73.       CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
  74.       e_message-type   = 'E'.
  75.       EXIT.
  76.     ELSE.
  77.       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
  78.         EXPORTING
  79.           wait = 'X'.
  80.       e_message-type    = 'S'.
  81.       e_message-message = 'PO预制发票过账成功!'.
  82.     ENDIF.
  83.   ENDIF.

  84. ENDFUNCTION.
  85. FORM frm_re_belnr_input CHANGING pc_belnr TYPE re_belnr.

  86.   CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  87.     EXPORTING
  88.       input  = pc_belnr
  89.     IMPORTING
  90.       output = pc_belnr.

  91. ENDFORM.
复制代码
回复

使用道具 举报

快速回帖

本版积分规则
您需要登录后才可以回帖 登录 | 注册有礼

快速回复 返回顶部 返回列表