If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Saving report output to file system outside cognos using SDK

Started by KavitaPrasad, 25 Mar 2013 05:02:53 AM

Previous topic - Next topic

KavitaPrasad

Hi,
I have a requirement to generate and save a report through cognos sdk at a particular location in hard disk, say c:\ReportOutput. I have configured this path in cognos connection and administration as well. Below are the run options that I am setting for this:

   /* option to save output */
      RunOptionBoolean repSaveOutput = new RunOptionBoolean();
      repSaveOutput.setName(RunOptionEnum.archive);
      repSaveOutput.setValue(true);
      reportRunOptions[0] = repSaveOutput;
     
      ArchiveOptionSearchPathSingleObject repSaveAs = new ArchiveOptionSearchPathSingleObject();
      repSaveAs.setName(ArchiveOptionEnum.archiveLocation);
      repSaveAs.setValue(new SearchPathSingleObject("/configuration/archiveLocation[@name='Store-1']"));
      reportRunOptions[1] = repSaveAs;
     
      /* option to choose the output file name */
      MultilingualToken[] reportSaveNames = new MultilingualToken[1];
      MultilingualToken reportName_enUS = new MultilingualToken();
      reportName_enUS.setLocale("en-US");
      reportName_enUS.setValue("report-1");
      reportSaveNames[0] = reportName_enUS;

      ArchiveOptionString aos = new ArchiveOptionString();
      aos.setName(ArchiveOptionEnum.filenameStub);
      aos.setValue(reportName_enUS.getValue());
      reportRunOptions[2] = aos;

      ArchiveOptionConflictResolution aocr = new ArchiveOptionConflictResolution();
      aocr.setName(ArchiveOptionEnum.conflictResolution);
      aocr.setValue(ArchiveConflictResolutionEnum.replace);
      reportRunOptions[3] = aocr;

      /* option to choose the output format e.g., pdf, html, csv */
      RunOptionStringArray repOutputFormat = new RunOptionStringArray();
      repOutputFormat.setName(RunOptionEnum.outputFormat);
      repOutputFormat.setValue(new String[] {"PDF"});
      reportRunOptions[4] = repOutputFormat;

      /* set report orientation ( only for PDF format) */
      RunOptionString repOrientation = new RunOptionString();
      repOrientation.setName(RunOptionEnum.outputPageOrientation);
      repOrientation.setValue("landscape");
      reportRunOptions[5] = repOutputFormat;

      /* option to choose the primary time period threshold to wait till the report is generated */
      AsynchOptionInt primaryWaitValue = new AsynchOptionInt();
      primaryWaitValue.setName(AsynchOptionEnum.primaryWaitThreshold);
      primaryWaitValue.setValue(7);
      reportRunOptions[6] = primaryWaitValue;

      /* option to choose the secondary time period threshold to wait till the report is generated */
      AsynchOptionInt secondaryWaitValue = new AsynchOptionInt();
      secondaryWaitValue.setName(AsynchOptionEnum.secondaryWaitThreshold);
      secondaryWaitValue.setValue(30);
      reportRunOptions[7] = secondaryWaitValue;

But I am getting NullPointerException while running the report as below :

AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode:
faultString: Exception in Automated Report, InvokeReport API; nested exception is:
   java.lang.NullPointerException
