Jump to content
We've recently updated our Privacy Statement, available here ×

Subreport integration in the father report


rikiti
Go to solution Solved by elizam,

Recommended Posts

Hello,

I need to understand the SubReport integration in a report on Jasper Studio. Is it still necessary to create a parameter in the subreport and then add it to the parent report? In my case I do not know which parameter to pass.

In the father report, I make this request to retrieve the orders table by selected period:

SELECT entreprisejasperreports.commandes.`Id_commande`,    DATE_FORMAT(entreprisejasperreports.commandes.`DateCommande`, GET_FORMAT(DATE, 'EUR')) AS 'Date commande',    entreprisejasperreports.commandes.`Produit`,    entreprisejasperreports.commandes.`Prix`,    entreprisejasperreports.commandes.`Id_client`FROM entreprisejasperreports.commandes  WHERE  DATE(entreprisejasperreports.commandes.`DateCommande`) BETWEEN  $P{Date1}  AND  $P{Date2}[/code]

Here is the screen of the subreport with the request below, I get all the orders (total of sales) of my base by year and by products:

https://www.developpez.net/forums/attachments/p349430d1518046279/logiciels/solutions-d-entreprise/business-intelligence/jasper/integration-subreport-rapport-pere/titre.png/

And this is code SQL of this screen :

SELECT Produit, SUM(Prix) 'Ventes par produit', YEAR(entreprisejasperreports.commandes.`DateCommande`) AS 'Date commande'  FROM commandes   GROUP BY  entreprisejasperreports.commandes.`Produit`[/code]

Thank you for your help
 

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Hi rikiti, 

If you want the selected parameters ($P{Date1} , $P{Date2}) to filter the subreport data as well, then yes you need to pass the parameters. I dont see you using any parameters in the subreport so not sure if this is what you want to achieve. 

Currently the way you have it setup: 
Your main report (parent ) what you call father reports runs it's own sql set and return data to be used in the main report or you could pass data to subreports or other reporting elements. 
Your sub report returns a seperate data set that is ussuable in subreport and not in main. 

If you want subreports or other elements like charts, crosstab etc to make use of parameter selected by user in main, then you need to pass over the parameters.  
To do this you need to create same parameters in subreports. 
So in this case Date1 and Date2, same datatypes, no need to set default expression as when you link with main parameters, the main parameters default values will be passed over. 
So when selecting your subreport under the properties tab, look for subreport tab, then there is a "Edit Parameter" button. 
Then select Add button. 
Parameter Name should be: Date1 
Parameter Expression should be : $P{Date1}  (You should be able to browse for it when selecting the  Expresion editor button) 
Add Date 2 aswell and finish. 

To test: Drag date 1 and date 2 as fields in your subreport header/footer or summary band and test to see the value being passed over. 
Then confirm if working, update your subreport sql to include the $P{Date1} and $P{Date2} parameters. 

Hope it helped. 
If it did, please upvote my answers. 
Thank you

 

Link to comment
Share on other sites

No i would like add a report in another report for generate a same pdf file. I don't want filter data in subreport compared to report parent. Query in report parent is different to query subreport. I want just add a report after another a report.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...