var cn = new ActiveXObject("ADODB.Connection"); // object for connection
var rs = new ActiveXObject("ADODB.Recordset"); // object for record set
var strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source = 'C:\\BotDevelopment\\Sample\\local\\POs.xlsx';Extended Properties='Excel 12.0;HDR=Yes'";
cn.Open(strConn);
//In the below queries "Supplier" and "Quantity" is the name of the column in excel workbook and "Sheet1" is the name of the worksheet.
var SQL = "select * from [Sheet1$] where [Supplier] is not NULL"; //Only to read rows where Supplier Value is provided
var SQL = "select [Supplier],[Quantity] from [Sheet1$]"; // To select data for Supplier and Quantity column
rs.Open(SQL, cn);
var index=0; // index variable to loop a array
while(rs.EOF != true){ // till record is present in the recordset
rootData.PODetails[index] = ctx.dataManagers.rootData_PODetails.create() ; //rootData.PODetails is an array defined in SAP Intelligent RPA Context
rootData.PODetails[index].Supplier=rs("Supplier").value; //rs("Supplier").value is the Supplier value in the current record
rootData.PODetails[index].Quantity=rs("Quantity").value; //rs("Quantity").value is the Quantity value in the current record
ctx.log(rs("Supplier").value,e.logIconType.Info); // to print Supplier value in log
ctx.log(rs("Quantity").value,e.logIconType.Info); // to print Quantity vaue in log
rs.MoveNext(); // move to nect record in the current record set.
index++;
}
var index=0;
while(rs.EOF != true){
rootData.PODetails[index] = ctx.dataManagers.rootData_PODetails.create() ;
rootData.PODetails[index].Supplier=rs("F1").value; //rs("F1") denotes the first column of the recorset
rootData.PODetails[index].Quantity=rs("F4").value;//rs("F4") denotes the fourth column of the recorset
ctx.log(rs("F1").value,e.logIconType.Info);
ctx.log(rs("F4").value,e.logIconType.Info);
rs.MoveNext();
index++;
}
rs.Close(); //close record set
cn.Close(); // close connection
GLOBAL.step({ Custom: function(ev, sc, st) {
var rootData = sc.data;
ctx.workflow('ReadData', 'd845b031-08eb-489a-90dd-8bbd16f0f399') ;
// Custom
var cn = new ActiveXObject("ADODB.Connection");
var strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source = 'C:\\RPAProject\\Sample\\local\\POs_Old.xlsx';Extended Properties='Excel 12.0;HDR=Yes'";
cn.Open(strConn);
var rs = new ActiveXObject("ADODB.Recordset");
var SQL = "select * from [Sheet1$] where [Supplier] is not null";
rs.Open(SQL, cn);
var index=0;
while(rs.EOF != true){
rootData.PODetails[index] = ctx.dataManagers.rootData_PODetails.create() ;
rootData.PODetails[index].Supplier=rs("Supplier").value;
rootData.PODetails[index].Quantity=rs("Quantity").value;
ctx.log(rs("Supplier").value,e.logIconType.Info);
ctx.log(rs("Quantity").value,e.logIconType.Info);
rs.MoveNext();
index++;
}
rs.Close();
cn.Close();
sc.endScenario();
sc.endStep(); // end Scenario
return;
}});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
37 | |
25 | |
17 | |
13 | |
7 | |
7 | |
7 | |
6 | |
6 | |
6 |