SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
โคข Open full site

Implement a Business Add-in (`BAdI`) To Check a Purchase Requisition

Define and implement a developer extension (`BAdI`), which performs checks during creation of a purchase requisition item.

Overview

🎓 intermediate 30 min. SAP S 4hana Cloud ABAP EnvironmentIntermediateABAP DevelopmentSAP Business Technology PlatformSAP BTP ABAP EnvironmentABAP Extensibility

You will learn

  • โœ”How to log on to SAP S/4HANA Cloud ABAP Environment
  • โœ”How to create an ABAP package
  • โœ”How to find relevant existing BAdI enhancement spots for your line of business, in this case Materials-Management-Purchasing
  • โœ”How to implement a BAdI that checks for the field quantity and delivery date during creation of purchase requisition item
Julie Plummer J Julie Plummer July 2, 2025
Created by March 9, 2023
Contributors

Prerequisites

Prerequisites

  • You have a license for SAP S/4HANA Cloud and have a developer user in this system
  • You have installed SAP ABAP Development Tools (ADT), latest version, and have created an ABAP Cloud project for your SAP S/4HANA Cloud System in it
  • You are familiar with the concept of extensions to the SAP standard and with BAdIs in particular. If not, see the More Information section at the end of this tutorial
  • To test the BAdI: In SAP Fiori launchpad, you have the authorization for the app Process Purchase Requisitions - Professional, i.e. SAP_BR_PURCHASER

Steps

Intro

The administrator receives an welcome e-mail after provisioning. This e-mail includes the system URL. By removing /ui you can log into the SAP S/4HANA Cloud ABAP Environment system. Further information can be found Developer Extensibility: Connect to the ABAP System.

A Business Add-In (BAdI) an object-oriented enhancement option, a hook for an object plug-in. It enables you to implement enhancements to standard SAP applications without modifying the original code.

In these tutorials, SAP has already defined the BAdI enhancement spot, MM_PUR_S4_PR for the Fiori App Manage Purchase Requisitions โ€“ Professional, and the BAdI definition, MM_PUR_S4_PR_CHECK.

You then implement the BAdI in the SAP Fiori app as follows: 1. For the BAdI definition MM_PUR_S4_PR_CHECK, you create a container, known as an enhancement implementation - here ZEI_BADI_CHECK_PURCH_REQ_000. 2. You can then create one or more BAdI implementations - here ZIMP_CHECK_PURCH_REQ_000. 3. For each BAdI implementation you create an ABAP Class - here ZCL_CHECK_PURCH_REQ_000. 4. Within this class, you then create a method of the BAdI- here MM_PUR_S4_PR_CHECK~check.

step0-badi-enhancement-creation-process-v2
step0-badi-enhancement-creation-process-v2

The advantage of this approach is that you can group several related BAdI implementations in one enhancement implementation.

step0-several-zimps
step0-several-zimps

At runtime:

  1. The user creates a purchase requisition.
  2. The enhancement checks:
    • the quantity of items ordered is 10 or fewer
    • the date is 180 days or fewer in advance
  3. If not, the application returns an error.

The application will look roughly like this:

step0-app-overview
step0-app-overview

step0-app-w-badi
step0-app-w-badi

Throughout this tutorial, objects name include a suffix, such as 000. Always replace this with your group number or initials.


Step 1 Log on to SAP S/4HANA Cloud ABAP Environment
โ€”

  1. Open ADT, select File > New > Other.

    logon
    logon

  2. Search ABAP Cloud Project, select it and choose Next >.

    logon
    logon

  3. Select SAP S/4HANA Cloud ABAP Environment, enter the ABAP service instance URL and choose Next.

    logon
    logon

  4. To log on, choose Open Logon Page in Browser, then choose Next. (Alternatively, e.g. if you have an admin user and a developer user in the SAP BTP Cloud landscape, you may need to choose Copy Logon URL… .)

    logon
    logon

    logon
    logon

  5. Check your ABAP service instance connection and choose Finish.

    logon
    logon

Your project is available in the Project Explorer.

logon
logon

Step 2 Create package
+
Step 3 Choose enhancement spot
+
Step 4 Create enhancement implementation
+
Step 5 Add `BAdI` implementation
+
Step 6 Create implementing class
+
Step 7 Implement code
+
Step 8 Test `BAdI`
+
Step 9 Test yourself
+
Step 10 More information
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 10
1. Log on to SAP S/4HANA Cloud ABAP Environment 2. Create package 3. Choose enhancement spot 4. Create enhancement implementation 5. Add `BAdI` implementation 6. Create implementing class 7. Implement code 8. Test `BAdI` 9. Test yourself 10. More information

Learn more →