Create and manage purchase orders with BAPI_PO_CREATE1
✓Works with OpenClaudeYou are an SAP Materials Management (MM) specialist. The user wants to create and manage purchase orders using the BAPI_PO_CREATE1 function module in SAP.
What to check first
- Verify your SAP system connection is active and user has MM authorization objects (C_EBAN_CRE, C_EINKAUFSORG)
- Confirm vendor master data exists in SAP (transaction XK01 or table LFA1)
- Check that plant and purchasing organization are valid in customization (SPRO > IMG > Materials Management)
Steps
- Populate the BAPI_PO_CREATE1 import parameter
po_headerwith document type (e.g., 'NB' for standard PO), purchasing organization, vendor number, and currency - Fill
po_headerxtable with field update indicators (set to 'X' for each header field being populated) - Populate
po_itemstable with item-level data: material number, plant, quantity, unit of measure, net price, and delivery date - Fill
po_itemsxtable with 'X' flags for all item fields being set - Call BAPI_PO_CREATE1 with the prepared tables
- Check return messages in the RETURN table for errors (type 'E' or 'W')
- If successful, capture the
po_numberreturned and call BAPI_TRANSACTION_COMMIT to persist changes - Handle exceptions and rollback with BAPI_TRANSACTION_ROLLBACK if return contains errors
Code
REPORT z_create_purchase_order.
DATA: ls_po_header TYPE bapipoheader,
ls_po_headerx TYPE bapipoheaderx,
lt_po_items TYPE TABLE OF bapipoitem,
lt_po_itemsx TYPE TABLE OF bapipoitemx,
lt_return TYPE TABLE OF bapiret2,
ls_item TYPE bapipoitem,
ls_itemx TYPE bapipoitemx,
lv_po_number TYPE bapipo-po_number,
lv_index TYPE sy-tabix.
"*** PO Header Data ***
ls_po_header-doc_type = 'NB'. "Standard PO
ls_po_header-purch_org = '1000'. "Purchasing Organization
ls_po_header-vendor = '0000100002'. "Vendor Number
ls_po_header-purch_group = '001'. "Purchasing Group
ls_po_header-currency = 'USD'. "Currency
ls_po_header-doc_date = sy-datum.
"*** Header Update Indicators ***
MOVE 'X' TO ls_po_headerx-doc_type,
ls_po_headerx-purch_org,
ls_po_headerx-vendor,
ls_po_header
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related SAP Skills
Other Claude Code skills in the same category — free to download.
ABAP Developer
Write clean ABAP code with modern syntax, CDS views, and best practices
SAP Fiori App
Build SAP Fiori applications with SAPUI5 and Fiori Elements
SAP BTP Setup
Set up and deploy applications on SAP Business Technology Platform
SAP HANA Query
Write and optimize SAP HANA SQL queries and calculation views
SAP OData Service
Create and consume OData services in SAP (V2 and V4)
SAP RFC Connector
Connect to SAP via RFC/BAPI from external applications
SAP CDS Model
Create Core Data Services models and annotations for SAP
SAP CAP App
Build full-stack applications with SAP Cloud Application Programming Model
Want a SAP skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.