
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...
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.
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.
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:
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.
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.
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.
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.
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.
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
10 | |
8 | |
7 | |
7 | |
5 | |
5 | |
4 | |
4 | |
3 |