Variable Expression issue

 I have a variable expression which is subtracting two numbers.  I want to modify this report so that it only displays the negative answer.  meaning I only want to see the resulting answers which are a negative number.  Anyone have any suggestions?  

Code:
	<variable name="STK_RTOT" class="java.lang.String" resetType="Group" incrementType="Group" incrementGroup="SOHNUM_0" resetGroup="ITMREF_0" calculation="Sum">
		<variableExpression><![CDATA[$F{TOTSTK} - $V{STK_CNT}]]></variableExpression>
		<initialValueExpression><![CDATA[0]]></initialValueExpression>
	</variable></td></tr></tbody></table>
mmedici's picture
299
Joined: Aug 12 2010 - 6:47am
Last seen: 13 years 1 month ago

18 Answers:

Explore using printWhenExpression. This should do the trick.

printWhenExpression:
Definition of a Boolean expression that will determine if the element or the band should be printed or not.
darth_fader's picture
Joined: Mar 7 2010 - 9:45pm
Last seen: 8 hours 25 min ago

 so i have looked into it, but i am not a programmer and i have no idea what i am doing.

Can someone please provide me with some guidance on how to use it.

or is there a way to just manipulate that existing code?

mmedici's picture
299
Joined: Aug 12 2010 - 6:47am
Last seen: 13 years 1 month ago

 wanted to follow up to see if anyone had any suggstions on this

mmedici's picture
299
Joined: Aug 12 2010 - 6:47am
Last seen: 13 years 1 month ago

 If I understood you correctly, you want to do something like what I have put in the code below.

It should print the number if less than 0, otherwise print ""

It uses the short if this?then do this:else do this syntax.

I hope that helps.

Code:
($F{TOTSTK} - $V{STK_CNT} < 0)?$F{TOTSTK} - $V{STK_CNT}:""</td></tr></tbody></table>
chgsd's picture
175
Joined: Jun 6 2010 - 4:15pm
Last seen: 10 years 2 months ago

 When i try and insert that printwhenexpression i get an error of:

 

Error loading the report template:

Org.xml.sax.SAXParseException:cvc-complex-type.2.4.a: Invalid content was found starting with the element 'printWhenExpression'. One '{variableExpression, initialValueExpression}' is expected. 

 

any thoughts on this error?

mmedici's picture
299
Joined: Aug 12 2010 - 6:47am
Last seen: 13 years 1 month ago

 What I was recommending was actually bypassing the printWhenExpression. Please review the code below and see if it works. There isn't anything wrong with printWhenExpression, but because of your mentioning your beginning with this, I meant to give you a string to replace your existing string with.

printWhenExpression needs to return evaluate to true/false, and is like a switch that enables printing or not printing. What I gave to you always prints, just it prints nothing if the result is 0 or greater.

I hope this helps.

Cheers,

CHgsd

Code:
	<variable name="STK_RTOT" class="java.lang.String" resetType="Group" incrementType="Group" incrementGroup="SOHNUM_0" resetGroup="ITMREF_0" calculation="Sum">
		<variableExpression><![CDATA[($F{TOTSTK} - $V{STK_CNT} < 0)?$F{TOTSTK} - $V{STK_CNT}:""]]></variableExpression>
		<initialValueExpression><![CDATA[0]]></initialValueExpression>
	</variable></td></tr></tbody></table>
chgsd's picture
175
Joined: Jun 6 2010 - 4:15pm
Last seen: 10 years 2 months ago

This worked really well.  However, is there a way for it not to show the rows that are positive?

 

meaning, it ran the report and shows an anser for all the items which are negative, and deosn't show anything if it is positive.  However it shows the row, is there a way to remove the row or item if the answer is negative?

mmedici's picture
299
Joined: Aug 12 2010 - 6:47am
Last seen: 13 years 1 month ago

 Anyone have any other suggestions on this?

 

i think a printwhenexpression may be the answer i am looking for, problem is when i google how to use the expression i don't see much information out there on it.

Anyone know how to make that expression work in this instance? 

mmedici's picture
299
Joined: Aug 12 2010 - 6:47am
Last seen: 13 years 1 month ago

 let me know if it would do anyone any good to post the entire report code out here as well.  i can do that too if need be

