Skip to Content
Technical Articles

SAP iRPA integration with SuccessFactors: create users based on employees (Challenge Submission)

This is a submission for the SAP Intelligent RPA Tutorial Challenge.

 

My name is Jonis de Klerk, 23 years young and living in Belgium 😊

I’ve started learning about RPA using uiPath which triggered my interest and now I’ve switched over to SAP iRPA.

 

The purpose of this blog post is to show you how to integrate SuccessFactors with SAP iRPA. In this tutorial we will use SuccessFactors to extract a list of users using an AJAX call and create SAP logon users with them.

Some prerequisites in order to be able to follow this blog post are the following:

  1. Desktop studio and desktop agent installed and configured (https://help.sap.com/viewer/6b9c8e86a0be43539b670de962834562/Cloud/en-US)
  2. SuccessFactors system and its corresponding API url to connect to.
    (https://apps.support.sap.com/sap/support/knowledge/public/en/2776694 &
    https://help.sap.com/viewer/d599f15995d348a1b45ba5603e2aba9b/1911/en-US/03e1fc3791684367a6a76a614a2916de.html)
  3. Base knowledge of SAP iRPA (creating a project/workflow, adding applications/pages,…)
    (https://help.sap.com/viewer/8ecea00c1f854fd0a433c4aef5da1ea2/Cloud/en-US)

 

The blog post is divided into 3 parts:

  1. Create an AJAX call to SuccessFactors API.
  2. Open SAP Logon and login
  3. Process the list of employees

The complete scenario:

In this scenario we start by retrieving all the information required from SuccessFactors, which we’ll loop through and create a user for each of them. The creation of the users is done in a loop. The processing of the different screens is done for each employee.

 

 

Create a new project and workflow and follow the steps below.

 

1.      Create an AJAX call to SuccessFactors API.

Execute SF API call

First step into recreating this scenario is creating a custom activity.

In this custom code activity, we add an ajax call with the following parameters.

ctx.ajax.call({
	method: e.ajax.method.get,
	url: 'https://XXXXXXXXXXXXX.successfactors.eu/odata/v2/User?$top=2',
	username: "",
	password: "",
	async: false,
	contentType: e.ajax.content.json,
	success: function(res, status, xhr) {
		var response = ctx.xml.xml2object(res);
		var outputArray = [];
		ctx.log(response.feed);
		for (var i in response.feed.entry) {
			ctx.log(ctx.json.stringify(response.feed.entry[i].content['m:properties'])); // Stringify is used purely for logging.
			outputArray.push(response.feed.entry[i].content['m:properties'])
		}
		rootData.MyDatabase.dataOutput = outputArray;
			
		sc.endStep(); // Call_Open_SAP
		return;
	}});

 

In the success function we extract the data needed, in this case, a for loop is used to go through all the entries and the properties of each are being extracted and added into a context variable dataOutput.

This context variable dataOutput is marked as an array. In order to create such a data object, go to Workflow designer -> context tab. In this context tab we’ll create a folder called MyDatabase and add an item (dataOutput) to it. To clarify a data object is an Array, make sure to mark its checkbox.

 

 

2.     Open SAP Logon

As soon as the data has been retrieved, we open SAP logon and login. The opening and logging into SAP logon has been created in a separate scenario(workflow).

In order to be able to do this, the required pages have to be captured and application SAP logon has to be added.

The screens are:

  • Initial system selection screen
  • Login screen
  • Welcome screen

 

In pWindowSAPLogon the system is selected. This is done by adding a click activity on the item required.

In pSAP management, login with your SAP logon user by adding the set activity on both inputs.

In pSAPEasyAccess, the required transaction is opened, in this case “/nSU01”

 

 

3.      Process the list of employees

Next step is starting a loop by adding a “Start loop activity”, this is required as the same process has to be executed for each employee. Using the loop automatically creates an index and initializes it with 0.

This variable is called sc.localData.startLoop (Don’t change)

 

Notice that pMaintainUsers and pMaintainUsersLogonTab are the same page. It is, except a different tab is selected. To be able to recognize both pages. It’s required to add a reference item in the page (the tab selected). To do this, go to the applications designer, find the page captured, right click on the tab item and select ‘Set as reference item’.

pUserMaintenance

we enter the retrieved username from our ajax call. Before that is done, a check is required to see if we have reached the end of our array (rootData.MyDatabase.outputData). Therefore we add an exit loop activity and check if sc.localData.startLoop is equal to rootData.MyDatabase.dataOutput.

GLOBAL.step({ pUserMaintenanceIni_m: function(ev, sc, st) {
	var rootData = sc.data;
	ctx.workflow('scSFextractUserCreate', '3d423aff-15ee-47b6-bd1d-d5208d8eaaff') ;
	// Wait until the Page loads
	SAPLogon750.pUserMaintenanceIni.wait(function(ev) {
		
		// Exit loop
		if (sc.localData.Startloop === rootData.MyDatabase.dataOutput.length)
		{
			sc.localData.Startloop = -1 ;
			sc.endStep('NEXT_LOOP');
			return ;
		}
		SAPLogon750.pUserMaintenanceIni.edUser.set(rootData.MyDatabase.dataOutput[sc.localData.Startloop]['d:username']);
		SAPLogon750.pUserMaintenanceIni.btGuiButton.click();
		sc.endStep(); // pMaintainUsers_manage
		return;
	});
}});

 

pMaintainUsers

In this step, we make sure to press the ‘Address’ tab and enter the found employee’s firstname and lastname. After both have been entered, insert a click activity on the ‘Logon data’ tab.

The data entered in the lastname and first name come from our context object dataOutput. The sc.localData.Startloop is the index of the dataOutput array we’re looping through.

GLOBAL.step({ pMaintainUsers_manage: function(ev, sc, st) {
	var rootData = sc.data;
	ctx.workflow('scSFextractUserCreate', '89be521e-584f-4301-a40f-18eda7f0a0e7') ;
	// Wait until the Page loads
	SAPLogon750.pMaintainUsers.wait(function(ev) {
		SAPLogon750.pMaintainUsers.edLastName.set(rootData.MyDatabase.dataOutput[sc.localData.Startloop]['d:lastName']);
		SAPLogon750.pMaintainUsers.edFirstName.set(rootData.MyDatabase.dataOutput[sc.localData.Startloop]['d:firstName']);
		SAPLogon750.pMaintainUsers.oLogonData.click();
		sc.endStep(); // pMaintainUsersLogonTa
		return;
	});
}});

pMaintainUsersLogonTab

In this page, ‘logon data’ tab is selected. In this tab, we enter an initial password. Set a variable with this initial password and set it into both password fields.

After both password fields have been entered, add a click activity on the save button.

 

 

What did we learn:

  • How to integrate with SuccessFactors using AJAX calls and extracting the required data.
  • How to process a dataset correctly in a loop.
  • How to connect to SAP logon and execute a transaction.

 

There you go! You just created an automated scenario which extracts users from SuccessFactors and created a SAP logon user for each of them.

Enjoy!!

 

1 Comment
You must be Logged on to comment or reply to a post.
  • Nice blog, small suggestion, instead of xml you could use json for OData response which will simplify parsing as json natively interpreted by javascript.

    Best Regards, Yevgen