Crystal Report - How to deal with empty data? - crystal-reports

I have sub report linked with EmployeeID. But for some employees I don't have data so report get suppressed. And I get record at wrong place. I want to avoid this so what can I do ?

I get record at wrong place
What do you mean the wrong place? Don't you mean the sub-report is taking up space when there are no records for an employee?
It depends on the sub-report layout, but I usually make the sub-report very thin in the main report and then I'll set suppress formulas in the visible sub-report sections. That can be done with an isnull() check on some key. I think there is also a special keyword you can use to check if there are records, I forget the name though.

You should be able to use the section suppress option on all the sections of the sub-report. I believe you can tie the section suppression to a formula. In that formula you need to check against the record count variable(I forget the exact name) and return a boolean in that formula to show/hide the given section.

Related

Pass Record Selection Data to Subreport

I have a main report that uses a formula in the Record Selection. The numbers are set by choosing the "is between" option in the Select Expert. I need these numbers to go through to the subreport, however, no matter what I do, I can't get both numbers through to the subreport, just the one. Is there any way I can pass both these numbers through to the subrport? Neither of them are based on parameters, we use a system here at work where the parameter is set at runtime.
Attached is a picture of the main reports' Select Expert - I need to get the 2 and 6 through to the subreport. Is this possible?
Thank you.
The answer in the link below seems to work, if you have a similar problem. To quote:
Create two formulas
MinValue as Minimum({vw_P_SDL_MTDSummaryList.PAYROLLDETAIL_ID})
and MaxValue as Maximum({vw_P_SDL_MTDSummaryList.PAYROLLDETAIL_ID})
and pass them to the subreport as a parameter without linking it to any of the > field in sub report.
http://scn.sap.com/message/16971134#16971134

Including a subreport into a GROUPING section

Crystal Reports: including a subreport into a grouping section?
asked the same question, but I am hoping a comment on the accepted answer is wrong: that it can't be done because the subreport must be in the details section. Also, what the selected answer says to do isn't working (perhaps because of the other detail, no pun intended).
So this looks like a duplicate question, yet the original question does not appear to be answered, and certainly the accepted "answer" is not usable by me.
(see also How to handle a duplicate question when the original has an accepted answer that is not really acceptable?)
My subreport can list one to many items, each of which can join to one or more items in the main report details. The common field they join on is the grouping item. So, for example, the subreport might have three items and the details five, but if I put it all in the details, I would have fifteen rows, with the first part repeated five times and the second part three times.
The common item appears as a "command field", a "report field". and the Group item. But no matter which of those I link as a subreport parameter, the subreport gets nothing and asks me to enter a value when I try to view the report.
In a more recent version of Crystal Reports you have two options: You can either connect the subreport to a value on the main report via the subreport parameter dialog. or you can pass a Shared Variable between the reports. If you are using the subreport parameter dialog, then the value passed in will be whatever that value is at the time the group is displayed. If the value comes from a detail in that group or from a variable on the main report it shoud pass fine. If the value is something that would be displayed after the group is displayed on the report (going top to bottom) then the value won't be written yet and will be passed to the report as null or blank.
Shared Variables are shared between a report and all of its subreports. If you need to get data from a subreport or pass a single value to multiple subreports, it might be the better option. If the shared variable is changed in the report or a subreport, it'll use the new value in everything after that.
SAP has a good guide on both techniques here:
http://scn.sap.com/people/ashish.bamzai/blog/2011/11/23/passing-values-between-reports-crystal-reports-2008
Bear in mind that Crystal Variables are always populated based on their position in the report and the order they are printed in. If something needs to happen after another group or subreport prints, you'll need to use the WhilePrintingRecords keyword.

How can I get a field to print at the top of every page in JasperReports?

I am using iReport 3.7.6 to create this report.
I have a report based off of an XML file. There is a 2-column master report and it has a detail band with a subreport.
I have a field called "Name" in the subreport. I want it to print at the top of every page. Or even at the top of every column. I have tried virtually everything I know how to do.
"Print When Detail Overflows" doesn't work, because this setting is in the detail.
I sure hope I don't need to create a subreport for every report break I want. I'll have like 4 or 5 subreports.
Is there some way to determine when the page has changed, and then use that event in a "Print When" expression?
Here is one solution, presuming the value does not change between pages:
Write a query for a subreport that obtains only the Name value.
Change the dimensions of the subreport to be as small as necessary.
Place the subreport in the page header band of the master report.
To answer your question accurately, more details (such as pictures of what you have versus what you want) would be helpful.
you can use pageCount variable which is implicitly available in jasper reports to know whether the page has changed or not.

Suppress Crystal Reports section if there are no rows in a datatable

I have a section in a Crystal Report that I want to suppress. I need to suppress it if there are 0 rows in a particular table in the dataset I am using. How would I do this? The Record Number special field provided appears to be an internal count of records in the report, and does not relate to the rows in the underlying data table.
I am creating the report from C#, but I cannot suppress the section from the code (it doesn't fit the project structure) - I must be able to do it from the report itself. The table concerned is definitely being passed to the report in the dataset, but it contains 0 rows. There must be a way to establish this inside the report itself.....
Can anyone please point me in the right direction?
In the Crystal Reports designer, view the properties of your section and there should be an option to Suppress, which you can give it a formula to return the appropriate boolean value.
You could then use the Count() function within that formula and (I believe) you can pass the name of your dataset to the Count() function to get the number of rows in that dataset.
I did the same thing on a complex report about 3 months ago but I don't have access to the report any more having changed jobs so I'm sorry I cannot be more specific, but hoepfully this gives you a starting point.
Just had a quick Google - try this.
If the section does only contain database fields and f.e. no text fields, then you could use the setting "Suppress Blank Section" in the "Section Export" (rightclick section) for that section.
As an alternative you could use the following formula in the "Suppress" in the "Section Export" for that section:
IsNull({table.field})
"{table.field}" is one of the fields in the dataset.
Hope this helps.
Go to "Section Expert" and click "Supress (No Drill-Down)" and try adding this:
IF {"DragYourFieldHere"} = "" then true else false
Create one dummy group,check on its header for each page,add the header in the group header of the dummy group.

Inclusion and exclusion of subreports (iReport-JasperReports)

I need to include or exclude a subreport based on a condition. I'm using iReport to create JasperReports. I.e., if a subreport has values, I need to include that subreport, otherwise not. Can anyone please send a sample or tell me how to resolve this.
you can in the master report get data from your data source that allows you to identify if the subreport should be included, then use the 'printWhenExpression' field on the subreport element to check that data.
I use this regularly - for example the printWhenExpression field may contain:
new Boolean($F{TOTAL_STATS}.intValue() != 0)
where TOTAL_STATS is from the master report's database query. If non-zero we show a subreport detailing some data.
From my knowledge, if there aren't any data printed in the subreport, Jasper eliminates the blank space. In other words, if your subreport would normally occupy half a page, but there is no data, then the empty space is eliminated. I'm not sure this is what you mean by including or excluding the report.
Another solution would be to place the subreport in the main report, and from right-click ->properties -> Subreport tab, you select the "Subreport condition" tab and write your condition there. If the condition is true, the content of the subreport will be printed, otherwise it won't be printed.
Jamie Love's answer about "printWhenExpression" is on target.
if there aren't any data printed in the subreport, Jasper eliminates the blank space
Actually, at least in JasperReports 3.7.0 there is a subreport property "Remove Line When Blank" that controls that behavior. By default - at least when I use iReport - that parameter is off.
WEG