Application Development and Automation 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: 
Read only

BAPI_PO_CREATE1

Former Member
0 Likes
697

Hi,

When i create PO using bapi,i am getting error message, if i have more then one Item in item table(POITEM). the error msg is "No instance of object type PurchaseOrder has been created. External reference:" and

"Net price must be greater than 0".

The Item table contains 2 Line Items, for 1 item, po is creating, if I have to 2 Items, then the item table is updated, the 1st is removed, only the second item is available with net price as zeor.

I here with attached the code

wa_phd-comp_code = comp.

wa_phd-doc_type = 'RBT'.

wa_phd-vendor = wa_hd-kunnr.

wa_phd-purch_org = p_org.

wa_phd-pur_group = p_grp.

wa_phdx-comp_code = 'X'.

wa_phdx-doc_type = 'X'.

wa_phdx-vendor = 'X'.

wa_phdx-purch_org = 'X'.

wa_phdx-pur_group = 'X'.

LOOP AT t_item .

T_po-po_item = t_item-posnr.

T_po-material = t_item-matnr.

T_po-plant = plant.

T_po-quantity = t_item-kwmemg.

wa_po-net_price = t_item-netpr.

T_pox-po_item = t_item-posnr.

T_pox-material = 'X'.

T_pox-plant = 'X'.

T_pox-STGE_LOC = 'X' .

T_pox-QUANTITY = 'X'.

T_pox-TAX_CODE = 'X' .

T_pox-ITEM_CAT = 'X' .

T_pox-ACCTASSCAT = 'X' .

APPEND T_PO.

APPEND T_POX.

ENDLOOP.

CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

poheader = wa_phd

poheaderx = wa_phdx

NO_PRICE_FROM_PO = 'X'

IMPORTING

exppurchaseorder = po_vbeln

TABLES

return = t_ret

poitem = t_po

poitemx = t_pox.

IF NOT PO_VBELN IS INITIAL.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ELSE.

MESSAGE e440.

ENDIF.

3 REPLIES 3
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
545

I see something out of sorts here. You are not moving the net price to T_PO.



wa_phd-comp_code = comp.
wa_phd-doc_type = 'RBT'.
wa_phd-vendor = wa_hd-kunnr.
wa_phd-purch_org = p_org.
wa_phd-pur_group = p_grp.

wa_phdx-comp_code = 'X'.
wa_phdx-doc_type = 'X'.
wa_phdx-vendor = 'X'.
wa_phdx-purch_org = 'X'.
wa_phdx-pur_group = 'X'.

LOOP AT t_item .

T_po-po_item = t_item-posnr.
T_po-material = t_item-matnr.
T_po-plant = plant.
T_po-quantity = t_item-kwmemg.
<b>wa_po-net_price = t_item-netpr.</b>

T_pox-po_item = t_item-posnr.
T_pox-material = 'X'.
T_pox-plant = 'X'.
T_pox-STGE_LOC = 'X' .
T_pox-QUANTITY = 'X'.
T_pox-TAX_CODE = 'X' .
T_pox-ITEM_CAT = 'X' .
T_pox-ACCTASSCAT = 'X' .
APPEND T_PO.
APPEND T_POX.
ENDLOOP.


CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = wa_phd
poheaderx = wa_phdx
NO_PRICE_FROM_PO = 'X'
IMPORTING
exppurchaseorder = po_vbeln
TABLES
return = t_ret
poitem = t_po
poitemx = t_pox.

IF NOT PO_VBELN IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ELSE.
MESSAGE e440.

ENDIF.

Read only

0 Likes
545

and also you didn't set the corresponding X structure field for NET_PRICE.

T_POX-NET_PRICE = 'X'.

Read only

Former Member
0 Likes
545

Hi,

Hi U r Missing the following fields in Items Structure:

T_po-net_price = t_item-netpr.

T_pox-po_itemx = 'X'

T_poX-net_price = 'X'.

Sreedhar