Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

No instance of object type PurchaseOrder has been created. External referen

Former Member
0 Kudos

Hi Gurus,

We are using ECC 6.0.

When we try to create a PO from excel using bapi_po_create1 FM doesnot get created, but we get this error message "No instance of object type PurchaseOrder has been created. External reference: "

any help on this ???

Regards,

Sureshkumar.s

10 REPLIES 10

Former Member
0 Kudos

Hi,

You are not passing the correct values in the BAPI for PO Creation.

There are lots of post/blogs in SDN about the data to be passed for PO creation .

You can go through that.

Corect the data once.

Thanks

Arbind

0 Kudos

Hi Arbind

Thanks for your quick responce

This is our code

REPORT ZME21N.

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.

  • Header Level Data

pohead-comp_code = 'NCCP'.

pohead-doc_type = 'NB' .

pohead-creat_date = sy-datum .

pohead-vendor = 'ITT'.

pohead-purch_org = 'NCPO'.

pohead-pur_group = 'P53'.

pohead-GR_MESSAGE = 'X'.

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 = 'YD1801581X1R00SB-N'.

poitem-plant = '1002'.

poitem-stge_loc = 'ST01'.

poitem-quantity = 1.

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 = 1.

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 i036.

endif.

Can you tell me what is the wrong value

Regards

Suresh

0 Kudos

Is number range for this document type external or internal.If its external,pass PO number otherwise leave it blank.

0 Kudos

Hi,

In th import parameter POHEADER pass the Purchase Order Number and POHEADER-PO_NUMBER = 'X'.

Check it out once whther PO Number is external or Internal.

Thanks

Arbind

0 Kudos

Hi Arbind

My Requirement is PO was automatically create and PO number is internal

please advise

Regards

Suresh

0 Kudos

Hi,

Please check once that internal number range has been created in SNRO for that particular Docyment type and it is activated.

May be the problem with the internal number range.

Anywayz plz go through the sample code...


REPORT ZPURCHASEORDER.
data:
header like BAPIMEPOHEADER,
headerx like BAPIMEPOHEADERX,
it_item like standard table of BAPIMEPOITEM,
it_itemx like standard table of BAPIMEPOITEMX,
return like standard table of BAPIRET2,
wa_item like BAPIMEPOITEM,
wa_itemx like BAPIMEPOITEMX,
p_int type i,
p_matnr like mara-matnr,
p_pono like ekko-ebeln.
DATA: BEGIN OF BAPIRETURN OCCURS 0.
INCLUDE STRUCTURE BAPIRET2.
DATA: END OF BAPIRETURN.
constants:
c_x type c value 'X'.
header-comp_code = '3000'.
header-doc_type = 'DP25'.
header-creat_date = sy-datum.
header-item_intvl = '10'.
header-vendor = 'ARAMI-00'.
header-langu = sy-langu.
header-pmnttrms = '0001'.
header-purch_org = '3000'.
header-pur_group = '010'.
header-currency = 'USD'.
headerx-comp_code = c_x.
headerx-doc_type = c_x.
headerx-creat_date = c_x.
headerx-item_intvl = c_x .
headerx-vendor = c_x.
headerx-langu = c_x.
headerx-pmnttrms = c_x .
headerx-purch_org = c_x.
headerx-pur_group = c_x.
p_int = p_int + 10.
wa_item-po_item = p_int.
p_matnr = 'T-SRM01'.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = p_matnr
IMPORTING
output = p_matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
wa_item-material = p_matnr.
wa_item-plant = '3200'.
wa_item-quantity = 100.
wa_item-conf_ctrl = 'Z01'.
wa_item-ACKN_REQD = 'X'.
WA_ITEM-ERS = ''.
APPEND wa_item TO it_item.
wa_itemx-po_item = p_int.
wa_itemx-material = c_x.
wa_itemx-plant = c_x .
wa_itemx-stge_loc = c_x .
wa_itemx-quantity = c_x .
wa_itemx-item_cat = c_x .
wa_itemx-acctasscat = c_x .
wa_itemx-conf_ctrl = 'X'.
wa_itemx-ACKN_REQD = 'X'.
WA_ITEMX-ERS = 'X'.
APPEND wa_itemx TO it_itemx.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = header
poheaderx = headerx
IMPORTING
exppurchaseorder = p_pono
TABLES
return = return
poitem = it_item
poitemx = it_itemx.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = BAPIRETURN.
write:/ p_pon

.

Thanks

Arbind

0 Kudos

Hi Arbind

Thanks for your quick reply

That program working fine .but in our ME21N Tcode Save before checking one userexist but here didnot check

how to setup check this userexit?

Thanks and Regards

Suresh

0 Kudos

Hi Suresh,

I didnot get you.

In Me21n before save we used to check for that you can use BADI ME_PROCESS_PO_CUST and check method for any changes.

Thanks

Arbind

0 Kudos

Hi Arbind

Before saving Po we have maintained costing va02 tcode Total PO value with in budget allowing this user exit sae the Po

otherwise GrN made or exceed budget didnot allow the userexit

That userexit didnot heck using bapi_po_create1

Thanks and Regards

Suresh

birendra_chatterjee
Active Participant
0 Kudos

Hi Suresh,

You can debug the BAPI, and check why this error is coming. Sometimes, if the BAPI is unable to generate a suitable error message, it gives a generic message in return which is 'No instance of object type PurchaseOrder has been created'.

Rgds,

Birendra