<?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="Rite_Aid_Shipping" pageWidth="283" pageHeight="434" columnWidth="283" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
	<property name="ireport.zoom" value="1.5"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="133"/>
	<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,
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,
T.descr as ITEM_DESCR,
T.ITEM_CODE__UPC AS ITEM_CODE__UPC,
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__UPC AS ITEM_CODE__UPC,
i.descr,
(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}' = '02'
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__UPC AS ITEM_CODE__UPC,
i.descr,
(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}' = '02'
) 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.Integer"/>
	<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="ITEM_DESCR" class="java.lang.String"/>
	<field name="ITEM_CODE__UPC" class="java.lang.String"/>
	<field name="DLV_PIN_SUB" class="java.lang.String"/>
	<field name="MASTER_CARTON" class="java.lang.String"/>
	<variable name="compute_2" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String(ibase.webitm.reports.sun.BaseReportGFMethods.gf_bar_code(ibase.webitm.reports.utility.BaseReportMethods.trim($F{ITEM_CODE__UPC}) ) )]]></variableExpression>
	</variable>
	<variable name="compute_3" 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_4" 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_5" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String("(00) "+ibase.webitm.reports.utility.BaseReportMethods.trim($F{SSCC_18}))]]></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_8" 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_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>
	<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="402" splitType="Stretch">
			<rectangle>
				<reportElement x="2" y="12" width="258" height="388">
					<printWhenExpression><![CDATA[new Boolean(false)]]></printWhenExpression>
				</reportElement>
			</rectangle>
			<line>
				<reportElement x="2" y="73" width="258" height="1"/>
			</line>
			<line>
				<reportElement x="2" y="144" width="258" height="1"/>
			</line>
			<line>
				<reportElement x="2" y="216" width="258" height="1"/>
			</line>
			<line>
				<reportElement x="2" y="287" width="258" height="1"/>
			</line>
			<line>
				<reportElement x="128" y="12" width="1" height="61"/>
			</line>
			<line>
				<reportElement x="144" y="73" width="1" height="72"/>
			</line>
			<line>
				<reportElement x="124" y="216" width="1" height="71"/>
			</line>
			<staticText>
				<reportElement x="6" y="13" width="33" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="8" isBold="true"/>
				</textElement>
				<text><![CDATA[FROM:]]></text>
			</staticText>
			<staticText>
				<reportElement x="131" y="13" width="27" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="8" isBold="true"/>
				</textElement>
				<text><![CDATA[TO:]]></text>
			</staticText>
			<staticText>
				<reportElement x="5" y="76" width="121" height="13"/>
				<textElement>
					<font fontName="Times New Roman" size="8" isBold="true"/>
				</textElement>
				<text><![CDATA[(420) Ship To Postal Code ]]></text>
			</staticText>
			<staticText>
				<reportElement x="148" y="76" width="51" height="12"/>
				<textElement>
					<font fontName="Times New Roman" size="8" isBold="true"/>
				</textElement>
				<text><![CDATA[CARRIER:]]></text>
			</staticText>
			<staticText>
				<reportElement x="147" y="113" width="24" height="13"/>
				<textElement>
					<font fontName="Times New Roman" size="8" isBold="true"/>
				</textElement>
				<text><![CDATA[PRO:]]></text>
			</staticText>
			<staticText>
				<reportElement x="147" y="127" width="24" height="13"/>
				<textElement>
					<font fontName="Times New Roman" size="8" isBold="true"/>
				</textElement>
				<text><![CDATA[B/L:
]]></text>
			</staticText>
			<staticText>
				<reportElement x="5" y="148" width="27" height="13"/>
				<textElement>
					<font fontName="Times New Roman" size="8" isBold="true"/>
				</textElement>
				<text><![CDATA[PO:]]></text>
			</staticText>
			<staticText>
				<reportElement x="5" y="166" width="27" height="13"/>
				<textElement>
					<font fontName="Times New Roman" size="8" isBold="true"/>
				</textElement>
				<text><![CDATA[Desc:]]></text>
			</staticText>
			<staticText>
				<reportElement x="5" y="200" width="27" height="13"/>
				<textElement>
					<font fontName="Times New Roman" size="8" isBold="true"/>
				</textElement>
				<text><![CDATA[Qty:]]></text>
			</staticText>
			<staticText>
				<reportElement x="5" y="183" width="27" height="13"/>
				<textElement>
					<font fontName="Times New Roman" size="8" isBold="true"/>
				</textElement>
				<text><![CDATA[Type:]]></text>
			</staticText>
			<staticText>
				<reportElement x="6" y="221" width="65" height="13"/>
				<textElement>
					<font fontName="Times New Roman" size="8" isBold="true"/>
				</textElement>
				<text><![CDATA[Rite Aid Item:]]></text>
			</staticText>
			<staticText>
				<reportElement x="127" y="220" width="27" height="13"/>
				<textElement>
					<font fontName="Times New Roman" size="8" isBold="true"/>
				</textElement>
				<text><![CDATA[UPC#:]]></text>
			</staticText>
			<staticText>
				<reportElement x="4" y="289" width="43" height="13"/>
				<textElement>
					<font fontName="Times New Roman" size="8" isBold="true"/>
				</textElement>
				<text><![CDATA[SSCC-18]]></text>
			</staticText>
			<textField isBlankWhenNull="true">
				<reportElement x="5" y="37" width="121" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{SITE_ADD1}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="5" y="50" width="120" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{SITE_ADD2}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="5" y="62" width="120" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{compute_8}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="131" y="37" width="126" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{DLV_ADD1}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="131" y="50" width="127" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{DLV_ADD2}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="149" y="91" width="105" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{TRAN_NAME}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="36" y="148" width="150" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{CUST_PORD}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="37" y="166" width="221" height="17"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{ITEM_DESCR}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="37" y="200" width="125" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.Integer"><![CDATA[$F{QTY_EACHES}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="7" y="239" width="117" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{CUST_ITEM_REF}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="154" y="221" width="100" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{ITEM_CODE__UPC}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="4" y="314" width="255" height="73"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font fontName="Code 128AB Tall" size="32"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{compute_3}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="125" y="236" width="135" height="51"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font fontName="Code 128AB" size="22"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{compute_2}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="3" y="103" width="140" height="41"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font fontName="Code 128AB" size="26"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{compute_1}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="3" y="89" width="140" height="14"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font fontName="Times New Roman"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{compute_4}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="4" y="302" width="256" height="12"/>
				<textElement textAlignment="Center">
					<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="62" width="125" height="12"/>
				<textElement>
					<font fontName="Times New Roman" size="7" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{compute_6}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="131" y="24" width="126" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{cust_name}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="6" y="24" width="121" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{SITE_DESCR}]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<columnFooter>
		<band splitType="Stretch"/>
	</columnFooter>
	<pageFooter>
		<band splitType="Stretch"/>
	</pageFooter>
	<summary>
		<band splitType="Stretch"/>
	</summary>
</jasperReport>
