The query occasionally arises of how to automate the generation of a report.
Command line switches can be applied to the report viewer to allow a report to be executed directly from a command line, rather than from a user having to manually execute the report.
Below is a list of command line switches that are available when running the report viewer.
-A<ConnectionName> - This is the connection name the report viewer should use when executing the report. The connection name identifies the SQL server, database and SQL connection credentials. If you do not want to specify the connection name, there are switches that allow the SQL details to be specified directly.
-R<Report file name> - This switch specifies which report needs to be executed and must point to the .RTM file.
-S<parameter> - If there are parameters that are attached to the report, you need to specify the values the report should use when it is executed. If you have multiple parameters the name and value need to be separated by a comma (i.e PARAMETERNAME1=VALUE1,PARAMETERNAME2-VALUE2).
-U<username> - The Report Writer username that needs to be used when executing the report.
-P - Preview the report rather than print to the default printer.
-SERVER<SQL Server Name> - The name of the SQL server if you choose not to use the -A<ConnectionName> parameter.
-DB<Databasename> - The name of the database to connect to if you are not using the -A<ConnectionName> parameter.
-DBUser<SQL Database User> - The SQL user that should be used when connecting to the database if you are not using the -A<ConnectionName> parameter.
-DBPWD<SQL Database User Password> - The password of the SQL user specified with the -DBAUser parameter that the system will use if you do not use the -A<ConnectionName> parameter.
Below is an example of the command line script that is run when a job card is printed from within Eralis Job:
C:\Program Files (x86)\SAP\SAP Business One\AddOns\Eralis Software\Eralis Job Costing\Reports\EnpriseReportViewer.exe
-SERVER=REM-JAMESB
-DB=SBO_Test
-DBUSER=sa
-DBPWD=sa
-P
-RC:\Program Files (x86)\SAP\SAP Business One\AddOns\Eralis Software\Eralis Job Costing\Reports\JobCard.RTM
-S{CURRENT=10040}
We have found that storing the reports in the standard folder structure does create a long command line string that can create problems. We recommend moving the reports that you want to run automatically, along with the report writer executable, to another directory with an easier path.
If you do this, please be aware that you will need the following files for the program in the same directory:
EnpriseReportViewer.exe
EnCryptLib.dll
Enconnect.ini
For this example, I have moved the files into a new directory C:\REPORTS. This changes the command string that needs to be executed to:
C:\report\EnpriseReportViewer.exe -SERVER=REM-JAMESB -DB=SBO_Test -DBUSER=sa -DBPWD=sa -P -RC:\report\JobCard.RTM -S{CURRENT=10040}
The next step in the process is to set up the auto execution of the report. To do this, use the standard Windows Task Scheduler which takes you through a wizard to establish what needs to be run and how frequently.
After that the report is executed on a daily basis.
Comments
0 comments
Please sign in to leave a comment.