BAPI Part 2: Calling a BAPI — Inputs, X Structures, RETURN and Commit
Preview · a free account unlocks the full lesson
Call BAPI SALESORDER CREATEFROMDAT2 step by step: fill header, item, partner and schedule structures, set the corresponding X (change flag) structures, use internal formats, evaluate RETURN, then commit with wait or roll back.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Part 1 explained what BAPIs are in general. Now we call one of the most heavily used ones in practice: creating a sales order with BAPI_SALESORDER_CREATEFROMDAT2.
Its parameters break down by area. ORDER_HEADER_IN, of type BAPISDHD1, carries fields like DOC_TYPE, SALES_ORG, DISTR_CHAN, DIVISION and PURCH_NO_C. ORDER_HEADER_INX, of type BAPISDHD1X, mirrors those same fields as flags and also carries UPDATEFLAG = 'I'. ORDER_ITEMS_IN and ORDER_ITEMS_INX carry ITM_NUMBER, MATERIAL and TARGET_QTY, among others. ORDER_PARTNERS carries PARTN_ROLE — 'AG' for sold-to, 'WE' for ship-to — together with PARTN_NUMB. ORDER_SCHEDULES_IN and _INX carry ITM_NUMBER, SCHED_LINE and REQ_QTY. RETURN carries the resulting messages, and SALESDOCUMENT returns the new document number.
The X structures exist to tell the BAPI exactly which fields you are actually passing — this matters especially in change BAPIs, where a field left initial means "don't change this," rather than "set this to blank." The rule is simple: every field you fill gets a corresponding 'X' in the X structure, and key fields such as ITM_NUMBER are repeated there as well.
Fill the data structures (…_IN) and, where the BAPI has them, the matching X structures (…_INX) with 'X' for every field you supply. Forgetting an X flag means the BAPI ignores the value — no error is raised, the data is just silently missing from the result.
Create a free account to keep reading
You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.
- Full explanation
- Code example
- Real project scenario
- Common mistakes
- Best practices
- Interview angle
One tap with Google works too. Every topic keeps its first lesson open to everyone.
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
- CONVERSION_EXIT_ALPHA_INPUTALPHA Conversion Exit for Numeric Key Fields
- CONVERSION_EXIT_CUNIT_INPUTConvert External Commercial Unit to Internal SAP Unit
- BAPI_TRANSACTION_ROLLBACKBAPI_TRANSACTION_ROLLBACK Rollback Logic and Pitfalls
- 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.