Documente Academic
Documente Profesional
Documente Cultură
Consulting
Oracle Solutions
Oracle Application users will be very familiar with the Applications concurrent
manager and how to use it to schedule Applications processes. Many users also use
Oracle Discoverer to generate reports from their applications data. This paper
describes how Oracle Applications Concurrent Processing can be used to schedule
Discoverer workbooks. The end user submits requests for a Discoverer report to the
concurrent manager and can view the report generated with the request output viewer.
Discoverer has a workbook scheduler built into the product but this is an alternative
approach to using the Discoverer scheduling. This approach uses the Discoverer
export functionality to generate reports in files that can be downloaded by the
Applications users.
Infrastructure Requirements
This solution requires that the Discoverer reports are produced in files and we must use the
Discoverer User Edition running on a Windows workstation to do this. The Discoverer User
Edition can be used to generate output in HTML or Excel files from the command line. The
Discoverer User edition can run on Windows NT/2000/2003/XP workstations and uses TNS
to connect to the database server.
Page 1 of 12
Cabot
Consulting
Oracle Solutions
The design allows many Discoverer exports to be processed simultaneously on one or more
Discoverer workstations. These workstations can be dedicated to processing Discoverer
scheduled workbooks providing a secure mechanism for generating Discoverer reports. Your
users dont need to connect to the Discoverer workstations; all the processing is completely
automatic, controlled from the database server.
The Applications Concurrent Manager retrieves request output from the Unix server and in
this architecture, the Unix server has a Samba drive which is shared with the Discoverer
workstations so that the Discoverer User Edition can write output directly onto the Unix
server.
Discoverer
Workstation
Scheduled Job
Exported File
Unix Server
Applications
Database
Samba
Drive
Scheduled workbook
concurrent request
Report
Output
End User
Workstation
Page 2 of 12
Cabot
Consulting
Oracle Solutions
The end users enter the details of the workbook being scheduled into the parameters of the
request. The schedule workbook request program has the following parameters:
Responsibility This is the responsibility that is used to process the workbook. The
responsibility can be different from the current responsibility, but this responsibility
must be assigned to the user who submits the request.
Workbook This can be any workbook in the database that the user can access that is
shared with the responsibility. The end user selects the workbook from a valueset that
lists all the workbooks in the EUL that the user can schedule.
Worksheet The name of the worksheet in the workbook to be processed.
Type The type of export required. Discoverer supports CSV, HTML and Excel
exports.
Parameter 1 to 8 Theses are the parameters to be applied when the workbook is
exported. In this solution up to 8 parameters can be specified for the export. Each
parameter for the Discoverer workbook is entered as a separate parameter into the
request. There are some limitations on the parameters that can be used, for example,
if the request is scheduled to run periodically then each time the workbook is
processed the parameters applied are the same. But more about parameters later.
Output Responsibility Optionally an alternative responsibility can be specified. This
allows the user entering the request to share the output of the report with other users.
An end user with this responsibility can view the output of the report but does not
necessarily have to have the privileges to run the report in Discoverer.
Description This is an optional description or title that will be given to the output
generated by this request.
An example showing the entry of a Discoverer scheduling request into the standard
concurrent request form is shown below. In this example, the Discoverer workbook requires 4
parameters. The name of the parameter and the value for the parameter is entered into a single
request parameter. If the name or value of the parameter contains spaces then the parameter
name or value must be enclosed in double quotes.
So to summarise, the end user schedules a new workbook by creating and saving the
workbook in the EUL, sharing the workbook with a responsibility and then submitting a
request giving the details of the workbook to be processed.
Page 3 of 12
Cabot
Consulting
Oracle Solutions
Frequently, the user will want to process a report with different combinations of parameters,
for example, to run a report once for each organisation or customer. Manually submitting
multiple requests into the concurrent manager would be impractical, and therefore the
solution allows the user to create many requests to process workbooks by using a scheduling
list workbook.
An example of a scheduling list workbook is shown below. In our example, the user wishes to
generate a report for each pay team. The scheduling list workbook returns a row for each
report that the user wishes to generate. There is a column in the workbook for each request
parameter and in addition the workbook contains a calculated item calling a custom submit
job function. This custom function is mapped into the EUL and submits a Discoverer
schedule workbook request to the concurrent manager when the workbook is processed.
Page 4 of 12
Cabot
Consulting
Oracle Solutions
In our example the user submits a single request to process the scheduling list workbook.
When this workbook is processed on the Discoverer workstation a further set of concurrent
requests are created to generate a report for each pay team. These requests are then processed
in turn by the concurrent manager creating all the reports required.
The end user can create the scheduling list workbook using an EUL folder that returns a row
for each pay team. Most of the items shown in the workbook would be calculated items
containing the text for the parameters of the workbook being scheduled.
The use of scheduling list workbook provides a convenient and flexible mechanism for
processing workbooks. In our example, if a new pay team was entered into the system the
workbook scheduling would not require any change. The new pay team would be included
automatically in the scheduling list workbook and hence a new Discoverer report would be
generated automatically for the new pay team.
Page 5 of 12
Cabot
Consulting
Oracle Solutions
Page 6 of 12
Cabot
Consulting
Oracle Solutions
Page 7 of 12
Cabot
Consulting
Oracle Solutions
The concurrent program does not process the Discoverer workbook; once the parameters have
been validated the request adds the workbook details to the scheduled jobs queue. The
schedule jobs queue is implemented as a database table as defined below. Initially, the job
status is set to WAITING.
CREATE TABLE XXDIS.XXDIS_SCHEDULE_QUEUE
(REQUEST_ID NUMBER(15,0) NOT NULL,
USER_NAME VARCHAR2(100),
RESPONSIBILITY_NAME VARCHAR2(100),
WORKBOOK VARCHAR2(240) NOT NULL,
WORKSHEET VARCHAR2(240) NOT NULL,
WORKBOOK_TYPE VARCHAR2(10) DEFAULT 'HTML',
PARAMETER1 VARCHAR2(240),
PARAMETER2 VARCHAR2(240),
PARAMETER3 VARCHAR2(240),
PARAMETER4 VARCHAR2(240),
PARAMETER5 VARCHAR2(240),
PARAMETER6 VARCHAR2(240),
PARAMETER7 VARCHAR2(240),
PARAMETER8 VARCHAR2(240),
STATUS VARCHAR2(20) NOT NULL DEFAULT 'WAITING',
START_DATE DATE,
WORKSTATION VARCHAR2(100),
PROCESSED_BY VARCHAR2(100),
COMPLETION_DATE DATE,
COMPLETION_MESSAGE VARCHAR2(2000),
CONSTRAINT XXDIS_SCHEDULE_QUEUE_PK PRIMARY KEY (REQUEST_ID) USING INDEX )
The end users can develop scheduling list workbooks; a workbook containing a list of
workbooks that need to be processed. These workbooks call a SUBMIT_JOB function that
submits a request to the concurrent manager.
This PL/SQL SUBMIT_JOB function is mapped into the Discoverer EUL and uses the
standard Oracle API to create a new concurrent request to process the Discoverer workbook
that have been supplied in parameter to the function. The end user can call this function by
creating a calculated item in a workbook. The function then checks which Application user is
running the workbook, so that only when the workbook is run on the Discoverer workstations
are the new concurrent requests created.
Page 8 of 12
Cabot
Consulting
Oracle Solutions
Set tkgoDB =CreateObject("ADODB.Connection")
' open a connection to the database
msConnect = "UID=" & gsUser & ";PWD=" & gsPassword & ";CONNECTSTRING=" & gsInstance
tkgoDB.Open "Driver={Microsoft ODBC for Oracle};" & msConnect
Do While True
' Check if there is a job to process
Set moRS=tkgoDB.execute( _
"SELECT apps.xxdis_schedule_pkg.start_job REQUEST_ID FROM dual")
moRS.MoveFirst
msRequest = moRS("REQUEST_ID")
' If no jobs then exit
If msRequest = "0" Then
Exit Do
End If
The START_JOB function checks the queue for any jobs that are to be processed. The code
below shows the start of the START_JOB PL/SQL function.
FUNCTION start_job RETURN VARCHAR2
IS
PRAGMA AUTONOMOUS_TRANSACTION;
v_request_id
NUMBER(15);
BEGIN
-- lock table to prevent any other sessions trying to select the min request id
LOCK TABLE XXDIS.XXMDIS_SCHEDULE_QUEUE IN SHARE ROW EXCLUSIVE MODE;
-- find the next job
SELECT request_id
INTO v_request_id
FROM xxmod.xxdis_schedule_queue
WHERE request_id = (SELECT MIN(request_id)
FROM xxdis.xxdis_schedule_queue
WHERE status = 'WAITING')
FOR UPDATE;
The START_JOB function then updates the schedule queue table adding the details of which
workstation and Application user is processing the request. The function then returns the
number of the request being processed to the workstation.
-- Release lock
COMMIT;
RETURN (v_request_id);
EXCEPTION
WHEN NO_DATA_FOUND THEN
COMMIT;
RETURN (0);
END start_job;
The VB script then gets the details of the workbook that needs to be exported from a database
view. The database view below returns the Discoverer export command that is to be
processed.
Page 9 of 12
Cabot
Consulting
Oracle Solutions
CREATE OR REPLACE VIEW XXDIS_EXPORT_CMD_V
AS
SELECT xq.request_id, TRANSLATE(
'/CONNECT '||xq.processed_by||':"'||xq.responsibility_name||
'"/'||NVL(fu.email_address, 'password')||'@$TNS$'||
'/OPENDB "'||xq.workbook||'" '||
'/SHEET "'||xq.worksheet||'" '||
CASE WHEN xq.parameter1 IS NOT NULL THEN '/PARAMETER '||parameter1||'
CASE WHEN xq.parameter2 IS NOT NULL THEN '/PARAMETER '||parameter2||'
CASE WHEN xq.parameter3 IS NOT NULL THEN '/PARAMETER '||parameter3||'
CASE WHEN xq.parameter4 IS NOT NULL THEN '/PARAMETER '||parameter4||'
CASE WHEN xq.parameter5 IS NOT NULL THEN '/PARAMETER '||parameter5||'
CASE WHEN xq.parameter6 IS NOT NULL THEN '/PARAMETER '||parameter6||'
CASE WHEN xq.parameter7 IS NOT NULL THEN '/PARAMETER '||parameter7||'
CASE WHEN xq.parameter8 IS NOT NULL THEN '/PARAMETER '||parameter8||'
'/EXPORT '||xq.workbook_type||
' "$SAMBA$\o'||TO_CHAR(xq.request_id, 'fm999999999990')||'.out" '
'/LOGFILE l'||TO_CHAR(xq.request_id, 'fm999999999990')||'.log '||
'/BATCH', CHR(10)||chr(13), ' ') cmd
FROM xxdis.xxdis_schedule_queue xq, fnd_user fu
WHERE xq.processed_by = fu.user_name (+);
'
'
'
'
'
'
'
'
END
END
END
END
END
END
END
END
||
||
||
||
||
||
||
||
Notice that in this implementation the password of the dummy Application user is held in the
email address field of the Application user. This is just a convenient place to hold the
unencrypted password that Discoverer will need to connect as the Application user.
The code fragment below shows how the VB script uses the Discoverer User Edition
command line to run the export command. The VB script uses the Discoverer /CMDFILE
command and a command file to overcome the limitations of the Windows command line.
' Process job
Set moRS=tkgoDB.execute( _
"SELECT cmd EXPORT_CMD FROM apps.xxdis_export_cmd_v " & _
"WHERE request_id = " & msRequest)
moRS.MoveFirst
msExpCmd = moRS("EXPORT_CMD")
' write command into a temporary file
msCmdFile = "r" & msRequest & ".cmd"
Set moOutputStream = tkgoFileSystem.CreateTextFile(msCmdFile, True)
' Substitute $SAMBA$ and $TNS$ locally configured variables
moOutputStream.Write Replace(Replace(msCmd, "$SAMBA$", gsOutDir),_
"$TNS$", gsInstance) & vbCRLF
moOutputStream.Close
' Call Discoverer to process the command
msCommand = gsBinDir & gsDiscoExe & " /EUL " & gsEUL &
The script goes on to create a log file for the job and calls a COMPLETE_JOB PL/SQL
function to set the status of the job to COMPLETED in the database.
Page 10 of 12
Cabot
Consulting
Oracle Solutions
'HTML'
'PDF'
'XLS'
'TXT'
'TEXT'
'CSV'
'XML'
THEN 'text/html'
THEN 'application/pdf'
THEN 'application/vnd.ms-excel'
THEN 'text/plain'
THEN 'text/plain'
THEN 'application/vnd.ms-excel'
THEN 'application/vnd.ms-excel'
ELSE 'text/html'
END, FALSE, 'ISO-8859-1');
Finally, you will need a function to build the URL that contains a call to the
DOWNLOAD_FILE function. The function returns a URL that loads the request output into a
new browser window. The function below can be mapped into the EUL and returns a URL
that can be used as a hyperlink in Discoverer workbooks. You will need to set the content
type of the item to be FILE in the EUL for Discoverer to recognise the item as a hyperlink
in the workbook.
-- return download output file URL
FUNCTION download_ourl (p_request_id IN NUMBER,
p_filetype IN VARCHAR2) RETURN VARCHAR2
IS
BEGIN
RETURN
fnd_profile.VALUE('APPS_WEB_AGENT')||'/xxdis_report_output_pkg.download_file?'||
'F='||xxdis_encrypt_pkg.encrypt_name('o'||TO_CHAR(p_request_id,
'fm099999')||'.out')||'&'||
'T='||p_filetype||'&'||
'D=OUT';
END download_ourl;
Notice that the procedure and the function use a custom package to encrypt the filename
appearing in the URL. The filename is encrypted for two reasons; the filename in the URL
cannot be changed by an end user and only alphanumeric characters are used to define the
filename in the URL. This package is a wrapper around the
DBMS_OBFUSCATION_TOOLKIT encryption package and the encrypt and decrypt
functions are shown below.
Page 11 of 12
Cabot
Consulting
Oracle Solutions
g_key
Further considerations
There are a number of areas where the solution may need to be adapted to meet more specific
requirements.
Workbook Processing The solution can be extended to carry out further processing on the
Discoverer workstations. Adobe Acrobat and the Discoverer print command can be used to
generate Discoverer reports in PDF. This may be required because PDF is not a Discoverer
export option for Application users. The Discoverer workstation could also be used to
automatically email reports to other users and mail merge Discoverer output into documents.
Report Output Distribution Many end users may wish to retrieve reports directly, for
example, through a portal, rather than using a Discoverer report to select and download output
from a request. The Discoverer workstations can be used to produce HTML reports and then
it is straightforward to use the DOWNLOAD_FILE function shown above and database
views to build the Discoverer reports into a web based application. Hence this type of
Discoverer scheduling can be used to maintain reports, for example, on a corporate web site.
Page 12 of 12