In many SAP implementations, automating the creation of standard business documents like sales inquiries is essential for streamlining processes and integrating with external systems. Instead of manually using transactions like VA11 to create inquiries, leveraging BAPIs provides a programmatic approach that can be incorporated into

  1. Custom ABAP programs
  2. Third-party interfaces
  3. Automated workflows.

By identifying and understanding the correct BAPI, reading its documentation thoroughly, and following the necessary steps learn how Creating Customer Inquiry using BAPI—saves time, reducing errors, and improving integration with other business tools.

What is BAPI?

A BAPI (Business Application Programming Interface) is a standardized, stable, and language-independent programming interface that provides external access to SAP business objects and processes.

BAPIs are defined and stored in the SAP Business Object Repository, ensuring they adhere to uniform standards and naming conventions. By using BAPIs, one can create, read, update, or delete data within SAP modules—such as

  • Sales and Distribution
  • Materials Management
  • Finance

Creating Customer Inquiry using BAPI

Before creating any BAPI-based solution in SAP, it’s essential to:

  1. Identify the correct BAPI for your business requirement.
  2. Read the BAPI’s documentation to understand its functionality, required parameters, and constraints.

In this example, we’ll demonstrate how to create a customer inquiry using a relevant BAPI. Traditionally, you might create a customer inquiry using transaction code VA11. However, by leveraging a BAPI, you can integrate this process into custom programs or external systems.


Transaction Code to Find BAPIs

T-Code: BAPI
Use this transaction to open the BAPI explorer, where you can browse various BAPIs available in the SAP system.

Example: If you want to create a customer inquiry, you should look for a BAPI related to SD (Sales and Distribution) inquiries.

Tip: Always use the latest BAPI method. The highest version number at the end of a BAPI name generally indicates the most recent one.

Opening BAPI Explorer

Identifying the Correct BAPI

To find suitable BAPIs for creating a customer inquiry:

  1. Go to Transaction Code: SE84 (Repository Information System).
  2. Navigate to: Program Library → Function Modules.
  3. Enter a search pattern such as *bapi* for the Function Module and SD* for the Application Package. This filters out BAPIs related to SD.
  4. Execute the search. You will see a list of available BAPIs.
Searching BAPIs in SE84

A list of SD-related BAPIs will be displayed:

List of SD BAPIs

Selecting the BAPI for Customer Inquiry

For creating a customer inquiry, we can use the BAPI:
BAPI_INQUIRY_CREATEFROMDATA2

This BAPI lets you provide header, item, and partner data to create the inquiry. It’s important to review the BAPI documentation before use.

BAPI Inquiry Method

When you open the BAPI, read the provided documentation. It will explain the mandatory parameters and how to structure the input data (header, items, partners), as well as how to handle configuration if needed.


Reading the BAPI Documentation

The documentation typically specifies:

  • Required Input Parameters
    • INQUIRY_HEADER_IN: For header data such as document type, sales organization, distribution channel, and division.
    • INQUIRY_PARTNERS: For partner data, such as sold-to party (SP) and ship-to party.
    • INQUIRY_ITEMS_IN: For item-level details such as material and quantity.
  • Processing Notes:
    • If you do not explicitly provide a ship-to party, the sold-to party will be used as the ship-to party.
    • The BAPI does not automatically commit the changes; you must call BAPI_TRANSACTION_COMMIT after a successful BAPI call.
BAPI Documentation

Steps to Use the BAPI in Your Program

Step 1: Identify the BAPI

We have identified BAPI_INQUIRY_CREATEFROMDATA2 as the correct BAPI for creating customer inquiries.

Step 2: Review the BAPI Structure (SE37)

  1. Go to Transaction Code: SE37.
  2. Enter BAPI_INQUIRY_CREATEFROMDATA2 and display the function module.
  3. Review the import, export, and table parameters to understand what data needs to be passed.
BAPI Structure in SE37

Step 3: Define Input Parameters in Your ABAP Program

In your ABAP code, define variables and internal tables corresponding to the BAPI parameters:

DATA: ls_inquiry_header_data TYPE BAPISDHD1,
      lt_inquiry_item_data   TYPE TABLE OF BAPISDITM,
      lt_partner_data        TYPE TABLE OF BAPIPARNR.

"Set header data
ls_inquiry_header_data-doc_type   = 'IN'.      " Inquiry document type
ls_inquiry_header_data-sales_org  = '1000'.    " Sales Organization
ls_inquiry_header_data-distr_chan = '10'.      " Distribution Channel
ls_inquiry_header_data-division   = '00'.      " Division

"Add item data to lt_inquiry_item_data and partner data to lt_partner_data as required

Step 4: Call the BAPI

Call the BAPI with the populated parameters:

CALL FUNCTION 'BAPI_INQUIRY_CREATEFROMDATA2'
  EXPORTING
    inquiry_header_in = ls_inquiry_header_data
  TABLES
    inquiry_items_in  = lt_inquiry_item_data
    inquiry_partners  = lt_partner_data
    return            = lt_return.

Check the return table for any errors or messages.


Step 5: Check for Errors

If any errors occurred, they will be populated in the return parameter:

READ TABLE lt_return WITH KEY type = 'E'.
IF sy-subrc = 0.
  WRITE: / 'Error creating inquiry:', lt_return-message.
  EXIT.
ENDIF.

If no errors are found, proceed.


Step 6: Commit the Transaction

The BAPI itself does not perform a database commit, so you need to call BAPI_TRANSACTION_COMMIT if everything is successful:

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
  EXPORTING
    wait = 'X'.

This ensures the inquiry is saved in the system.


Conclusion

By following these steps, you can successfully create a customer inquiry in SAP using the BAPI_INQUIRY_CREATEFROMDATA2 method. Always begin by identifying the right BAPI and reviewing its documentation carefully. Then, incorporate the BAPI into your ABAP program, pass the required parameters, handle any errors, and commit the transaction.

This approach provides a flexible and programmatic way to create inquiries—perfect for integration scenarios, data uploads, or custom enhancements in your SAP landscape.

Remember:

  • Use the latest BAPI version available.
  • Thoroughly read the documentation for required parameters and special conditions.
  • Always commit after a successful BAPI call.

Additional Note:
This tutorial presumes familiarity with ABAP coding, basic SAP SD concepts, and navigating standard SAP transactions. If you’re new to ABAP or SAP SD, consider reviewing SAP’s official documentation or working with an experienced consultant to ensure proper configuration and data handling.