Jump to content
Changes to the Jaspersoft community edition download ×

how do concat in a variable several string?


josechinese

Recommended Posts

i need concat in a variable several string, but the string is product of a sub report, i need concat all the results in a line.

 

example.

 

data base

 

costumer ---> phones

 

report source

 

main report --> with customer data

subreport --> phones query

 

 

 

report out put

id_customer | phones |

1 | phone1, phone2,...|

2 | phone1, phone2,...|

 

 

please help me!!

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi,

 

String concatenation is achieved using a scriptlet.

A custom variable incrementor could also be used, but it would trickier to implement, so I do not advise it yet.

 

You can see string concatenation using scriptlet in the /demo/samples/scriptlet sample provided with the project, where we concatenate city names and display the list at the end of the report.

If you want to concatenate values across different subreports, I think you need to create a scriptlet object that you pass from the master to all the subreports using the REPORT_SCRIPTLET built-in parameter.

This scriptlet object that the master report creates and provides to subreports will keep the list internally and would reveal it when you want to display it int a text field.

 

I hope this helps.

Teodor

Link to comment
Share on other sites

  • 4 weeks later...

Hi I have a similar problem and I don´t understand your answer. My problem :I have to design a Report that gives an overview of yearly production for all companies in a state.

Amount of X Pieces : xAmount of y pieces : yNew Customers : zProduction in first trimester : ...
And if security informations are avalaible (Database field), I must give all security comments, which are String fields in the database. Here is my approach- All information come in the <summary> section.- I call in the <detail> section subReports that will calculate values and I return subReport Variable to ReportVariable like :[code:1] <returnValue subreportVariable="MS1_INSP_B_3JAHR" toVariable="MS1_INSP_B_3JAHRE_TOTAL" calculation="Sum"/>[/code:1]- I have a String variable $V{COMMENTS} where I intend to copy/append the same way all comments from companies with security information.- I call the security subreport in the <detail> section, with security field $F{SECURITY_VORH} as parameter. In the subReport I use a query to fetch security comment if $F{SECURITY_VORH}=1. Comment is stored into the variable $V{SEC_INFO}.My question how can I return the content of $V{SEC_INFO} into $V{COMMENTS}, so that $V{COMMENTS} will contain all security comments one after the other.I tried using [code:1]<returnValue subreportVariable="SEC_INFO" toVariable="COMMENTS" calculation="Nothing"/>[/code:1] but it didn´t work. The $V{COMMENTS} is empty, although when displaying the subReport in the <detail> section, I see all comments. So the real problem is [color=#000080]appending $V{SEC_INFO} into $V{COMMENTS}[/color]I should have this kind of result :
Erstanzeige unter Firmen vom 09.05.1986. Umfirmierung am 18.09.2000 angezeigtInterner Alarm- und Gefahrenabwehrplan vorhanden:ÃœberarbeitungenTest: Juni 2002Company NameAdressCity
Now I don´t understand a bit about scriptlet, and how can I use your answer for this task. NB: I work on a particular platform where I just write jrxml files. I don´t think that I can write additional java code since other people have programmed it and we are not allowed to add/change anything.

 

Post edited by: bamiDom, at: 2008/01/07 12:05

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...