mmedici's picture
299
Joined: Aug 12 2010 - 6:47am
Last seen: 13 years 1 month ago
If it can wait a few hours I can write the block of code for you, having the full report wouldn't hurt, but just the code for the element in question and perhaps surrounding elements would suffice.
I can get to this in probably 4-6hours.
chgsd's picture
175
Joined: Jun 6 2010 - 4:15pm
Last seen: 10 years 2 months ago

I inserted the entire code below.

 

if you could make this work that would be fantastic, i would be indebted to you.

 

 

Code:
<?xml version="1.0" encoding="UTF-8"  ?>
<!-- Created with iReport - A designer for JasperReports -->
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport
		 name="stockreqe2"
 
		 language="groovy"		 columnCount="1"
		 printOrder="Vertical"
		 orientation="Portrait"
		 pageWidth="842"
		 pageHeight="595"
		 columnWidth="782"
		 columnSpacing="0"
		 leftMargin="30"
		 rightMargin="30"
		 topMargin="20"
		 bottomMargin="20"
		 whenNoDataType="NoPages"
		 isTitleNewPage="false"
		 isSummaryNewPage="false">
	<property name="ireport.scriptlethandling" value="0" />
	<property name="ireport.encoding" value="UTF-8" />
	<import value="java.util.*" />
	<import value="net.sf.jasperreports.engine.*" />
	<import value="net.sf.jasperreports.engine.data.*" />
 
	<queryString><![CDATA[SELECT CC.ITMREF_0,CC.ITMDES_0,CC.SHIDAT_0,CC.SOHNUM_0,CC.BPCORD_0,CC.BPCNAM_0,CC.SOQSTA_0,CC.SOHTYP_0,CC.QTY_0,NVL2(CS.TOTSTK,CS.TOTSTK,0) TOTSTK
    FROM (SELECT SORDERQ.ITMREF_0,SORDERP.ITMDES_0,SORDER.SHIDAT_0,SORDERQ.SOHNUM_0,SORDERQ.BPCORD_0,BPCUSTOMER.BPCNAM_0,SORDER.SOHTYP_0,SORDERQ.SOQSTA_0,SORDERQ.QTY_0 FROM 
    SORDERQ INNER JOIN SORDERP ON SORDERQ.SOHNUM_0 = SORDERP.SOHNUM_0
            AND SORDERQ.SOQSEQ_0 = SORDERP.SOPSEQ_0
            AND SORDERQ.SOPLIN_0 = SORDERP.SOPLIN_0
            INNER JOIN BPCUSTOMER ON SORDERQ.BPCORD_0 = BPCUSTOMER.BPCNUM_0
            INNER JOIN SORDER ON SORDERQ.SOHNUM_0 = SORDER.SOHNUM_0) CC 
 
            LEFT OUTER JOIN (SELECT ITMREF_0,SUM(QTYSTU_0) TOTSTK 
            FROM STOCK where STA_0 = 'A' GROUP BY ITMREF_0 ORDER BY ITMREF_0) CS ON CS.ITMREF_0 = CC.ITMREF_0
WHERE CC.SOQSTA_0 <> 3 AND CC.ITMREF_0 <> '105170' AND CC.SOHTYP_0 <> 'ZS'
ORDER BY CC.ITMREF_0,CC.SHIDAT_0]]></queryString>
 
	<field name="ITMREF_0" class="java.lang.String"/>
	<field name="ITMDES_0" class="java.lang.String"/>
	<field name="SHIDAT_0" class="java.sql.Timestamp"/>
	<field name="SOHNUM_0" class="java.lang.String"/>
	<field name="BPCORD_0" class="java.lang.String"/>
	<field name="BPCNAM_0" class="java.lang.String"/>
	<field name="SOQSTA_0" class="java.math.BigDecimal"/>
	<field name="SOHTYP_0" class="java.lang.String"/>
	<field name="QTY_0" class="java.math.BigDecimal"/>
	<field name="TOTSTK" class="java.math.BigDecimal"/>
 
	<variable name="STK_CNT" class="java.math.BigDecimal" resetType="Group" incrementType="Group" incrementGroup="SOHNUM_0" resetGroup="ITMREF_0" calculation="Sum">
		<variableExpression><![CDATA[$F{QTY_0}]]></variableExpression>
	</variable>
	<variable name="STK_RTOT" class="java.lang.String" resetType="Group" incrementType="Group" incrementGroup="SOHNUM_0" resetGroup="ITMREF_0" calculation="Sum">
		<variableExpression><![CDATA[$F{TOTSTK} - $V{STK_CNT}]]></variableExpression>
		<initialValueExpression><![CDATA[0]]></initialValueExpression>
	</variable>
 
		<group  name="ITMREF_0" >
			<groupExpression><![CDATA[$F{ITMREF_0}]]></groupExpression>
			<groupHeader>
			<band height="25"  isSplitAllowed="true" >
				<rectangle radius="0" >
					<reportElement
						x="0"
						y="0"
						width="782"
						height="25"
						forecolor="#8080FF"
						backcolor="#000000"
						key="rectangle"/>
					<graphicElement stretchType="NoStretch"/>
				</rectangle>
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="0"
						y="0"
						width="98"
						height="23"
						forecolor="#FFFFFF"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement>
						<font size="18"/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$F{ITMREF_0}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="108"
						y="0"
						width="374"
						height="23"
						forecolor="#FFFFFF"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement verticalAlignment="Middle">
						<font size="18" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$F{ITMDES_0}]]></textFieldExpression>
				</textField>
				<subreport  isUsingCache="true">
					<reportElement
						x="485"
						y="0"
						width="264"
						height="25"
						key="subreport-1"/>
					<subreportParameter  name="ITMREF">
						<subreportParameterExpression><![CDATA[$F{ITMREF_0}]]></subreportParameterExpression>
					</subreportParameter>
					<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
					<subreportExpression  class="java.lang.String"><![CDATA["repo:POINQ.jrxml"]]></subreportExpression>
				</subreport>
			</band>
			</groupHeader>
			<groupFooter>
			<band height="0"  isSplitAllowed="true" >
			</band>
			</groupFooter>
		</group>
		<group  name="SOHNUM_0" >
			<groupExpression><![CDATA[$F{SOHNUM_0}]]></groupExpression>
			<groupHeader>
			<band height="0"  isSplitAllowed="true" >
			</band>
			</groupHeader>
			<groupFooter>
			<band height="0"  isSplitAllowed="true" >
			</band>
			</groupFooter>
		</group>
		<background>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</background>
		<title>
			<band height="50"  isSplitAllowed="true" >
				<staticText>
					<reportElement
						x="159"
						y="5"
						width="465"
						height="40"
						key="staticText"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement textAlignment="Center" verticalAlignment="Middle">
						<font size="30"/>
					</textElement>
				<text><![CDATA[TO_SHIP]]></text>
				</staticText>
				<line direction="TopDown">
					<reportElement
						x="0"
						y="48"
						width="781"
						height="1"
						forecolor="#000000"
						backcolor="#FFFFFF"
						key="line"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
				<line direction="TopDown">
					<reportElement
						x="0"
						y="3"
						width="781"
						height="1"
						forecolor="#000000"
						backcolor="#FFFFFF"
						key="line"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
			</band>
		</title>
		<pageHeader>
			<band height="9"  isSplitAllowed="true" >
			</band>
		</pageHeader>
		<columnHeader>
			<band height="18"  isSplitAllowed="true" >
				<rectangle>
					<reportElement
						mode="Opaque"
						x="0"
						y="0"
						width="782"
						height="17"
						forecolor="#000000"
						backcolor="#808080"
						key="rectangle"/>
					<graphicElement stretchType="NoStretch">
					<pen lineWidth="0.0" lineStyle="Solid"/>
