Skip to Content
0
Former Member
Nov 26, 2008 at 03:51 AM

Error of bapi: BAPI_PO_CREATE

74 Views

Hi experts,

I use the bapi: BAPI_PO_CREATE to create a new po, code:

data: it_po_header like bapiekkoc occurs 0 with header line,

it_po_items like bapiekpoc occurs 0 with header line,

it_po_item_add_data like bapiekpoa occurs 0 with header line,

it_po_item_schedules like bapieket occurs 0 with header line,

it_po_item_account_assignment like bapiekkn occurs 0 with header line,

it_return like bapireturn occurs 0 with header line.

data: tmp_purnum like bapiekkoc-po_number.

data: tmp_ebelp like ekpo-ebelp.

refresh: it_po_header, it_po_items, it_po_item_add_data, it_po_item_schedules, it_po_item_account_assignment, it_return.

it_po_header-doc_date = sy-datum.

it_po_header-doc_type = v_doc_type

it_po_header-doc_cat = 'F'.

it_po_header-co_code = c_co_code.

it_po_header-purch_org = c_purch_org.

it_po_header-pur_group = v_pur_group.

it_po_header-vendor = v_vendor.

append it_po_header.

it_po_items-po_item = 10.

it_po_items-material = wa_itab-material.

it_po_items-acctasscat = 'M'.

it_po_items-short_text = wa_itab-short_text.

it_po_items-plant = wa_itab-plant.

it_po_items-unit = wa_itab-unit.

it_po_items-tax_code = wa_itab-tax_code.

it_po_items-net_price = wa_itab-net_price.

it_po_items-price_unit = wa_itab-price_unit.

it_po_items-orderpr_un = wa_itab-orderpr_un.

it_po_items-po_price = 'X'.

append it_po_items.

it_po_item_add_data-po_item = 10.

it_po_item_add_data-gr_ind = 'X'.

it_po_item_add_data-ir_ind = 'X'.

append it_po_item_add_data.

it_po_item_schedules-po_item = 10.

it_po_item_schedules-serial_no = 1.

it_po_item_schedules-deliv_date = sy-datum.

it_po_item_schedules-quantity = wa_itab-quantity.

it_po_item_schedules-preq_no = wa_itab-preq_no.

it_po_item_schedules-preq_item = wa_itab-preq_item.

append it_po_item_schedules.

it_po_item_account_assignment-po_item = 10.

it_po_item_account_assignment-serial_no = 1.

it_po_item_account_assignment-quantity = wa_itab-quantity.

+it_po_item_account_assignment-g_l_acct = '1211010000'.+

it_po_item_account_assignment-sd_doc = wa_itab-sd_doc.

it_po_item_account_assignment-sdoc_item = wa_itab-sdoc_item.

append it_po_item_account_assignment.

clear tmp_purnum.

call function 'BAPI_PO_CREATE'

exporting

po_header = it_po_header

importing

purchaseorder = tmp_purnum

tables

po_items = it_po_items

po_item_add_data = it_po_item_add_data

po_item_schedules = it_po_item_schedules

po_item_account_assignment = it_po_item_account_assignment

return = it_return.

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = 'X'.

the error show can not assign the code '1211010000'. but I use me21n it is ok, How can I do? thanks!