Skip to Content
author's profile photo Former Member
Former Member

How to Create the PO Using BAPI

hi Friends,

i want to up load the PO using the BAPI.

Initially i went through the ME21N.

And i gave the following values.then i can able to create the PO.

the values are:

document typeIND Standard PO

Vendor : 1000 C.E.B. BERLIN

Org. : 1000 IDES Deutschland

Purch. Group : 001 Dietl,B.

Company Code : 1000 IDES AG

material : 100-100

PO Quantity :10

Plant :1100

now i wrote a BPAI program.

like this

data : poheader type bapimepoheader.

data : bapiret2 type table of bapiret2.

data : poitem type bapimepoitem .

data : it_poitem TYPE TABLE OF bapimepoitem.

DATA : SCHEDULE TYPE BAPIMEPOSCHEDULE,

IT_SCHEDULE TYPE TABLE OF BAPIMEPOSCHEDULE,

SCHEDULEX TYPE BAPIMEPOSCHEDULX,

IT_SCHEDULEX TYPE TABLE OF BAPIMEPOSCHEDULX.

DATA : BAPIMEPOHEADERX TYPE BAPIMEPOHEADERX.

DATA : WA_POITEMX TYPE bapimepoitemX.

DATA : POITEMX TYPE TABLE OF BAPIMEPOITEMX.

data : poheader type bapimepoheader.

DATA : BAPIMEPOHEADERX TYPE BAPIMEPOHEADERX.

data : poitem type bapimepoitem .

data : it_poitem TYPE TABLE OF bapimepoitem.

DATA : SCHEDULE TYPE BAPIMEPOSCHEDULE,

IT_SCHEDULE TYPE TABLE OF BAPIMEPOSCHEDULE,

SCHEDULEX TYPE BAPIMEPOSCHEDULX,

IT_SCHEDULEX TYPE TABLE OF BAPIMEPOSCHEDULX.

data : bapiret2 type table of bapiret2.

DATA : WA_POITEMX TYPE bapimepoitemX,

POITEMX TYPE TABLE OF BAPIMEPOITEMX.

data : out_ebeln type ebeln.

start-of-selection.

*HEADER DETAILS

poheader-comp_code = '1000'."wa_data-bukrs.

poheader-purch_org = '1000'."wa_data-ekorg.

poheader-pur_group = '001'."wa_data-bkgrp.

poheader-vendor = '1000'."wa_data-elifn.

poheader-doc_type = 'INB'."wa_data-esart.

poheader-ITEM_INTVL = '0001'.

BAPIMEPOHEADERX-comp_code = 'X'.

BAPIMEPOHEADERX-doc_type = 'X'.

BAPIMEPOHEADERX-pur_group = 'X'.

BAPIMEPOHEADERX-purch_org = 'X'.

BAPIMEPOHEADERX-vendor = 'X'.

*ITEM DETAILS

poitem-PO_ITEM = '00010'.

*MOVE '100-100' TO poitem-material.

poitem-material = '100-100'.

*poitem-material = wa_data-matnr.

poitem-plant = '1100'.

poitem-quantity = '10.00'."wa_data-bstmg.

DATE = SY-DATUM + 1.

poitem-ITEM_CAT = '0'.

poitem-ACCTASSCAT = ' '.

poitem-VEND_MAT = '100-100'.

append poitem to it_poitem.

WA_poitemx-PO_ITEM = '00010'.

WA_poitemx-MATERIAL = 'X'.

WA_poitemx-PLANT = 'X'.

WA_poitemx-QUANTITY = 'X'.

*WA_poitemx-ACCTASSCAT = 'K' .

*WA_poitemx-PO_ITEMx = 'X'.

APPEND WA_POITEMX TO poitemX.

**SCHEDULEX

SCHEDULEX-PO_ITEM = '10'.

SCHEDULEX-PO_ITEMX = 'X'.

APPEND SCHEDULEX TO IT_SCHEDULEX.

**SCHEDULE DATE

SCHEDULE-PO_ITEM = '10'.

SCHEDULE-DELIVERY_DATE = DATE.

APPEND SCHEDULE TO IT_SCHEDULE.

call function 'BAPI_PO_CREATE1'

exporting

poheader = poheader

POHEADERX = BAPIMEPOHEADERX

  • POADDRVENDOR =

  • TESTRUN =

  • MEMORY_UNCOMPLETE =

  • MEMORY_COMPLETE =

  • POEXPIMPHEADER =

  • POEXPIMPHEADERX =

  • VERSIONS =

  • NO_MESSAGING =

  • NO_MESSAGE_REQ =

  • NO_AUTHORITY =

  • NO_PRICE_FROM_PO =

importing

exppurchaseorder = out_ebeln

  • EXPHEADER =

  • EXPPOEXPIMPHEADER =

tables

return = bapiret2

