Thursday, July 9, 2015

Saving an OBIEE report on a Folder via Agent.

Here I have given steps to place OBIEE 11g report on a shared folder.
First step is to create an Agent.


We can directly go to the Delivery Content tab. Subject is not really necessary as we are not sending it in email. Select the report and format for the report to be placed.

No need to set the recipients or destinations. We need to create an post action in Actions tab. We will come back to that later. Now save this Agent.
We need to create a VB Script file as below and need to call it as a post action in the above agent.
_________________________________________________________________________________

'##=====================================================================
'## Title: Export Report
'## Rev: 1.0
'## Author: Swaminathan Vadivelu
'## Purpose:
'## 1. This script takes a file from OBIEE and saves to the file system
'## 2. Creates a reporting subdirectory if not already present
'##
'## Inputs (specified in Actions tab of OBIEE Delivers Agent):
'## 1. Parameter(0) - This actual file to be exported
'## 2. Parameter(1) - The file name specified within OBIEE
'##
'##=====================================================================

'##Create a variable and assign the base folder path where to store the file:
Dim sPath
sPath = "D:\Report Exports"
'##Remember the above path is either a shared folder or folder on OBIEE server.

Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")

'##check whether directory exists, if not create
Dim objDir
If Not objFSO.FolderExists(sPath) Then
Set objDir = objFSO.CreateFolder(sPath)
End If
Set objDir = Nothing

'##build string to get date in yyyy-mm-dd format
Dim sDate, sDateFull
sDate = Now
sDateFull = DatePart("yyyy", sDate) & "-"
If Len(DatePart("m", sDate))=1 Then sDateFull = sDateFull & "0" End If
sDateFull = sDateFull & DatePart("m", sDate) & "-"
If Len(DatePart("d", sDate))=1 Then sDateFull = sDateFull & "0" End If
sDateFull = sDateFull & DatePart("d", sDate)

'##Create a complete path with file name and add the date on the file name:
Dim sFileName
sFileName = sPath & "\" & Parameter(1) & "-" & sDateFull & ".xls"

'##Place the file on the folder:
Dim objFile
objFSO.CopyFile Parameter(0), sFileName, True
Set objFile = Nothing
Set objFSO = Nothing
_________________________________________________________________________________

Place this file on a path and call it from Agent. Create a Invoke Server script from Actions tab like below.

And set the VB script path and parameters as per the VB script.

Save the agent and run it. It will send the report in excel format to the folder specified in VB script.



If you want to schedule the agent after a ETL process or some other task, you can create a batch script and link it to the ETL process to run after the load. Refer this LINK.

2 comments:

  1. Hi
    Does it work if OBIEE installed on linux machine?
    Thanks

    ReplyDelete
  2. Hi
    Does it work if OBIEE installed on linux machine?Please Let me know if any extra steps need to follow for that
    Thanks

    ReplyDelete