faultActor:
faultNode:
faultDetail:
   {http://xml.apache.org/axis/}hostname:kavprasa

Exception in Automated Report, InvokeReport API; nested exception is:
   java.lang.NullPointerException
   at com.ibm.retail.xc.report.automated.InvokeReportAPIForPOS.runReport(InvokeReportAPIForPOS.java:652)
   at com.ibm.retail.xc.report.automated.InvokeReportAPIForPOS.init(InvokeReportAPIForPOS.java:371)
   at com.ibm.retail.xc.report.automated.InvokeReportAPIForPOS.main(InvokeReportAPIForPOS.java:907)
Caused by: java.lang.NullPointerException
   at com.cognos.org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:223)
   at com.cognos.org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:130)
   at com.cognos.org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1088)
   at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
   at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
   at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
   at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
   at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
   at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
   at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
   at com.cognos.org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:228)
   at com.cognos.org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:699)
   at com.cognos.org.apache.axis.Message.getSOAPEnvelope(Message.java:436)
   at com.cognos.org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:797)
   at com.cognos.org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:145)
   at com.cognos.org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
   at com.cognos.org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:119)
   at com.cognos.org.apache.axis.SimpleChain.invoke(SimpleChain.java:84)
   at com.cognos.org.apache.axis.client.AxisClient.invoke(AxisClient.java:166)
   at com.cognos.org.apache.axis.client.Call.invokeEngine(Call.java:2785)
   at com.cognos.org.apache.axis.client.Call.invoke(Call.java:2768)
   at com.cognos.org.apache.axis.client.Call.invoke(Call.java:2444)
   at com.cognos.org.apache.axis.client.Call.invoke(Call.java:2367)
   at com.cognos.org.apache.axis.client.Call.invoke(Call.java:1813)
   at com.cognos.developer.schemas.bibus._3.ReportServiceStub.run(ReportServiceStub.java:7578)
   at com.ibm.retail.xc.report.automated.InvokeReportAPIForPOS.runReport(InvokeReportAPIForPOS.java:600)

Cognos log shows these messages :

9.124.39.195:9300   7652   2013-03-25 15:20:03.240   +5:30   7BF211C1AAC976302892385A88301FCF32DB37FC   4yMlq2Gd8qMylhC4lhqd9ly2Glw2dsvMvw4sqvqq   4yMlq2Gd8qMylhC4lhqd9ly2Glw2dsvMvw4sqvqq      7440   RSVP   4707   1   Audit.RTUsage.RSVP   Response   Report ReportService   /content/package[@name='POSReports']/report[@name='PRICE MODIFICATION REPORT']   Failure   RSV-SRV-0063 An error occurred while executing the 'asynchRun_Request' command.    
9.124.39.195:9300   7652   2013-03-25 15:20:03.240   +5:30   7BF211C1AAC976302892385A88301FCF32DB37FC   4yMlq2Gd8qMylhC4lhqd9ly2Glw2dsvMvw4sqvqq   4yMlq2Gd8qMylhC4lhqd9ly2Glw2dsvMvw4sqvqq      2220   RSVP   4707   1   Audit.RTUsage.RSVP   Response   Report ReportService      Failure   RSV-SRV-0066 A soap fault has been returned.


The code runs fine if I give the output path inside cognos package.
Can anybody please suggest me on what might be going wrong here.

KavitaPrasad

I could run the program successfully by setting the below attributes for report filter:

Map.Entry<String, String> parameterKeyVal = (Map.Entry<String, String>)paramCounter.next();
SimpleParmValueItem[] item1_parm1 = new SimpleParmValueItem[1];
item1_parm1[0] = new SimpleParmValueItem();
item1_parm1[0].setUse((String)parameterKeyVal.getValue());
item1_parm1[0].setDisplay((String)parameterKeyVal.getValue());
item1_parm1[0].setInclusive(true);

dew

Hi.

Not sure if you have come right with this however here is some steps for doing this.  (there might be a better way)


Step 1 - Run the reports, and save the outputs to the content store
You must set each report's runOption to saveOutput = true)

RunOptionBoolean saveOutput = new RunOptionBoolean();
saveOutput.setName(RunOptionEnum.saveOutput);
saveOutput.setValue(true);
runOptions[index] = saveOutput;


its a good idea to check the AsynchReply for when the service is done with saving the outputs.

Step 2 - get report output searchpaths
Query the content store, and locate those reports you just ran to get their searchpaths (if you do not have them already)
2b - Put  "/reportVersion[last()]//output" at the end of each reportSearchPath to get the outputs for that report.
2c  - You can use the  cmService.query() with the above created searchpath to bring back all reports outputs.


Step 3 - save the files to filesystem
For each report output object return by the above query, stream the bytes to a file on your system. 
You will need to check what the format is (for example PDF) for each 'output' object, and append that to the file name.

Note that your user account must be allowed to save reports to the content store for this to work.

Hope this helps,

Dew