data: lt_items_old like table of bapiebanv with header line.
data: lt_items_new like table of bapiebanv with header line.
data: lt_account_old like table of bapiebknv with header line.
data: lt_account_new like table of bapiebknv with header line.
data: lt_items like table of bapieban with header line.
data: lt_account like table of bapiebkn with header line.
data: lt_bapireturn like table of bapireturn with header line.
call function 'BAPI_REQUISITION_GETDETAIL'
exporting
number = i_banfn
account_assignment = 'X'
tables
requisition_items = lt_items
requisition_account_assignment = lt_account.
loop at lt_items.
move-corresponding lt_items to lt_items_old.
append lt_items_old.
clear lt_items_old.
move-corresponding lt_items to lt_items_new.
loop at t_eban where bnfpo = lt_items-preq_item.
lt_items_new-short_text = t_eban-txz01.
lt_items_new-store_loc = t_eban-lgort. "库存地点
lt_items_new-quantity = t_eban-menge.
lt_items_new-unit = t_eban-meins.
lt_items_new-deliv_date = t_eban-lfdat.
lt_items_new-mat_grp = t_eban-matkl.
lt_items_new-store_loc = t_eban-lgort.
lt_items_new-pur_group = t_eban-ekgrp.
lt_items_new-c_amt_bapi = t_eban-preis.
lt_items_new-trackingno = t_eban-bednr.
lt_items_new-currency = t_eban-waers.
lt_items_new-price_unit = t_eban-peinh.
endloop.
append lt_items_new.
clear lt_items_new.
endloop.
loop at lt_account.
move-corresponding lt_account to lt_account_old.
append lt_account_old.
clear lt_account_old.
move-corresponding lt_account to lt_account_new.
loop at t_ebkn where bnfpo = lt_account-preq_item.
lt_account_new-wbs_elem_e = t_ebkn-ps_psp_pnr.
lt_account_new-g_l_acct = t_ebkn-sakto.
lt_account_new-cost_ctr = t_ebkn-kostl.
lt_account_new-asset_no = t_ebkn-anln1.
lt_account_new-order_no = t_ebkn-aufnr.
lt_account_new-co_area = t_ebkn-kokrs.
endloop.
append lt_account_new.
clear lt_account_new.
endloop.
loop at t_eban.
read table lt_items with key preq_item = t_eban-bnfpo.
if sy-subrc <> 0.
lt_items_new-preq_item = t_eban-bnfpo. "采购申请的项目编号
lt_items_new-short_text = t_eban-txz01.
lt_items_new-store_loc = t_eban-lgort. "库存地点
lt_items_new-quantity = t_eban-menge.
lt_items_new-unit = t_eban-meins.
lt_items_new-deliv_date = t_eban-lfdat.
lt_items_new-mat_grp = t_eban-matkl.
lt_items_new-store_loc = t_eban-lgort.
lt_items_new-pur_group = t_eban-ekgrp.
lt_items_new-c_amt_bapi = t_eban-preis.
lt_items_new-trackingno = t_eban-bednr.
lt_items_new-currency = t_eban-waers.
lt_items_new-price_unit = t_eban-peinh.
lt_items_new-des_vendor = t_eban-lifnr. "期望的供应商
lt_items_new-fixed_vend = t_eban-flief. "固定的供应商
lt_items_new-info_rec = t_eban-infnr. "采购信息记录的编号
lt_items_new-purch_org = t_eban-ekorg. "采购组织
append lt_items_new.
clear lt_items_new.
endif.
endloop.
loop at t_ebkn.
read table lt_account with key preq_item = t_ebkn-bnfpo.
if sy-subrc <> 0.
lt_account_new-preq_item = t_ebkn-bnfpo.
lt_account_new-wbs_elem_e = t_ebkn-ps_psp_pnr.
lt_account_new-g_l_acct = t_ebkn-sakto.
lt_account_new-cost_ctr = t_ebkn-kostl.
lt_account_new-asset_no = t_ebkn-anln1.
lt_account_new-order_no = t_ebkn-aufnr.
lt_account_new-co_area = t_ebkn-kokrs.
append lt_account_new.
clear lt_account_new.
endif.
endloop.
call function 'BAPI_REQUISITION_CHANGE'
exporting
number = i_banfn
tables
requisition_items_old = lt_items_old
requisition_items_new = lt_items_new
requisition_account_old = lt_account_old
requisition_account_new = lt_account_new
return = lt_bapireturn.