VF01/VF11 创建和冲销开票凭证

1、创建开票凭证

1.1、前台

VF01创建开票凭证

1.2、源代码

"--------------------@斌将军--------------------
DATA
:lt_billingdatain TYPE TABLE OF bapivbrk WITH HEADER LINE, lt_conditiondatain TYPE TABLE OF bapikomv WITH HEADER LINE, lt_success TYPE TABLE OF bapivbrksuccess, lt_return TYPE TABLE OF bapiret1. DATA:lv_check TYPE char1, lv_message TYPE char200. CLEAR:lt_billingdatain. lt_billingdatain-ref_doc = '0080012360'."交货单号 lt_billingdatain-ref_item = '10'. lt_billingdatain-doc_number = '0010001709'."销售订单号 lt_billingdatain-itm_number = '10'. " lt_billingdatain-ref_doc_ca = 'J'."凭证类别 *lt_billingdatain-payer = lv_payer. "付款方 20191030 add *lt_billingdatain-material = ''."gs_root-matnr. "物料编码 *lt_billingdatain-req_qty = ''."gs_root-fkimg. "数量 *lt_billingdatain-sales_unit = ''."gs_root-vrkme. "数量单位 APPEND lt_billingdatain. *CLEAR:lt_conditiondatain. *gv_index = gv_index + 1. *lt_conditiondatain-data_index = gv_index. "其他结构的表格项目的指针 *lt_conditiondatain-cond_type = 'ZPR1'. "条件类型 *lt_conditiondatain-cond_value = gs_root-kbetr."金额 *lt_conditiondatain-cond_curr = 'CNY'. "货币单位 *lt_conditiondatain-cond_p_unt = '1'. "货币单位 *APPEND lt_conditiondatain. "调用bapi生成发票号 CALL FUNCTION 'BAPI_BILLINGDOC_CREATEMULTIPLE' TABLES billingdatain = lt_billingdatain conditiondatain = lt_conditiondatain return = lt_return success = lt_success. CLEAR:lv_check,lv_message. LOOP AT lt_return INTO DATA(ls_return) WHERE type CA 'AEX'. lv_check = 'E'. lv_message = lv_message && ls_return-message. ENDLOOP. IF lv_check = 'E'. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. ELSE. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. ENDIF.
"--------------------@斌将军--------------------

2、冲销开票凭证

2.1、前台

VF11冲销开票凭证

2.2、源代码

"--------------------@斌将军--------------------
DATA:lv_bill_doc TYPE bapivbrksuccess-bill_doc,
     lt_success         TYPE TABLE OF bapivbrksuccess,
     lt_return          TYPE TABLE OF bapiret1.
DATA:lv_check   TYPE char1,
     lv_message TYPE char200.

lv_bill_doc = '0090000367'."需要冲销的发票
  CALL FUNCTION 'BAPI_BILLINGDOC_CANCEL1'
    EXPORTING
      billingdocument = lv_bill_doc
    TABLES
      return          = lt_return
      success         = lt_success.

  CLEAR:lv_check,lv_message.
  LOOP AT lt_return INTO DATA(ls_return) WHERE type CA 'AEX'.
    lv_check = 'E'.
    lv_message = lv_message && ls_return-message.
  ENDLOOP.

  IF lv_check = 'E'.
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
  ELSE.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait = 'X'.
  ENDIF.
"--------------------@斌将军--------------------

VL03N查看交货单凭证流

 

定期更文,欢迎关注

 
 
 
 
posted @ 2023-04-26 17:41  斌将军  阅读(528)  评论(0编辑  收藏  举报