Create PO using BAPI
CREATE
PURCHASE
ORDER USING
BAPI
Create PO using BAPI
To create a PO using BAPI (programmatically):
You can use this BAPI:
BAPI_PO_CREATE1
To use this in a custom program, you need to either:
1. Write a custom ABAP report or function module that calls BAPI_PO_CREATE1
2. Use tools like SE38, SE80, or SE37 to build and test it
Create PO using BAPI in SE38 (custom report):
DATA: lt_poitem TYPE TABLE OF bapimepoitem,
lt_poitemx TYPE TABLE OF bapimepoitemx,
lt_return TYPE TABLE OF bapiret2,
ls_header TYPE bapimepoheader,
ls_headerx TYPE bapimepoheaderx,
lv_po_number TYPE bapivbeln.
ls_header-doc_type = 'NB'. "Standard PO
ls_header-vendor = '1000'. "Vendor Number
ls_headerx-doc_type = 'X'.
ls_headerx-vendor = 'X'.
APPEND VALUE #( po_item = '00010'
material = 'MAT001'
plant = '1000'
quantity = '10'
net_price = '50' ) TO lt_poitem.
APPEND VALUE #( po_item = '00010'
material = 'X'
plant = 'X'
quantity = 'X'
net_price = 'X' ) TO lt_poitemx.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = ls_header
poheaderx = ls_headerx
TABLES
return = lt_return
poitem = lt_poitem
poitemx = lt_poitemx.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
[email protected] Ph: 8500420368
Create PO using BAPI
wait = 'X'.
Testing BAPI without custom code:
If you want to test BAPI_PO_CREATE1 directly, use:
T-code SE37 – Function Builder
o Enter BAPI_PO_CREATE1
o Click on Test/Execute (F8)
o Fill in the required fields and run it
Explore more :
Steps to create PO :
1. Tcode SE37 or BAPI or SE80
2. Enter FM BAPI_PO_CREATE1
3. Click on POHEADER
4. Enter PO header data like Co-cd, doc.type, vendor, pur.org,
pur.group,etc..
5. Go back & click on POHEADERX----
6. Give’X’ indicator for the field for which we have entered the data.
This will help to fetch the data while creating PO.
7. Go back & click on POITEM
8. Enter PO item data like item no., material, plant, Store location,
qty, net price etc…
9. Go back & click on POITEMX----
10.Give’X’ indicator for the field for which we have entered the data.
This will help to fetch the data while creating PO.
11. Save it (give proper name so we can find this variant will
creating po next time as well).
12. Go back & go to SE37.
On menu click on----Function Module----Execute----test sequence.
13. Give below sequences:
1. BAPI_PO_CREATE1
2. BAPI_TRANSACTION_COMMIT
14. Click on “Test data directory” button.
15. Select our variant & execute.
16. Copy PO for further references or to check in display mode.
[email protected] Ph: 8500420368
Create PO using BAPI
17. Go back & check for messages in results (table).
18. Go back & execute again & here PO process will be complete.
19. Finally, open the PO in ME23N & check.Check se37 also.
Go with detailed screenshots:
1. Goto BAPI Transaction Code
2. Goto Materials Management – Purchasing – Purchase Order –
CreateFromData1(Function module) or directly go to SE37- Function
builder
3. Click on Test/Execute Icon
Create PO using BAPI
4. Put the values in POHEADER, POHEADERX, POITEM and
POITEMX
5. Select POHEADER
6. Click on the highlighted icon to get the fields in a single entry.
Create PO using BAPI
7. Select PO header Mandatory fields
COMPANY CODE
DOC_TYPE
VENDOR
PURCHASE ORGANIZATION
PURCHASE GROUP
8. Put X in the fields you want to use.
Create PO using BAPI
9.Select POITEM
10.Enter the values in the fields
Create PO using BAPI
11.Goto POITEMX
12.Put X in the fields you want to use.
13.Save the Test data
Create PO using BAPI
14.Goto SE37 Transaction code
15.Click on Function Module – Execute – Test Sequences
16.Enter BAPI_PO_CREATE1 And
BAPI_TRANSACTION_COMMIT
Function Module
17.Execute it
18.After Executing it will redirect to the Test Function Module
window
19.Select Goto – Test Data Directory
20.Select your Test Data
Create Purchase Order using BAPI
21.Click on Execute
22. BAPI_PO_CREATE1 was successfully executed
23.Go back and Execute again
24.A Return value is 000 means
BAPI_TRANSACTION_COMMIT is successfully
executed without error and PO is created.
[email protected] PH : 8500420368
Create Purchase Order using BAPI
25.Goto ME22N Transaction code
26.Purchase order is successfully created
Thanks !
[email protected] PH : 8500420368