Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
chandrasekarK
Participant
Hi all.

I have come up with another blog on SAP Intelligent RPA. In my previous blog , I have explained upon the process of Extracting Information from the Documents using SAP IRPA and Doc Parser.

Today in this blog, I would like to give a walkthrough for you all about Calling BAPI through SAP Intelligent RPA. I have my reference from the Mr. Vijay G and who had given a wonderful idea on using BAPI through IRPA and also from Mr Vijay sharma 's blog of Posting GL Entries using BAPI.

I was initially trying to automate a Transaction in SAP GUI where I need to get the data from System in order to generate a report. I had faced some difficulties in capturing and accessing the elements present in the screen. That's where I got the idea of accessing data through RFC for the function modules from my Senior and I gave it a shot. At last I was successfully able to call the BAPI to extract the data from the SAP System and also it saved me the multiple tasks of capturing and automating multiple screens.

Calling BAPI from SAP IRPA involves Simples steps as follows:

Step 1 : Create a new Project in SAP IRPA Desktop Studio.

Step 2 : Goto Workflow Perspective -> Create a new workflow -> Add the Custom activity.

Step 3 : Create the Required Context items to store your accessed data from the SAP System.


 

Here I have created a sample workflow with a custom activity named BAPI and i have created 3 array context variables to store the data from the RFC. Since the Data i am going to extract is whole table I am using array context.

Once you have created this , Save and Build the Project.

Step 4 : Goto the Scripts -> Select your Workflow Script file Which have been generated.

Open your JS file (Here Bapi.js). Goto the Custom activity code.

Establish Connection with your SAP System by using below code.
function getBAPI(){
var BAPI = new ActiveXObject("SAP.Functions");
var Connection = BAPI.Connection;
Connection.ApplicationServer = "Your Application Server IP";
Connection.SystemNumber = 'Your System Instance No';
Connection.Client = "Your Client ID";
Connection.User = "USERNAME";
Connection.Password = "PASSWORD";
Connection.logon(0, true);
return BAPI;
}

Replace your system in the Required Lines.

now call the Above func to establish the Connection.
var BAPI = getBAPI();

Now Add the RFC Function Module you want to call
var RFC = BAPI.Add("GET_FSYS_SINGLE"); 
RFC.Call();

Now You can access the Table data and Other Parameters inside the Function Modules.
var Result = RFC.tables("TF_FSYS_SINGLE");

for (var i=1;i<=Result.RowCount;i++){
var data = Result.Value(i,"FSYSNAME");
rootData.Name[i]=data;
}

for (var i=1;i<=Result.RowCount;i++){
var data = Result.Value(i,"CAPACITY");
rootData.Capacity[i]=data;
}

for (var i=1;i<=Result.RowCount;i++){
var data = Result.Value(i,"FREE");
rootData.Free[i]=data;
}

Here I have accessed the table named "TF_FSYS_SINGLE" in the Function Module "GET_FSYS_SINGLE".

The Data the table are iterated and stored in the Context array variables (Name,Capacity,Free).

The Full code can be found below.
function getBAPI(){
var BAPI = new ActiveXObject("SAP.Functions");
var Connection = BAPI.Connection;
Connection.ApplicationServer = "Your Application Server IP";
Connection.SystemNumber = 'Your System Instance No';
Connection.Client = "Your Client ID";
Connection.User = "USERNAME";
Connection.Password = "PASSWORD";
Connection.logon(0, true);
return BAPI;
}
var BAPI = getBAPI();
var RFC = BAPI.Add("GET_FSYS_SINGLE");
RFC.Call();
var Result = RFC.tables("TF_FSYS_SINGLE");

for (var i=1;i<=Result.RowCount;i++){
var data = Result.Value(i,"FSYSNAME");
rootData.Name[i]=data;
}

for (var i=1;i<=Result.RowCount;i++){
var data = Result.Value(i,"CAPACITY");
rootData.Capacity[i]=data;
}

for (var i=1;i<=Result.RowCount;i++){
var data = Result.Value(i,"FREE");
rootData.Free[i]=data;
}

 

Conclusion


The Data which have been stored in the context variable can be utilized anywhere in the project such using in Excel, sending Mails, generating reports, Integration with other systems, etc. I hope it helps you in using RFC with SAP IRPA. Share you feedbacks. Thank you

 

References :



  1. https://blogs.sap.com/2019/11/19/sap-intelligent-rpa-enablement-and-getting-started/

  2. https://blogs.sap.com/2020/03/24/an-overview-of-components-for-sap-intelligent-robotic-process-autom...

  3. https://blogs.sap.com/2019/12/06/call-sap-business-application-programming-interface-using-sap-intel...

  4. https://blogs.sap.com/2020/08/06/post-general-journal-entries-via-rfc-using-sap-intelligent-rpa/


2 Comments
Labels in this area