Topic
  • 4 replies
  • Latest Post - ‏2013-04-17T07:03:05Z by KavitaP
KavitaP
KavitaP
3 Posts

Pinned topic How to save report output to file system outside cognos using SDK

‏2013-03-25T10:46:17Z |
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 connectiona nd 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"));
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/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.
Updated on 2013-04-01T05:34:42Z at 2013-04-01T05:34:42Z by KavitaP
  • KavitaP
    KavitaP
    3 Posts
    ACCEPTED ANSWER

    Re: How to save report output to file system outside cognos using SDK

    ‏2013-04-17T07:03:05Z  

    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);

  • SystemAdmin
    SystemAdmin
    217 Posts

    Re: How to save report output to file system outside cognos using SDK

    ‏2013-03-30T16:35:47Z  
    KavitaP,

    You can do something like this(below) to save it. Check sdk doc to0, it has plenty of samples regarding this;

    Once you get hold of AsynchReply or so then , use it to extract bytehttp://] to feed into FileOutPutStream. You might have to treat byte[ differently based on out out type.

    Hope this helps.


    AsynchReply res =repService.run(new SearchPathSingleObject(reportPath), parameters, runOptions);

    // The report is finished, let's fetch the results and save them to
    // a file.
    if (res.getStatus() == AsynchReplyStatusEnum.complete)

    {
    AsynchDetailReportOutput reportOutput = null;

    for (int i = 0; i < res.getDetails().length; i++)
    {
    if (res.getDetails()[i]
    instanceof AsynchDetailReportOutput)
    {
    reportOutput =
    (AsynchDetailReportOutput)res.getDetails()[i];
    break;
    }
    }

    String[] data = reportOutput.getOutputPages();

    System.out.println(
    "Writing report output to " + outputPath + "...");
    FileOutputStream fs = new FileOutputStream(outputPath);

    for (int idx = 0; idx < data.length; idx++) {
    fs.write(reportOutput.getOutputPages()idx.getBytes());
    }
    fs.flush();

    fs.close();
    System.out.println("... done.");
    }

  • KavitaP
    KavitaP
    3 Posts

    Re: How to save report output to file system outside cognos using SDK

    ‏2013-03-30T17:46:27Z  
    Thanks for the reply. The problem here is that I get this error at this run method itself. The issue is with the run options that I am passing. Could you please help me with these run options?
  • SystemAdmin
    SystemAdmin
    217 Posts

    Re: How to save report output to file system outside cognos using SDK

    ‏2013-03-30T18:43:54Z  
    • KavitaP
    • ‏2013-03-30T17:46:27Z
    Thanks for the reply. The problem here is that I get this error at this run method itself. The issue is with the run options that I am passing. Could you please help me with these run options?
    Why don't you post/attach the code from the class? It might help identify the issue easily.
  • KavitaP
    KavitaP
    3 Posts

    Re: How to save report output to file system outside cognos using SDK

    ‏2013-04-17T07:03:05Z  

    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);