What is BAPI in SAP SD?
BAPI (Business Application Programming Interface) = Standard SAP function modules
that allow external systems or custom programs to interact safely with SAP business
objects (Sales Order, Delivery, Invoice, etc.).
BAPIs are stable, released by SAP, and do not modify directly tables — only through
business logic.
Scenarios where BAPIs are Required in SD
hi
Scenario BAPI Used Why Needed
Create Sales Order from
external portal
a
Change Sales Order
ris
BAPI_SALESORDER_CREATEFR
OMDAT2
BAPI_SALESORDER_CHANGE
Auto-create order
without VA01
Update quantity, pricing
quantity
ah
Create Outbound Delivery BAPI_OUTB_DELIVERY_CREAT Auto-create delivery
E_SLS after order
Post Goods Issue (PGI) for BAPI_OUTB_DELIVERY_CONFI Perform PGI
M
Delivery RM_DEC automatically
Create Billing Document BAPI_BILLINGDOC_CREATEFR Generate Invoice
OMDATA without VF01
Cancel Billing Document BAPI_BILLINGDOC_CANCEL Cancel wrongly created
invoice
Update Partner Functions BAPI_SALESORDER_CHANGE Change Sold-to / Ship-to
in Sales Orders Party
Get Sales Order Details for BAPI_SALESORDER_GETSTATU Fetch order status
Reporting S
Mass Update Customer BAPI_CUSTOMER_CHANGEFROM Update Customer
Master data DATA1 Address/Email
Business Requirement 1: Create Sales Order Automatically
hi
When a customer places an order on a website, the system should
auto-create Sales Order in SAP without user logging into SAP.
Solution using BAPI:
Use BAPI_SALESORDER_CREATEFROMDAT2.
Configuration / Setup Steps:
1. Identify Data:
a ris
○ Website Order Data → SAP Fields Mapping (VKORG, VTWEG, SPART,
KUNNR, MATNR, KWMENG, etc.)
2. Custom Program / Middleware Integration:
ah
○ Use RFC (Remote Function Call) from Middleware or SAP PI/PO/CPI to call
BAPI.
○ Or Develop a custom ABAP Report which reads file/API and calls BAPI.
3. BAPI Call:
M
○ Fill header (ORDER_HEADER_IN)
○ Fill partner (ORDER_PARTNERS)
○ Fill items (ORDER_ITEMS_IN)
4. Handle BAPI Return Messages:
○ Success → Commit Work
○ Failure → Show Error to Web system
Outcome:
Website order becomes SAP Sales Order automatically without user manual effort (no
VA01 needed).
Business Requirement 2: Post Goods Issue Automatically
After picking goods in the warehouse, the system must auto-post PGI (Post
Goods Issue) without users going to VL02N.
Solution using BAPI:
Use BAPI_OUTB_DELIVERY_CONFIRM_DEC.
Configuration / Setup Steps:
1. Identify Delivery:
hi
○ Delivery Number needed (e.g., 80001234)
2. Custom Program:
○ Develop ABAP job to pick deliveries ready for PGI.
3. BAPI Call:
ris
○ Fill header and item confirmation structure.
4. Success Handling:
a
○ If success, show Material Document Number.
○ If error, log in Z-table for reprocessing.
ah
Outcome: PGI is posted automatically without manual VL02N work.
Business Requirement 3: Cancel Billing Document
M
If a wrong invoice is created, the system should cancel it
programmatically.
Solution using BAPI:
Use BAPI_BILLINGDOC_CANCEL.
Configuration / Setup Steps:
1. Input:
○ Billing Document Number (VBRK-VBELN)
2. BAPI Call:
○ Provide Billing Doc Number, Reason for Cancellation.
3. Handle Return:
○ Capture success/failure messages.
Outcome: Incorrect invoices canceled without using VF11 manually.
Technical & Configuration Points for BAPIs
Item Details
hi
Authorization User must have RFC / BAPI execution authorization
COMMIT
Error
Handling
a execution
ris
Some BAPIs need BAPI_TRANSACTION_COMMIT after
Always read RETURN parameter of BAPI
ah
Performance Bulk BAPI calls via background jobs if massive volume
Testing Use SE37 to test BAPIs manually
M
RFC Setup Required if external system is calling SAP BAPI
Extensions Use EXTENSIONIN parameter to pass custom fields
Summary Table
BAPI Use
BAPI_SALESORDER_CREATEFR Create Sales Order
OMDAT2
BAPI_SALESORDER_CHANGE Change Sales Order
hi
BAPI_OUTB_DELIVERY_CREAT Create Delivery
E_SLS
BAPI_OUTB_DELIVERY_CONFI
RM_DEC
BAPI_BILLINGDOC_CREATEFR
a ris
PGI Post for Delivery
Create Billing
OMDATA Document
ah
BAPI_BILLINGDOC_CANCEL Cancel Billing
Document
BAPI_CUSTOMER_CHANGEFROM Update Customer
M
DATA1