šŸ”„ EARLY BIRD SPECIAL:Save 10% on all SAP Online Courses! (Limited Slots)

Learn how to create custom BADI, BAPI, IDoc & Tables in SAP ABAP

E
ERPVITS Team
Author
2026-04-24
8 min read
Learn how to create custom BADI, BAPI, IDoc & Tables in SAP ABAP

How to Create Custom BADI, BAPI, IDoc, and Custom Table in SAP ABAP — Complete Guide

SAP ABAP (Advanced Business App Programming) can be described as the foundation to SAP development. It doesn't matter if you're a newbie trying to enter the SAP ecosystem or a veteran developer seeking to enhance your technical expertise, knowing how to build custom objects using SAP ABAP is vital. In this thorough guide, we'll walk users through how to create a custom BADIs within SAP ABAP and also how to design an individual Table, and how you can create a custom BAPI, as well as how to build an individual IDoc — all in one place.

The four foundations in SAP customisation are some of the commonly tested areas on SAP ABAP tests. Learning them will not only boost your actual SAP development capabilities but provide your professional with an edge over your competition.


What is SAP ABAP and Why Customization Matters

SAP ABAP is the SAP's exclusive programming language that is used to create and modify enterprise applications using the SAP NetWeaver platform. As companies grow and develop the traditional SAP functions often fall short of addressing unique requirements of the business. This is why customizing SAP is crucial.

Special objects within SAP ABAP allow developers to:

  • Extend the standard SAP behavior without changing the source code
  • Create bespoke functionality that is tailored to the business processes
  • Integrate SAP with third-party systems via standard interfaces
  • Make sure that your upgrade is compatible by utilizing the extension framework of SAP

With the foundation set now, let's dive into the steps for each kind of customization.


How to Create a Custom Table in SAP ABAP

The term "custom table" refers to a Custom table created in SAP ABAP will be an ABAP database table that is created using the ABAP Dictionary (SE11) to keep business-specific information that does not belong in a conventional SAP table. Knowing how to design an individual table in SAP ABAP is one of the most fundamental skills an ABAP developer needs to master.

Step-by-Step: How to Create Custom Table in SAP ABAP

Step 1: Open Transaction SE11

Log into your SAP system, and then navigate to the transaction code SE11 (ABAP Dictionary). Choose the "Database Table" radio button and type in the table's name (always make use of your table's Z or Y namespaces for customized objects e.g., ZEMPLOYEE_DATA).

Step 2: Enter Table Attributes

Select "Create" and then fill with the following information:

  • Short Description: Provide a meaningful description
  • Delivery Class: Pick A (Application Table) for master/transaction details
  • Data Browser/Table View: Set to "Display/Maintenance Allowed"

Step 3: Define Fields

Click on the "Fields" tab, and then create your table's fields:

Field Name Key Data Element Description
MANDT āœ… MANDT Client
EMPID āœ… ZEMPID Employee ID
EMPNAME ZEMPNAME Employee Name
DEPT ZDEPT Department

Always be sure to include the MANDT field as the primary key field for tables dependent on clients.

Step 4: Set the Technical Settings

Go to "Technical Settings" and configure:

  • Data Class: APPL0 (Master Data) or APPL1 (Transaction Data)
  • Size Classification: Based on expected volumes of data (0 is between 3,600 records; 5 = more than 10 million)
  • Buffering: Allow if your table is likely to be read frequently

Step 5: Activate the Table

Click the keys Ctrl and F3 and then click on the activate button (flame icon). When activated the physical table is built inside the database.

Step 6: Maintain Data via SM30

It is possible to maintain entries through the transaction SM30 (Table Maintenance Generator) or by using SE16 (Data Browser).

Tips for Success: Use the namespace Z/Y on all custom objects to ensure that there are no conflicts when performing SAP updates.

How to Create Custom BADI in SAP ABAP

The Business Add-In (BAdI) is an SAP enhancement technique that permits developers to add custom logic in the standard SAP applications without changing the code. Being able to know how to design a BADIs that are custom using SAP ABAP is a vital ability for any enhancement developer.

There are two kinds of BAdIs in SAP:

  • Traditional BAdI (used in earlier SAP systems, SE18/SE19)
  • Advanced/New BAdI (used in the latest SAP systems and based on the enhancement spots)

We will concentrate on the New BAdI method which is widely utilized for the SAP ECC 6.0 and S/4HANA.

