data:i_bukrsliket001-bukrsvalue'1000',"公司代码
i_netwrlikevbap-netwrvalue1,"金额
i_saknrlikezsdt015-hkontvalue'0066021001'."总账科目
performfrm_create_bkpfusingi_bukrsi_netwri_saknr.
*&---------------------------------------------------------------------*
*&Formfrm_create_bkpf
*&---------------------------------------------------------------------*
formfrm_create_bkpfusingi_bukrsi_netwri_saknr.
*-----------------------Datadefinition-------------------------------
data:lw_documentheadertypebapiache09,"凭证抬头
l_obj_typetypebapiache09-obj_type,
l_obj_keytypebapiache09-obj_key,
l_obj_systypebapiache09-obj_sys,
lt_accountgltypetableofbapiacgl09,"总账科目项
lw_accountgltypebapiacgl09,
lt_currencyamounttypetableofbapiaccr09,"货币项目
lw_currencyamounttypebapiaccr09,
lt_returntypetableofbapiret2,
lw_returntypebapiret2,
lt_extension2typetableofbapiparex,"参考结构
lw_extension2typebapiparex,
lc_msg_temptypestring.
*-----------------------header----------------------------------------
lw_documentheader-bus_act='RFBU'."业务事务
lw_documentheader-username=sy-uname."用户
lw_documentheader-comp_code=i_bukrs."公司代码
lw_documentheader-doc_date=sy-datum."凭证中的凭证日期
lw_documentheader-pstng_date=sy-datum."凭证中的记帐日期
lw_documentheader-doc_type='SA'."凭证类型,DZ:客户付款,SA:总账科目凭证
lw_documentheader-header_txt='费用记账-收款单创建'."凭证抬头文本,这个必须要带上才能创建成功
*-----------------------Item------------------------------------------
*---货币项目
lw_currencyamount-itemno_acc=1."行项目
lw_currencyamount-currency='CNY'."货币
lw_currencyamount-amt_doccur=i_netwr."金额
appendlw_currencyamounttolt_currencyamount.
lw_currencyamount-itemno_acc=2."行项目
lw_currencyamount-currency='CNY'."货币
lw_currencyamount-amt_doccur=0-i_netwr."金额
appendlw_currencyamounttolt_currencyamount.
*---总账科目
clearlw_accountgl.
lw_accountgl-itemno_acc=1."行项目
lw_accountgl-gl_account='0066021501'."总帐科目
lw_accountgl-comp_code=i_bukrs."公司代码
lw_accountgl-costcenter='1000210056'."成本中心
appendlw_accountgltolt_accountgl.
clearlw_accountgl.
lw_accountgl-itemno_acc=2."行项目
lw_accountgl-gl_account='0021910012'."总帐科目,?
lw_accountgl-comp_code=i_bukrs."公司代码
appendlw_accountgltolt_accountgl.
*---扩展结构
data:lw_field_enhancetypezfi_e_001.
lw_field_enhance-posnr=2.
lw_field_enhance-zz0001='1201'.
lw_extension2-structure='ZFI_E_001'.
lw_extension2-valuepart1=lw_field_enhance.
appendlw_extension2tolt_extension2.
*---callbapi
callfunction'BAPI_ACC_DOCUMENT_POST'
exporting
documentheader=lw_documentheader
importing
obj_type=l_obj_type
obj_key=l_obj_key
obj_sys=l_obj_sys
tables
accountgl=lt_accountgl
currencyamount=lt_currencyamount
return=lt_return
extension2=lt_extension2.
*---处理BAPI返回结果
deletelt_returnwheretype='S'ortype='I'ortype='W'.
iflt_returnisinitial.
callfunction'BAPI_TRANSACTION_COMMIT'
exporting
wait='X'.
*p_belnr=l_obj_key(10).
else.
callfunction'BAPI_TRANSACTION_ROLLBACK'.
endif.
endform."FRM_CREATE_BKPF