Friday, June 29, 2012

Chaining iBots to Purge and Build Cache

This can be obtained by following steps;


1. Create a purging cache report from the direct database request;

           The steps are elaborated in the previous post.



2. Create the iBot for the report whom cache is required to be build;


3. Now create an iBot and add the purging cache report in the conditional request;



4. In the next step chain the iBot for whom the cache is required to be built in the advanced Tab of the iBot.



5. Schedule as required.

When the iBot will run it will purge the cache first and then build the cache.

Cheers and Long Live Pakistan ;)



Purging Cache in the Answers using Direct Database Request:

In order to purge cache using direct request create a new database in repository as follows;

1 )      Set Database to “ODBC Basic”
2 )      Check “Allow Direct Database Request by Default”



Next Step is to add connection pool in the database as follows;
1)      Set Call Interface to “ODBC 2.0”
2)      Set Data Source Name to “Analytics Web”
3)      Add username and password

In the next step create a direct database request and add following;
To Purge the whole cache;
1)      Add Call SAPurgeAllCache(); in the SQL Statement
2)      Provide connection poll information



To Purge cache by Query;
1)      Add Call SAPurgeAllCache(‘SQL QUERY’); in the SQL Statement
e.g. Call SAPurgeCacheByQuery('SELECT Ledgers."Charge #" saw_0 FROM Payments ORDER BY saw_0');
The query can be obtained from the Manage Session window in the administration;


2)      Provide connection poll information



To Purge cache by Table;
1)      Add Call SAPurgeCacheByTable (‘TABLE NAME’); in the SQL Statement
e.g. Call SAPurgeCacheByTable( ‘CHARGES’);

2)      Provide connection poll information

To Purge cache by Database;
1)      Add Call SAPurgeCacheByDatabase (‘DATABASE NAME’); in the SQL Statement
e.g. Call SAPurgeCacheByDatabase( 'SEQUELMED' );

2)      Provide connection poll information


Purge Cache report can also be added as a link on the dashboard to purge cache at any time;


Furthermore purge cache report can also be added in the conditional request of an iBot to schedule purging.

Cheers and Long Live Pakistan ;)

Wednesday, June 27, 2012

Setting up iBot to save report to a folder


Here are the steps;


Create a JavaScript file with below contents name it "savetofile.js" and save it at \\bise1\bi\server\Scripts\Common ;

var FSO = new ActiveXObject("Scripting.FileSystemObject");
//var foldername = GetConfigurationValue("Log Dir", "iBots") + "\\" + UserID
var foldername = "\\Reports"
var rptname;
with (new Date) {
rptname = ((((getFullYear() * 100 + getMonth() + 1) * 100 + getDate()) * 100 + getHours()) * 100 + getMinutes()) * 100 + getSeconds();
}
if (FSO.FolderExists(foldername))
{
var fileName = foldername + "\\" + "RPT_" + rptname + Parameter(1) + Parameter(2);
var fooFile = FSO.CopyFile(Parameter(0), fileName, true);
}
else
{
FSO.CreateFolder(foldername);
//var fileName = foldername + "\\" + JobID + "-" + InstanceID + "-" + Parameter(1);
var fileName = foldername + "\\" + "RPT_" + rptname + Parameter(1) + Parameter(2);
var fooFile = FSO.CopyFile(Parameter(0), fileName, true);
}



Step 1: Create an iBot and set schedule as required;



Step 2: Select Delivery Contents for iBot and select send content as “Attachement(PDF)”



Step 3: Select Email for the Specific Devices in the destination Tab;



Step 4: In the advanced tab select Add Action and then Custom Script



Step 5:
In the file name add “savetofile.js”
Select “Pass Delivery content to script” in the radio button
In the other parameter add two text boxes. In the first box add file name and in the second box add file extension and click OK



Step 6: Save the iBot



Step 7: The report will be saved in the directory “C:\Reports”
File will be named with following convention;
RPT_DATETIME_REPORTNAME.EXTENSION



Step 8: Done and the iBot will look like this;



Cheers & Long Live Pakistan ;)