Step-by-Step: How to Create Custom BADI in SAP ABAP

Step 1: Create an Enhancement Spot

Go to the transaction SE18 (BAdI Builder — Definition). Give a name to the BAdI term (e.g., ZBADI_EMPVALIDATION) and then click "Create."

Step 2: Define the BAdI Interface

On the BAdI definitions screen:

  • Enter a short text description
  • Click on the "Interface" tab
  • Indicate the name of the interface (e.g., ZIF_EMPVALIDATION)
  • Define the procedures of the interface that implementors can use to bypass

Example method:

METHODS: validate_employee
  IMPORTING
    iv_empid   TYPE zempid
  EXPORTING
    ev_valid   TYPE abap_bool.

Step 3: Activate the BAdI Definition

Save and activate the BAdI definition. This will create an interface within the system that developers can use in the future.

Step 4: Create a BAdI Implementation

Go to the transaction SE19 (BAdI Builder — Implementation):

  • Enter a new implementation name (e.g., ZBADI_EMPVALIDATION_IMPL)
  • Use the BAdI definition that you have created
  • Click "Create"

Step 5: Write the Implementation Code

In the class implementing it (automatically made), go to the method, and then add your ABAP logic:

METHOD zif_empvalidation~validate_employee.
  SELECT SINGLE empid FROM zemployee_data
    INTO @DATA(lv_id)
    WHERE empid = @iv_empid.
  IF sy-subrc = 0.
    ev_valid = abap_true.
  ELSE.
    ev_valid = abap_false.
  ENDIF.
ENDMETHOD.

Step 6: Call the BAdI in Your Program

Utilize the BAdI in every ABAP application by calling its interface using the GET BADI as well as the CALL BADI statements:

DATA: lo_badi TYPE REF TO ZBADI_EMPVALIDATION.
GET BADI lo_badi.
CALL BADI lo_badi->validate_employee
  EXPORTING iv_empid = lv_empid
  IMPORTING ev_valid = lv_valid.
Career Insights: BAdI expertise is among the most sought-after competencies for SAP ABAP interviewing, specifically for positions in SAP Enhancement and Upgrade projects.

How to Create Custom BAPI in SAP ABAP

A Business API (BAPI) is a standard programming interface that allows other systems as well as internal ABAP programs to interact with SAP enterprise objects in a structured and controlled method. Knowing how to build custom BAPIs in SAP ABAP is crucial to integrate workflows and develop workflow.

Custom BAPIs are designed in the form of function modules that are classified under the BAPI function category.

Step-by-Step: How to Create Custom BAPI in SAP ABAP

Step 1: Open SE37 (Function Builder)

Go to transaction SE37 and enter a name for your function module (e.g., ZBAPI_CREATE_EMPLOYEE). Click "Create."

Step 2: Set Function Group and Attributes

  • Function Groups: Create or use an existing Z function group (e.g., ZEMP_FG)
  • Short Text: Provide a clear description
  • Processing Type: Change to "Remote-Enabled Module (RFC)" — this is mandatory for BAPIs

Step 3: Define Parameters

Click on the "Import," "Export," and "Tables" tabs:

Parameter Type Description
IS_EMP_DATA Import (Structure) Information about inputs from employees
EV_EMP_ID Export The new Employee ID was created
ET_RETURN Tables Standard BAPIRET2 return table

Always follow an industry standard BAPIRET2 structure for the return table. This is a standard SAP convention for all BAPIs.

Step 4: Write the BAPI Logic

FUNCTION ZBAPI_CREATE_EMPLOYEE.
*"--- Importing / Exporting / Tables defined above ---

  DATA: ls_employee TYPE zemployee_data.

  " Validate input
  IF is_emp_data-empname IS INITIAL.
    APPEND VALUE #( type = 'E' message = 'Employee name is required' )
      TO et_return.
    RETURN.
  ENDIF.

  " Create record
  MOVE-CORRESPONDING is_emp_data TO ls_employee.
  ls_employee-empid = '1001'. " Auto-generate in real scenarios

  INSERT INTO zemployee_data VALUES ls_employee.
  IF sy-subrc = 0.
    COMMIT WORK.
    ev_emp_id = ls_employee-empid.
    APPEND VALUE #( type = 'S' message = 'Employee created successfully' )
      TO et_return.
  ENDIF.

ENDFUNCTION.

Step 5: Test in SE37

Utilize the "Test/Execute" (F8) choice in SE37 to verify your BAPI using tests before installing it.

