05-12-2010 5:46 AM
Hi all,
My requirment create purchase reqistion using quota allocations.
Ex : vendor A with 30%quota(maintained in equp table against quantam number)
vendor B with 70%quota
Here In my flat file my quantity is 10kg two seperate Purchase Requestion (in me53n) it should be created one with vendor A & Quantity 3kgs and another with vendor B & Quantity 7kgs.
Please suggest me on the same if any Function modules avaiable.
Thanks,
05-12-2010 6:22 AM
Hi,
Write logic to split the quantity and then call the bapi "BAPI_REQUISTION_CREATE"
Regards
Vinod
05-12-2010 6:39 AM
Hi Vinod,
I think ure the same person replied yesterday.
I was using Bapi_requestion_create and able split the quota quantiy .....but unable to assign the vendor properly after creation.
Below is my Code :
*******Split PRs with respect to Quota ************************
data : lv_lines type i,
lv_qty type p DECIMALS 4.
lv_qty = it_oo-qty.
DESCRIBE TABLE t_equp LINES lv_lines.
IF lv_lines GT 1.
clear : w_equp.
loop at t_equp into w_equp
where qunum = w_equk-qunum.
if not w_equp is initial.
refresh : t_req_item.
clear : w_eord,
t_req_item[],
t_req_item.
READ TABLE t_eord INTO w_eord
WITH KEY matnr = it_oo_sum_purch-matnr_sap
werks = it_oo_sum_purch-plant
lifnr = w_equp-lifnr.
if sy-subrc is initial.
it_oo_purch-AGREE = w_eord-EBELN. "To Fill ALV
it_oo_purch-ITEM = w_eord-EBELP. "To Fill ALV
it_oo_purch-FORNEC = w_equp-LIFNR. "To Fill ALV
t_req_item-doc_type = c_zbmr.
t_req_item-pur_group = it_oo-ekgrp.
t_req_item-material = it_oo_sum_purch-matnr_sap.
t_req_item-plant = it_oo_sum_purch-plant.
t_req_item-AGREEMENT = w_eord-EBELN.
t_req_item-AGMT_ITEM = w_eord-EBELP.
t_req_item-FIXED_VEND = w_eord-LIFNR.
t_req_item-DES_VENDOR = w_equp-LIFNR.
t_req_item-QUOTA_ARR = w_equk-qunum.
t_req_item-QUOTARRITM = w_equp-qupos.
t_req_item-gr_ind = c_x.
t_req_item-ir_ind = c_x.
t_req_item-MRP_CONTR = 'NOV'.
CONCATENATE it_oo_sum_purch-due_dte+4(4)
it_oo_sum_purch-due_dte+2(2)
it_oo_sum_purch-due_dte(2)
INTO t_req_item-deliv_date.
t_req_item-QUANTITY = ( w_equp-QUOTE / 100 ) * lv_QTY.
endif.
**************************************************
********Rounding off values*******************
data : lv_int(20) type c,
lv_dec(20) type c,
lv_tot(20) type c.
clear : lv_int ,
lv_dec,
lv_tot.
lv_tot = t_req_item-QUANTITY.
split lv_tot at '.' into lv_int lv_dec.
if lv_dec(1) ge '5'.
lv_int = lv_int + 1.
endif.
t_req_item-QUANTITY = lv_int.
APPEND t_req_item.
clear : v_number.
**************************************************
Create purchase requisition by group
CALL FUNCTION 'BAPI_REQUISITION_CREATE'
IMPORTING
number = v_number
TABLES
requisition_items = t_req_item
return = t_return.