Sunday, 15 January 2017

Copy Results to the File System - Using Java Scipt (Windows Only)

Oracle Business Intelligence 11g, doesn’t provide any built-in method to allow Agent to automatically export/archive OBIEE11g content(Entire Dashboard(or) Dashboard Page(or) Analysis(or) Conditional Report of Agent(or) even Briefing Book) to file system. Ideally there should be a "Destination" of file/FTP added to New Agent screens just like BI Publisher allows FTP. Although this can be done by linking an action to the agent which invokes Java Scripts, VB Scripts, EJBs (Java), etc.. which physically move the OBIEE11g content to the file system.

Action Framework of OBIEE 11g opens up direct integration with Java. So, any process that can be called via Java can be directly called from OBIEE 11g as well. This example configures a java script for the Oracle BI Scheduler that copies the results of an agent to another directory. The script copies the temporary file that contains the results of the Conditional Request to the agent log directory. The JobID, InstanceID, and UserID are used in the file name to guarantee that the result sets do not overwrite each other with each execution of the agent, for each user, or for other agents that share this script.

The below example script uses the following values:
  • The agent is run as an Administrator privileges.
  • The agent log directory on the Oracle BI Scheduler computer is $ORACLE_INSTANCE\diagnostics\logs\OracleBISchedulerComponent\coreapplication_obisch1
  • The output of this example, after the agent is run, is a file on the Oracle BI Scheduler computer called $ORACLE_INSTANCE\diagnostics\logs\OracleBISchedulerComponent\coreapplication_obisch1\101-1208-weblogic-Script1.PDF
  • For all script jobs from chained agents, the full path name to the temporary file is specified in Parameter(0)
The script is as below,

/////////////////////////////////////////////////////////////
//
// createResultFile.js
//
// Copies the results in the temporary file to a new file name
//
// Parameter(0) = Agent Result File Path
// Parameter(1) = Last Part of Output File Name (no path)
//
/////////////////////////////////////////////////////////////
var FSO = new ActiveXObject("Scripting.FileSystemObject");
var fileName = GetConfigurationValue("Log Dir", "iBots") + "\\" + JobID + "-" + InstanceID + "-" + UserID + Parameter(1);
var fooFile = FSO.CopyFile(Parameter(0), fileName, true);

Configure custom script properties for agents:

  • On the Home page in Oracle BI EE, click the New menu and select the Agent option.
  • Click Create and Browse to select an analysis Click OK..

  • Display the Actions tab and click the Add New Action icon and select the Invoke Server Script menu option.
  • Select the first row of parameters and click the Delete button.
  • Click the Add Document Parameter icon.
  • Enter properties for the parameter as displayed below.
  • Use the plus icon to display a new row for a second parameter.
  • Enter properties for the parameter as displayed below.
  • Click Ok and Save the agent.
  • Now run the agent.
  • Verify the file is generated at the above mentioned location i.e. $ORACLE_INSTANCE\diagnostics\logs\OracleBISchedulerComponent\coreapplication_obisch1\

Where,
JobID: Returns the job identification number that is associated with this instance which in this example is 5
InstanceID: Returns the instance identification number that is associated with this instance. Here it is 27
UserID: Returns the user identification number that is associated with the instance which is weblogic in this case
In the next article, we will see how to configure an agent with VB Script to export a report / dashboard to a shared location.

No comments:

Post a Comment