itssamrat Posted March 25, 2011 Share Posted March 25, 2011 Hi experts,I have a report where i am getting multiple account ids say 1 and 2 and 3 and 4 and 5I need to pass all these account ids to a subreport as a parameter .The subreport SQL will have a clause :- accountid in $p{accountid}so in $p{accountid} i need a comma separated list of account ids.but these accountids are returned rowwise(5 separate rows) in master report. can you please tell me how can i prepare a comma seprated list of accountids to pass to my subreport. Cheers,Samrat. so in $p( Link to comment Share on other sites More sharing options...
phantastes Posted March 25, 2011 Share Posted March 25, 2011 Hi,I'm not sure if this is what you are asking for but you could try to add the values to a variable. And then pass that variable to the subreport. This can be done by grouping the report (by country in my example):Country CityEngland LondonEngland CambridgeEngland OxfordCountry Footer $V{City_List}The Contry_List variable would be populated like this:Variable Class: StringCalculation: NothingReset Type: GroupReset Group: CountryIncrement Type: NoneVariable Expression: see code belowInitial Value Expression: "" (Make sure to set this to an empty String!) Code:"".equalsIgnoreCase($V{City_List}) ?$F{city} == null ? $V{City_List}:$V{City_List}+""+$F{city}.trim():$F{city} == null ? $V{City_List}:$V{City_List}.contains($F{city}.trim()) ? $V{City_List} : $V{City_List}+", "+$F{city}.trim() Link to comment Share on other sites More sharing options...
itssamrat Posted March 26, 2011 Author Share Posted March 26, 2011 Hi phantastes,Thanks a lot for ur reply. I was also thinking in the same lines. But i didn't know how to implement it.Can i have the values in the variable as comma separated strings such as :- '1000','1001','1002'Also can you kindly explain me the variable expression code :-"".equalsIgnoreCase($V{City_List}) ?$F{city} == null ? $V{City_List}:$V{City_List}+""+$F{city}.trim():$F{city} == null ? $V{City_List}:$V{City_List}.contains($F{city}.trim()) ? $V{City_List} : $V{City_List}+", "+$F{city}.trim()A brief walkthrough will help me understand.Thanks a lot in anticipation Samrat. Link to comment Share on other sites More sharing options...
phantastes Posted March 31, 2011 Share Posted March 31, 2011 Hi,Yes you can a string such as '1000','1001','1002' by just adding the single quotes to the exrpession below. I've added it to the code. The expression adds the field value to the variable if the variable is not null. It also adds a comma before (and now a single quote before and after) the field. There is some extra checks to handle the first field being added to the variable (by not adding a comma before the first value).I'm also adding the trim() method to make sure there is no blank space at the end of the string.I hope that helps! MagnusCode:"".equalsIgnoreCase($V{City_List}) ?$F{city} == null ? $V{City_List}:$V{City_List}+"'"+$F{city}.trim()+"'":$F{city} == null ? $V{City_List}:$V{City_List}.contains($F{city}.trim()) ? $V{City_List} : $V{City_List}+",'"+$F{city}.trim()"'" Link to comment Share on other sites More sharing options...
yashaswita.bhoir Posted June 25, 2013 Share Posted June 25, 2013 Hey @phantastes, I see the same code is not applicable for a BigDecimal field. What do I do in order to get a list of comma separated values for a field other than string, or in my case a BigDecimal? 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