Step 6: Register the BAPI (Optional)

To create your custom BAPI on the Business Object Repository (BOR), go to the transaction SWO1 and then link your function to an enterprise object. This step is only for internal use, but recommended for official integration.

Notice: Always include error handling through using the BAPIRET2 return table. Do not employ MESSAGE statements within BAPIs as they interfere with an RFC call.

How to Create Custom IDoc in SAP ABAP

The Intermediate Document (IDoc) is SAP's standard data container to facilitate an asynchronous exchange of messages between SAP and other systems (or among two SAP systems). Knowing how to make a custom IDoc using SAP ABAP is essential to integrating EDI/ALE projects.

An IDoc is composed of three fundamental elements:

  • Control Record: Sender/Receiver header with information about the type of message
  • Data Records: Segments that contain the real business information
  • Status Records: Processing status information

Step-by-Step: How to Create Custom IDoc in SAP ABAP

Step 1: Create a Custom Segment

Enter transaction WE31 (IDoc Segment Editor):

  • Enter a name for the segment (e.g., ZEMPLOYEE_SEG) and then click "Create"
  • Include fields in the segment that represents your data structure

Example segment fields:

Field Data Element Description
EMPID ZEMPID Employee ID
EMPNAME ZEMPNAME Employee Name
DEPT ZDEPT Department

Save and then activate the segment.

Step 2: Create the IDoc Type (Basic Type)

Go to the transaction WE30 (IDoc Type Development):

  • Enter the IDoc name of the type (e.g., ZEMP_IDOC01) and click "Create"
  • Choose "Create New Basic Type"
  • Create your own segment (ZEMPLOYEE_SEG) to the IDoc structure by right-clicking the root node

Define whether the segment is obligatory and what its minimum/maximum number of instances and its hierarchy.

Step 3: Create a Message Type

Go to the transaction WE81 (IDoc Message Types) and create an individual messaging type (e.g., ZEMPLMSG). This is the logical title used to identify routing.

Step 4: Link IDoc Type to Message Type

Go to the transaction WE82 and create an assignment:

  • Message Type: ZEMPLMSG
  • Basic Type: ZEMP_IDOC01

Step 5: Create an Inbound/Outbound Function Module

For outbound IDocs, create a function module that populates the IDoc data records and calls MASTER_IDOC_DISTRIBUTE.

To process Inbound IDocs you must create an application module that includes an SAP-specific signature for the IDoc inbound processing framework.

FUNCTION ZIDOC_INBOUND_EMPLOYEE.
*"--- Importing: INPUT_METHOD, MASS_PROCESSING ---
*"--- Tables: IDOC_CONTRL, IDOC_DATA, IDOC_STATUS ---

  DATA: ls_data    TYPE edidd,
        ls_emp     TYPE zemployee_data.

  LOOP AT idoc_data INTO ls_data
    WHERE segnam = 'ZEMPLOYEE_SEG'.
    ls_emp-empid   = ls_data-sdata+0(10).
    ls_emp-empname = ls_data-sdata+10(40).
    ls_emp-dept    = ls_data-sdata+50(20).
    INSERT INTO zemployee_data VALUES ls_emp.
  ENDLOOP.

  IF sy-subrc = 0.
    APPEND VALUE #( docnum = idoc_contrl[ 1 ]-docnum
                    status = '53'
                    statxt = 'IDoc posted successfully' )
      TO idoc_status.
  ENDIF.

ENDFUNCTION.

Step 6: Configure Partner Profiles

