最近用到一些函数,网上的相关资料不多,这里记录一下。
本文链接:https://www.cnblogs.com/hhelibeb/p/17012303.html
1,使用 RV_INVOICE_HEAD_MAINTAIN 更新VBRK-ZUNOR和VBRK-XBLNR等字段。
场景:金税发票接口需要更新发票相关字段,如VBRK-ZUNOR,VBRK-XBLNR和其它增强字段。
代码示例:- DATA:
- xkomfk TYPE STANDARD TABLE OF komfk,
- xkomv TYPE STANDARD TABLE OF komv,
- xthead TYPE STANDARD TABLE OF theadvb,
- xvbfs TYPE STANDARD TABLE OF vbfs,
- xvbpa TYPE STANDARD TABLE OF vbpavb,
- xvbrk TYPE STANDARD TABLE OF vbrkvb,
- xvbrp TYPE STANDARD TABLE OF vbrpvb,
- xvbss TYPE STANDARD TABLE OF vbss.
- SELECT SINGLE * FROM vbrk
- WHERE vbeln = @is_nvbrk-vbeln
- INTO @ls_vbrk.
- CALL FUNCTION 'RV_INVOICE_DOCUMENT_READ'
- EXPORTING
- konv_read = 'X'
- vbrk_i = ls_vbrk
- TABLES
- xkomv = xkomv
- xvbpa = xvbpa
- xvbrk = xvbrk
- xvbrp = xvbrp
- xkomfk = xkomfk
- xvbfs = xvbfs
- xthead = xthead
- xvbss = xvbss
- EXCEPTIONS
- no_authority = 1
- OTHERS = 2.
- IF sy-subrc <> 0.
- * Implement suitable error handling here
- ENDIF.
- ls_vbrk-xblnr = '123'.
- ls_vbrk-zuonr = '321'.
- CALL FUNCTION 'RV_INVOICE_HEAD_MAINTAIN'
- EXPORTING
- vbrk_i = ls_vbrk
- TABLES
- xkomfk = xkomfk
- xkomv = xkomv
- xthead = xthead
- xvbfs = xvbfs
- xvbpa = xvbpa
- xvbrk = xvbrk
- xvbrp = xvbrp
- xvbss = xvbss.
- IF sy-subrc <> 0.
- MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH
- sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO DATA(lv_dummy).
- ENDIF.
- DATA: ls_vbsk TYPE vbsk.
- ls_vbsk-mandt = sy-mandt.
- ls_vbsk-ernam = ls_vbrk-ernam.
- ls_vbsk-erdat = ls_vbrk-erdat.
- ls_vbsk-uzeit = ls_vbrk-erzet.
- CALL FUNCTION 'RV_INVOICE_DOCUMENT_ADD'
- EXPORTING
- vbsk_i = ls_vbsk
- TABLES
- xkomfk = xkomfk
- xkomv = xkomv
- xthead = xthead
- xvbfs = xvbfs
- xvbpa = xvbpa
- xvbrk = xvbrk
- xvbrp = xvbrp
- xvbss = xvbss.
复制代码 2,用 CSAI_BOM_MAINTAIN 实现IB01设备BOM创建、IB02设备BOM修改
场景:批量上传维护设备BOM
下面的代码可以用于创建和新增设备BOM,但不能删除已有设备BOM。如要删除已有设备BOM,需设置t_stpob中的删除标记。- DATA: ecsin LIKE csin,
- estkob LIKE stkob,
- estzub LIKE stzub,
- emastb LIKE mastb,
- items TYPE sgt_t_bom_comp,
- t_stpob TYPE tt_stpo.
- DATA: fl_warning LIKE capiflag-flwarning.
- ecsin-stlty = 'E' . "设备
- ecsin-stlan = lr_data->stlan .
- ecsin-datuv = sy-datum.
- ecsin-werks = lr_data->werks.
- ecsin-equnr = lr_data->equnr1.
- CALL FUNCTION 'CSAI_BOM_READ'
- EXPORTING
- ecsin = ecsin
- IMPORTING
- fl_warning = fl_warning
- TABLES
- t_stpob = t_stpob
- EXCEPTIONS
- error = 1
- OTHERS = 2.
-
- t_stpob = VALUE #( BASE t_stpob
- ( posnr = lv_posnr postp = lr_data->postp idnrk = lr_data->idnrk menge = lr_data->menge )
- ).
- CALL FUNCTION 'CSAI_BOM_MAINTAIN'
- EXPORTING
- fl_bom_create = 'X'
- ecsin = ecsin
- estkob = estkob
- estzub = estzub
- fl_commit_and_wait = 'X'
- IMPORTING
- fl_warning = fl_warning
- TABLES
- t_stpob = t_stpob
- EXCEPTIONS
- error = 1
- OTHERS = 2.
复制代码 3,使用 L_INV_COUNT_EXT 实现LI11N输入库存盘点。
上传盘点数据,程序实现LI01N, LI11N, LI20, LI21盘点过账功能。
其中LI01N, LI20, LI21可以用BDC实现,LI11N通过函数实现。
数据来自表LQUA,需要注意如果数量为0,则要设置零库存标识。- DATA: lt_linv TYPE STANDARD TABLE OF e1linvx.
- DATA: ls_linv TYPE e1linvx.
- ls_linv-lgnum = '120'.
- ls_linv-lqnum = '752'.
- ls_linv-lgort = 'B021'.
- ls_linv-ivnum = '0000000030'. "LI01N生成的盘点记录
- ls_linv-idatu = sy-datum.
- ls_linv-wdatu = sy-datum.
- ls_linv-lgpla = 'B05-123'.
- ls_linv-plpos = '1'.
- ls_linv-lgtyp = 'B05'.
- ls_linv-matnr = '000000000020000214'.
- ls_linv-werks = '1000'.
- ls_linv-charg = '212922123'.
- ls_linv-lsonr = '12345'.
- ls_linv-letyp = 'IP'.
- ls_linv-menga = 2.
- ls_linv-lenum = '12345'.
- ls_linv-altme = 'BOT'.
- IF ls_linv-menga = 0.
- ls_linv-kznul = 'X'.
- ENDIF.
- INSERT ls_linv INTO TABLE lt_linv.
- CALL FUNCTION 'L_INV_COUNT_EXT'
- EXPORTING
- i_check_only = i_check_only
- i_commit = 'X'
- TABLES
- s_linv = lt_linv
- EXCEPTIONS
- either_quantity_or_empty_bin = 1
- ivnum_not_found = 2
- check_problem = 3
- no_count_allowed = 4
- l_inv_read = 5
- bin_not_in_ivnum = 6
- counts_not_updated = 7
- lock_error = 8.
复制代码
需要注意这三个功能涉及的函数都是未发布状态,如果有其它已发布函数可以实现相同功能,请优先考虑已发布函数。
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |