0

I've found two functions, BAPI_PO_CREATE and BAPI_PO_CREATE1. Since the CREATE1 has a more recent modification date, I assumed this would be the best one to use. As an example, I'm creating a rather simple purchase without a material.

call function 'BAPI_PO_CREATE1'
  exporting
    poheader   = po_header
    poheaderx  = po_header_x
    testrun    = abap_false
  tables
    return     = returning
    poitem     = po_items
    poitemx    = po_items_x
    poaccount  = po_accounts
    poaccountx = po_accounts_x
    poschedule = po_schedule
    poschedulex = po_schedule_x.

As such, I'm using a G/L Account and WBS element as the cost object:

append initial line to po_accounts assigning field-symbol(<po_account>).
<po_account>-po_item = current_position.
" Classes that call CONVERSION_EXIT
<po_account>-gl_account = /dim/cl_bonadm_exit=>int_saknr( <item>-gl_account ).
<po_account>-wbs_element = /dim/cl_bonadm_exit=>int_posnr( <item>-wbs_id ).

append initial line to po_accounts_x assigning field-symbol(<po_account_x>).
<po_account_x>-po_item = current_position.
<po_account_x>-po_itemx = abap_true.
<po_account_x>-gl_account = abap_true.
<po_account_x>-wbs_element = abap_true.

However, the I continue to get the error message:

No instance of object type PurchaseOrder has been created. External reference:
Purchase order item 00010 still contains faulty account assignments
Can delivery date be met?
Account 475000 requires an assignment to a CO object

Which shouldn't be the case, when I fill in the same exact data in ME21n I still get the delivery date warning but not the error on purchase order item. I have come across two different SAP notes but neither of them can be implemented. As well, even when I remove the WBS element from the account I still get the error message.

I've also tried filling in the WBS element in the CO-object field of the BAPI structure, but that did nothing. I can trace the point in the BAPI where it throws this error message but I can't find out why it's happening.

Entire method: http://hastebin.com/ufarisozav.xml

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
user3704258
  • 1
  • 1
  • 2

1 Answers1

0

You will need to fill the table poaccountx as well (as shown in the documentation of the function module), otherwise the system might ignore some or all of the data inserted into the poaccount table.

vwegert
  • 18,371
  • 3
  • 37
  • 55
  • I've filled this in as well, I just didn't include the code snippet, added to post – user3704258 Nov 02 '16 at 09:11
  • That is why a *complete* sample is so important. Did you also fill `SERIAL_NO` and forgot to paste that? – vwegert Nov 02 '16 at 09:16
  • nope, let me throw something in it and see. Edit: nothing changed, I've included a snippet of the entire method. – user3704258 Nov 02 '16 at 09:17
  • You need to provide the `SERIAL_NO` in both `poaccount` and `poaccountx`. – vwegert Nov 02 '16 at 09:46
  • I've filled in those fields, it makes no difference. There is also something I find quite weird. When I don't provide a GL account or I use a different account, the table I sent to the BAPI has a different GL account filled in (e.g. I put 800 and I see that it turns into 475000 and reports that) – user3704258 Nov 02 '16 at 10:00
  • As it says, the account is a cost element and therefore needs a CO object. It is message KI 235. Search SAP notes for it. You will find plenty of SAP notes for it. If WBS-Element is non statistical it should work. Maybe try just for testing purposes a cost center. Refer also to SAP note 2217322. – Tapio Reisinger Nov 03 '16 at 08:21
  • Check also account assignment category in line item and read documentation of BAPI. It is well documented. – Tapio Reisinger Nov 03 '16 at 08:33