SAP ABAP Park Customer Invoice FV70 Using BDC
function Z_VIM_PARK_FV70.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(I_HEADER) TYPE ZSVIM_LIVNPO_HEADER
*" TABLES
*" LT_GLACCOUNT STRUCTURE ZSVIM_LIVNPO_GL OPTIONAL
*" LT_WIHTAX STRUCTURE ZSVIM_LIVNPO_WHT OPTIONAL
*" LT_RETURN STRUCTURE BDCMSGCOLL
*"----------------------------------------------------------------------
data :
parameter_id type usr05-parid,
parameter_value type usr05-parva.
parameter_id = 'FO2'.
parameter_value = ' X X X X'.
call function 'G_SET_USER_PARAMETER'
exporting
parameter_id = parameter_id
parameter_value = parameter_value.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
data :
ls_gl type zsvim_livnpo_gl,
ls_wihtax type zsvim_livnpo_wht,
ls_bdcopt type ctu_params,
ls_knb1 type knb1,
str_bldat type char10,
str_budat type char10,
str_zfbdt type char10,
itabidx(2) type n,
strbdcfld type string.
refresh bdc_data.
ls_bdcopt-dismode = 'N'. "A=FOREGROUND N=BACKGROUND E=ERROR
ls_bdcopt-updmode = 'A'. "S=SYNCHRONOUS A=ASYNCHRONOUS L=LOCAL
ls_bdcopt-defsize = 'X'.
ls_bdcopt-racommit = 'X'.
ls_bdcopt-nobinpt = 'X'.
clear : str_bldat, str_budat, str_zfbdt.
concatenate i_header-bldat+6(2) '.' i_header-bldat+4(2) '.' i_header-bldat(4) into str_bldat.
concatenate i_header-budat+6(2) '.' i_header-budat+4(2) '.' i_header-budat(4) into str_budat.
concatenate i_header-zfbdt+6(2) '.' i_header-zfbdt+4(2) '.' i_header-zfbdt(4) into str_zfbdt.
clear ls_knb1.
select single * from knb1 into ls_knb1 where kunnr = i_header-lifnr and bukrs = i_header-bukrs.
if ls_knb1 is initial.
exit.
endif.
perform bdc_dynpro using 'SAPLACHD' '1000'.
perform bdc_field using 'BDC_CURSOR'
'BKPF-BUKRS'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'BKPF-BUKRS'
i_header-bukrs.
perform bdc_dynpro using 'SAPMF05A' '1200'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF05A-BUSCS'
'R'.
perform bdc_field using 'BDC_CURSOR'
'INVFO-BLDAT'.
perform bdc_field using 'INVFO-ACCNT'
i_header-lifnr.
perform bdc_field using 'INVFO-BLDAT'
str_bldat.
perform bdc_field using 'INVFO-BUDAT'
str_budat.
perform bdc_field using 'INVFO-WAERS'
i_header-waers.
perform bdc_field using 'INVFO-MWSKZ'
i_header-mwskz1.
if ls_knb1-zterm is initial.
perform bdc_dynpro using 'SAPMF05A' '1200'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'INVFO-ZTERM'.
perform bdc_field using 'INVFO-ZFBDT'
str_zfbdt.
perform bdc_field using 'INVFO-ZTERM'
i_header-zterm.
perform bdc_field using 'INVFO-ZLSPR'
i_header-zlspr.
endif.
perform bdc_dynpro using 'SAPMF05A' '1200'.
perform bdc_field using 'BDC_OKCODE'
'=MORE'.
perform bdc_dynpro using 'SAPMF05A' '1200'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'INVFO-GSBER'.
perform bdc_field using 'INVFO-ZUONR'
i_header-zuonr.
perform bdc_field using 'INVFO-BKTXT'
i_header-bktxt.
perform bdc_field using 'INVFO-GSBER'
i_header-bupla.
perform bdc_dynpro using 'SAPMF05A' '1200'.
perform bdc_field using 'BDC_OKCODE'
'=MAIN'.
perform bdc_dynpro using 'SAPMF05A' '1200'.
perform bdc_field using 'BDC_OKCODE'
'=DUMMY'.
perform bdc_field using 'RF05A-BUSCS'
'R'.
perform bdc_field using 'BDC_CURSOR'
'INVFO-MWSKZ'.
perform bdc_field using 'INVFO-ACCNT'
i_header-lifnr.
perform bdc_field using 'INVFO-BLDAT'
str_bldat.
perform bdc_field using 'INVFO-XBLNR'
i_header-xblnr.
perform bdc_field using 'INVFO-BUDAT'
str_budat.
perform bdc_field using 'INVFO-WAERS'
i_header-waers.
perform bdc_field using 'INVFO-MWSKZ'
i_header-mwskz1.
perform bdc_field using 'INVFO-BUPLA'
i_header-bupla.
perform bdc_field using 'INVFO-SGTXT'
i_header-sgtxt.
perform bdc_dynpro using 'SAPMF05A' '1200'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
"GL DATA
clear : ls_gl, itabidx.
loop at lt_glaccount into ls_gl.
itabidx = itabidx + 1.
if itabidx >= 4.
itabidx = 4.
endif.
clear strbdcfld.
concatenate 'ACGL_ITEM-HKONT(' itabidx ')' into strbdcfld.
perform bdc_field using 'BDC_CURSOR'
strbdcfld.
clear strbdcfld.
concatenate 'ACGL_ITEM-HKONT(' itabidx ')' into strbdcfld.
perform bdc_field using strbdcfld
ls_gl-hkont.
clear strbdcfld.
concatenate 'ACGL_ITEM-MWSKZ(' itabidx ')' into strbdcfld.
perform bdc_field using strbdcfld
ls_gl-adtxcode.
clear strbdcfld.
concatenate 'ACGL_ITEM-WRBTR(' itabidx ')' into strbdcfld.
perform bdc_field using strbdcfld
ls_gl-adjamount.
clear strbdcfld.
concatenate 'ACGL_ITEM-ZUONR(' itabidx ')' into strbdcfld.
perform bdc_field using strbdcfld
ls_gl-zuonr.
clear strbdcfld.
concatenate 'ACGL_ITEM-SGTXT(' itabidx ')' into strbdcfld.
perform bdc_field using strbdcfld
ls_gl-adtext.
clear strbdcfld.
concatenate 'ACGL_ITEM-GSBER(' itabidx ')' into strbdcfld.
perform bdc_field using strbdcfld
i_header-bupla.
clear strbdcfld.
concatenate 'ACGL_ITEM-KOSTL(' itabidx ')' into strbdcfld.
perform bdc_field using strbdcfld
ls_gl-kostl.
if itabidx >= 4.
clear strbdcfld.
concatenate 'ACGL_ITEM-MARKSP(' itabidx ')' into strbdcfld.
perform bdc_field using strbdcfld
'X'.
perform bdc_dynpro using 'SAPMF05A' '1200'.
perform bdc_field using 'BDC_OKCODE'
'=0005'.
else.
perform bdc_dynpro using 'SAPMF05A' '1200'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
endif.
clear ls_gl.
endloop.
perform bdc_field using 'BDC_OKCODE'
'=DUMMY'.
perform bdc_field using 'RF05A-BUSCS'
'R'.
perform bdc_field using 'BDC_CURSOR'
'INVFO-XMWST'.
perform bdc_field using 'INVFO-ACCNT'
i_header-lifnr.
perform bdc_field using 'INVFO-BLDAT'
str_bldat.
perform bdc_field using 'INVFO-XBLNR'
i_header-xblnr.
perform bdc_field using 'INVFO-BUDAT'
str_budat.
perform bdc_field using 'INVFO-WRBTR'
i_header-rmwwr.
perform bdc_field using 'INVFO-XMWST'
'X'.
perform bdc_field using 'INVFO-MWSKZ'
i_header-mwskz1.
perform bdc_field using 'INVFO-BUPLA'
i_header-bupla.
perform bdc_field using 'INVFO-SGTXT'
i_header-sgtxt.
"Tab Payment
perform bdc_dynpro using 'SAPMF05A' '1200'.
perform bdc_field using 'BDC_OKCODE'
'=PAYM'.
perform bdc_dynpro using 'SAPMF05A' '1200'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'INVFO-ZTERM'.
perform bdc_field using 'INVFO-ZFBDT'
str_zfbdt.
perform bdc_field using 'INVFO-ZTERM'
i_header-zterm.
perform bdc_field using 'INVFO-ZLSPR'
i_header-zlspr.
"Tab Details
perform bdc_dynpro using 'SAPMF05A' '1200'.
perform bdc_field using 'BDC_OKCODE'
'=MORE'.
perform bdc_dynpro using 'SAPMF05A' '1200'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'INVFO-GSBER'.
perform bdc_field using 'INVFO-ZUONR'
i_header-zuonr.
perform bdc_field using 'INVFO-BKTXT'
i_header-bktxt.
perform bdc_field using 'INVFO-GSBER'
i_header-bupla.
perform bdc_dynpro using 'SAPMF05A' '1200'.
perform bdc_field using 'BDC_OKCODE'
'=WT'.
perform bdc_dynpro using 'SAPMF05A' '1200'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
clear : ls_wihtax, itabidx.
loop at lt_wihtax into ls_wihtax.
itabidx = itabidx + 1.
clear strbdcfld.
concatenate 'ACWT_ITEM-WT_WITHCD(' itabidx ')' into strbdcfld.
perform bdc_field using 'BDC_CURSOR'
strbdcfld.
clear strbdcfld.
concatenate 'ACWT_ITEM-WT_WITHCD(' itabidx ')' into strbdcfld.
perform bdc_field using strbdcfld
ls_wihtax-wt_withcd.
clear strbdcfld.
concatenate 'ACWT_ITEM-WT_QSSHB(' itabidx ')' into strbdcfld.
perform bdc_field using strbdcfld
ls_wihtax-wt_amount.
clear ls_wihtax.
endloop.
perform bdc_dynpro using 'SAPMF05A' '1200'.
perform bdc_field using 'BDC_OKCODE'
'=BP'.
perform bdc_field using 'BDC_CURSOR'
'ACWT_ITEM-WT_QSSHB(01)'.
refresh lt_return.
call transaction 'FV70'
using bdc_data
messages into lt_return
options from ls_bdcopt.
clear parameter_value.
parameter_value = ' X X X'.
call function 'G_SET_USER_PARAMETER'
exporting
parameter_id = parameter_id
parameter_value = parameter_value.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
endfunction.
Comments
Post a Comment