In SAP S/4HANA Cloud, customers can extend the solution by adding their own business processing logic in most processes, either because it is very specific to a given customer (and hence does not make sense for an ERP to include this logic)  or in some cases simply because the solution does not – yet – offer the sought functionality. That said, it is understood that customers need this level of flexibility and to that end SAP offers the Custom Business Logic functionality.

In this post we will explore the capabilities that exist for you to embed your own business logic, at the heart of your processes within SAP/S4HANA Cloud, by leveraging the Custom Fields and Logic Fiori application.

If you enjoy this post, please consider subscribing to our youtube channel and follow the hashtag #S4HCKS on twitter.

Example Code Snippet

In the video I have added some custom logic code, which I am adding below. Feel free to use it and amend it as needed.

DATA: lv_purchaseorderbycustomer TYPE c LENGTH 35.

SELECT SINGLE PurchaseOrderByCustomer FROM I_SalesDocument INTO @lv_purchaseorderbycustomer
    WHERE   PurchaseOrderByCustomer = @salesdocument-purchaseorderbycustomer
    AND     SoldToParty = @salesdocument-soldtoparty
    AND     SalesOrganization = @salesdocument-salesorganization.

If lv_purchaseorderbycustomer is not initial.
      append value #(  messagetype = 'E' messagetext = 'This document cannot be saved due to an existing identical order reference.' ) to messages.
endif.

Disclaimer: I am by no stretch of the imagination a knowledgeable programmer , so please use this code at your own risk and if you make it better, then please share it with the community.