Skip to Content
Technical Articles
Author's profile photo Thomas Jentsch

SAP RPA 2.0: add activities – Custom script SDK tutorials

This tutorial is based on my SAP Intelligent RPA experience working with the Custom script activity and will introduce a generic Template/ Design Pattern you can adopt for APIs of different products – the Custom script SDK.

  • Developer
    In Custom scripts you can develop JavaScript code and also use APIs (e.g. REST APIs). You will save the Custom script as Automation
  • Citizen Developers or Business Process Experts
    Like Activities provided by IPRA SDK packages, the Automation can be used in the workflow to define an automation process

So the concept supports the Low-Code/No-Code approach of  SAP RPA also for API usage.

I have done this for APIs of different products and recognized, that even for a small set of Custom scripts in my SAP Intelligent RPA Cloud studio projects

  • there is duplicated code
  • adding features would lead to more duplicated code
  • the code is really hard to maintain
  • need a better way to structure and organize the Custom scripts
  • should use JavaScript concepts like: Classes, Functions in variables, …

Tutorial Blogs

Custom script SDK – Overview

Standard SDK Package

Part of the SAP Intelligent RPA product, you can get them from the store.
Content: Data Types, Activities 

Custom script SDK Package

You will develop a Custom script SDK in a Cloud Studio Project, generate and share as Package.
Content: Data Types, Automations

The Custom script activity in the automations

  • will contain the JavaScript code
    supports the ECMAScript (ES6) version that means let, const, and lambda functions, …
    a limitation I have recognized; you cannot use the import statement
    API calls for your product
  • can define Input and Output Parameters
  • can use Standard SDK activities, like
    irpa_core.core.log(‘message’); or irpa_core.clipboard.get();

You can find more implementation details for the Custom script activity in the Cloud Studio User Guide – Custom Scripting.

Design Pattern Sample API

A template package that will be used to develop your Custom script SDKs.
The sample API is very simple, the methods initexecute (with parameters) and done will only write messages to the console.
It provides Data Types and Automations that will be used in your SDK implementation. The JavaClass for the Sample API will be the starting point for your API implementation.

Automation concepts

Here a sample, how the workflow in an automation could look like. In this case we are using the Design Pattern package.

  • Step cs_activity_Sample
    Input Parameter: name of the activity (for the sample API: init, execute, done)
    Input Parameter: parameter value
  • Step Execute
    Input Parameter: parameter value
    the name is already specified in the Automation Execute

So you can have a Automation the could execute all activities of your API (cs_activity) or you have have Automations for each activity (Execute, …).

Custom script – Activities Class

Here the template of the JavaScript class that will implement the methods of the API. You can find the source code in the Design Pattern tutorial and the sample for an Rest API in the SAP Analytics Cloud tutorial.

Conclusion

Hope this tutorial is useful and you can adopt the concepts to develop a Custom script SDK for your API and product.

 

Assigned Tags

      4 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo dang long
      dang long

      Hi Thomas,

       

      many thank, this session is very detail, i looking for way how can i manage data in SDK.2.

      At SDK.1 I set data to variable sc.localData.taskList = [...], and i custom a function like this :

      Var _uc = (function(){
      .....
      })()

       

      can you advise me, Thank you

      Author's profile photo Thomas Jentsch
      Thomas Jentsch
      Blog Post Author

      Not sure I fully understand the question, but may be this sample Custom script help.
      The first createList() creates a variable with a defined data type 'Object' (you must create the data type first using the fields listed here):

      const v = irpa_core.variable.createList($.object, [{ propertyString: "a", propertyBoolean: true, propertyNumber: 1 }, { propertyString: "b", propertyBoolean: false, propertyNumber: 2 }]);
      irpa_core.core.log(v.length);
      irpa_core.core.log(v);
      
      const n = irpa_core.variable.createList('number', [1,2,3,4]);
      irpa_core.core.log(n.length);
      irpa_core.core.log(n);

      Data%20type-%20Object

      Data type- Object

      Author's profile photo dang long
      dang long

      I organize code in project IRPA v.1
      - i create a "InitializeVariables.js" file
      - i definde a class by syntax var tap = (function(){ ... })()
      result : i can use this class any where in project

       

      how can i do that in V.2?

      Many thanks

      Author's profile photo Jerome GRONDIN
      Jerome GRONDIN

      Hello,

       

      Intelligent RPA 2.0 has a more LC/NC approach. Therefore, we do recommend not to use so many custom scripts whenever it is possible.

      If for some reason you really need to have a class declared like this, I suggest you do it in a custom script activity, and return it as an output (type ANY)

      Then, you should be able to access this class instance everywhere in your project, as it is stored in a local variable (Step1.output for example)

       

      Regards,

      J.