Maximo | Scheduling, Generating & Posting a report to server | #Maximo #AutomationScript #Cron
Scenario :
Schedule a report to be saved in the server for user access. As user does not
want to run and download a report every time.
1. Create
a path in server.
2. Create
a script to create a report and post.
3.
Associate the created script as a parameter to the cron.
Lets roll!
1. Create
a folder under F drive in the server box:
2. Create
a script:
Go To Automation script and Click on Create Script > Script. This being a cron script it would not need a launchpoint.
Script =
CUSREPORTGEN
Description
= To write a Report file
Script
Language = Jython
----Sample
code looks like below----
#Library
from psdi.mbo import MboConstants
from com.ibm.tivoli.maximo.report.birt.runtime
import ReportParameterData
from com.ibm.tivoli.maximo.report.birt.admin
import ReportAdminServiceRemote
from psdi.server import MXServer
from java.io import File,FileOutputStream
from java.text import SimpleDateFormat
from java.util import Date
from java.util import Calendar
# Defining
services
userInfo =
MXServer.getMXServer().getSystemUserInfo()
reportAdminService
= MXServer.getMXServer().lookup("BIRTREPORT")
date=str(date.today())
# Report
Parameter details
parameterData
= ReportParameterData()
parameterData.addParameter("SITEID","TESTSITE")
#More
parameters can be added as per requirement
# Report
details
reportParam
= File("F:\REPORTS\WOREPORTS","WOReportTestN_" + date +
".pdf")
reportOutput
= reportAdminService.runReport(userInfo, "TestReport.rptdesign",
"WOTRACK", parameterData, reportParam.getName(), "pdf")
fileOutput
= FileOutputStream(reportParam.getAbsolutePath())
# Report
Generation and adding in server folder
try:
fileOutput.write(reportOutput)
fileOutput.flush()
finally:
fileOutput.close()
3. Script
association to cron:
Go To --> System Configuration --> Platform Configuration -->Cron Task Setup
Click on
New Cron Task Setup
Cron Task
= REPORTGENCRON
Description
= Cron for writing a Report
Class =
com.ibm.tivoli.maximo.script.ScriptCrontask
Access
Level = FULL
Cron Task
Instance Name = REPORTGENCRONTASK
Description
= Task for Cron
Schedule =
1d,0,30,12,*,*,*,*,*,*
Run as
User = MAXADMIN
Active = 1
Keep
History = 1
Max Number
of History Records = 10000
SCRIPTARG
= None
SCRIPTNAME
= CUSREPORTGEN
--Check after the cron runs in the folder path for the report pdf file.
###THANKYOUU###
***************************************************************************************************************************************
Nice one. Thanks for sharing with us ☺️
ReplyDelete