2008 Jul 15 7:42 AM
HI Guru's,
I am not able to create PO through Standard BAPI .
( BAPI_PO_CREATE. )
Is there any possibility to create PO through BAPI only .
Thank's and Regard's
Ankit Singh Rathore .
HI Guru's,
I am not able to create PO through Standard BAPI .
( BAPI_PO_CREATE. )
Is there any possibility to create PO through BAPI only .
Thank's and Regard's
Ankit Singh Rathore .
2008 Jul 15 7:47 AM
Hi
You have the complete code here
http://abaplovers.blogspot.com/2008/05/purchase-order-bapi-sap-abap.html
Reward if useful.
Regards
Divya
2008 Jul 15 7:48 AM
U can use BAPI_PO_CREATE1.
Here is the sample code.
DATA : l_ponumber LIKE ekpo-ebeln,
l_msgty TYPE c,
l_msgid(2) TYPE c,
l_msgno(3) TYPE c,
l_msgtx(100) TYPE c,
l_errflag TYPE c.
DATA : BEGIN OF tl_bapireturn OCCURS 0.
INCLUDE STRUCTURE bapiret2.
DATA : END OF tl_bapireturn.
*C-- Data declarations for type of subc / serial nos
data: begin of lt_disub_sertab occurs 0,
ebelp like ekpo-ebelp, " PO Item #
sernr like e1rmsno-sernr, " PO Item Serial #
end of lt_disub_sertab.
data: begin of lt_disub_poitem occurs 0,
ebelp like ekpo-ebelp, " PO Item #
serru like ekpo-serru, " Sub contracting Type
anzsn like ekpo-anzsn, " No. of Ser # (= Item Qty)
disub_sobkz like ekpo-disub_sobkz,
disub_pspnr like ekpo-disub_pspnr,
disub_kunnr like ekpo-disub_kunnr,
disub_vbeln like ekpo-disub_vbeln,
disub_posnr like ekpo-disub_posnr,
disub_owner like ekpo-disub_owner,
end of lt_disub_poitem.
*C-- End of data declarations for type of subc / serial nos
CLEAR: l_ponumber.
CLEAR: tl_bapireturn.
REFRESH: tl_bapireturn.
*C-- Handling Type of SubC / Serial Nos
clear lt_disub_poitem.
refresh lt_disub_poitem.
loop at t_po_item
where po_number = t_po_header-po_number.
lt_disub_poitem-ebelp = t_po_item-po_item.
lt_disub_poitem-serru = '1'.
lt_disub_poitem-anzsn = t_po_item-quantity.
append lt_disub_poitem.
clear lt_disub_poitem.
endloop.
Serial Numbers
clear lt_disub_sertab.
refresh lt_disub_sertab.
loop at t_po_itemseril
where po_number = t_po_header-po_number.
lt_disub_sertab-ebelp = t_po_itemseril-po_item.
lt_disub_sertab-sernr = t_po_itemseril-serno.
append lt_disub_sertab.
clear lt_disub_sertab.
endloop.
Export Internal tables to Memory.
export: lt_disub_poitem to memory id 'disub_item',
lt_disub_sertab to memory id 'disub_sertab'.
*C-- End of handling Type of SubC / Serial Nos
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = t_bapi_poheader
POHEADERX = t_bapi_poheaderx
POADDRVENDOR = t_bapi_poaddrvendor
TESTRUN = p_trun
MEMORY_UNCOMPLETE =
MEMORY_COMPLETE =
POEXPIMPHEADER = t_bapi_poexpimpheader
POEXPIMPHEADERX = t_bapi_poexpimpheaderx
VERSIONS =
NO_MESSAGING =
NO_MESSAGE_REQ =
NO_AUTHORITY =
NO_PRICE_FROM_PO =
IMPORTING
EXPPURCHASEORDER = l_ponumber
EXPHEADER =
EXPPOEXPIMPHEADER =
TABLES
RETURN = tl_bapireturn
POITEM = t_bapi_poitem
POITEMX = t_bapi_poitemx
POADDRDELIVERY =
POSCHEDULE = t_bapi_poschedule
POSCHEDULEX = t_bapi_poschedulex
POACCOUNT = t_bapi_poaccount
POACCOUNTPROFITSEGMENT =
POACCOUNTX = t_bapi_poaccountx
POCONDHEADER =
POCONDHEADERX =
POCOND =
POCONDX =
POLIMITS = t_bapi_polimits
POCONTRACTLIMITS =
POSERVICES =
POSRVACCESSVALUES =
POSERVICESTEXT =
EXTENSIONIN =
EXTENSIONOUT =
POEXPIMPITEM = t_bapi_poexpimpitem
POEXPIMPITEMX = t_bapi_poexpimpitemx
POTEXTHEADER = t_bapi_potextheader
POTEXTITEM =
ALLVERSIONS =
POPARTNER =
NFMETALLITMS =
.
IF p_trun IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN =
.
ENDIF.
*C-- Write messages
WRITE: / 'PO Number: '(012), t_po_header-po_number.
CLEAR l_errflag.
LOOP AT tl_bapireturn.
CLEAR: l_msgty, l_msgid, l_msgno, l_msgtx.
l_msgty = tl_bapireturn-type.
l_msgid = tl_bapireturn-id.
l_msgno = tl_bapireturn-number.
l_msgtx = tl_bapireturn-message.
WRITE: / l_msgty, l_msgid, l_msgno, l_msgtx.
IF l_msgty EQ 'E'.
l_errflag = 'X'.
ENDIF. " l_msgty EQ 'E'
ENDLOOP.
2008 Jul 15 7:54 AM
Hi Ankit,
i am not sure but you can try with
BAPI_STOREORDER_CREATE Creates Documents (PR, PO, Delivery or Sales order) From Store Orders
or have alook in th elink below for BAPI's:
http://www.sapbapi.com/bapi-list/
With all the luck,
Pritam.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |