Apolo Posted September 8, 2006 Share Posted September 8, 2006 HiMaybe anybody know, how returned value from subreport use in variable in main report?I have:1. <returnValue subreportVariable="icount" toVariable="icount"/>,2. Text field in main report with “Textfield expression†= “$V{icount}†and “Evaluation time†= “Bandâ€3. Variable “var†in main report with “Variable expressionâ€=“$V{icount}â€4. Text field in main report with “Textfield expression†= “$V{var}†and “Evaluation time†= “Band†When I generate report value of text field (icount) is correct, however value of test field (var) is null. How solve this problem? Thanks. P.S.Sorry for bad English. Link to comment Share on other sites More sharing options...
lucianc Posted September 12, 2006 Share Posted September 12, 2006 You can't use variables with values returned from subreports in other variables' expressions, because variable expressions are evaluated at the beginning of the band rendering, and subreport return values while the band gets rendered. You should try to find a way to avoid this. How are you using the value returned from the subreport in your other variable? Regards,Lucian Link to comment Share on other sites More sharing options...
Apolo Posted September 13, 2006 Author Share Posted September 13, 2006 How are you using the value returned from the subreport in your other variable? I need find sum of returned values. + In the future more complex data processing from subreport can be necessary. I solved this problem by using very simple scriptlet: Code: + 2 text fields: 1. field1: a. textfield expression: "" + $P{REPORT_SCRIPTLET}.addcount($V{icount}.intValue()) b. evaluation time: “Band†c. band: “Detail†2. field2: a. textfield expression: "" + $P{REPORT_SCRIPTLET}.getcount() b. evaluation time: “Now†c. band: “Summary†result: Value, which is returned from subreport, processed in the scriptlet. Link to comment Share on other sites More sharing options...
lucianc Posted September 14, 2006 Share Posted September 14, 2006 If you need to sum values returned from the subreport, you can use a new variable and return a value with "Sum" calculation type: Code: HTH, Lucian Link to comment Share on other sites More sharing options...
Apolo Posted September 14, 2006 Author Share Posted September 14, 2006 I have added one more returnable value with calculation type: “Sum†Code: Property of variable var: Code: Text field with variable var is in “Summary†Property of text field: Evaluation time: “Band†Result: variable var contain last value from subreport instead of sum of returned values. Maybe you have a sample how calculate sum of values returned from subreport? Link to comment Share on other sites More sharing options...
lucianc Posted September 14, 2006 Share Posted September 14, 2006 Your variable should have calculation="System", only the returned values should specify calculation="Sum". You can check the "subreport" sample distributed with JR. HTH,LucianPost edited by: lucianc, at: 2006/09/14 15:47 Link to comment Share on other sites More sharing options...
Apolo Posted September 15, 2006 Author Share Posted September 15, 2006 I found resolution of problem: in variable var "Variable expression" must be "${var}" variable parameters: Code: Then all will work. Link to comment Share on other sites More sharing options...
jfuentes Posted December 1, 2006 Share Posted December 1, 2006 Hi all. I'm new to this forum. In the last days we have been evaluating JasperReports as our report generation system. We are trying to move from JInfonet Jreports to JasperReports. But we are experiencing problems with working with return values from subreports. As I understand from last posts, we can't use returned values in the definition of other expressions... And here is the problem. With the other product, we've been using this technique to generate intermediate values to reach final results. Could we do this same process with JasperReports? Do we need to use scriptlets to evaluate returned values from subreports? Thanks in advance, Greetings. Juan Fuentes Link to comment Share on other sites More sharing options...
jfuentes Posted December 1, 2006 Share Posted December 1, 2006 Well, I have already tried with Scriplets (my very first scriptlet ;) and the result has been the same :( I'll go on working on it. Any suggestion? Thanks in advance Link to comment Share on other sites More sharing options...
lucianc Posted December 4, 2006 Share Posted December 4, 2006 Can you be more specific about what you need to do with values returned from subreports? "Generate intermediate values to reach final results" is rather vague, a concrete example would help. Regards,Lucian Link to comment Share on other sites More sharing options...
jfuentes Posted December 4, 2006 Share Posted December 4, 2006 Thanks for your interest Lucian. We have already solve this problem... well by now: We have created a group that corresponds to every line of the detail. Then set the subreport in the group header. In this way, expressions in the detail band are evaluated after running the subreports, and the values from the subreports are already set. Thanks ;) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now