cancel
Showing results for 
Search instead for 
Did you mean: 

How to create an instance

Former Member
0 Kudos

Hi all,

Actually, I want to create an instance without priting or sending to any destination.

My code steps should be:

1. logon

2. get report object

3. set parameters information

4. create an instance / schedule report

once I create all instances for different reports, then I need to read all created instance objects (report with data populated) and sent to printer.

Is this possible? If possible, please suggest how to proceed further.

Thanks,

Krishna

Accepted Solutions (0)

Answers (1)

Answers (1)

aasavaribhave
Advisor
Advisor
0 Kudos

you can schedule the reports to their default location ( what you see in history of a report template). It creates the report instance in output file repository.

Then you can open the report instance with RAS SDK and use PrintOutputController.printReport() method to print the instance.

Former Member
0 Kudos

Hi Thanks for your valuable response.

But I did tht but I could not find the object in the history. please give me some smaple code snippet, if u can.

Because as per my knowledge either we should send to some destination like (FTP,SMTP, Managed or unmanaged disk) or we should print the report.

correct me If i am wrong.

Thanks

aasavaribhave
Advisor
Advisor
0 Kudos

here is a general code sample - you may need to modify it.


<%
IEnterpriseSession oEnterpriseSession = null;
IInfoStore oInfoStore = null;

String username = "administrator";
String password = "<password>";
String cmsname = "<cmsname>";
String authType = "secEnterprise";
String reportName = "<reportname>";

	oEnterpriseSession = CrystalEnterprise.getSessionMgr().logon(username, password, cmsname, authType);
	oInfoStore = (IInfoStore)oEnterpriseSession.getService("","InfoStore");
	String query = 	"select top 1 * from ci_infoobjects where si_name='" + reportName + "' and si_instance=0";
	IInfoObjects reports = oInfoStore.query(query);
	IReport report = (IReport) reports.get(0);
	ISchedulingInfo schedInfo = report.getSchedulingInfo();
	schedInfo.setRightNow(true);
	schedInfo.setType(CeScheduleType.ONCE);
	// schedule the report to default destination.
	oInfoStore.schedule(reports);

	// retrieve report instance. You may have do this multiple times if the report is still in process.
	query = "select top 1 * from ci_infoobjects where si_name='" + reportName + "' and si_instance=1 order by si_creation_time desc";
	IInfoObjects instances = oInfoStore.query(query);
	IInfoObject instance = (IInfoObject) instance.get(0);

	IReportAppFactory rptAppFactory = (IReportAppFactory)es.getService("", "RASReportService");
	ReportClientDocument clientDoc = rptAppFactory.openDocument(instance, 0, Locale.ENGLISH);
	//set PrintReportOptions object properties. Look in RAS SDK documentation for further info.

	clientDoc.getPrintOutputController().printReport(PrintReportOptions object);
	
	
	clientDoc.close();
oEnterpriseSession.logoff();


%>

Former Member
0 Kudos

Hey thanks once again for excellent response.

I tried the same thing. I could find the instance in the crystal server but while printing program got hanged at openDocument state.

do I need to change anything specific to my server details.

Please help me.

Thanks,

Krishna

aasavaribhave
Advisor
Advisor
0 Kudos

make sure that instance is completed before openDocument() is called. this can be done by periodic checking of schedule status. Also RAS needs to be up.

Former Member
0 Kudos

Hi,

Yes, RAS is up and running and I am trying to openDocument only after successfull completion of schedule.

Do I need to use PSReportFactory or InfoStore services?

If so, I could not find any print related method in those classes.

Please help.

Thanks

aasavaribhave
Advisor
Advisor
0 Kudos

PS factory doesn't have any print method directly like RAS. is the instance you are trying to open is RPT or some other format?

Former Member
0 Kudos

getting exception saying service is disabled.

aasavaribhave
Advisor
Advisor
0 Kudos

are you using unmanaged RAS and is guest account disabled?