Navigate to the transaction WE20 (Partner Profiles) and create:

  • Partner Number (the sender/receiving system's logical name)
  • Outbound and Inbound Parameters connecting the type of message and function module
  • Port settings within WE21

Step 7: Test Using WE19

Utilize transaction WE19 (IDoc Test Tool) to create a test IDoc and test outbound and inbound processing.

Career Insights: IDoc knowledge is highly sought after for SAP integration positions. Developers who have practical IDoc expertise command substantially higher wages in the ERP integration as well as EDI market for consulting.

Best Practices for SAP ABAP Customization

No matter if you're working with customized tables, BAdIs or BAPIs or IDocs, these guidelines will ensure that your development is robust as well as maintainable. They will also ensure that your upgrades are safe:

  1. Always use the Z/Y namespace — All custom objects need to be prefixed by Z or Y in order to keep them from conflicting with SAP standard objects during system upgrade.
  2. Be consistent with Naming Conventions — Use an appropriate, consistent name such as ZBAPI_, ZBADI_, ZIDOC_, ZT_ for tables. This increases understanding and collaboration among teams.
  3. Document Your Code — Write comments inline and create functional specifications for each custom object. The next developers (and your own future self) will appreciate it.
  4. Use Enhancement Spots instead of Modifications — Never alter the standard SAP codes directly. Make use of BAdIs, User exits, enhancement spots, or customer exits to enhance capabilities.
  5. Always handle errors gracefully — Utilize structured return messages (BAPIRET2 for BAPIs and status records for IDocs). Beware of making use of the MESSAGE statements in function modules.
  6. Test in Development Before Transport — Always thoroughly unit-test in DEV prior to transporting items to QAS and PRD through transport requests (SE01/SE09).
  7. Use Data Security Guidelines — Custom tables and BAPIs must comply with SAP authorization objects. Include authority-checking statements whenever sensitive data is accessed.

Career Tips for SAP ABAP Developers

SAP ABAP remains one of the most sought-after ERP abilities in the world. Here's how you can make use of your knowledge about customization for professional advancement:

  • Create a Portfolio of real SAP objects — Practical experience with BAdIs, BAPIs, IDocs as well as custom table designs is superior to theoretical understanding. Make sure you document your implementations and projects.
  • Pursue SAP Certifications — The SAP Certified Development Associate — ABAP with SAP NetWeaver certificate confirms your expertise and is accepted by employers across the globe.
  • Learn about S/4HANA ABAP — The modern SAP design is moving into S/4HANA, and CDS (Core Data Services) views. Combine your classic ABAP knowledge with your S/4HANA expertise to stay current.
  • Join Forums — Platforms such as the SAP Community Network (SCN) encourage active contributors. Answering questions regarding BADI, BAPI, and IDoc creation can help build your professional credibility.
  • Target Integration Roles — Developers who have strong IDoc and BAPI experience are highly sought-after to work on SAP integration roles, EDI consultation, and SAP middleware projects, each of which offers premium pay.

Conclusion

Learning how to create a custom BADIs using SAP ABAP, how to create a custom table using SAP ABAP, how to design a custom BAPIs within SAP ABAP, as well as how to create a custom IDoc within SAP ABAP are fundamental abilities that can lead to an array of SAP career opportunities in development and consulting.

Each of these techniques for customization serves a distinct function: custom tables are used to store specific business information, BAdIs allow for the extension of standard programs without modifications, BAPIs offer the business with a structured API interface to objects, IDocs allow the exchange of data in a timely manner. Together, they make up the basis of almost all SAP Implementation projects.

If you're just beginning on your SAP ABAP experience or are looking to advance into a senior development or SAP architect position, spending time in these four areas will yield substantial dividends. Begin with hands-on training using a SAP sandbox system and then document your experience and work towards certification.


Frequently Asked Questions (FAQs)

Q1: What's the distinction between BADI and User Exit within SAP ABAP?

A User Exit is an older SAP enhancement technique that is limited in its flexibilities, whereas a BAdI has more of an object-centric approach and can be used with multiple active implementations and is the preferred method for the current SAP development.

Q2: Can I make a BAPI without RFC?

No. All BAPIs have to be RFC-enabled (Remote Function Modules) since they are intended for remote access by other systems or external SAP components.

Q3: What's the most number of sections that can be contained in an individual IDoc?

There is no set limit, however best practices in terms of performance and maintenance recommend maintaining IDoc structures as simple and flat as possible. Hierarchies with complex structures should be divided into several IDocs as soon as feasible.

Q4: How can I move Custom ABAP objects to Production?

Use SAP Workbench Requests (transaction SE09/SE10) to generate transport requests. Always transport DEV → QAS → PRD, and never perform direct changes to Production.

Q5: Is SAP ABAP still useful in 2026 and even after?

Absolutely. As SAP S/4HANA adoption is growing across the globe, ABAP developers who also are aware of CDS views, RAP (Restful ABAP Programming Model) and OData Services are amongst the most sought-after experts in the field of enterprise software.

Ready to advance your SAP ABAP career? Explore our comprehensive SAP ABAP training courses and certification prep programs designed to help you land your next role in one of the world's most in-demand technology ecosystems.

Request More Info

Get expert guidance on your SAP career path.

0 + 0 = ?

By submitting, you agree to our privacy policy.