文章目录
- 前言
- 一、pandas是什么?
- 二、使用步骤
- 1.引入库
- 2.读入数据
- 总结
前言
一般涉及修改财务凭证,或者其它凭证,不应直接更新数据库,而是使用系统提供的function module,或者BAPI,或者使用BDC。
一、
示例:pandas 是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的。
二、使用步骤
1.FI_DOCUMENT_CHANGE
注意一般调用结束后还应该考虑commit work,和rollback work。
如果手动SE37测试发现在S/4没更新ACDOCA可能是就是这个原因导致的,具体可查看解释:
2713775 - FI_DOCUMENT_CHANGE is not updating ACDOCA - SAP for Me
代码如下(示例):
*&---------------------------------------------------------------------*
*& Report ZTEST
*&---------------------------------------------------------------------*
*& Test program: Update FI document
*&---------------------------------------------------------------------*
report ztest.
* Constants document to be changed - TO BE CHANGED
constants:
lc_bukrs type bukrs value 'BEN0',
lc_belnr type belnr_d value '0560000096',
lc_gjahr type gjahr value '2017',
lc_buzei type buzei value '001'.
* Constants
constants:
lc_k type koart value 'K', " Vendor Account Type
lc_gname type eqegraname value 'BKPF', " Elementary Lock of Lock Entry (Table Name)
lc_zuonr type char05 value 'ZUONR'. " Field name for assignment at line item
* Variables
data: lv_garg type eqegraarg. " Argument String of Lock Entry
* Structures
data: ls_accchg type accchg. " Changing FI Document Work Area
* Tables
data:
lt_accchg type standard table of accchg, " Changing FI Document
lt_enq type standard table of seqg3. " Lock entry details
* Filling the fields to be changed
ls_accchg-fdname = lc_zuonr.
ls_accchg-newval = 'TEST UPDATE'. " New value assignment field - TO BE CHANGED
append ls_accchg to lt_accchg.
** UPDATE FI DOCUMENT
if lt_accchg is not initial.
* Check if there is lock on document before proceeding
call function 'ENQUEUE_READ'
exporting
gclient = sy-mandt
gname = lc_gname " BKPF
garg = lv_garg
tables
enq = lt_enq
exceptions
communication_failure = 1
system_failure = 2
others = 3.
if sy-subrc eq 0 and lt_enq is initial.
* Call the FM to update the FI document
call function 'FI_DOCUMENT_CHANGE'
exporting
i_bukrs = lc_bukrs
i_belnr = lc_belnr
i_gjahr = lc_gjahr
i_buzei = lc_buzei
tables
t_accchg = lt_accchg
exceptions
no_reference = 1
no_document = 2
many_documents = 3
wrong_input = 4
overwrite_creditcard = 5
others = 6.
if sy-subrc = 0.
* Commit the changes
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
endif.
endif.
endif.
2.FI_ITEMS_MASS_CHANGE
这个FM里面其实是在使用BDC进行修改,
代码如下(示例):
CALL FUNCTION 'FI_ITEMS_MASS_CHANGE'
EXPORTING
S_BSEG = wa_bseg
IMPORTING
ERRTAB = it_errtab[]
TABLES
IT_BUZTAB = it_buztab
IT_FLDTAB = it_fldtab
EXCEPTIONS
BDC_ERRORS = 1
OTHERS = 2