修改采购申请;BAPI_REQUISITION_CH…

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.



BAPI_REQUISITION_CREATE 创建了服务类的采购申请里面有一个参数(REQUISITION_SERVICES),
BAPI_REQUISITION_CHANGE 和 BAPI_PR_CHANGE但是这二个BPAI里都没有专门的参数存入服务类的数据;
还有一个奇怪的现象,创建申请的有二个BAPI修改的也有二个;可是BAPI_REQUISITION_CREATE BAPI_REQUISITION_CHANGE 从名字上看这二个应该是一起的一个创建一个修改,
可是这二个BAPI里的参数几乎都不一样;
而 BAPI_PR_CREATE 和 BAPI_PR_CHANGE这二个BAPI里面参数却都是一样的,很奇怪;很显然我如果用BAPI_PR_CREATE创建的申请可以用BAPI_PR_CHANGE来改(但这个BAPI却不能创建服务类申请,因为没有相关的参数),可是我用BAPI_REQUISITION_CREATE创建的申请却不能用BAPI_REQUISITION_CHANGE 来改。
posted @ 2014-01-22 09:24  胡来  阅读(976)  评论(0编辑  收藏  举报