Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
TJe
Product and Topic Expert
Product and Topic Expert
In this blog I will show, how you can use the SAP Intelligent RPA 2.0 Low-Code/No-Code approach on top of the SAP BusinessObjects REST API.

Knowing the concepts can be very useful also when you are working with other SAP Applications, Here a similar blog for SAP Analytics Cloud

You will learn how to

  • create Automations for reuse in other projects (like Activities provided by the Intelligent RPA SDK packages)

  • generate and share a reusable Package

  • use a Data Type and Input and Output Parameters

  • use Javascript in the Custom script Activity (REST requests using the irpa_core.request() method)

  • the basics of using the REST API and get a template you can use to implement your own requirements


Overview


In the first part, I will create a Project and Package with some sample automations for the BOE Platform (Logon, Logoff, Group). Here we will use the SAP BusinessObjects REST API, so this part needs Javascript skills and is typically done by Expert Bot Developers.

In the second part, we will create another Project and here we can use the package created in the first part. This will allow Citizen Developers or Business Process Experts to define automations, no coding skills are needed.

Here how the final automation looks like in Cloud Studio:


For general information regarding SAP Intelligent RPA (videos, blogs, openSAP courses) please read the blog SAP Intelligent RPA – enablement and getting started  there is also a free trial.

First Part: Project and Package


We will create a New Project, a Data Type to manage session parameters and Automations for Logon, Logoff and manage the SAP BusinessObjects Groups. Finally we generate a Package from the project and this package will be used in the second part.

  • Create a New Project

  • Use the Project name: BOE REST-API CustomScript Sample

  • To work with the REST API of BusinessObjects, the SAP Intelligent RPA Core SDK is required.So make sure this package is added to your project.
    If the Core SDK package is not available on your tenant, you can acquire it from the Store.

  • Select Dependencies - Manage Dependencies

  • Add Dependency

  • You will find the package in the list

  • Select Create - Data Type

  • Use the name dtSessionBOE


  • Define the fields of the data type as show in the picture below
    - use New Field to add a new row
    - use New Child to group parameters, here username, password, authentication
    - authentication shows also, how to define values that can be selected later (secEnterprise,secLDAP,secWinAD,secSAPR3)

  • Select Save


Automation - Logon



  • Select Create - Automation

  • The Configure agent version may be displayed - select your installed agent version and confirm

  • Use the name Logon - CustomScript for the automation
    optional description: Logon to SAP BusinessObjects using REST API

  • Select I/O to define an Output parameter
    The automation will create a BusinessObjects session and we will use this session in other automations as input parameter. We will set the value for the output parameter later in this automation.
    name: sessionBOE
    select type dtSessionBOE from the list

  • Add the activity to set the session parameters to your automation
    - select from Data - Data Types dtSessionBOE and drop to the flow diagram

  • Select the activity Create dtSessionBOE... in the flow diagram and select Edit Activity

  • Enter the parameters of your BusinessObjects system
    access URL of the REST API, username, password, ...
    important: Slash character / at the end of the url, e.g: http://server42:6405/biprws/

  • Save your automation - press Save

  • Add the activity Custom Script to your automation

  • Select the activity Custom script in the flow diagram and select Edit Script

  • Select Add new input parameter

  • Enter Input parameter name pSession and select type dtSessionBOE from the list

  • Copy the following script code to line 1
    const options = {
    resolveBodyOnly: true,
    responseType: 'json',
    url: pSession.accessURL + 'logon/long',
    method: 'POST',
    headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
    },
    body: JSON.stringify({
    'password': pSession.logonParameters.password,
    'clientType': '',
    'auth': pSession.logonParameters.authentication,
    'userName': pSession.logonParameters.username
    })
    };
    const response = await irpa_core.request.call(options);
    //irpa_core.core.log(response);
    pSession.logonToken = response.logonToken;

     


  • You should have the following definition
    red marker is an indicator, that the input parameter is missing (see next step)




  • Select Custom Script in the flow diagram



  • For parameter pSession, select generatedObject from the list
    generatedObject is the Output Parameter from the step Create dtSessionBOE data object

  • Select End in the flow diagram
    now we will assign the value for the output parameter of the automation, we have defined at the beginning. Select generatedObject from the list. In the custom script we have stored the session token in this variable .

  • Save your automation


Test the Logon



  • Select Test

  • On the Test Automation dialog select your Environment, here Test

  • Test should be successful

  • You can check the Session in the Central Management Console of your BusinessObjects system


