Skip to Content
avatar image
Former Member

Error while Creating a PO using BAPI_PO_CREATE1

Hi Friends,

The following issue that I have observed and as explained below is one of the weirdest scenarios that I have seen while working with SAP. Hence, kindly help me with possible errors from my end. I am working on ECC 6.0.

Requirement: To automatically create a PO.

Option used: I have used a BAPI: u2018BAPI_PO_CREATE1u2019

Scenario: When I execute the BAPI u2018BAPI_PO_CREATE1u2019 directly in sequence with u2018BAPI_TRANSACTION_COMMITu2019, the PO gets created successfully. The data entered as input is:

POHEADER-COMP_CODE

POHEADER-DOC_TYPE

POHEADER-PMNTTRMS

POITEM-PO_ITEM

POITEM-QUANTITY

POITEM-TAX_CODE

POITEM-TAXJURCODE

POITEM-RFQ_NO

POITEM-RFQ_ITEM

POITEM-PREQ_NO

POITEM-PREQ_ITEM

POITEM-PREQ_NAME

POSCHEDULE-PO_ITEM

POSCHEDULE-SCHED_LINE

POSCHEDULE-QUANTITY

POSCHEDULE-PREQ_NO

POSCHEDULE-PREQ_ITEM

Problem: I need to pass data to the BAPI through code, so I called the BAPI u2018BAPI_PO_CREATE1u2019 and u2018BAPI_TRANSACTION_COMMITu2019 in a test function module as well as report. I passed the same data as mentioned above i.e. while creating the PO by passing data to the BAPI directly.

But the BAPI returns an error BAPI header data still faulty, enter plant, Pur. Org., Pur. Grp., etc.

I tried by passing all the available data for the header and then for the items, but finally, I still get an error that the item is from a different order account and just cannot create a PO.

The Test FM code is as shown below:

DATA : PYMNT_TERMS TYPE YOAF_SEC_MASTER-TER_PYMNT.

DATA : ITEM_NO(4) .

DATA : CURRENCY TYPE LFM1-WAERS.

DATA : POHEAD TYPE BAPIMEPOHEADER.

DATA : POHEADX TYPE BAPIMEPOHEADERX.

DATA : EXP_HEAD TYPE BAPIMEPOHEADER.

DATA : POITEM TYPE TABLE OF BAPIMEPOITEM WITH HEADER LINE.

DATA : POITEMX TYPE TABLE OF BAPIMEPOITEMX WITH HEADER LINE.

DATA : POSCHED TYPE TABLE OF BAPIMEPOSCHEDULE WITH HEADER LINE.

DATA : POSCHEDX TYPE TABLE OF BAPIMEPOSCHEDULX WITH HEADER LINE.

DATA : EX_PO_NUMBER TYPE BAPIMEPOHEADER-PO_NUMBER.

CONSTANTS : C_X VALUE 'X'.

POHEAD-COMP_CODE = 'P110'.

POHEAD-DOC_TYPE = DOC_TYPE.

POHEAD-PMNTTRMS = 'P10'.

POHEADX-COMP_CODE = C_X.

POHEADX-DOC_TYPE = C_X.

POHEADX-PMNTTRMS = C_X.

POITEM-PO_ITEM = '00001'.

POITEM-QUANTITY = '1.000'.

POITEM-TAX_CODE = 'D2'.

POITEM-TAXJURCODE = 'MH01'.

POITEM-RFQ_NO = '2300009491'.

POITEM-RFQ_ITEM = '00001'.

POITEM-PREQ_NO = '200003583'.

POITEM-PREQ_ITEM = '00001'.

POITEM-PREQ_NAME = 'SACHIN'.

APPEND POITEM.

POITEMX-PO_ITEM = '00001'.

POITEMX-PO_ITEMX = C_X.

POITEMX-QUANTITY = C_X .

POITEMX-TAX_CODE = C_X .

POITEMX-TAXJURCODE = C_X .

POITEM-RFQ_NO = C_X.

POITEM-RFQ_ITEM = C_X.

POITEM-PREQ_NO = C_X.

POITEM-PREQ_ITEM = C_X.

POITEMX-PREQ_NAME = C_X.

APPEND POITEMX.

POSCHED-PO_ITEM = '00001'.

POSCHED-SCHED_LINE = '0001'.

POSCHED-QUANTITY = '1.000'.

POSCHED-PREQ_NO = '1200003583'.

POSCHED-PREQ_ITEM = '00001'.

APPEND POSCHED.

POSCHEDX-PO_ITEM = '1'.

POSCHEDX-SCHED_LINE = '0001'.

POSCHEDX-PO_ITEMX = C_X.

POSCHEDX-SCHED_LINEX = C_X.

POSCHEDX-QUANTITY = C_X.

POSCHEDX-PREQ_NO = C_X.

POSCHEDX-PREQ_ITEM = C_X.

APPEND POSCHEDX.

CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

POHEADER = POHEAD

POHEADERX = POHEADX

IMPORTING

EXPPURCHASEORDER = EX_PO_NUMBER

EXPHEADER = EXP_HEAD

  • EXPPOEXPIMPHEADER =

TABLES

RETURN = RETURN_ERROR

POITEM = POITEM

POITEMX = POITEMX

  • POADDRDELIVERY =

POSCHEDULE = POSCHED

POSCHEDULEX = POSCHEDX

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

IMPORTING

RETURN = RETURN_ERROR.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Feb 04, 2009 at 12:20 PM

    Hi,

    You are passing different purchase req. no's in

    POITEM-PREQ_NO = '200003583'.

    POSCHED-PREQ_NO = '1200003583'.

    Check whether this is causing the problem.

    Regards,

    Dwaraka.S

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 04, 2009 at 12:39 PM

    Hi,

    Probably few details not passed..

    try with this

    POITEM-plant = 'PLANT CODE'.

    APPEND POITEM.

    POHEAD-PUR_GROUP = 'Purchase group '.

    POHEAD-PURCH_ORG = 'Purchase organisation'.

    APPEND POHEAD.

    Cheers,

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      As mentioned that this error was one of the wierdest SAP issues I have faced, it was due to the silliest copy paste errors on my behalf. I completely overlooked the POITEMX naming.

      For 4 values of RFQ_NO, RFQ_ITEM, PREQ_NO, PREQ_ITEM, I didnt have the 'X' for POITEMX and kept on looking for errors for days.

      BAPI_PO_CREATE1 works with min. possible inputs successfully.

      Thanks to all!

  • avatar image
    Former Member
    Feb 05, 2009 at 08:53 AM

    PO was created with just PR and RFQ numbers. All the other applicable and maintained data was fetched while BAPI_PO_CREATE1 was executed.

    Add comment
    10|10000 characters needed characters exceeded