10-17-2008 1:40 PM
Hi im trying to create a purchase requisition using the bapi BAPI_REQUISITION_CREATE.
My code is given below.
REPORT ZMM_PR_CREATE1_DEX1 .
data:t_pritem like standard table of BAPIEBANC with header line,
t_pritadd like standard table of BAPIEBKN with header line,
t_return like BAPIRETURN occurs 0 with header line,
v_ponumber(10).
t_pritem-DOC_TYPE = 'NB'.
t_pritem-MATERIAL = '91237'.
t_pritem-QUANTITY = '1'.
t_pritem-UNIT = 'ACR'.
t_pritem-DELIV_DATE = '20090120'.
t_pritem-PLANT = '6400'.
*t_pritem-STORE_LOC = '0132'.
t_pritem-ACCTASSCAT = 'K'.
append t_pritem.
t_pritadd-COST_CTR = '640210'.
*t_pritadd-G_L_ACCT = '512000120'.
append t_pritadd.
CALL FUNCTION 'BAPI_REQUISITION_CREATE'
EXPORTING
skip_items_with_error = 'X'
IMPORTING
NUMBER = v_ponumber
TABLES
REQUISITION_ITEMS = t_pritem
REQUISITION_ACCOUNT_ASSIGNMENT = t_pritadd
return = t_return.
loop at t_return.
write : t_return-MESSAGE.
endloop.
write : v_ponumber.
Now the problem is.
When i put all this data manually ie. through transaction ME51 it seems to go in just fine .
However when i send it as above it gives me the error message "Cost center 1000/640210 does not exist.
i just can't figure out why.
Pleas help guys. Relevent answers will be rewarded.
10-17-2008 1:45 PM
Hi Dexter,
If you specify values for Cost Center and GL account in this way be sure to include any suppressed zero's.
For instance: Cost Center is CHAR 10, so your coding should be:
t_pritadd-COST_CTR = '0000640210'.
Regards,
John.
10-17-2008 1:45 PM
Hi Dexter,
If you specify values for Cost Center and GL account in this way be sure to include any suppressed zero's.
For instance: Cost Center is CHAR 10, so your coding should be:
t_pritadd-COST_CTR = '0000640210'.
Regards,
John.
10-20-2008 4:57 AM
10-17-2008 2:04 PM
Hi,
Here is code.
data: i_banc type bapiebanc occurs 0 with header line.
data: i_bkn type bapiebkn occurs 0 with header line.
data: i_ret type bapireturn occurs 0 with header line.
data: i_band type bapieband occurs 0 with header line.
data: i_bantx type bapiebantx occurs 0 with header line.
data number type bapiebanc-preq_no.
i_banc-acctasscat = par_asset.
i_banc-short_text = 'VehicleBooking'.
i_banc-quantity = '1'.
i_banc-DEL_DATCAT = '1'.
i_banc-deliv_date = par_date .
i_banc-mat_grp = 'TRAVEL'.
i_banc-unit = 'ST'.
i_banc-c_amt_bapi = 100.
i_bkn-cost_ctr = par_cost.
i_bkn-g_l_acct = par_gl.
i_bkn-fund = par_fund.
i_bkn-funds_ctr = par_fund_ctr.
append i_banc.
append i_bkn.
call function 'BAPI_REQUISITION_CREATE'
exporting
skip_items_with_error = 'X'
importing
number = number
tables
requisition_items = i_banc
requisition_account_assignment = i_bkn
requisition_item_text = i_bantx
return = i_ret
.
Describe table i_ret lines count.
If count > 0.
loop at i_ret.
Message e000(zbooking) with i_ret-message
endloop.
Endif.
if not number is initial.
S000(zbookings) with 'Requisition number ' , number ,' created'.
endif.
you must make sure your fund exit within cost centre and fund centre
due to not entering fund centre or cost centre.
Hope this helps.
Rhea.