Skip to Content
Technical Articles
Author's profile photo Zhehui Xia

SAP S/4HANA Cloud, public edition, ABAP Environment Case 1: Enhanced Goods Receipt Process

As you can know from the title, there will be a series of our blogs about some cases in SAP S/4HANA Cloud, public edition, ABAP Environment. Before we start, I’d like to suggest that you can read two blogs, one written by Marco, and the other one written by Vincent. Marco provides a great summary of all extensibility techniques used in SAP S/4HANA Cloud, public edition. Vincent introduces some cases to us and I’d like to write some blogs to show the details of our cases. I hope that can bring some insights for you in 3SL Exploration. Enjoy it!

1. Scenario Requirements

1.1  Case Background

Based on the physical situation of goods, our warehouse colleague wants to pass information about the goods receipt such as damage of intrinsic matter, product validity exception, etc. to QA quality inspector at goods receipt. The warehouse clerk fills in the header text field of the material document resulting from the goods receipt posting at goods receipt posting and this field is not passed from the goods receipt material document to the automatically generated inspection lot of the goods receipt via standard functionality. So we want to achieve this business requirement by way of development.

1.2  System Action

Front office condition: The material master quality attempt requires the corresponding inspection type to be activated, and the configuration of the QM module needs to be improved.

When creating a Material Document based on a Purchase Document, an Inspection Lot is automatically generated on the selected item with an empty Short Text for the automatically created Inspection Lot. You want to pass some information downstream, so when creating an Inspection Lot, call the BAdI to modify the Short Text.

1.2.1  Create Material Document

With Post Goods Receipt for Purchase Document APP, when you create a Material Document, you fill in the Note field, which is reflected on the automatically created Inspection Lot.


Create Material Document

1.2.2  Display Inspection Lot

Use Display Inspection Log App to see that the Short Text field in the automatically created Inspection Lot has been set to be filled in the Note of the Material Document.


Display Inspection Lot

2. Detailed Steps

2.1  BAdI for Release-Out Found

Enhancements Spots MMIM_GR4XY_FIORI

– MMIM_GR4XY_CHECK_DATA      Change Header and Item Data in Goods Receipts

When creating a Material Document, save the value of the Note field for further use.

The BAdI can be found under Release Objects > Enhancements > MM > MM-IM > Enhancements Spots.



Enhancements Spots QPL1_INSPLOT_CHANGE

– QPL1_INSPLOT_CHANGE      Change Inspection Lot Header During Lot Creation

When creating an Inspection Lot automatically, assign the value of the Note field you just saved to Short Text.

You find the BAdI under Release Objects > Enhancements > QM > QM-IM > Enhancements Spots.



2.2  Define Implementations for BAdI Enhancements

First create a Package, right-click ZLOCAL > New > ABAP Package.

Fill in Name and Description of the Package and check Add to favorite packages for easy follow-up. Click Next.

Then lick Next > Finish to complete package creation.


New ABAP Package

Right-click the newly created Package and click New > Other ABAP Repository Object.

Enter BAdI to search, check BadI Enhancement Implementation and click Next.

Enter Name and Description and click Browse to the right of Enhancement Spot.

Enter MMIM_GR4XY_FIORI to search and select, click OK.

Click Next > Finish to complete the creation of the first BAdI enhancement implementation.


New BAdI Enhancement Implementation

The creation of the second BAdI enhancement implementation is done in the same step, choose QPL1_CHANGE_AT_CREATE4CLD as Enhancement Spot.

2.3  Add BAdI Definition for Enhancement Extension Point on Material Document

Open the first enhancement implementation you created in the previous step, click Add BAdI Implementation, click Browse to the right of BAdI Definition, search for it, select MMIM_GR4XY_CHECK_DATA, and click OK.

Then fill in BAdI Implementation Name and click Add.


Add BAdI Implementation

When you have finished adding BAdI Definition, we are prompted that the implementing class is missing.


Class Missing

Add a BAdI Definition for the second enhancement implementation using the same steps to create the section. Select BADI_QPL1_CHANGE_AT_CREATE4CLD as the BAdI Definition for the second enhancement implementation.

2.4  Custom implementation logic in ABAP classes

Right-click the package you created and click New > ABAP Class.

After entering Name and Description for the class, click Next.

Click Finish to finish creating the class.


New ABAP Class

In the created class, customize the implementation logic. When the Material Document is saved, a variable is used to store the Note field of the Material Document for subsequent use.

Save and click 🕯 in the upper menu bar to activate the class.

CLASS zcl_gr4xy_check_data DEFINITION


    CLASS-DATA headertext TYPE string.
    INTERFACES if_badi_interface .
    INTERFACES if_mmim_gr4xy_check_data .


  METHOD if_mmim_gr4xy_check_data~check.

    headertext = gr4xy_header-materialdocumentheadertext.


Add the class you just created as an implementation class to the BAdI Implementation you created earlier. Click Browse, select the BAdI Implementation you created earlier, and click OK.

Add an implementation class for the second BAdI Implementation with the same steps. In the created class, customize the implementation logic. When creating an Inspection Lot automatically, assign the value of the Note field you just saved to Short Text.

Save and click 🕯 in the upper menu bar to activate the class.

CLASS zcl_change_at_create4cld DEFINITION


    INTERFACES if_badi_interface .
    INTERFACES if_ex_qpl1_change_at_create4cl .


  METHOD if_ex_qpl1_change_at_create4cl~execute_change.

*   Test BADI in Lot Change during Creation
    inspectionlottext = zcl_gr4xy_check_data=>headertext.


2.5  Activate BAdI enhancement

Mark Active Implementation, save it, click 🕯 in the upper menu bar, and the implementation will be called below will indicate that the BAdI enhancement activation has been completed.


BAdI Enhancement Implementation – MMIM_GR4XY_CHECK_DATA


BAdI Enhancement Implementation – QPL1_INSPLOT_CHANGE

3. More Information on SAP S/4HANA Cloud, Public Edition

  • SAP S/4HANA Cloud, public edition, release info here
  • Latest SAP S/4HANA Cloud, public edition, release blog posts here and previous release highlights here
  • Product videos on our SAP S/4HANA Cloud, public edition and SAP S/4HANA YouTube playlist
  • SAP S/4HANA PSCC Digital Enablement Wheel here
  • Early Release Webinar Series here
  • Inside SAP S/4HANA Podcast here
  • openSAP Microlearnings for SAP S/4HANA here
  • Best practices for SAP S/4HANA Cloud, public edition, here
  • SAP S/4HANA Cloud, public edition, Community: here
  • Feature Scope Description here
  • What’s New here
  • Help Portal Product Page here
  • SAP S/4HANA Cloud ABAP Environment Community here

Follow us via @SAP and #S4HANA or follow Zhehui Xia

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Viktor Szlatki
      Viktor Szlatki

      Hi Zhehui,

      great blog, it really works!

      It is not really clear for me how can be the right


      visible from badi


      It is called in the same update process somehow? How can you be sure that you allways got the right headertext from the right goods receipt in you inspection lot?


      Author's profile photo Zhehui Xia
      Zhehui Xia
      Blog Post Author

      Hi Viktor,

      Sorry for late reply. We use the first BAdI GR4XY_CHECK_DATA to store NOTE - as headertext, a variable. Then we can use the second BAdI to read the variable and put it into inspection lot. It would trigger the first BAdI to get headertext so it's always right.

      Best Regards,