Cognos SDK Guide by BI Centre can be purchased from PayPal.

You will have your own functional Cognos 8 SDK web solution that has been tailored to be scalable and flexible in order to adapt to your unique business requirements and solution architecture.


Thursday, January 24, 2008

Run a report with prompts -- CognosSDK.cs

Our working sample includes Report Studio reports that all contain prompts. In order for the reports to be executed they need to have their prompt page parameter objects populated with a valid parameter value. In order to achieve this we need to display the report's prompt page to the end user so that they can enter the prompt value into the appropriate prompt control. The approach that we will use to render the report's prompt page to the end user is to execute the selected report and satisfy the method's signature with an empty parameter value collection. Passing in an empty parameter value collection forces the Report Service to place the request into a 'prompting' status. We can then retrieve the request's HTML representation of the report's prompt page, and then render this HTML string to the ASP.NET page.



Note that our executeReport() method is looking for a Boolean value to state whether or not to prompt. When we want the prompt page then we set this Boolean value to True.



public string executeReport(string reportSearchPath,parameterValue[] pv, reportService1 reportService, string[] strFormat, bool blnPrompt){



………… method body………

…………

…………

}





The executeReport() method contains an asynchReply variable that is used to capture the conversation context of the request.



asynchReply C8reply = reportService.run(spSingle, pv ,arrRunOpts);





We will then pass the C8reply variable as an input parameter to the getOutputPage() method. This method will be used to populate a string variable with a string representation of the prompt page's HTML. It is this value that is written to PromptPage.aspx and displays the report's prompt page to the end user.



strHTML = getOutputPage(C8reply);





public string getOutputPage(asynchReply response)

{

asynchDetailReportOutput reportOutput = null;



try

{

for (int i = 0; i < response.details.Length; i++)

{

if (response.details[i] is asynchDetailReportOutput)

{

reportOutput =

(asynchDetailReportOutput)response.details[i];

break;

}

}

}

catch (SoapException exSoap)

{

ExHandler exCognos = new ExHandler(exSoap);

return _ErrMsg = exCognos.Details + " :-: " + exCognos.Message + " :-: " + exCognos.Severity + " :-: " + exCognos.ErrorCode;

}



//text based output is split into pages -- return the current page

return reportOutput.outputPages[0].ToString();

}



Before we display the prompt page to the end user we want make some modifications to the HTML that was returned. Our CustomizeHTML() helper function is used to update the HTML in order to work with our sample web solution. The main change will involve adding our own customized finish button to the prompt page to control the form's submission to Output.aspx. This will also enable us to add our own JavaScript function to the button's onClick() event. This is achieved in the CognosSDKHelper.js file.