<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Target shipping label" pageWidth="283" pageHeight="438" columnWidth="283" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
	<property name="ireport.zoom" value="1.2100000000000062"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<parameter name="REPLORDER" class="java.lang.String"/>
	<parameter name="FORMATID" class="java.lang.String"/>
	<queryString>
		<![CDATA[select site.descr as site_descr,
site.add1 as site_add1,
site.add2 as site_add2,
site.city as site_city,
site.state_code as site_state_code,
site.pin as site_pin,
(SELECT CUST_NAME FROM CUSTOMER WHERE CUST_CODE = T.CUST_CODE__DLV) as cust_name,
(SELECT CUST_ITEM__REF  FROM SORDDET WHERE SORDDET.SALE_ORDER = T.SALE_ORDER AND SORDDET.LINE_NO = T.LINE_NO__SORD) as CUST_ITEM_REF,
T.DLV_ADD1,
T.DLV_ADD2,
t.DLV_CITY AS DLV_CITY,
T.DLV_STATE AS DLV_STATE,
T.DLV_PIN AS DLV_PIN,
substr(T.DLV_PIN,0,5) AS DLV_PIN_SUB,
(SELECT TRAN_NAME FROM TRANSPORTER WHERE TRAN_CODE = T.TRAN_CODE) AS TRAN_NAME,
T.CUST_PORD AS CUST_PORD,
SUBSTR(T.CUST_PORD,1,3) as cust_prod ,
SUBSTR(T.CUST_PORD,4,6) as cust_prod1 ,
SUBSTR(T.CUST_PORD,10) as cust_prod2,
T.ITEM_CODE AS ITEM_CODE,
T.LOC_CODE AS LOC_CODE,
T.NO_ART AS NO_ART,
T.QUANTITY AS QUANTITY,
T.QTY_EACHES AS QTY_EACHES,
T.NOOF_CARTONS,
T.LINE_NO AS PICK_LINE_NO,
CM.CARTON_NO  AS SSCC_18,
1 AS CARTON_NO1,
CASE WHEN CM.MASTER_CARTON IS NULL OR LENGTH(TRIM(CM.MASTER_CARTON)) = 0 THEN '1' ELSE MASTER_CARTON END AS MASTER_CARTON

 from  (

select r.REPL_ORDER REPL_ORDER,
r.ORDER_DATE,
r.SITE_CODE,
r.SALE_ORDER,
r.WAVE_ID,
r.ORDER_TYPE,
r.CHG_USER,
r.CHG_DATE,
r.CHG_TERM,
rd.LINE_NO,
rd.LINE_NO__SORD,
rd.ITEM_CODE,
rd.LOC_CODE,
rd.LOT_NO,
rd.LOT_SL,
rd.NO_ART,
rd.QUANTITY,
rd.EXP_LEV   ,
i.unit,
i.COUNT_CODE__MFG,
SO.CUST_CODE__DLV AS CUST_CODE__DLV,
SO.CUST_PORD AS CUST_PORD,
SO.DLV_ADD1 AS DLV_ADD1,
SO.DLV_ADD2 AS DLV_ADD2,
SO.DLV_CITY AS DLV_CITY,
SO.STATE_CODE__DLV DLV_STATE,
SO.DLV_PIN AS DLV_PIN,
SO.TRAN_CODE AS TRAN_CODE,
I.ITEM_CODE__NDC11 AS ITEM_CODE__NDC11,
(RD.QUANTITY / RD.NO_ART) AS QTY_EACHES,
(SELECT SUM(NO_ART) FROM repl_ord_det RD1 WHERE RD1.REPL_ORDER = RD.REPL_ORDER
	AND RD1.LOC_CODE = RD.LOC_CODE AND RD1.ITEM_CODE = RD.ITEM_CODE) AS NOOF_CARTONS
from repl_ord_hdr r, repl_ord_det rd,item i,SORDER SO
where r.repl_order = rd.repl_order
and i.item_code = rd.item_code
and r.repl_order = '$P!{REPLORDER}'
AND SO.SALE_ORDER = R.SALE_ORDER
AND  '$P!{FORMATID}' = '03'
union all
select p.PICK_ORDER PICK_ORDER,
p.ORDER_DATE ORDER_DATE,
p.SITE_CODE SITE_CODE,
p.SALE_ORDER,
p.WAVE_ID,
p.PICK_TYPE,
p.CHG_USER,
p.CHG_DATE,
p.CHG_TERM,
pd.LINE_NO,
pd.LINE_NO__SORD,
pd.ITEM_CODE,
pd.LOC_CODE,
pd.LOT_NO,
pd.LOT_SL,
pd.NO_ART,
pd.QUANTITY,
pd.EXP_LEV ,
i.unit,
i.COUNT_CODE__MFG,
SO.CUST_CODE__DLV AS CUST_CODE__DLV,
SO.CUST_PORD AS CUST_PORD,
SO.DLV_ADD1 AS DLV_ADD1,
SO.DLV_ADD2 AS DLV_ADD2,
SO.DLV_CITY AS DLV_CITY,
SO.STATE_CODE__DLV DLV_STATE,
SO.DLV_PIN AS DLV_PIN,
SO.TRAN_CODE AS TRAN_CODE,
I.ITEM_CODE__NDC11 AS ITEM_CODE__NDC11,
(PD.QUANTITY / PD.NO_ART) AS QTY_EACHES,
(SELECT SUM(NO_ART) FROM pick_ord_det PD1 WHERE PD1.PICK_ORDER = PD.PICK_ORDER
	AND PD1.LOC_CODE = PD.LOC_CODE AND PD1.ITEM_CODE = PD.ITEM_CODE) AS NOOF_CARTONS
from pick_ord_hdr p, pick_ord_det pd,item i, SORDER SO
where p.pick_order = pd.pick_order
and i.item_code = pd.item_code
and p.pick_order = '$P!{REPLORDER}'
AND SO.SALE_ORDER = P.SALE_ORDER
AND  '$P!{FORMATID}' = '03'
) t,
CARTON_MASTER CM,
SITE
WHERE CM.PICK_ORDER = T.REPL_ORDER
AND CM.LINE_NO__PICK = T.LINE_NO
AND SITE.SITE_CODE = T.SITE_CODE
order by CASE WHEN CM.MASTER_CARTON IS NULL OR LENGTH(TRIM(CM.MASTER_CARTON)) = 0 THEN '1' ELSE MASTER_CARTON END,t.loc_code,t.loc_code,T.ITEM_CODE,T.LINE_NO]]>
	</queryString>
	<field name="TRAN_NAME" class="java.lang.String"/>
	<field name="CARTON_NO1" class="java.lang.Double"/>
	<field name="CUST_PORD" class="java.lang.String"/>
	<field name="DLV_ADD1" class="java.lang.String"/>
	<field name="DLV_ADD2" class="java.lang.String"/>
	<field name="DLV_CITY" class="java.lang.String"/>
	<field name="DLV_STATE" class="java.lang.String"/>
	<field name="DLV_PIN" class="java.lang.String"/>
	<field name="QTY_EACHES" class="java.lang.String"/>
	<field name="SITE_ADD1" class="java.lang.String"/>
	<field name="SITE_ADD2" class="java.lang.String"/>
	<field name="SITE_CITY" class="java.lang.String"/>
	<field name="SITE_PIN" class="java.lang.String"/>
	<field name="SITE_STATE_CODE" class="java.lang.String"/>
	<field name="cust_name" class="java.lang.String"/>
	<field name="ITEM_CODE" class="java.lang.String"/>
	<field name="LOC_CODE" class="java.lang.String"/>
	<field name="SSCC_18" class="java.lang.String"/>
	<field name="NO_ART" class="java.lang.Integer"/>
	<field name="SITE_DESCR" class="java.lang.String"/>
	<field name="CUST_ITEM_REF" class="java.lang.String"/>
	<field name="DLV_PIN_SUB" class="java.lang.String"/>
	<field name="CUST_PROD" class="java.lang.String"/>
	<field name="CUST_PROD1" class="java.lang.String"/>
	<field name="CUST_PROD2" class="java.lang.String"/>
	<field name="MASTER_CARTON" class="java.lang.String"/>
	<variable name="COMPUTE_1" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String(ibase.webitm.reports.sun.BaseReportGFMethods.gf_bar_code("420"+ibase.webitm.reports.utility.BaseReportMethods.trim($F{DLV_PIN_SUB}) ) )]]></variableExpression>
	</variable>
	<variable name="COMPUTE_2" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String(ibase.webitm.reports.sun.BaseReportGFMethods.gf_bar_code("00"+ibase.webitm.reports.utility.BaseReportMethods.trim($F{SSCC_18}) ) )]]></variableExpression>
	</variable>
	<variable name="COMPUTE_3" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String("(420) "+ibase.webitm.reports.utility.BaseReportMethods.trim($F{DLV_PIN_SUB}))]]></variableExpression>
	</variable>
	<variable name="COMPUTE_4" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String("(00) "+ibase.webitm.reports.utility.BaseReportMethods.trim($F{SSCC_18}))]]></variableExpression>
	</variable>
	<variable name="TOCUST" class="java.lang.String"/>
	<variable name="compute_5" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String((ibase.webitm.reports.utility.BaseReportMethods.isNull($F{SITE_CITY}) ? " " : ($F{SITE_CITY}).trim())+"  "+(ibase.webitm.reports.utility.BaseReportMethods.isNull($F{SITE_STATE_CODE} ) ? " " : ($F{SITE_STATE_CODE}).trim())+" "+ (ibase.webitm.reports.utility.BaseReportMethods.isNull($F{SITE_PIN}) ? " " :($F{SITE_PIN}).trim()))]]></variableExpression>
	</variable>
	<variable name="compute_6" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String((ibase.webitm.reports.utility.BaseReportMethods.isNull($F{DLV_CITY}) ? " " : ($F{DLV_CITY}).trim())+" "+(ibase.webitm.reports.utility.BaseReportMethods.isNull($F{DLV_STATE} ) ? " " : ($F{DLV_STATE}).trim())+" "+ (ibase.webitm.reports.utility.BaseReportMethods.isNull($F{DLV_PIN}) ? " " :($F{DLV_PIN}).trim()))]]></variableExpression>
	</variable>
	<variable name="compute_7" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String((ibase.webitm.reports.utility.BaseReportMethods.isNull($F{CUST_PROD}) ? " " : $F{CUST_PROD})+(ibase.webitm.reports.utility.BaseReportMethods.isNull($F{CUST_PROD1} ) ? " " : " - " +$F{CUST_PROD1})+ (ibase.webitm.reports.utility.BaseReportMethods.isNull($F{CUST_PROD2}) ? " " : " - " +$F{CUST_PROD2}))]]></variableExpression>
	</variable>
	<group name="Location" isStartNewPage="true">
		<groupExpression><![CDATA[$F{LOC_CODE}]]></groupExpression>
		<groupHeader>
			<band/>
		</groupHeader>
		<groupFooter>
			<band height="7">
				<subreport>
					<reportElement isPrintRepeatedValues="false" x="6" y="2" width="254" height="5" printWhenGroupChanges="Location"/>
					<parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]></parametersMapExpression>
					<subreportParameter name="LOC_CODE">
						<subreportParameterExpression><![CDATA[$F{LOC_CODE}]]></subreportParameterExpression>
					</subreportParameter>
					<subreportParameter name="REPLORDER">
						<subreportParameterExpression><![CDATA[$P{REPLORDER}]]></subreportParameterExpression>
					</subreportParameter>
					<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
					<subreportExpression class="java.io.InputStream"><![CDATA[new FileInputStream("C:/jboss-5.1.0.GA/server/default/deploy/ibase.ear/ibase.war/webitm/reports/jrxml/pick_task_break.jasper")]]></subreportExpression>
				</subreport>
			</band>
		</groupFooter>
	</group>
	<group name="carton break" isStartNewPage="true">
		<groupExpression><![CDATA[$F{MASTER_CARTON}]]></groupExpression>
		<groupHeader>
			<band/>
		</groupHeader>
		<groupFooter>
			<band height="7">
				<subreport>
					<reportElement isPrintRepeatedValues="false" x="6" y="2" width="254" height="5" printWhenGroupChanges="carton break">
						<printWhenExpression><![CDATA[new Boolean(!$F{MASTER_CARTON}.equals("1")?true:false)]]></printWhenExpression>
					</reportElement>
					<parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]></parametersMapExpression>
					<subreportParameter name="MASTER_CARTON">
						<subreportParameterExpression><![CDATA[$F{MASTER_CARTON}]]></subreportParameterExpression>
					</subreportParameter>
					<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
					<subreportExpression class="java.io.InputStream"><![CDATA[new FileInputStream("C:/jboss-5.1.0.GA/server/default/deploy/ibase.ear/ibase.war/webitm/reports/jrxml/carton_break.jasper")]]></subreportExpression>
				</subreport>
			</band>
		</groupFooter>
	</group>
	<background>
		<band splitType="Stretch"/>
	</background>
	<title>
		<band splitType="Stretch"/>
	</title>
	<pageHeader>
		<band splitType="Stretch"/>
	</pageHeader>
	<columnHeader>
		<band splitType="Stretch"/>
	</columnHeader>
	<detail>
		<band height="406" splitType="Stretch">
			<rectangle>
				<reportElement mode="Transparent" x="2" y="14" width="259" height="390">
					<printWhenExpression><![CDATA[new Boolean(false)]]></printWhenExpression>
				</reportElement>
			</rectangle>
			<staticText>
				<reportElement x="4" y="15" width="120" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="8" isBold="false"/>
				</textElement>
				<text><![CDATA[FROM :]]></text>
			</staticText>
			<line>
				<reportElement x="129" y="12" width="1" height="70"/>
			</line>
			<staticText>
				<reportElement x="132" y="15" width="100" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="8" isBold="true"/>
				</textElement>
				<text><![CDATA[TO :]]></text>
			</staticText>
			<staticText>
				<reportElement x="9" y="87" width="120" height="12"/>
				<textElement>
					<font fontName="Times New Roman" isBold="true"/>
				</textElement>
				<text><![CDATA[(420) Ship to Postal Code:]]></text>
			</staticText>
			<line>
				<reportElement x="2" y="298" width="260" height="1"/>
			</line>
			<line>
				<reportElement x="2" y="226" width="260" height="1"/>
			</line>
			<staticText>
				<reportElement x="7" y="160" width="30" height="15"/>
				<textElement textAlignment="Left" verticalAlignment="Middle">
					<font fontName="Times New Roman" size="10" isBold="true"/>
				</textElement>
				<text><![CDATA[PO#:]]></text>
			</staticText>
			<line>
				<reportElement x="2" y="82" width="260" height="1"/>
			</line>
			<line>
				<reportElement x="2" y="154" width="260" height="1"/>
			</line>
			<line>
				<reportElement x="145" y="82" width="1" height="72"/>
			</line>
			<staticText>
				<reportElement x="149" y="88" width="80" height="12"/>
				<textElement verticalAlignment="Middle">
					<font fontName="Times New Roman" size="8" isBold="false"/>
				</textElement>
				<text><![CDATA[CARRIER:]]></text>
			</staticText>
			<staticText>
				<reportElement x="7" y="178" width="30" height="15"/>
				<textElement textAlignment="Left" verticalAlignment="Middle">
					<font fontName="Times New Roman" size="10" isBold="true"/>
				</textElement>
				<text><![CDATA[DPCI:]]></text>
			</staticText>
			<staticText>
				<reportElement x="7" y="196" width="50" height="15"/>
				<textElement textAlignment="Left" verticalAlignment="Middle">
					<font fontName="Times New Roman" size="10" isBold="true"/>
				</textElement>
				<text><![CDATA[Casepack :]]></text>
			</staticText>
			<textField isBlankWhenNull="true">
				<reportElement x="4" y="41" width="125" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{SITE_ADD1}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="4" y="54" width="125" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{SITE_ADD2}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="132" y="54" width="125" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="9" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{DLV_ADD2}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="132" y="41" width="130" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="9" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{DLV_ADD1}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="150" y="101" width="112" height="15"/>
				<textElement textAlignment="Left" verticalAlignment="Middle">
					<font fontName="Times New Roman" size="8"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{TRAN_NAME}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="38" y="160" width="225" height="15"/>
				<textElement textAlignment="Left" verticalAlignment="Middle">
					<font fontName="Times New Roman" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{compute_7}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="38" y="178" width="224" height="15"/>
				<textElement textAlignment="Left" verticalAlignment="Middle">
					<font fontName="Times New Roman" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{CUST_ITEM_REF}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="59" y="196" width="204" height="15"/>
				<textElement textAlignment="Left" verticalAlignment="Middle">
					<font fontName="Times New Roman" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{QTY_EACHES}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement x="11" y="304" width="179" height="15"/>
				<textElement textAlignment="Left" verticalAlignment="Top">
					<font fontName="Times New Roman" size="7" isBold="false"/>
				</textElement>
				<text><![CDATA[(00) SERIAL SHIPPING CONTAINER]]></text>
			</staticText>
			<textField isBlankWhenNull="true">
				<reportElement x="7" y="117" width="137" height="36"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font fontName="Code 128AB" size="24"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{COMPUTE_1}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="3" y="338" width="259" height="66"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font fontName="Code 128AB" size="32" isBold="false"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{COMPUTE_2}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="4" y="101" width="141" height="17"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font fontName="Times New Roman" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{COMPUTE_3}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="9" y="319" width="245" height="14"/>
				<textElement textAlignment="Center">
					<font fontName="Times New Roman" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{COMPUTE_4}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="132" y="28" width="130" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="9" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{cust_name}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="2" y="28" width="125" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{SITE_DESCR}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="3" y="68" width="125" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{compute_5}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="132" y="68" width="125" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="9" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{compute_6}]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<columnFooter>
		<band splitType="Stretch"/>
	</columnFooter>
	<pageFooter>
		<band splitType="Stretch"/>
	</pageFooter>
	<summary>
		<band splitType="Stretch"/>
	</summary>
</jasperReport>