Automation - Logoff



  • Select Create - Automation

  • Use the name Logoff - CustomScript for the automation
    optional description: Logoff from SAP BusinessObjects using REST API

  • Select I/O to define an Input parameter
    The automation will use the session created with the Logon - Custom Script automation.
    name: sessionBOE
    select type dtSessionBOE from the list

  • Add the activity Custom Script to your automation

  • Select the activity Custom script in the flow diagram and select Edit Script

  • Select Add new input parameter

  • Enter Input parameter name pSession and select type dtSessionBOE from the list

  • Copy the following script code to line 1
    const options = {
    resolveBodyOnly: true,
    responseType: 'json',
    url: pSession.accessURL + 'logoff',
    method: 'POST',
    headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
    'X-SAP-LogonToken': pSession.logonToken
    }
    };
    irpa_core.core.log(options);
    const response = await irpa_core.request.call(options);
    irpa_core.core.log(response);
    pSession.logonToken = null;


  • You should have the following definition
    red marker is an indicator, that the input parameter is missing (see next step)


  • Select Custom Script in the flow diagram



  • For parameter pSession, select sessionBOE from the list
    this is the Input Parameter for our automation, created with the Logon automation

  • Save the automation


Automation - Group


Most of the steps are the same like for the Automation - Logoff, so we will just have screens for the differences. To keep it simple in the sample it is only possible to add a group, but the automation could be enhanced to delete groups, ...

  • Select Create - Automation

  • Use the name Group - CustomScript for the automation
    optional description: Manage Groups in SAP BusinessObjects using the REST API

  • Select I/O to define an Input parameter
    The automation will use the session created with the Logon - Custom Script automation.
    name: sessionBOE
    select type dtSessionBOE from the list
    in addition we have the parameters
    - method: to define if a group should be added, deleted, ...
    - name: the name of the group

  • Add the activity Custom Script to your automation

  • Select the activity Custom script in the flow diagram and select Edit Script

  • Select Add new input parameter

  • Enter Input parameter name pSession and select type dtSessionBOE from the list

  • Select Add new input parameter

  • Enter Input parameter name name and select type String from the list

  • Copy the following script code to line 1
    const options = {
    resolveBodyOnly: true,
    responseType: 'json',
    url: pSession.accessURL + '/v1/usergroups/usergroup',
    method: 'POST',
    headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
    'X-SAP-LogonToken': pSession.logonToken
    },
    body : JSON.stringify({
    'name': name
    })
    };
    const response = await irpa_core.request.call(options);


  • You should have the following definition
    red marker is an indicator, that the input parameter is missing (see next step)


  • Select Custom Script in the flow diagram



  • For parameter pSession, select sessionBOE from the list
    this is the Input Parameter for our automation, created with the Logon automation

  • For parameter name, select name from the list, this is the input parameter defined for the automation.

  • Save the automation


 

Test the automations


Now you can test the Logon, Group and Logoff in a new automation, which you probably would do to make sure everything works fine. You can also use easily debugging features of Cloud Studio when testing in the same project.
As we are now creating a package from our project, we will use the package in the second part and also test our automations in the second project.

Generate and Share the Package



  • Select Projects

  • On the sample project select the icon Generate Package

  • Confirm the name and select Generate Package

  • Select Packages

  • On the package select More Options and Share

  • On Share Package set Share with: Anyone and Authorization: Read, click on Share

  • Your Package is now shared and can be used in Projects


Second Part: No-code Project


Now we will create and test an automation using the package.

Automation – Create Group



  • Create a New Project

  • Use the Project name: Demo BOE

  • Select Dependencies – Manage Dependencies

  • Select Other and click Add Dependency

  • Select the Package and Version from the list and click Add

  • The package is in the list, select close

  • Select Create – Automation

  • The Configure agent version may be displayed – select your installed agent version and confirm

  • Use the name Create Group for the automation

  • Add the automations Logon, Group and Logoff to your flow

  • Select each step and rename the steps, use
    Logon – SAP BusinessObjects
    Create Group
    Logoff – SAP BusinessObjects

  • Select step Create Group and set the Input Parameters
    sessionBOE from the list
    add string as method
    00-Intelligent RPA string for the Group to create

  • Select step Logoff – SAP BusinessObjects and set the Input Parameter
    sessionBOE from the list

  • Save the automation


Test the automation



  • Select Test

  • Select your Environment

  • The automations should be executed successfully

  • The group is created in your SAP BusinessObjects system


Conclusion


You have used several key concepts, how to

  • create Automations for reuse in other projects (like Activities provided by the Intelligent RPA SDK packages)

  • generate and share a reusable Package

  • use a Data Type and Input and Output Parameters

  • use Javascript in the Custom script Activity (REST requests using the irpa_core.request() method)

  • the basics of using the REST API and a template you can use to implement your own requirements


Hope this was useful and you can now start your own journey in using the REST API of your SAP Application.
4 Comments