Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
Caetano
Product and Topic Expert
Product and Topic Expert
3,815

I recently came across an interesting thread in the SAP Community, where a user was asking if he can block users to change the production order quantity. I think that this is the perfect business requirement to demonstrate how we can implement a simple custom logic that is compliant with the clean core approach.

Note: If you are not familiar with clean core, I suggest that you go through the following learning journey: https://learning.sap.com/learning-journeys/practicing-clean-core-extensibility-for-sap-s-4hana-cloud...

 

blog custom logic.png

SAP S/4HANA 2023 Private Cloud Edition introduced the new Fiori App Custom Logic (F6957), which allows us to create implementation of BAdIs that were released by SAP and that are clean core compatible.

You can access this app in the Fiori Launchpad if role SAP_BR_EXTENSIBILITY_SPEC is assigned to your user. 

 

In this blog we will use this app to create a new implementation of BAdI Manufacturing Order Check Before Save – BD_MFGORDER_CHECK_BEFORE_SAVE, and we will introduce a new check that will throw an error message whenever an user tries to change the order quantity, after the order creation. 

The first step to create our BAdI implementation is to launch this app in the Fiori Launchpad. We will then see a list of the existing BAdI implementations, which can be managed in the app. We will then click the button Create to generate a new BAdI implementation.

Custom logic 2.png

In the following screen, we will search for the extension point that will be used for our custom logic, and if we search by MFGORDER, we can find all the extension points available for manufacturing orders.

Custom logic 3.png

We can find more information about each one of the extension points by clicking button View Documentation, where a popup screen will be shown with additional details about the BAdI, as we can see in the figure below:

Custom Logic 4.png

Step 2 is not relevant in this example, as don’t need connectors or filters, so we can go straight to step 3, where we will define the Implementation ID and provide a description.

Custom Logic 5.png

After that, we should click button Review, and we will be able to see all the information about the New Implementation in a single screen. Here, we can proceed with the creation by clicking button Create.

Custom Logic 6.png

With our implementation created, we need to publish it, by clicking the button Publish (might take a few seconds), and we will finally be able to branch in the editor, by clicking the Open Code Editor button.

Custom Logic 7.png

The code editor is quite simple, and we have the code in the left side, and the available parameters in the right side. If we click the button Show Sample Code, we can see a popup screen with a sample implementation provided by SAP, as we can see below. The code of this sample implementation is very simple, and there are comments to make it easily understandable.

Custom Logic 8.png

I have copied the code provided from SAP, and adapted it to create my own implementation, where I’m going to compare the new order quantity with the old order quantity and thrown an error message when they are different.

Here is the code of my BAdI implementation:

*   only perform the implementation for order category is "Production Order"
    CHECK manufacturingorder-manufacturingordercategory = if_mfgorder_check_before_save=>con_productionorder.

*   check if the production order quantity has been changed
    IF manufacturingorder-MFGORDERPLANNEDTOTALQTY <> manufacturingorder_old-MFGORDERPLANNEDTOTALQTY AND
       manufacturingorder_old-MFGORDERPLANNEDTOTALQTY <> 0.
*           add the an error message with helpful information to the message table
            INSERT VALUE #(
                     messagetype = 'E'
                     messagetext = |Production order quantity cannot be changed| ##NO_TEXT
                   ) INTO TABLE messages.

    ENDIF.

Here, it is important to mention that this editor uses Restricted ABAP, which does not support all the features originally available in ABAP. This blog provides more details about Restricted ABAP and the supported features.

Whenever we finish the code, we can click button Save and Publish to activate our implementation.

Custom Logic 9.png

 

With our implementation published, we can go to transaction CO02 and try to change the order quantity, to see what will happen. As shown in the figure below, an error message is triggered if we try to save an order with a different quantity.

Custom Logic 10.png

This is just a very simple example, used to demonstrate how the Fiori App Custom Logic can be used to implement custom checks in a production order, but you can use it as a starting point for your own implementation. For example, you can add a tolerance for the quantity change, you can allow changes for orders that are not released, or you can add any check that your business need.

 

Brought to you by the SAP S/4HANA RIG

 

 

 

 

 

5 Comments
beyhan_meyrali
Active Participant

Hi Caetano,

As usual great and helpful information.

I learnt tons from your posts.

Thanks for sharing.

Regards 

RobertVit
Active Contributor
0 Kudos

Hi Caetano,

indeed simple.

Waiting on some more complex examples.

 

Kind regards

Robert

Raja_S_Reddy_B
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Caetano,

Thanks A Lot for sharing such Wonderful & Most Useful Info.
This requirement comes up very frequently from the Business

Best Regards
Raja

Sujin_Appukuttan
Participant
0 Kudos

Hi Caetano,

 

 Simple and well explained show casing the use of Enhancement in Private Cloud via Clean Core. Could we still achieve Enhancement via Clean Core in case Extensions points are not available? 

 

Regards,

Sujin

abhi1185
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Caetano,

As this BADI definition is released for both Key user and for cloud development. We have implemented it directly from ADT and activated it . Not published it, as we have implemented it directly from ADT and not key user extension.

abhi1185_0-1724835229115.png

We need to implement some checks in manufacturing Order (IW32). We are on S/4HANA 2022 (S4CORE107) , however BADI implementation is not getting triggered. 

Can you please suggest if we are missing something.

 

Regards,

Abhishek