差旅报销接口,在OA中填写报销申请,经审批之后,调用SAP报销接口写回SAP,写入SAP系统并返回财务凭证。
接口输入参数
接口返回参数
接口表参数
表结构
SAP接口代码
function z_if_fico_acc_document_post.
*"----------------------------------------------------------------------
*"*"局部接口:
*" IMPORTING
*" VALUE(IM_HEADER) TYPE ZSACC_HEADER
*" EXPORTING
*" VALUE(EX_MESSAGE) TYPE CHAR120
*" VALUE(EX_BELNR) TYPE BELNR_D
*" TABLES
*" TB_CR_ITEMS STRUCTURE ZSACC_ITEMS
*" TB_DR_ITEMS STRUCTURE ZSACC_ITEMS
*" TB_RETURN STRUCTURE BAPIRET2
*"----------------------------------------------------------------------
data: gt_docheader like table of bapiache09 with header line,
gt_accountgl like table of bapiacgl09 with header line,
ga_accountgl type bapiacgl09,
gt_acccust like table of bapiacar09 with header line,
gt_payble type table of bapiacap09,
ga_payble type bapiacap09,
gt_amount like table of bapiaccr09 with header line,
ga_amount type bapiaccr09,
gt_return like table of bapiret2 with header line,
ga_return type bapiret2,
gv_post_doc like bapiache09-obj_key,
ga_debit_items type zsacc_items,
ga_credit_items type zsacc_items,
ga_extension2 type bapiextc,
gt_extension2 type standard table of bapiparex with header line,
ga_zsacc_extension type zsacc_extension,
l_index like sy-tabix,
ls_lfa1 type lfa1,
ls_kna1 type kna1,
ls_t095 type t095,
ls_anla type anla.
data: ls_tvarvc type tvarvc.
data: l_balance_amt type bapidmbtr.
data: l_lc_waers type t001-waers.
data: ls_t001 type t001.
data:
l_frm_cur type bapi1093_1-from_curr,
l_to_cur type bapi1093_1-to_currncy,
l_keydate type bapi1093_2-trans_date,
l_amt type dmbtr,
l_ex_amt type dmbtr,
l_tot_ex_amt type dmbtr,
l_waers type waers.
data: ls_t012k type t012k.
data: lt_dr_sum type table of zsacc_items,
ls_dr_sum type zsacc_items.
data: g_pp_with_po_flag.
data: g_pre_payment_flag.
clear g_pp_with_po_flag.
if im_header-bus_type ne '01' and "个人报销
im_header-bus_type ne '02' and "付款
im_header-bus_type ne '03' and "预付款
im_header-bus_type ne '04' and "个人借支
im_header-bus_type ne '05'. "海关税金
concatenate 'Invaild business type code:' im_header-bus_type into ex_message .
exit.
endif.
*begin of modify by itl-wfy 20230628.
set parameter id 'FBGENDAT' field 'X'.
fbgenmac 'Z_IF_FICO_ACC_DOCUMENT_POST'.
*end of modify by itl-wfy 20230628.
"2019.03.31 for system cut off - process histical process in OA
if im_header-bus_type = '01' or im_header-bus_type = '04'. "个人借支及报销需启用新工号 add by ivan 20190416
if im_header-bldat < '20190401'.
ex_message = text-i14.
ex_belnr = '8888888888'.
exit.
endif.
endif.
"end of adding M.C
if im_header-bus_type = '05'. "海关税金
ex_message = '海关税金不产生SAP凭证!'.
ex_belnr = '9999999999'.
exit.
endif.
"get SAP username against im_header-ername
select single * into ls_tvarvc from tvarvc where name = im_header-ername .
if sy-subrc eq 0.
im_header-ername = ls_tvarvc-low.
else.
im_header-ername = sy-uname.
endif.
"Get Exclude final Account
* SELECT SINGLE * INTO ls_tvarvc FROM tvarvc WHERE name = 'FI_GLAC_EXCLUDE'.
* "get local document currency
select single * into ls_t001 from t001 where bukrs = im_header-bukrs.
l_lc_waers = ls_t001-waers.
if im_header-bus_type = '01'. "Amount verify
l_tot_ex_amt = 0.
loop at tb_cr_items into ga_debit_items.
l_tot_ex_amt = l_tot_ex_amt + ga_debit_items-wrbtr + ga_debit_items-mwsts.
endloop.
if im_header-plcr_amt <> l_tot_ex_amt .
ex_message = 'Balance in items with header total amount!'.
exit.
endif.
endif.
if im_header-bldat is initial.
ex_message = 'Missing document date!'.
exit.
endif.
if im_header-budat is initial.
ex_message = 'Missing document posting date!'.
exit.
endif.
if im_header-staff_no is initial.
ex_message = 'Missing Staff No!'.
exit.
endif.
if im_header-staff_nm is initial.
ex_message = 'Missing Staff Name!'.
exit.
endif.
if im_header-bukrs is initial.
ex_message = text-i01.
exit.
endif.
if im_header-waers is initial.
ex_message = text-i02.
exit.
endif.
if im_header-bldat is initial.
ex_message = text-i03.
exit.
endif.
"M.C 2019.03.29
if im_header-bldat is initial.
if im_header-budat is initial.
im_header-bldat = sy-datum.
else.
im_header-bldat = im_header-budat.
endif.
endif.
"end of adding M.C
if im_header-budat is initial.
ex_message = text-i04.
exit.
endif.
if tb_dr_items[] is initial.
ex_message = text-i05.
exit.
endif.
if tb_cr_items[] is initial.
ex_message = text-i06.
exit.
endif.
if ( im_header-bus_type = '01' or im_header-bus_type eq '04' ).
if im_header-staff_no is initial.
ex_message = text-i09.
exit.
elseif im_header-staff_nm is initial.
ex_message = text-i10.
exit.
elseif not im_header-staff_no is initial.
call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
exporting
input = im_header-staff_no
importing
output = im_header-staff_no.
endif.
if not im_header-staff_no is initial and not im_header-staff_nm is initial .
data: l_ex_subrc type sy-subrc,
ret type table of bapiret2.
data: l_lifnr type lfa1-lifnr,
l_name1 type name1.
* DATA:LEN TYPE I.
data: l_pernr type zpernr_d.
*
"2019.03.29 m.c
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = im_header-staff_no
importing
output = l_pernr.
concatenate 'E' l_pernr into im_header-staff_no.
"end of adding.
l_lifnr = im_header-staff_no.
l_name1 = im_header-staff_nm.
clear ls_lfa1.
select single a~lifnr into ls_lfa1 from lfa1 as a join lfb1 as b on a~lifnr = b~lifnr
where a~lifnr = l_lifnr
and b~bukrs = im_header-bukrs.
.
if sy-subrc ne 0.
l_ex_subrc = -4.
call function 'Z_IF_MM_VENDOR_CREATE'
exporting
im_lifnr = im_header-staff_no
im_name = l_name1
im_bukrs = im_header-bukrs
* IM_AKONT = '0022410101'
* IM_ZTERM = 'Z001'
* IM_ZWELS = 'T'
im_ktokk = 'Z700'
importing
ex_subrc = l_ex_subrc
tables
tb_r