ERPClimb logoERPClimb
BAPI
ABAP Developmentbeginner 8 min read

BAPI Part 1: What a BAPI Is and How to Find One

Free sample lesson · open to everyone

Key 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 this lessonShow sections

Visual overview

BAPI Part 1: What a BAPI Is and How to Find One — learning sheetFlow: Run transaction BAPI → Sales and Distribution → Sales Order → CreateFromDat2; read the documentation → SE37: display BAPI_SALESORDER_CREATEFROMDAT2 and its parameters → Test it in SE37 (test sequence with BAPI_TRANSACTION_COMMIT) in a test system. Key ideas: WHY BAPIS; CHARACTERISTICS; FINDING A BAPI; COMMON EXAMPLES. Watch out: A document number returned by a BAPI does not prove success — only a RETURN without errors plus a successful commit does.ERPClimb.com / ABAP / LESSON 1/10 / LEARNING SHEETBAPI Part 1: What a BAPI Is and How to Find One1 · HOW IT FLOWS1Run transaction BAPI →Sales and Distribution →Sales Order →…2SE37displayBAPI_SALESORDER_CREATEFROMDAT2 and…3Test it in SE37 (testsequence withBAPI_TRANSACTION_COMMIT)…2 · KEY IDEAS EXPLAINEDWhy BAPIsWhen a program must create or change SAP businessdocuments (sales orders, goods movements, FIpostings), it should not write SAP tables directly…CharacteristicsReleased and stable: SAP keeps the interfacecompatible across releases.RFC-enabled: callable locally and from externalsystems.Finding A BAPITransaction BAPI: hierarchy by applicationcomponent → business object → methods, withdocumentation and the FM name.SE37: search BAPI_*SALESORDER* and read the FMdocumentation.Common ExamplesBAPI_SALESORDER_CREATEFROMDAT2 /BAPI_SALESORDER_CHANGEBAPI_PO_CREATE1 / BAPI_PO_CHANGE3 · REMEMBER · WATCH OUTRememberA BAPI (Business Application Programming Interface) is a releasedmethod of a business object (e.g. SalesOrder.CreateFromDat2)…BAPIs report errors in a RETURN parameter (BAPIRET2) instead of dialogmessages, and most do not commit — the caller does…Find BAPIs with transaction BAPI (BAPI Explorer), SE37 (BAPI_*), SWO1(Business Object Builder).!Watch outA document number returned by a BAPIdoes not prove success — only aRETURN without errors plus asuccessful commit does.4 · IN A REAL PROJECTAn interface team initially created sales orders by recording VA01 with BDC. After a support package added afield to the screen, the recording failed for a whole night's orders. They switched toBAPI_SALESORDER_CREATEFROMDAT2: the same business checks ran, errors came back as readable RETURN messages…Original ERPClimb learning sheet • Verify against your SAP release and edition

Expert visual walkthrough

ABAP DEVELOPMENT ACADEMY · Integration pathERPClimb.com

What a BAPI Is and How to Find One

BAPI · Chapter-specific technical teaching map

Integration path

1Concept

Business Object / BAPI

2Concept

SE37 signature

3Concept

Input mapping

4Concept

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…

Conceptual study map, not an SAP configuration screenshot or a guaranteed runtime sequence. Consult the lesson for implementation prerequisites and exceptions.

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

ABAP Code
* ===== 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?

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

Referenced SAP objects

Reviewed reference pages for the objects this page mentions.

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.