Wednesday, 17 February 2010

SAP Purchase Order Creation Error via BAPI - "In case of account assignment, please enter acc. assignment data for item" Some of the quirks of BAPI_PO_CREATE1 (via a custom BAPI)

I have been calling the SAP BAPI "BAPI_PO_CREATE1" indirectly via a custom BAPI created by one of the other guys in my development team. However, I have found out some things about this the hard way:
  1. If you haven't applied all the most recent SAP fixes to your install since mid 2009 til now (Feb 2010), you will be in a world of pain as it is IMPOSSIBLE to post a service item entry (ItemCat = "D" against a purchase order header). You will always get the following error (aka error 06 436):
    "'In case of account assignment, please enter acc. assignment data for item'"
    I spent hours butting my head against the wall because of this obscure bug when trying to call our custom BAPI. Some basic details are in the SAP Note 1373051 below (As per the image, German is considered to be the 'Master' language'!)  I believe this problem would also occur with the SAP Purchase Order Enterprise services as they call the BAPI directly.

  2. As described in https://forums.sdn.sap.com/thread.jspa?threadID=877029, to get the BAPI_PO_CREATE1 to work at all with a service item (Item Category = 'D' (Service) and Spend type of 'K' (Cost Centre), you need to create all the correct entries in the following BAPI tables:
    a) POITEM
    b) POITEMX (Change Flags - must have entries for all columns that have data)
    c) POACCOUNT
    d) POACCOUNTX (Change Flags - must have entries for all columns that have data)
    e) POSERVICES (This doesn't have a matching change flag table) - which goes into the ESLL table in SAP)
    f) POSRVACCESSVALUES

    If you don't put this information in, you will get the error "Please maintain services or limits"

    As described in the link:

    For service items: POITEM-PCKG_NO = ‘0000000001’. (assign package no as a dummy number)

    Set PCKG_NO flag in POITEMX table as ‘X’.

    Package No is the link that connect POITEM table to POACCOUNT table through tables POSERVICES and POSRVACCESSVALUES.

    Set POACCOUNT-SERIAL_NO to ‘01’.

    Set same PCKG_NO to ‘0000000001’ in POSERVICES table. Maintain two entries in POSERVICES table like this:

    WA_POSERVICES-PCKG_NO = ‘0000000001’.
    WA_POSERVICES-LINE_NO = ‘0000000001’.
    WA_POSERVICES-OUTL_IND = ‘X’.
    WA_POSERVICES-SUBPCKG_NO = ‘0000000003’. (Dummy No.)
    WA_POSERVICES-QUANTITY = ‘100.000’.
    WA_POSERVICES-BASE_UOM = ‘EA’.
    WA_POSERVICES-PRICE_UNIT = ‘1’.
    WA_POSERVICES-GR_PRICE = ‘100.000’. 
    WA_POSERVICES-SHORT_TEXT = ‘SERVICE TEST’.
    APPEND WA_POSERVICES TO IT_POSERVICES.
    
    WA_POSERVICES- PCKG_NO = ‘0000000003’.
    WA_POSERVICES- LINE_NO = ‘0000000002’.
    WA_POSERVICES-QUANTITY = ‘10.000’.
    WA_POSERVICES- BASE_UOM = ‘EA’.
    WA_POSERVICES--PRICE_UNIT = ‘1’.
    WA_POSERVICES-GR_PRICE = ‘100.000’. 
    WA_POSERVICES-SHORT_TEXT = ‘SERVICE 1’.
    WA_POSERVICES-MATL_GROUP = ‘0012’.
    APPEND WA_POSERVICES TO IT_POSERVICES.
    
    Set PCKG_NO as SUB_PCKG_NO in table POSRVACCESSVALUES this:
    WA_POSRVACCESSVALUES-PCKG_NO = ‘0000000003’.
    WA_POSRVACCESSVALUES-LINE_NO = ‘0000000002’.
    WA_POSRVACCESSVALUES-SERNO_LINE = ‘01’.
    WA_POSRVACCESSVALUES-SERIAL_NO = ‘01’.
    WA_POSRVACCESSVALUES-QUANTITY = ’10.000’.
    APPEND WA_POSRVACCESSVALUES TO IT_ POSRVACCESSVALUES.
  3. Also note that if you get errors relating to "Cost Object XXXXXX does not exist on DD.MM.YYYY", then you have likely set the value of "CostObject" on the Account Parameter. Depending on your config, it is typically OK to just leave this blank, and feed your cost object information into the relevant column on the Account Table (Asset/Cost Centre/Project etc).
PS. Why not use Enterprise Services rather than the custom BAPIs? I've more recently learnt that the official best way to do some of these changes (rather than writing custom BAPIs) is to EXTEND the Enterprise Service Extensions (according to Jan from SAP who visited us recently). However there is scant documentation on this so is only really in the realm of "Internal SAP Employees Only" development.

I've found that SAP Enterprise Services are even more complex and are more difficult to customize than the simpler BAPI mechanisms we have established here at my current client. Custom BAPIs have the main disadvantage of duplicating some datatypes (there are global datatypes defined in SAP Enterprise Services) and an increased difficulty in data type governance and consolidation that this entails.

5 comments:

Leo said...

Thanks for good article about
Free Purchase Order Forms

Kiyan Adhyatma Ibrahim said...

Dear David,

I have created an LSMW for create PO via BAPI_PO_CREATE1.

When I process the IDOC, I got the error " Control indicators for controlling area XXX do not exist ".

I have check the config, there is no problem.

Please help me, what should I do?

Karthik said...

Awesome David, I would like to say one more thing that, this is also helpful, when you create Blanket Purchase orders. We need to follow the above steps to create one using this BAPI_PO_CREATE1.

Prakash Doguparthy said...

Hi David,

I really appreciate for your Blog about this issue.. I faced the same trouble and after visiting your blog and implemented your inputs in program...

and then it worked in a very great way :)

Regards,
Prakash Doguparthy

Amar Rajput said...

Nice Blog! Experience the Best Assignment Writing Services at Assignment Help Sydney Australia