Skip to Content

Implement your own Approvals for SAP Business ByDesign Manager Approvals with SAP Cloud Applications Studio

What is this about?

This guide demonstrates how you can add your own category of approvals to SAP Business ByDesign Manager Approvals simply with SAP Cloud Applications Studio. We use a rather simplified example to give you a fast start.

If you do not know SAP Manager Approvals for Business ByDesign, check out this short information about the application.

What you may know is, that SAP delivers a set of already implemented approval categories with the app, but you can add your own approvals side by side to the SAP delivered approvals and users won’t see any difference.

What do I need?

You need to be a SAP Cloud Applications Studio Developer in a SAP Business ByDesign tenant and you have already SAP Cloud Studio installed and ready for development of your own solution.

Refer to SAP Community Network for further information about SAP Cloud Application Studio:

http://scn.sap.com/community/business-bydesign/studio

For testing you need a business user that can access SAP Manager Approvals at least from a browser. Check the Installation and Configuration Guides that you can find in the Managing My Area section of the SAP Business ByDesign Library that you can access from your SAP Business ByDesign system via Help Center.

We assume that you already have some experiences with SAP Cloud Applications Studio (this is not a beginner guide).

We also assume that you have in your solution already an object or similar entity that contains the business logic for a kind of approval process, for example: you have already a business object that has a field or status telling that it is approved or rejected or that the decision is still open. We also assume that you can somehow select the objects that are relevant for a user (e.g. in order to show him/her the list of objects he/she has to decide upon). You may even have already a complete approval process implemented and just want to extend your solution with the capability to use the SAP Manager Approvals app for the same.

First Results with just four Lines of Code

Create a new Solution

Use the SAP Cloud Studio to create a new empty customer specific solution.

Add an Enhancement Implementation

In order to add content to the Manager Approvals app, you need to implement certain Enhancement Spots with your logic (this is also known as BAdI). Every implementation corresponds with a certain UI call to fetch data or take action.

For a start, you need to add a new Enhancement Implementation to your project:

Pick namespace http://sap.com/xi/A1S and select option MobileApprovalGetOverview:

SAP Cloud Applications Studio will generate some objects for you, namely an Enhancement Implementation Filter (*.fltr) as well as the minimal ABSL code for the method (GET_OVERVIEW.absl).

Implement the Filter

Double click the filter object (*.fltr) to open it. Here you specify a filter value. It has to be unique for your category and will be referred to later as “Category ID”. Pick a string like your solution ID (like “YABCD1234”) and add it as filter value for the Category ID.

Implement the Method

Double click GET_OVERVIEW.absl to implement the enhancement option method. You should already see some code that simply declares a variable result and returns it.

Add the following four lines (marked). Replace the ApprovalCategory with the value you used above in the filter:

var result : MobileApprovalOverview; // Already created

result.CategoryName = "Cloud Studio Demo";

result.ApprovalCategory = "MA_DEMO1"; // Replace with filter value

result.Count = 5;

result.CategoryIcon = "lightbulb";

return result; // Already created

Activate everything and test

Now make sure that all objects are saved and activated (there should be no red dot at the object’s icon in the Solution Explorer but a nice checkmark).

If you now open the Manager Approvals app in that tenant with a user that has permissions (for the app; see configuration information in Help Center how to do this), you should see something similar to this:

Depending on the user you have chosen, some more categories may be visible.

Congratulations! You have added a new approval category. Of course the content is still missing. For this, you need to implement some more methods and also the number is hard coded. But you know have an idea about the general procedure.

How to proceed with this method?

Instead of having a hard coded number as the number of approvals, you may fetch the actual number of objects the current user has to approve. How to do this depends on the objects you like to present him/her. Very likely it is the result of a query on an object containing the current users or its business partner ID as well as the status for open approvals.

Please note that if your logic would present zero approvals, we automatically hide this from the user.

Fetching and Presenting Simple Tasks

When the user taps on the above implemented category tile, he/she will be navigated to the approval screen. On that screen the user will see all the approvals he/she has to decide upon.

Add new Enhancement Implementation

Similar to the above enhancement you already added, add a new Enhancement Implementation: Pick namespace http://sap.com/xi/A1S and select option MobileApprovalGetApprovalData.

Implement the Filter

Double click the filter object (*.fltr) to open it. Here you specify a filter value. It is important that you choose the same filter value that you have chosen above for the CategoriesOverview implementation! Those filter tie the different implementations together and make sure that after the user taps on your category, your tasks are being retrieved.

Implement the Method

Intention of this method is to return a list of approval tasks with detail information so that the user can decide upon them.

We will in the first attempt restrict this to a bare minimum to give you an idea how to do this. Of course the data in your case comes from your business object or entity you like to present to the user. In such cases you likely start with a query that selects your objects and maybe additional data you need to display.

