‎2006 Jun 09 3:49 PM
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.
‎2006 Jun 09 4:09 PM
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.
‎2006 Jun 09 4:43 PM
and also you didn't set the corresponding X structure field for NET_PRICE.
T_POX-NET_PRICE = 'X'.
‎2006 Jun 09 4:43 PM
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