Use Case: Does your business require custom approval rule on standard SAP ByDesign objects? If yes, then here is a quick guide on how to set it up.

Prerequisite:

  • You (customer) or your partner has a development tenant and has SAP Cloud Application Studio installed.
  • The standard Business object on which you want to build custom approval rule should be enabled for Multi Step approval.

The below use case deals with creation of custom rule for Purchase Order Approval where each Item from the PO is read to derive the Cost Center and its Manager. The manager wants to delegate his approval to others based on certain conditions like pricing.

Now, let’s get started. First step is to login into SAP Cloud Applications Studio with your development user and create a solution.

Steps to create Custom Approval Rule:


1. To maintain the delegates, create a Custom BO which can persist the delegates information as shown below:


CustomBO.png

2. Now, you can create screens on top of this custom BO, to Add/Maintain the list of delegates. To generate screens, right click on the BO and click on Create     Screens and select the option Screen Scenario with Navigation


Screens.png

Note: By selecting the option Screen Scenario with Navigation, the framework generates all the required screens for you starting from Work Center, Work                  Center View, OWL, OIF, QA etc… Also the framework ensures that navigation between the screens are configured for you.

3. Right Click on your solution and select Add New Item or click on Add New Item button and select the option Business Configuration Set as shown below       and give a meaningful name for it.


BCSet.png

4. Now, in this step click on the option Use Business Configuration Object, maintain a description for the BC set and from the drop down of the Name field       choose “ApprovalCustomResponsibilityCategory”

Note:

  • The option Use Business Configuration Object will not be enabled if you are on a test tenant. Hence at the very beginning of the document, it was mentioned to perform the implementation in the development tenant.
  • Once you are in development tenant then you can use SAP delivered std. Business Configuration Objects.

BCSet2.png

5. Click on Next, here you can maintain values for the BC set as shown:

BCSet Filter.png

Here, the value for BusinessObjectTypeCode/content can be found from Repository Explorer, type in the BO Name and then once you select the required BO, the information can be found like below and finish the process of creating BC set.

PO-OTC.png



6. Now, create a BC Option to the BAC element. Right click on the solution, Add New Item and select the option BAC elements


BAC.png


Click on Add, in the next window choose the option Business Option and maintain a value for the Name field under Basic Information and a meaningful description. Maintain a question in the Scoping Question field, this will be later on seen during the scoping of the business option which will be shown in the following steps.

You can also maintain the information of Anchor & Required Scope. Anchor specifies where your Business Option will be placed and Required Scope signifies any constraints for the Business Option. Go ahead and complete the process of creating the Business Option. Once the Business Option is created, you need to activate the same.

BAC2.png

7. Now, time to scope the above Business Option created from the front end. Login to the system and navigate to Business Configuration -> Implementation         Projects -> First Implementation -> Edit Project Scope -> Questions screen.

   

    Here drill down to Purchasing -> Purchase request & Order Management -> Purchase Orders and you can see the question created in the previous step.        Scope the question and trigger the deployment.


     Scope.png

8. Once the deployment is completed, you will be able to see the custom rule in the Workflow Approval process of the Purchase Order. To do this, navigate to       Application & User Management -> Approval Process -> Find the one relevant for Purchase Order and click on Copy.

    In the Work Distribution -> Choose Custom Work Distribution Category Code, and select the option which was earlier maintained by you in the BC set.

    You can also maintain some conditions, so that the workflow process is triggered only if the conditions are met.

    In my example, for ease of use there are no conditions maintained, which means the workflow process will be triggered all the time when the PO is ordered.

     Workflow Config.png

    Note: The validity for workflow process has to be maintained. So for custom workflow to be triggered, delimit the earlier process and enable the new one.

9. Now the last step in the implementation is to create an Enhancement Implementation, right click on the solution and Add New Item. Select Enhancement         Implementation, and chose the namespace and Enhancement Option as shown below in the screenshot and click on OK.


     Enhancement Impl.png

    You can maintain the filter parameter as the value which was specified in the BC set as shown:

     EI - Filter.png

    Now, save and activate the Enhancement Option.

    Now in the absl script you can write the code to retrieve the information about the PO. Loop through each Item in PO to find the Cost Center and the                 corresponding manager. With these information now query on the custom BO to find out the information about the delegates. Sample code is shown below.

     Code.png

  

    Finally, we have done with all the necessary steps for the custom rule to be triggered and it is now time to test it out.

10. Maintain delegates for few cost centers and managers for testing purpose.

  • You can maintain data manually from UI
  • Other option is that you can refer to the below blog on how to maintain data for this custom BO using XML File Input method.

http://scn.sap.com/community/business-bydesign/blog/2016/01/20/how-to-upload-data-for-custom-bo-using-excel

11. Navigate to Purchase Requests and Orders, create New Purchase Order and Items to the Purchase Order and ensure the PO is consistent without any         errors and click on Order. Once you click on Order, the custom approval rule is triggered and based on the configuration maintained in the custom BO, the         approvers for this PO are picked up as shown below:

   

     PO - With Approvers.png

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Pragathi Reddy

    Hi Guruprasad,

    Thanks for the blog, it is very informative.

    Following this process i have created a Custom Approval Process on Customer Quote BO (Sales Quote) for validating the item level values. when the conditions are satisfied it is working fine and going for the approval. But when the conditions are not met still it is going for the Approval (No Approver found; task unassigned) which should not happen as per the standard approval process.

    Can you please help me in solving the issue.

    Thanks In Advance.

    (0) 

Leave a Reply