2005 IR Help Posted August 26, 2006 Share Posted August 26, 2006 By: Salman Khattak - khattaksd Can we concat $F{Field} into $V{Variable}? 2004-06-17 11:04 Can we concat $F{Field} into $V{Variable} and print at evaluation time 'column'? Both are String. Something like this COL1 COL2 abc def ghi jkl -------------- abcghi defjkl <---- Column footer What say you? Salman By: Gregory A. Swarthout - gswarthout RE: Can we concat $F{Field} into $V{Variable} 2004-06-17 11:10 Yes By: Salman Khattak - khattaksd RE: Can we concat $F{Field} into $V{Variable}? 2004-06-17 11:14 :-) How? What expression to use in the variable's 'Variable Expression' and 'Initial Value Expression'? Thanks for your time. Salman By: Gregory A. Swarthout - gswarthout RE: Can we concat $F{Field} into $V{Variable} 2004-06-17 11:21 You don't need an initialValueExpression. The variableExpression would be just: $F{field1} + $F{field2} By: Salman Khattak - khattaksd RE: Can we concat $F{Field} into $V{Variable}? 2004-06-17 11:30 Thank you. But it seems my question is not clear. Let me reword my question. I want to concatenate values in a column not concatenate two fields. The values will be from one field. It is like doing a Total(Sum?) on an integer field but with Strings! By: Gregory A. Swarthout - gswarthout RE: Can we concat $F{Field} into $V{Variable} 2004-06-17 11:47 Ok, then, how about "" for the initialValueExpression and $V{Variable} + $F{Field} for the variableExpression By: Salman Khattak - khattaksd RE: Can we concat $F{Field} into $V{Variable}? 2004-06-17 12:14 Seems to be working. Need to tweak a bit and it will work perfect. Thanks Gregory!! By: Ramil - ramilrahman RE: Can we concat $F{Field} into $V{Variable}? 2004-07-07 03:40 Just try this code, otherwise it is not gonna work I think, 'cause I also faced the same problem. First you create a Dummy Group ( View -> Report Group) Let the Group expression be null Then move the textField which is in the detail band to the newly created Group Footer Change its band to that GroupFooter(Properties->band ) Change the Variable's Reset Type to "page" In the variable's Variable Expression field ($V{variable_name} != null)?($V{variable_name} + $F{field_name}) :( $F{field_name}) Let the initial value expression be blank Evaluation time of the TextField should be "Now" In the textField's Textfield Expression give $V{variable_name} Guess this is enough for you. Ramil.Rahman Link to comment Share on other sites More sharing options...
francesco334 Posted November 24, 2006 Share Posted November 24, 2006 Hello, I've some problem to concatenate a String!I have just concatenate a Double fieldand all works. But with String it doesn't works. I have a DetailHotel band where there is the field $F{SINVOICENUMBER} that appear correctly, in the hoteldetail band when I create the pdf. Then, I have created a variable "VINV" that has this expression :$F{SINVOICENUMBER}.equals($F{INVOICENUMBER}) ? "ciao" : "NO" and I've put this variable on the Summary band.When I export the pdf, the value of this variable is always "null". I don't understand why? In my variable, I have set:Variable.Class type=StringReset Type=ReportCalculation type=nothingIncrement Type=None Where I wrong?? As you'll note seeing the other variables, I've just sum the double value correctly! I send the Fattura.jrxml, xml data source and the pdf result, in the zip file. Thanks in advance,Francesco [file name=Fattura-c03c680563cf3b27a161942f2012d37a.zip size=9475]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/Fattura-c03c680563cf3b27a161942f2012d37a.zip[/file] Link to comment Share on other sites More sharing options...
francesco334 Posted November 24, 2006 Share Posted November 24, 2006 hello, all is set as you wrote me.But nothing..the value is null. I don't understand 1 thing :- if I declare the Variable a Double, I set "Variable class type=Double" and Calculation Type="Sum" and "Variable expression=new Double (Double.parseDouble($F{SINVOICENUMBER}))"- if I declare the Variable a String, I set "Variable class type=String" and Calculation Type="Nothing" and "Variable expression=$F{SINVOICENUMBER}" In the first case, I can see the value of the variable (in double) on the exported report.In the other case I have always NULL. I think I wrong to assign the string value of the field $F{SINVOICENUMMBER} to the variable.Because if Double works, it means that iReport can read the field $F{SINVOICENUMBER} correctly. Can anyone help me?? I have noone idea!Thanks..Francesco Link to comment Share on other sites More sharing options...
ColinE Posted November 24, 2006 Share Posted November 24, 2006 Hi, I had a quick look at your report. There were quite a few errors in your XPaths, when selecting an attribute you must have a slash before the @ symbol: e.g. BookingReferenceID@ID should be BookingReferenceID/@ID When I corrected these mistakes the text field $V{VINV} displayed just fine. Actually, you do not really need a variable for this expression, you can place the expression: $F{SINVOICENUMBER}.equals($F{INVOICENUMBER}) ? "ciao" : "NO" directly into the expression for the text field. Regards,Colin E.----------- Now can someone please answer my question:http://www.jasperforge.org/index.php?option=com_joomlaboard&Itemid=215&func=view&id=18442&catid=9 Hint hint! Link to comment Share on other sites More sharing options...
francesco334 Posted November 25, 2006 Share Posted November 25, 2006 But I need variable because I must show the variable on Summary band, and the value is not a simple string, but I must concatenate a string field in the detail band, and show the variable value in summary band. So, the parameter with only @ID is showed in my report. Is not that the problem. If I show the filed value on the detail band it appear well. If I want show that value on summary band it appear null. Seems that doesn't add string value (of detail band) into the variable. I haven't any idea! Francesco Link to comment Share on other sites More sharing options...
teodord Posted December 11, 2006 Share Posted December 11, 2006 Hi, Try simpler things to see where the problem comes from.I suggest you modify the expression of the VINV variable so that it simply copies the value of the SINVOICENUMBER field.Then try put a text field in the detail band displaying this VINV variable, in addition to it being displayed in the summary.Check to see what values this variable has during the loop through the data source. I suspect that on the last record of the data source, this field is null. Note that if you want to have a variable that calculates the Sum of String values by concatenating them, you will probably end up implementing either a scriptlet (check the /demo/samples/scriptlet sample where we construct a list of city names) or a custom varibale incrementer (JRIncrementer interface) to assign to your variable. I hope this helps.Teodor 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