poitem = it_poitem[]

POITEMX = POITEMX

  • POADDRDELIVERY =

POSCHEDULE = IT_SCHEDULE

POSCHEDULEX = IT_SCHEDULEX

  • POACCOUNT =

  • POACCOUNTPROFITSEGMENT =

  • POACCOUNTX =

  • POCONDHEADER =

  • POCONDHEADERX =

  • POCOND =

  • POCONDX =

  • POLIMITS =

  • POCONTRACTLIMITS =

  • POSERVICES =

  • POSRVACCESSVALUES =

  • POSERVICESTEXT =

  • EXTENSIONIN =

  • EXTENSIONOUT =

  • POEXPIMPITEM =

  • POEXPIMPITEMX =

  • POTEXTHEADER =

  • POTEXTITEM =

  • ALLVERSIONS =

  • POPARTNER =

  • POCOMPONENTS =

  • POCOMPONENTSX =

  • POSHIPPING =

  • POSHIPPINGX =

  • POSHIPPINGEXP =.

.

iam getting the following messages in BAPIRET2 Table:

1. No instance of object type PurchaseOrder has been created. External reference:

2. PO header data still faulty

3. No master record exists for vendor 1000

4. Vendor master data for vendor 1000 not found

can any one suggest me how to rectify the problem.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 10:28 AM

    Hi

    i am giving an example prog.....please refer if useful.......

    report ztest_0001.

    constants : c_x value 'X'.

    data: del_date type sy-datum.

    data: pohead type bapimepoheader.

    data: poheadx type bapimepoheaderx.

    data: exp_head type bapimepoheader.

    data: return type table of bapiret2 with header line.

    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.

    parameters: p_matnr type ekpo-matnr.

    parameters: p_werks type ekpo-werks.

    parameters: p_lgort type ekpo-lgort.

    parameters: p_menge type ekpo-menge.

    parameters: p_lifnr type ekko-lifnr.

    parameters: p_ekorg type ekko-ekorg.

    parameters: p_ekgrp type ekko-ekgrp.

    parameters: p_bukrs type ekko-bukrs.

    • Header Level Data

    pohead-comp_code = p_bukrs.

    pohead-doc_type = 'NB' .

    pohead-creat_date = sy-datum .

    pohead-vendor = p_lifnr.

    pohead-purch_org = p_ekorg.

    pohead-pur_group = p_ekgrp.

    pohead-langu = sy-langu .

    pohead-doc_date = sy-datum.

    poheadx-comp_code = c_x.

    poheadx-doc_type = c_x.

    poheadx-creat_date = c_x.

    poheadx-vendor = c_x.

    poheadx-langu = c_x.

    poheadx-purch_org = c_x.

    poheadx-pur_group = c_x.

    poheadx-doc_date = c_x.

    • Item Level Data

    poitem-po_item = 1.

    poitem-material = p_matnr.

    poitem-plant = p_werks.

    poitem-stge_loc = p_lgort.

    poitem-quantity = p_menge.

    append poitem.

    poitemx-po_item = 1.

    poitemx-po_itemx = c_x.

    poitemx-material = c_x.

    poitemx-plant = c_x .

    poitemx-stge_loc = c_x .

    poitemx-quantity = c_x .

    poitemx-tax_code = c_x .

    poitemx-item_cat = c_x .

    poitemx-acctasscat = c_x .

    append poitemx.

    • Schedule Line Level Data

    posched-po_item = 1.

    posched-sched_line = 1.

    posched-del_datcat_ext = 'D'.

    del_date = sy-datum + 1.

    write del_date to posched-delivery_date.

    posched-deliv_time = '000001'.

    posched-quantity = p_menge.

    append posched.

    poschedx-po_item = 1.

    poschedx-sched_line = 1.

    poschedx-po_itemx = c_x.

    poschedx-sched_linex = c_x.

    poschedx-del_datcat_ext = c_x.

    poschedx-delivery_date = c_x.

    poschedx-quantity = c_x.

    append poschedx.

    call function 'BAPI_PO_CREATE1'

    exporting

    poheader = pohead

    poheaderx = poheadx

    testrun = ' '

    importing

    exppurchaseorder = ex_po_number

    expheader = exp_head

    tables

    return = return

    poitem = poitem

    poitemx = poitemx

    poschedule = posched

    poschedulex = poschedx.

    call function 'BAPI_TRANSACTION_COMMIT'

    exporting

    wait = 'X'.

    if not ex_po_number is initial.

    call function 'DEQUEUE_ALL'.

    else.

    call function 'DEQUEUE_ALL'.

    message i020 . " " Process Done"

    endif.

    Regards

    Adesh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 05:27 AM

    Hi,

    Refer to thia link...

    bapipocreate1

    bapipocreate1

    Edited by: avinash kodarapu on Dec 22, 2008 10:58 AM

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.