BAPI Part 1: What a BAPI Is and How to Find One
Free sample lesson · open to everyone
Understand BAPIs: business object methods in the Business Object Repository, implemented as RFC-enabled function modules, with a stable interface, RETURN messages and caller-controlled commit — and how to find the right BAPI with transaction BAPI, SE37 and SWO1.
In this lessonShow sectionsHide sections
Visual overview
Expert visual walkthrough
What a BAPI Is and How to Find One
BAPI · Chapter-specific technical teaching map
Integration path
Business Object / BAPI
SE37 signature
Input mapping
Return
Tutor's chapter takeaway
Understand BAPIs: business object methods in the Business Object Repository, implemented as RFC-enabled function modules, with a stable interface, RETURN messages and caller-controlled commit — and how to find the right BAPI with transaction BAPI, SE37 and SWO1.
In a real project
An interface team initially created sales orders by recording VA01 with BDC. After a support package added a field to the screen, the recording failed for a whole night's orders. They switched to…
Watch out for
• Writing directly to SAP tables instead of using a BAPI. • Using BDC when a BAPI exists. • Treating a returned document number as success without checking RETURN. • Forgetting BAPI_TRANSACTION_COMMIT. • Using unreleased…
The situation: a real project scenario
An interface team initially created sales orders by recording VA01 with BDC. After a support package added a field to the screen, the recording failed for a whole night's orders.
They switched to BAPI_SALESORDER_CREATEFROMDAT2: the same business checks ran, errors came back as readable RETURN messages instead of screen errors, and screen changes no longer affected the interface.
Explanation
A BAPI, short for Business Application Programming Interface, is a released method of a business object — for example SalesOrder.CreateFromDat2 — implemented underneath as an RFC-enabled function module such as BAPI_SALESORDER_CREATEFROMDAT2.
Instead of raising dialog messages, BAPIs report success or failure through a RETURN parameter of type BAPIRET2, and most of them deliberately do not commit the database change themselves — that responsibility belongs to the caller, via BAPI_TRANSACTION_COMMIT.
You can find BAPIs through transaction BAPI (the BAPI Explorer), by searching BAPI_* in SE37, or by browsing business objects in SWO1 (the Business Object Builder).
One point worth internalizing early: a document number coming back from a BAPI call does not by itself prove success — only a RETURN table with no error messages, combined with a successful commit, counts as proof.
This series covers BAPIs in ten parts: this lesson on what a BAPI is and how to find one; Part 2 on calling a BAPI, including inputs, the X structures, RETURN, and commit; Part 3 comparing BAPI, RFC, and OData; Part 4 on understanding RETURN messages in depth; Part 5 on commit, wait, rollback, and the SAP LUW; Part 6 on mapping header, item, partner, and schedule data; Part 7 on test runs and simulation; Part 8 on EXTENSIONIN for custom fields; Part 9 on uploads, idempotency, and safe retry; and Part 10 on debugging the "success but no document" scenario.
BAPIs exist because when a program needs to create or change SAP business documents — sales orders, goods movements, FI postings — it shouldn't write SAP tables directly, nor should it fall back to screen-recording (BDC) if a BAPI already covers the case. A BAPI runs the exact same business logic as the corresponding transaction — the same checks, determinations, and updates — but exposes it through a stable, documented interface instead of a screen.
Several characteristics define a BAPI: it's released and stable, meaning SAP commits to keeping the interface compatible across releases; it's RFC-enabled, so it can be called locally or from an external system; it has no dialog at all, with no screens or popups, only messages returned in RETURN; and for most BAPIs, transaction control sits with the caller, who must explicitly call BAPI_TRANSACTION_COMMIT or BAPI_TRANSACTION_ROLLBACK. Naming follows a consistent pattern too: BAPI_<object>_<method>, with structures prefixed BAPI... and change flags carried in corresponding ...X structures.
To find a BAPI, transaction BAPI organizes them hierarchically by application component, then business object, then method, and includes documentation along with the underlying function module's name. In SE37 you can search for something like BAPI_*SALESORDER* and read the function module's documentation directly. In SWO1 you can look up a business object — BUS2032 for a sales order, for instance — and see which of its methods are marked as API. Whichever route you take, check the release status and documentation before relying on a BAPI.
Some BAPIs you'll meet often include BAPI_SALESORDER_CREATEFROMDAT2 and BAPI_SALESORDER_CHANGE, BAPI_PO_CREATE1 and BAPI_PO_CHANGE, BAPI_GOODSMVT_CREATE, BAPI_ACC_DOCUMENT_POST (paired with BAPI_ACC_DOCUMENT_CHECK for validation), and BAPI_MATERIAL_SAVEDATA.
When it comes to choosing an approach, direct INSERT or UPDATE statements against SAP tables should never be used, since they bypass checks, locks, and change documents entirely. BDC, meaning CALL TRANSACTION with a recorded screen sequence, should only be a fallback when no BAPI exists, and it's fragile whenever the underlying screens change. A BAPI is the preferred choice for programs and interfaces whenever one is available.
To practice: run transaction BAPI and navigate to Sales and Distribution → Sales Order → CreateFromDat2, reading its documentation; display BAPI_SALESORDER_CREATEFROMDAT2 and its parameters in SE37; and test it there, including a test sequence with BAPI_TRANSACTION_COMMIT, in a test system. With this you should be able to explain what a BAPI is, find one, and explain why it's generally the preferred approach.
Code example
* ===== Minimal BAPI call pattern (classic syntax) =====REPORT zbapi_basics. DATA: lt_return TYPE STANDARD TABLE OF bapiret2, " BAPIRET2 is the standard message structure almost every BAPI returns ls_return TYPE bapiret2, lv_error TYPE abap_bool. START-OF-SELECTION.* 1) Call the BAPI (parameters depend on the BAPI - see its documentation)* CALL FUNCTION 'BAPI_...'* EXPORTING ...* IMPORTING ...* TABLES return = lt_return. * 2) Evaluate RETURN - errors are types E and A LOOP AT lt_return INTO ls_return WHERE type = 'E' OR type = 'A'. lv_error = abap_true. WRITE: / ls_return-type, ls_return-id, ls_return-number, ls_return-message. ENDLOOP. * 3) Caller controls the transaction IF lv_error = abap_true. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. " BAPIs never commit themselves - caller must undo on error ELSE. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. " wait for the update to finish ENDIF. * ===== Finding BAPIs =====* Transaction BAPI : BAPI Explorer (component -> object -> method -> FM)* SE37 : BAPI_* + documentation* SWO1 : business object, e.g. BUS2032 (sales order)Watch out
Common mistakes
- Writing directly to SAP tables instead of using a BAPI.
- Using BDC when a BAPI exists.
- Treating a returned document number as success without checking RETURN.
- Forgetting BAPI_TRANSACTION_COMMIT.
- Using unreleased internal FMs instead of the documented BAPI.
Do this
Best practices
- Search BAPI Explorer first for any create/change requirement.
- Read the BAPI documentation and mandatory fields.
- Always evaluate RETURN.
- Commit or roll back explicitly.
- Test in SE37 test sequences before coding.
In the interview
Interview angle
Questions: "What is a BAPI?", "How do you find a BAPI?", "BAPI vs BDC?"
Strong answer: released method of a business object in the BOR, implemented as RFC-enabled FM, no dialog, messages in RETURN (BAPIRET2), caller commits with BAPI_TRANSACTION_COMMIT; find via transaction BAPI, SE37, SWO1; preferred over BDC (fragile) and direct table updates (bypass checks).
Practice this lesson
Quick check
0 of 3 questions attempted
Question 1 of 3
Why should a program use a BAPI instead of updating VBAK/VBAP directly?
Question 2 of 3
What is the primary purpose of the BAPI Explorer tool in the SAP GUI?
Question 3 of 3
What does BAPI stand for?
Practise this in an interview
Answer in your own words and get instant feedback, the way an interviewer would judge it.
1What is a BAPI in SAP ABAP?
2A legacy upload updated sales order tables (VBAK/VBAP) directly and produced inconsistent documents. What is wrong with this approach and what would you use instead?
Try a related Code Lab
This published exercise covers the same SAP topic. Apply the ideas in a hands-on scenario, then return to review your answers.
Open: BAPI Success Ignored Because RETURN Was Not Checked →See it in code
Each example starts from a requirement, shows the design, then the code step by step with a plain-language explanation of every part.
Was this lesson helpful?
Keep exploring
Interview questions on this topic
Related SAP topics
Referenced SAP objects
Reviewed reference pages for the objects this page mentions.
- BAPI_SALESORDER_CREATEFROMDAT2Create a Sales Order
- SWO1Business Object Builder
- SE37Function Builder for testing and building function modules
- VA01Create Sales Order
- BAPI_SALESORDER_CHANGEBAPI for Changing an Existing Sales Order
- BAPI_ACC_DOCUMENT_POSTGeneric Accounting Document Posting BAPI
- BAPI_PO_CREATE1BAPI_PO_CREATE1 Purchase Order Creation
- BAPI_TRANSACTION_ROLLBACKBAPI_TRANSACTION_ROLLBACK Rollback Logic and Pitfalls
- BAPI_ACC_DOCUMENT_CHECKBAPI_ACC_DOCUMENT_CHECK Validation Without Posting
- BAPI_MATERIAL_SAVEDATACreate or change a material master record
- BAPI_PO_CHANGEBAPI to Change an Existing Purchase Order
- BAPI_GOODSMVT_CREATEBAPI_GOODSMVT_CREATE Goods Movement Posting
- BAPI_TRANSACTION_COMMITCommit BAPI for Closing a BAPI LUW
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.