COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Cognos Administration => Topic started by: toper on 30 Jul 2012 03:55:37 AM

Title: Re-runing failed jobs/reports
Post by: toper on 30 Jul 2012 03:55:37 AM
Hello,

I have a number of reports that have its default parameters logic based on $current_timestamp.
When a job (containing many reports) fails, and I cant rerun it the same day, there is a problem.
The job reruns, but the prompts passed to the reports are not correct, as the $current_timestamp changes.

Its time consuming to manually rerun large number of reports.. and involve a human error :(
Would you have any ideas, how to make it work?
Title: Re: Re-runing failed jobs/reports
Post by: toper on 06 Aug 2012 04:12:54 AM
It seems most of us have perfect reports that never fail :)
Anyway, really no idea how to rerun properly?
Title: Re: Re-runing failed jobs/reports
Post by: RubenvdLinden on 20 Aug 2012 04:53:23 PM
It's not going to be pretty. In order to allow a rerun, you'll need fixed date prompt values.
You can create a prompt page with an invisible date prompt. Use javascript to set the value of the prompt (current date) and then submit the prompt.

I'll try to post an example tomorrow.
Title: Re: Re-runing failed jobs/reports
Post by: tjohnson3050 on 20 Aug 2012 05:00:35 PM
IBM has something called a Dynamic Report Specification Updater that enables mass changes:

http://www-01.ibm.com/support/docview.wss?uid=swg24021248

You could replace all of your current timestamp logic with something else (like current timestamp minus x days) and re-run the reports.
Title: Re: Re-runing failed jobs/reports
Post by: RubenvdLinden on 21 Aug 2012 03:05:07 AM
OK, here's the example I promised:

1. Create a prompt page in your report
2. Create a date prompt control and set the 'Select UI' property to 'Edit box'
3. Set the 'Name' property of the date prompt (in this example, I named it 'MyDate')
4. Set the 'Visible' property of the date prompt to 'No'
5. Remove the default prompt page footer
5. Create a HTML item object AFTER the date prompt:

<script type="text/javascript">
function init()
{
var dDate = new Date();
//Subtract one day for yesterday, remove the next line if you need current date
dDate.setDate(dDate.getDate()-1);

//Replace MyDate in next line with name of date prompt control
pickerControlMyDate.setValue(getFormatDate(dDate, 0 , 'YMD'));

canSubmitPrompt();

// The timeout in the next line is important; the date prompt variable setting might fail without a proper timeout
setTimeout("promptAction('finish');",1000);
}
init();
</script>

6. Replace existing date filters in your report with filters based on the date prompt variable.

If you run this report, you will see a blank page for about a second. After that, the report will run with a fixed date prompt value which allows you to rerun a failed report with the correct date value.
Title: Re: Re-runing failed jobs/reports
Post by: toper on 21 Aug 2012 03:30:01 AM
Hello,

thanks for this demo, I like it! I will use it in some of my reports.
I assume that it wont work in non-interactive batch job.. as there is no prompt page involved in the process?
I was hoping that cognos is smart enough to figure out the parameters that were sent to a report and provide the same values when the report is re-run.
Title: Re: Re-runing failed jobs/reports
Post by: RubenvdLinden on 21 Aug 2012 03:59:02 AM
If you use a date function like current_date, there's no parameter variable. You just tell Cognos to use the 'active' current date. You'll need prompt variables like in my example. With prompt values, Cognos should be smart enough to retain the 'old' values on a rerun.

Also, my demo works fine in the Cognos scheduler as a non-interactive batch report as long as you don't override the default prompt values on the schedule properties page. The javascript sets the date variable when the report runs on schedule. If the report fails and needs to rerun, Cognos should use the date variable of the failed run.
Title: Re: Re-runing failed jobs/reports
Post by: toper on 21 Aug 2012 04:32:46 AM
That's awesome, thanks so much. I need to rewrite my prompts then.
Title: Re: Re-runing failed jobs/reports
Post by: toper on 04 Oct 2012 06:40:39 AM
On the second thought - with this approach, users cant pick up their custom date.. as the prompt page will be automatically submitted :(