cancel
Showing results for 
Search instead for 
Did you mean: 

Subreports using stored procedure within a main report using a resultset

Former Member
0 Kudos

Hello,

I'm using Crystal Report Java SDK for simple report and report with subreports.

When I use store procedures for my main report and my subreports, everything is fine, the process is "automatic".

But when I use the same main report with a resultset and still stored procedures for my subreports I'm facing some "problems".

The thing is I have to set each parameters of each subreport... But I'm trying to do it in a generic way and I want to fetch each link between main report and subreport and to set subreport parameters with the right values.

1) When I loop on the SubreportLinks for a given subreport, I only have half of the attributes : the report side.

SubreportController subreportController = clientDoc.getSubreportController();

SubreportLinks links = subreportController.getSubreportLinks(subreportName);

I can't do anyhting without both side. So I'm wondering why i only have one side and if I do it the right way...

2) If the report parameter of my SubreportLink object is a ParameterField, I don't have anything at all

Facing this issue, I'm trying to do in a different way.

I'm using a resulset in input because I want to generate a report only if I have data in my ResultSet.

So, using a stored procedure for main report and subreports, the normal way, how can I know if the report ResultSet is empty or not ?

Or, is there a way not to generate the report is empty ? A counter ?

If I use :

clientDoc.getRowsetController().getRowsetBatchSize();

I always get "100", the default value.

But if I refresh the controller before getting the rowset batch size, I have an exception : "parameters are empty".

clientDoc.getRowsetController().refresh();

clientDoc.getRowsetController().getRowsetBatchSize();

Could someone help me solving this issue ?

Thank you,

Nicolas

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Hello Nicolas

I don't work with the Java SDK, but ocasionally peek in here as the forums does not have a dedicated Moderator.

Anyhow, from a high level perspective, I suspect that the reason for the issue is that the resultset does not match what the report engine is expecting, based on the original report design. I think this may be similar to dataset issues that I see with the .NET SDK and I wrote a small blog on how to troubleshoot these issues:

http://scn.sap.com/community/crystal-reports-for-visual-studio/blog/2009/03/02/troubleshooting-issue...

Have a look at the blog, it may lead you to a solution,

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow us on Twitter

Got Enhancement ideas? Try the SAP Idea Place

Share Your Knowledge in SCN Topic Spaces

Former Member
0 Kudos

Hello Ludek,

Thanks for your help, I appreciate.

In fact, I think I found a way for doing what I need.

I don't work anymore using both ResultSet for main report and stored procedures for subreports.

I generate my report always using stored procedures but I add a case in the process, before executing the report, in order to do something only if I have data returned by the sp.

I use the RowsetCursor, here is my code below  :

// Here I create a metadata using ONLY the database fields

IRowsetMetaData metadata = new RowsetMetaData();

Fields fields =  clientDoc.getDataDefController().getDataDefinition().getResultFields();

Fields dbFields = new Fields();

for (int i = 0; i < fields.size(); i++) {

    IField field = fields.getField(i);

    if (field instanceof DBField) {

        dbFields.add(field);

    }

}

metadata.setDataFields(dbFields);

...

RowsetCursor cursor = clientDoc.getRowsetController().createCursor(null, metadata);

FetchedRecordCountInfo countInfo = new FetchedRecordCountInfo();

countInfo.setIsTotalRecordsKnown(false);

// Here, if I don't have any record from my stored procedure, I don't execute the report process

int nbRecords = cursor.getRecordCount(countInfo);

if (nbRecords <= 0) {

    throw new ReportingException("UnmanagedJob - Report generation : No data, generation aborted.");

}

It works perfectly on my side !

I hope it will help other "lost users" of CR java SDK

Nicolas

former_member183750
Active Contributor
0 Kudos

Hello Nicolas

Many, many thanks for providing your solution.

- Ludek

Answers (0)