</graphicElement>
				</rectangle>
				<line direction="BottomUp">
					<reportElement
						x="0"
						y="0"
						width="782"
						height="1"
						forecolor="#000000"
						backcolor="#FFFFFF"
						key="line"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
				<line direction="BottomUp">
					<reportElement
						x="0"
						y="15"
						width="782"
						height="1"
						forecolor="#000000"
						backcolor="#FFFFFF"
						key="line"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
				<staticText>
					<reportElement
						x="86"
						y="0"
						width="86"
						height="17"
						forecolor="#FFFFFF"
						key="staticText"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement textAlignment="Center">
						<font size="12"/>
					</textElement>
				<text><![CDATA[SHIP DATE]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="172"
						y="0"
						width="86"
						height="17"
						forecolor="#FFFFFF"
						key="staticText"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement>
						<font size="12"/>
					</textElement>
				<text><![CDATA[ORDER]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="258"
						y="0"
						width="86"
						height="17"
						forecolor="#FFFFFF"
						key="staticText"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement>
						<font size="12"/>
					</textElement>
				<text><![CDATA[CUSTOMER #]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="344"
						y="0"
						width="86"
						height="17"
						forecolor="#FFFFFF"
						key="staticText"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement>
						<font size="12"/>
					</textElement>
				<text><![CDATA[CUSTOMER]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="430"
						y="0"
						width="48"
						height="17"
						forecolor="#FFFFFF"
						key="staticText"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement>
						<font size="12"/>
					</textElement>
				<text><![CDATA[QTY]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="478"
						y="0"
						width="60"
						height="17"
						forecolor="#FFFFFF"
						key="staticText"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement textAlignment="Center">
						<font size="12"/>
					</textElement>
				<text><![CDATA[ON HAND]]></text>
				</staticText>
				<line direction="TopDown">
					<reportElement
						x="0"
						y="16"
						width="782"
						height="1"
						forecolor="#808080"
						backcolor="#FFFFFF"
						key="line"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
				<staticText>
					<reportElement
						x="538"
						y="0"
						width="60"
						height="17"
						forecolor="#FFFFFF"
						key="staticText-2"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement textAlignment="Center">
						<font size="12"/>
					</textElement>
				<text><![CDATA[REQ TOT]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="601"
						y="0"
						width="102"
						height="17"
						forecolor="#FFFFFF"
						key="staticText-3"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement textAlignment="Center">
						<font size="12"/>
					</textElement>
				<text><![CDATA[STOCK AFTER]]></text>
				</staticText>
			</band>
		</columnHeader>
		<detail>
			<band height="20"  isSplitAllowed="true" >
				<textField isStretchWithOverflow="false" pattern="MM/dd/yyyy" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="86"
						y="2"
						width="86"
						height="17"
						forecolor="#000000"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement verticalAlignment="Middle">
						<font size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />
					</textElement>
				<textFieldExpression   class="java.sql.Timestamp"><![CDATA[$F{SHIDAT_0}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="172"
						y="2"
						width="86"
						height="17"
						forecolor="#000000"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement verticalAlignment="Middle">
						<font size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$F{SOHNUM_0}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="258"
						y="2"
						width="86"
						height="17"
						forecolor="#000000"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement verticalAlignment="Middle">
						<font size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$F{BPCORD_0}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="344"
						y="2"
						width="86"
						height="17"
						forecolor="#000000"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement verticalAlignment="Middle">
						<font size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$F{BPCNAM_0}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="430"
						y="2"
						width="55"
						height="17"
						forecolor="#000000"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement textAlignment="Center" verticalAlignment="Middle">
						<font size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />
					</textElement>
				<textFieldExpression   class="java.math.BigDecimal"><![CDATA[$F{QTY_0}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="478"
						y="2"
						width="55"
						height="17"
						forecolor="#000000"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement textAlignment="Center" verticalAlignment="Middle">
						<font size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />
					</textElement>
				<textFieldExpression   class="java.math.BigDecimal"><![CDATA[$F{TOTSTK}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" pattern="###0" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="540"
						y="1"
						width="64"
						height="18"
						key="textField"/>
					<box></box>
					<textElement verticalAlignment="Middle">
						<font/>
					</textElement>
				<textFieldExpression   class="java.math.BigDecimal"><![CDATA[$V{STK_CNT}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="610"
						y="1"
						width="96"
						height="18"
						key="textField"/>
					<box></box>
					<textElement textAlignment="Center" verticalAlignment="Middle">
						<font/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$V{STK_RTOT}]]></textFieldExpression>
				</textField>
			</band>
		</detail>
		<columnFooter>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</columnFooter>
		<pageFooter>
			<band height="27"  isSplitAllowed="true" >
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="573"
						y="4"
						width="170"
						height="19"
						forecolor="#000000"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement textAlignment="Right">
						<font/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA["Page " + $V{PAGE_NUMBER} + " of "]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Report" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						mode="Transparent"
						x="746"
						y="4"
						width="36"
						height="19"
						forecolor="#000000"
						backcolor="#FFFFFF"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement>
						<font size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA["" + $V{PAGE_NUMBER}]]></textFieldExpression>
				</textField>
				<line direction="TopDown">
					<reportElement
						x="0"
						y="3"
						width="782"
						height="1"
						forecolor="#000000"
						backcolor="#FFFFFF"
						key="line"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="1"
						y="6"
						width="209"
						height="19"
						forecolor="#000000"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement>
						<font/>
					</textElement>
				<textFieldExpression   class="java.util.Date"><![CDATA[new Date()]]></textFieldExpression>
				</textField>
			</band>
		</pageFooter>
		<summary>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</summary>
</jasperReport></td></tr></tbody></table>
mmedici's picture
299
Joined: Aug 12 2010 - 6:47am
Last seen: 13 years 1 month ago

 I am including below the relevant portion of your jrxml file. This should do what you want by only printing the textField if $V{STK_RTOT} is less than 0. If it evaluates to 0 or greater, the textfield should be absent.

Code:
				<textField>
					<reportElement x="610" y="1" width="96" height="18">
						<printWhenExpression><![CDATA[$V{STK_RTOT}<0]]></printWhenExpression>
					</reportElement>
					<textElement textAlignment="Center" verticalAlignment="Middle"/>
					<textFieldExpression class="java.lang.String"><![CDATA[$V{STK_RTOT}]]></textFieldExpression>
				</textField></td></tr></tbody></table>
chgsd's picture
175
Joined: Jun 6 2010 - 4:15pm
Last seen: 10 years 2 months ago

 close

 

getting an error message of

error evaluating expression: Source Text: $V{STK_RTOT}<0

mmedici's picture
299
Joined: Aug 12 2010 - 6:47am
Last seen: 13 years 1 month ago

The problem lies not in what I gave you, but what you already had. You are casting that variable as a string, when it is not.

Please change the class="java.lang.String" in the block below to something more appropriate, most likely java.math.BigDecimal in your case. I suspect that will solve your problem.

Cheers,

CHgsd

Code:
	<variable name="STK_RTOT" class="java.lang.String" resetType="Group" incrementType="Group" incrementGroup="SOHNUM_0" resetGroup="ITMREF_0" calculation="Sum">
		<variableExpression><![CDATA[$F{TOTSTK} - $V{STK_CNT}]]></variableExpression>
		<initialValueExpression><![CDATA[0]]></initialValueExpression>
	</variable></td></tr></tbody></table>
chgsd's picture
175
Joined: Jun 6 2010 - 4:15pm
Last seen: 10 years 2 months ago

Now it runs the report like your previous code did.

it doesn't show the anwer if it is greater then zero, but it still shows the item.

Code:
<?xml version="1.0" encoding="UTF-8"  ?>
<!-- Created with iReport - A designer for JasperReports -->
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport
		 name="stockreqe2"
 
		 language="groovy"		 columnCount="1"
		 printOrder="Vertical"
		 orientation="Portrait"
		 pageWidth="842"
		 pageHeight="595"
		 columnWidth="782"
		 columnSpacing="0"
		 leftMargin="30"
		 rightMargin="30"
		 topMargin="20"
		 bottomMargin="20"
		 whenNoDataType="NoPages"
		 isTitleNewPage="false"
		 isSummaryNewPage="false">
	<property name="ireport.scriptlethandling" value="0" />
	<property name="ireport.encoding" value="UTF-8" />
	<import value="java.util.*" />
	<import value="net.sf.jasperreports.engine.*" />
	<import value="net.sf.jasperreports.engine.data.*" />
 
	<queryString><![CDATA[SELECT CC.ITMREF_0,CC.ITMDES_0,CC.SHIDAT_0,CC.SOHNUM_0,CC.BPCORD_0,CC.BPCNAM_0,CC.SOQSTA_0,CC.SOHTYP_0,CC.QTY_0,NVL2(CS.TOTSTK,CS.TOTSTK,0) TOTSTK
    FROM (SELECT SORDERQ.ITMREF_0,SORDERP.ITMDES_0,SORDER.SHIDAT_0,SORDERQ.SOHNUM_0,SORDERQ.BPCORD_0,BPCUSTOMER.BPCNAM_0,SORDER.SOHTYP_0,SORDERQ.SOQSTA_0,SORDERQ.QTY_0 FROM 
    SORDERQ INNER JOIN SORDERP ON SORDERQ.SOHNUM_0 = SORDERP.SOHNUM_0
            AND SORDERQ.SOQSEQ_0 = SORDERP.SOPSEQ_0
            AND SORDERQ.SOPLIN_0 = SORDERP.SOPLIN_0
            INNER JOIN BPCUSTOMER ON SORDERQ.BPCORD_0 = BPCUSTOMER.BPCNUM_0
            INNER JOIN SORDER ON SORDERQ.SOHNUM_0 = SORDER.SOHNUM_0) CC 
 
            LEFT OUTER JOIN (SELECT ITMREF_0,SUM(QTYSTU_0) TOTSTK 
            FROM STOCK where STA_0 = 'A' GROUP BY ITMREF_0 ORDER BY ITMREF_0) CS ON CS.ITMREF_0 = CC.ITMREF_0
WHERE CC.SOQSTA_0 <> 3 AND CC.ITMREF_0 <> '105170' AND CC.SOHTYP_0 <> 'ZS'
ORDER BY CC.ITMREF_0,CC.SHIDAT_0]]></queryString>
 
	<field name="ITMREF_0" class="java.lang.String"/>
	<field name="ITMDES_0" class="java.lang.String"/>
	<field name="SHIDAT_0" class="java.sql.Timestamp"/>
	<field name="SOHNUM_0" class="java.lang.String"/>
	<field name="BPCORD_0" class="java.lang.String"/>
	<field name="BPCNAM_0" class="java.lang.String"/>
	<field name="SOQSTA_0" class="java.math.BigDecimal"/>
	<field name="SOHTYP_0" class="java.lang.String"/>
	<field name="QTY_0" class="java.math.BigDecimal"/>
	<field name="TOTSTK" class="java.math.BigDecimal"/>
 
	<variable name="STK_CNT" class="java.math.BigDecimal" resetType="Group" incrementType="Group" incrementGroup="SOHNUM_0" resetGroup="ITMREF_0" calculation="Sum">
		<variableExpression><![CDATA[$F{QTY_0}]]></variableExpression>
	</variable>
	<variable name="STK_RTOT" class="java.math.BigDecimal" resetType="Group" incrementType="Group" incrementGroup="SOHNUM_0" resetGroup="ITMREF_0" calculation="Sum">
		<variableExpression><![CDATA[$F{TOTSTK} - $V{STK_CNT}]]></variableExpression>
		<initialValueExpression><![CDATA[0]]></initialValueExpression>
	</variable>
 
		<group  name="ITMREF_0" >
			<groupExpression><![CDATA[$F{ITMREF_0}]]></groupExpression>
			<groupHeader>
			<band height="25"  isSplitAllowed="true" >
				<rectangle radius="0" >
					<reportElement
						x="0"
						y="0"
						width="782"
						height="25"
						forecolor="#8080FF"
						backcolor="#000000"
						key="rectangle"/>
					<graphicElement stretchType="NoStretch"/>
				</rectangle>
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="0"
						y="0"
						width="98"
						height="23"
						forecolor="#FFFFFF"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement>
						<font size="18"/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$F{ITMREF_0}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="108"
						y="0"
						width="374"
						height="23"
						forecolor="#FFFFFF"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement verticalAlignment="Middle">
						<font size="18" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$F{ITMDES_0}]]></textFieldExpression>
				</textField>
				<subreport  isUsingCache="true">
					<reportElement
						x="485"
						y="0"
						width="264"
						height="25"
						key="subreport-1"/>
					<subreportParameter  name="ITMREF">
						<subreportParameterExpression><![CDATA[$F{ITMREF_0}]]></subreportParameterExpression>
					</subreportParameter>
					<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
					<subreportExpression  class="java.lang.String"><![CDATA["repo:POINQ.jrxml"]]></subreportExpression>
				</subreport>
			</band>
			</groupHeader>
			<groupFooter>
			<band height="0"  isSplitAllowed="true" >
			</band>
			</groupFooter>
		</group>
		<group  name="SOHNUM_0" >
			<groupExpression><![CDATA[$F{SOHNUM_0}]]></groupExpression>
			<groupHeader>
			<band height="0"  isSplitAllowed="true" >
			</band>
			</groupHeader>
			<groupFooter>
			<band height="0"  isSplitAllowed="true" >
			</band>
			</groupFooter>
		</group>
		<background>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</background>
		<title>
			<band height="50"  isSplitAllowed="true" >
				<staticText>
					<reportElement
						x="159"
						y="5"
						width="465"
						height="40"
						key="staticText"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement textAlignment="Center" verticalAlignment="Middle">
						<font size="30"/>
					</textElement>
				<text><![CDATA[TO_SHIP]]></text>
				</staticText>
				<line direction="TopDown">
					<reportElement
						x="0"
						y="48"
						width="781"
						height="1"
						forecolor="#000000"
						backcolor="#FFFFFF"
						key="line"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
				<line direction="TopDown">
					<reportElement
						x="0"
						y="3"
						width="781"
						height="1"
						forecolor="#000000"
						backcolor="#FFFFFF"
						key="line"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
			</band>
		</title>
		<pageHeader>
			<band height="9"  isSplitAllowed="true" >
			</band>
		</pageHeader>
		<columnHeader>
			<band height="18"  isSplitAllowed="true" >
				<rectangle>
					<reportElement
						mode="Opaque"
						x="0"
						y="0"
						width="782"
						height="17"
						forecolor="#000000"
						backcolor="#808080"
						key="rectangle"/>
					<graphicElement stretchType="NoStretch">
					<pen lineWidth="0.0" lineStyle="Solid"/>
</graphicElement>
				</rectangle>
				<line direction="BottomUp">
					<reportElement
						x="0"
						y="0"
						width="782"
						height="1"
						forecolor="#000000"
						backcolor="#FFFFFF"
						key="line"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
				<line direction="BottomUp">
					<reportElement
						x="0"
						y="15"
						width="782"
						height="1"
						forecolor="#000000"
						backcolor="#FFFFFF"
						key="line"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
				<staticText>
					<reportElement
						x="86"
						y="0"
						width="86"
						height="17"
						forecolor="#FFFFFF"
						key="staticText"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement textAlignment="Center">
						<font size="12"/>
					</textElement>
				<text><![CDATA[SHIP DATE]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="172"
						y="0"
						width="86"
						height="17"
						forecolor="#FFFFFF"
						key="staticText"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement>
						<font size="12"/>
					</textElement>
				<text><![CDATA[ORDER]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="258"
						y="0"
						width="86"
						height="17"
						forecolor="#FFFFFF"
						key="staticText"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement>
						<font size="12"/>
					</textElement>
				<text><![CDATA[CUSTOMER #]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="344"
						y="0"
						width="86"
						height="17"
						forecolor="#FFFFFF"
						key="staticText"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement>
						<font size="12"/>
					</textElement>
				<text><![CDATA[CUSTOMER]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="430"
						y="0"
						width="48"
						height="17"
						forecolor="#FFFFFF"
						key="staticText"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement>
						<font size="12"/>
					</textElement>
				<text><![CDATA[QTY]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="478"
						y="0"
						width="60"
						height="17"
						forecolor="#FFFFFF"
						key="staticText"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement textAlignment="Center">
						<font size="12"/>
					</textElement>
				<text><![CDATA[ON HAND]]></text>
				</staticText>
				<line direction="TopDown">
					<reportElement
						x="0"
						y="16"
						width="782"
						height="1"
						forecolor="#808080"
						backcolor="#FFFFFF"
						key="line"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
				<staticText>
					<reportElement
						x="538"
						y="0"
						width="60"
						height="17"
						forecolor="#FFFFFF"
						key="staticText-2"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement textAlignment="Center">
						<font size="12"/>
					</textElement>
				<text><![CDATA[REQ TOT]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="601"
						y="0"
						width="102"
						height="17"
						forecolor="#FFFFFF"
						key="staticText-3"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement textAlignment="Center">
						<font size="12"/>
					</textElement>
				<text><![CDATA[STOCK AFTER]]></text>
				</staticText>
			</band>
		</columnHeader>
		<detail>
			<band height="20"  isSplitAllowed="true" >
				<textField isStretchWithOverflow="false" pattern="MM/dd/yyyy" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="86"
						y="2"
						width="86"
						height="17"
						forecolor="#000000"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement verticalAlignment="Middle">
						<font size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />
					</textElement>
				<textFieldExpression   class="java.sql.Timestamp"><![CDATA[$F{SHIDAT_0}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="172"
						y="2"
						width="86"
						height="17"
						forecolor="#000000"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement verticalAlignment="Middle">
						<font size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$F{SOHNUM_0}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="258"
						y="2"
						width="86"
						height="17"
						forecolor="#000000"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement verticalAlignment="Middle">
						<font size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$F{BPCORD_0}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="344"
						y="2"
						width="86"
						height="17"
						forecolor="#000000"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement verticalAlignment="Middle">
						<font size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$F{BPCNAM_0}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="430"
						y="2"
						width="55"
						height="17"
						forecolor="#000000"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement textAlignment="Center" verticalAlignment="Middle">
						<font size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />
					</textElement>
				<textFieldExpression   class="java.math.BigDecimal"><![CDATA[$F{QTY_0}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="478"
						y="2"
						width="55"
						height="17"
						forecolor="#000000"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement textAlignment="Center" verticalAlignment="Middle">
						<font size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />
					</textElement>
				<textFieldExpression   class="java.math.BigDecimal"><![CDATA[$F{TOTSTK}]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" pattern="###0" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="540"
						y="1"
						width="64"
						height="18"
						key="textField"/>
					<box></box>
					<textElement verticalAlignment="Middle">
						<font/>
					</textElement>
				<textFieldExpression   class="java.math.BigDecimal"><![CDATA[$V{STK_CNT}]]></textFieldExpression>
				</textField>
		    <textField>
 
                                      <reportElement x="610" y="1" width="96" height="18">
 
                                           <printWhenExpression><![CDATA[$V{STK_RTOT}<0]]></printWhenExpression>
 
                                       </reportElement>
 
                                        <textElement textAlignment="Center" verticalAlignment="Middle"/>
 
                                     <textFieldExpression class="java.lang.String"><![CDATA[$V{STK_RTOT}]]></textFieldExpression>
 
                            </textField>
			</band>
		</detail>
		<columnFooter>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</columnFooter>
		<pageFooter>
			<band height="27"  isSplitAllowed="true" >
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="573"
						y="4"
						width="170"
						height="19"
						forecolor="#000000"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement textAlignment="Right">
						<font/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA["Page " + $V{PAGE_NUMBER} + " of "]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Report" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						mode="Transparent"
						x="746"
						y="4"
						width="36"
						height="19"
						forecolor="#000000"
						backcolor="#FFFFFF"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement>
						<font size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA["" + $V{PAGE_NUMBER}]]></textFieldExpression>
				</textField>
				<line direction="TopDown">
					<reportElement
						x="0"
						y="3"
						width="782"
						height="1"
						forecolor="#000000"
						backcolor="#FFFFFF"
						key="line"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="1"
						y="6"
						width="209"
						height="19"
						forecolor="#000000"
						key="textField"/>
					<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
					<textElement>
						<font/>
					</textElement>
				<textFieldExpression   class="java.util.Date"><![CDATA[new Date()]]></textFieldExpression>
				</textField>
			</band>
		</pageFooter>
		<summary>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</summary>
</jasperReport>
</td></tr></tbody></table>
mmedici's picture
299
Joined: Aug 12 2010 - 6:47am
Last seen: 13 years 1 month ago

When you say "item" what do you mean. The textField will not be printed with the block I gave to you.

If you mean some parent element you need to use that same printWhenExpression for the given "item". For example if you do not want the detail band printed when that condition is met, put the printWhenExpression in the detail band.

Does that make more sense?

Cheers,

CHgsd

chgsd's picture
175
Joined: Jun 6 2010 - 4:15pm
Last seen: 10 years 2 months ago

 Ok, i put the printwhenexpression within the reportelement part of each column and it has made the information disappear which is great.

 

however, it leaves empty rows where that information was.

 

meaning the report comes out 152 pages, with a lot of empty or blank rows.  If we consolidated the rows to where there was only text then the report would only take 3 pages or so

 

by the way, thank you again for all of your help. 

mmedici's picture
299
Joined: Aug 12 2010 - 6:47am
Last seen: 13 years 1 month ago

 just following up to see if anyone has any idea on how to remove the blank rows. 

mmedici's picture
299
Joined: Aug 12 2010 - 6:47am
Last seen: 13 years 1 month ago
Feedback
randomness