Skip to Content
Business Trends

SAP RPA in Utilities Industry: BPEM Case Resolution Automation

As part of my preparation work for workshop I’m conducting at International Utilities Conference about Machine Learning and Robotic Process Automation (RPA) use cases in Utilities Industry I prepared the following RPA bot that can help to increase productivity in back offices of Utilities companies.

Introduction

Let’s start from basics, what is RPA? Robotic Process Automation (RPA) accelerates digital transformation of business processes by automatically replicating tedious actions to free up human workers for more high-value tasks. It is a form of business process automation technology based on metaphorical software robots (bots). RPA execution can happen in two ways:

  • Unattended (fully automated where bots work without human supervision)
  • Attended (partially automated where human is involved)

SAP RPA Overview

SAP RPA offering consists of Desktop Studio, Cloud Factory and Desktop Agent.

Desktop Studio is where you develop your automation scripts. Desktop agent is the one that executes the script on a desktop or server. Cloud Factory is SAP CP component where you can deploy a script and orchestrate/monitor the execution of scripts. It is also where you can specify on which desktops/servers the scripts should be executed.

More information on the actual solution is available in this blog.

Use Case Explanation

In S4HANA for Utilities business process exception management or clarification cases are created when the business process is failing due to an error and this error requires an intervention to be fixed. Usually, the BPEM cases are solved by the backoffice agents that use transaction EMMACL going through cases one by one and solving problems manually. The idea of this RPA bot is to simplify the life of agents by eliminating manual work on certain categories of cases.

Let’s take one specific example.

Billing process is stopped for certain Utilities contracts due to a block on the contract. This results in billing error and BPEM case is created. The agent use transaction EMMACL to see latest open cases. Next sequence of steps are the following:

  • Open the case in status ‘New’ for business process ‘EBI00001’ automatic billing
  • Switch the case in edit mode
  • Click on Process tab to view the procedure how to solve the case
  • Follow the first step, click on Change Contract
  • Navigate to Utilities contract, click on page 2 of Contract screen
  • Remove billing block reason which is a reason why the billing stops for this contract (at this stage there can be more logic to check whether block reason can be removed)
  • Save the contract, navigate back to BPEM Case
  • Perform the second step, which is a billing check
  • If successful, the status of case can be set as ‘Completed’, save
  • Optional step: send email via outlook to notify the supervisor that the case was closed (to demonstrate cross application automation capabilities).

That’s it.

Bot Creation

First, you need to install Desktop studio to be able to create bots. The process of bot creation is the following:

  1. Take screenshots of each screen that you want to automate
  2. Mark the UI elements that require clicks or interaction
  3. You need to be able to differentiate similar looking screens by some unique elements using so called ‘Must Exist’ or ‘Must Not Exist’ approach
  4. You need to create a workflow where you link all screens together in a sequence.
  5. Test the workflow by doing ‘build’ of the script and then running the script from the desktop studio (remark: the script is compiled in javascript code that you can view and edit)
  6. Script is launched by desktop agent and you can perform debugging if you would like

Once the script is running you can deploy it in Cloud Factory where you can orchestrate the script in terms where it is executed and how frequently.

Workflow view:

Short Video of Scenario

Lessons Learnt

It was pretty easy to get started and to create a bot. This bot can be orchestrated to be executed daily on a dedicated machine to simplify the life of agents.

Some useful tips:

It is very important that screens are correctly distinguished by unique criteria, for that you will have to use ‘Must exist’ and ‘Must not Exist’ UI element technique. Well explained by this blog.

//JS code to send email to close the case 
ctx.outlook.init();
var email = ctx.outlook.mail.create({To: "email@sap.com",
Subject: "Case Closed " + rootData.caseNumber,
HTMLBody: "Case Closed " + rootData.caseNumber});
ctx.outlook.mail.send(email);
ctx.outlook.end();

I struggled with one specific click on an icon in ALV grid, there was no way to perform it using current RPA SDK. For that with the help of RPA colleagues I was able to do it via VB script that you can execute as shown below. You can get the VB script by clicking Options in SAP GUI and launching Script recording and playback. Then, you start recording your actions on SAP GUI, when you press stop, you can get the actual VB script for the clicks that you did that you can execute via RPA. Again, this is more or less workaround if something doesn’t work.

function hereString(f) {
			  return f.toString().
			      replace(/^[^\/]+\/\*!?/, '').
			      replace(/\*\/[^\/]+$/, '');
			}

var MSScrCtrl = new ActiveXObject("MSScriptControl.ScriptControl");
MSScrCtrl.AllowUI = 1;
MSScrCtrl.Language = 'VBScript';
var VBSCode = hereString(function() {/*!
Here goes VB script that you can copy paste from SAP 
scripting engine
*/});
						
MSScrCtrl.AddCode(VBSCode);
MSScrCtrl.Run('ClickOnButton');

Clicking on button in ALV grid

SAPLogon760.pCaseListPage2.oSAPGUIGridViewCtrl1.selectRow(0);
SAPLogon760.pCaseListPage2.oSAPGUIGridViewCtrl1.clickDoubleCell(0, 'CASENR');

Setting dropdown menu

SAPLogon760.pChangeClarification1.cbStatus.setFocus();
SAPLogon760.pChangeClarification1.cbStatus.set('3'); //Set to completed

Have fun with RPA. Thanks to Con Ntalianis for the use case and Sabine Smai for helping out with some issues that I had with SAP GUI automation.

9 Comments
You must be Logged on to comment or reply to a post.
  • Very informative blog Yevgen!

     

    After reading your blog, I also tried making a bot for sending dynamic mail.

    But I am getting the following error :-.

    Can you please help me with it.

    /
        • Hi Abhishek, sorry the enablement of outlook in project settings was the only hiccup that i had. Do you have outlook app open? Otherwise, i have no further recommendations, I could suggest to create a BCP ticket on component CA-ML-IPA. The support colleagues were pretty helpful to resolve issues.

          Best Regards, Yevgen

  • Hi Yevgen – I would like to know if the SAPGUI logonpad click on a system ID is dynamic? If not, could you please let me know if that is achievable ? I am trying to get that but unable to find a way where I can read the datagrid and dynamically navigate to the data item…( the system id is being taken as user input using a popup)?

     

    Thanks & Regards

    Srinivas Rao.

    • Hi Srinivas, no I didn’t make it dynamic, it was a just click on a second item in the list. But im sure you can do a loop and iterate through elements and figure out which one to click dynamically if you wish.

      Best Regards, Yevgen