Sometimes you have the need to start a report execution in Cognos when the relevant ETL jobs are finished. In order to do this Cognos offers a tool called the trigger.bat. With this tool it is possible to start jobs or reports by external access. Normally it is installed on the Cognos Server in the following path:
<cognos install directory>\webapps\utilities\trigger\trigger.bat
If you want to run a report with the trigger.bat you first need to go to your report in Cognos and then configure a schedule. In the scheduling properties you have to set up a schedule by trigger. You simply need to type in a trigger name. This is needed in order to pass it to the trigger.bat which then runs the specific report.
The syntax for running a report with the trigger.bat utility is like this:
trigger.bat <cognos dispatcher> <User> <Password> <Namespace> <Trigger Name> |
This method works fine as long as you want to use the trigger.bat on the Cognos server. If you have a separate server for the ETL processing it’s not as easy as described above.
In this case you should create a directory on the ETL server in which you copy several things:
- The complete trigger-directory
- Files out of the following directory: <cognos install dir>\webapps\p2pd\WEB-INF\lib
- activation.jar
- axis.jar
- axisCrnpClient.jar
- commons-discovery-0.2.jar
- commons-logging-1.1.jar
- commons-logging-adapters-1.1.jar
- commons-logging-api-1.1.jar
- jaxrpc.jar
- mail.jar
- saaj.jar
- serializer.jar
- wsdl4j-1.5.1.jar
- The JRE directory of Cognos installation: <cognos install dir>\bin\jre. If you have the same JRE installed on your ETL server as on the Cognos server it should work fine with it too.
You should copy the content of the trigger-directory directly to you target directory and the jar-files and the JRE should go to separate sub-directories. When you have that you have to edit the trigger.bat:
set JAVA_HOME=d:/trigger_test/jre/7.0/ set JAR_HOME=d:/trigger_test/lib set CLASSPATH=d:/trigger_test/ set CLASSPATH=%CLASSPATH%;%JAR_HOME%/activation.jar set CLASSPATH=%CLASSPATH%;%JAR_HOME%/axis.jar set CLASSPATH=%CLASSPATH%;%JAR_HOME%/axisCrnpClient.jar set CLASSPATH=%CLASSPATH%;%JAR_HOME%/commons-discovery-0.2.jar set CLASSPATH=%CLASSPATH%;%JAR_HOME%/commons-logging-1.1.jar set CLASSPATH=%CLASSPATH%;%JAR_HOME%/commons-logging-adapters-1.1.jar set CLASSPATH=%CLASSPATH%;%JAR_HOME%/commons-logging-api-1.1.jar set CLASSPATH=%CLASSPATH%;%JAR_HOME%/jaxrpc.jar set CLASSPATH=%CLASSPATH%;%JAR_HOME%/mail.jar set CLASSPATH=%CLASSPATH%;%JAR_HOME%/saaj.jar set CLASSPATH=%CLASSPATH%;%JAR_HOME%/serializer.jar set CLASSPATH=%CLASSPATH%;%JAR_HOME%/wsdl4j-1.5.1.jar „%JAVA_HOME%bin/java.exe“ -classpath %CLASSPATH% d:/trigger_test/Trigger %1 %2 %3 %4 %5 |
You have to edit the bold marked lines. The JAVE_HOME hast to be set to the JRE dir. The JAR_HOME must point to the directory with the copied jar-files. The third bold marked line should be set to your created directory where the trigger.bat is located. The last bold line must be edited in the way that it points to the Trigger.class file (which is also located in the created directory).
The example above assumes that we have created the directory trigger_test on drive d: (windows machine). We copied the trigger directory of the Cognos server directly to this directory and created a sub-directory lib with the copied jar-files and a sub-directory JRE with the JRE of the Cognos Server.
Now we can run the trigger.bat also on the ETL server and it is possible to start Cognos reports as the last step in an ETL process for example.
If you are interested in this or other advanced Cognos/SQL topics you can also attend training on my corporate homepage. At the moment my open courses are only available in German. Inhouse training and online courses are also available in English language. So check out my open trainings (German) or my online courses (English)!