In our example we just hard code a list to show you the essentials of adding a task.

The typical code looks like this:

  1. var result : MobileApprovalApproval;
  2. var line : MobileApprovalApprovalInformation;
  3. line.Category = "MA_DEMO1"; // Replace with your own category!
  4. // line.UUID = ..; // Assign your object’s UUID here
  5. line.Description = "East Garden";
  6. line.EmployeeResponsible = "John Mayer";
  7. line.Info = "1 Apple";
  8. dataField.UILabel = "Diameter";
  9. dataField.Value = "9 cm";
  10. line.DataCollection.UIFieldInformation.Add(dataField);
  11. dataField.UILabel = "Weight";
  12. dataField.Value = "120 g";
  13. line.DataCollection.UIFieldInformation.Add(dataField);
  14. dataField.UILabel = "Brand";
  15. dataField.Value = "Long John";
  16. line.DataCollection.UIFieldInformation.Add(dataField);
  17. dataField.UILabel = "Quantity";
  18. dataField.Value = "1 each";
  19. line.DataCollection.UIFieldInformation.Add(dataField);
  20. result.Approvals.Add(line);
  21. return result;

What does all this mean? OK, above you see basically three kinds of sections:

  • Lines 4..5 and after 24 contain basically what you have to do (add your category ID as well as UUID as identification and add the line to the output structure)
  • Lines 7..9 contain information that you see on the face of a task tile
  • Lines 11..22 contain information that you will find in the details of the task

As result of the above, the user will get one single task with some information on the face and some in the details:

The same on a phone looks like the following pictures:

Please note that all the fields you add are basically text fields (strings), so you have to take care of your own about the representation of your data.

You can add more tasks by adding more lines to the result structures Approvals list.

Executing an Action

You can already execute Approve or Reject actions on the task in the above example, but basically nothing will happen since nobody actually changes the business object in the backend. This we will add now.

Add new Enhancement Implementation

Similar to the above enhancement you already added, add a new Enhancement Implementation: Pick namespace http://sap.com/xi/A1S and select option MobileApprovalExecuteAction.

Implement the Filter

Double click the filter object (*.fltr) to open it. Here you specify a filter value. It is important that you choose the same filter value that you have chosen above for the CategoriesOverview implementation! This filter should look similar to the one that you created in the previous chapter.

Implement the Method

Intention of this method is to process a list of approval tasks together with the actions the user has chosen (basically Approve or Reject) and an optional note text, that the user has entered. In our example we haven’t enabled this, so for us it is mainly to process the action on the business object that we are presenting.

Generally only one type of action (Approve, Reject) is executed at one time, but this action may have several tasks as parameter. The tasks are represented with their UUID provided by the implementation that we have created the last chapter. Optionally they may carry a text note.

var result : MobileApprovalActionResult;

var action : MobileApprovalActionName;

var note;

var taskUUID : MobileApprovalApprovalID;

// What action is executed

action = InputData.ActionName;

// Loop the parameters

foreach (var parameter in InputData.ActionParameter) {

      note = parameter.Note;

      taskUUID.UUID = parameter.UUID;

      // Do something with it

      // Return that all went OK (omit this, if not)

      result.ProcessesedApprovalID.Add(taskUUID);

}


return result;

The above code loops over the tasks received for a specific action and selects the relevant information from them, basically the UUID of the task that I have provided earlier.

The implementation can for example catch all the UUIDs for a particular action for a Business Object and them the action can be called for all the IDs provided.

The successfully processed UUIDs should be returned.

Please note, that the UI will later call the GetOverview implementation that we have implemented at the beginning and it is expected, that the number changes in case something has been decided upon (user started with 5 tasks and approved two, GetOverview should now return three, because the already approved two tasks are not selected anymore).

Conclusion

This document gives a shot introduction about the basic steps of the development of a new category for the SAP Manager Approval app for SAP Business ByDesign.

It should help to start, but we know, that there are a lot of more options and details that need to be explained. In the future we will follow this up with some more detailed information about additional options that you have.

Please use your feedback channels to SAP to let us know

  • What you think about this document
  • What you would like to read about
  • What features you are missing

General Disclaimer and Copyright Information

© 2015 SAP SE or an SAP affiliate company. All rights reserved.

No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an SAP affiliate company.

SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE
(or an SAP affiliate company) in Germany and other countries. Please see
http://global12.sap.com/corporate-en/legal/copyright/index.epx for additional trademark information and notices.

Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.

National product specifications may vary.

These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind, and SAP SE or its affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP SE or
SAP affiliate company products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.

In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation, and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platform directions and functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, which speak only as of their dates, and they should not be relied upon in making purchasing decisions.

Tags: