<?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="Ups_Ground_Shipping" pageWidth="283" pageHeight="425" columnWidth="243" leftMargin="20" rightMargin="20" topMargin="2" bottomMargin="2">
	<property name="ireport.zoom" value="1.5"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<parameter name="WaveID" class="java.lang.String"/>
	<queryString>
		<![CDATA[SELECT
     DISTINCT
     CASE WHEN SORDER."CUST_PORD" IS NULL THEN ' ' ELSE SORDER."CUST_PORD" END AS SORDER_CUST_PORD,
     CASE WHEN SORDER."DLV_ADD1" IS NULL THEN ' ' ELSE SORDER."DLV_ADD1" END AS SORDER_DLV_ADD1,
     CASE WHEN SORDER."DLV_ADD2" IS NULL THEN ' ' ELSE SORDER."DLV_ADD2" END AS SORDER_DLV_ADD2,
     CASE WHEN SORDER."DLV_ADD3" IS NULL THEN ' ' ELSE SORDER."DLV_ADD3" END AS SORDER_DLV_ADD3,
     CASE WHEN SORDER."DLV_CITY" IS NULL THEN ' ' ELSE SORDER."DLV_CITY" END AS SORDER_DLV_CITY,
     CASE WHEN SORDER."STATE_CODE__DLV" IS NULL THEN '' ELSE SORDER."STATE_CODE__DLV" END AS SORDER_STATE_CODE__DLV,
     CASE WHEN SORDER."DLV_PIN" IS NULL THEN ' ' ELSE SORDER."DLV_PIN" END AS SORDER_DLV_PIN,
     CASE WHEN SORDER."FRT_TERM" IS NULL THEN ' ' ELSE SORDER."FRT_TERM" END AS SORDER_FRT_TERM,
    CASE WHEN SITE."DESCR"IS NULL THEN ' ' ELSE SITE."DESCR" END AS SITE_DESCR,
     CASE WHEN SITE."ADD1"IS NULL THEN ' ' ELSE SITE."ADD1" END AS SITE_ADD1,
     CASE WHEN SITE."ADD2"IS NULL THEN ' ' ELSE SITE."ADD2" END AS SITE_ADD2,
     CASE WHEN SITE."CITY"IS NULL THEN ' 'ELSE SITE."CITY" END AS SITE_CITY,
     CASE WHEN SITE."PIN" IS NULL THEN ' 'ELSE SITE."PIN" END AS SITE_PIN,
     CASE WHEN SITE."STATE_CODE"IS NULL THEN ' ' ELSE SITE."STATE_CODE" END AS SITE_STATE_CODE,
     CASE WHEN ITEM."DESCR" IS NULL THEN ' ' ELSE ITEM."DESCR" END AS ITEM_DESCR,
     CASE WHEN DESPATCH."DESP_ID" IS NULL THEN ' ' ELSE DESPATCH."DESP_ID" END AS DESPATCH_TRAN_ID,
     CASE WHEN DESPATCH."TRAN_CODE" IS NULL THEN ' ' ELSE DESPATCH."TRAN_CODE" END AS DESPATCH_TRAN_CODE,
     CASE WHEN DESPATCH."SHIPMENT_ID" IS NULL THEN ' ' ELSE DESPATCH."SHIPMENT_ID" END AS DESPATCH_SHIPMENT_ID,
     CASE WHEN DESPATCHDET."SSCC_18"IS NULL THEN ' ' ELSE DESPATCHDET."SSCC_18" END AS DESPATCHDET_SSCC_18,
     CASE WHEN PICK_ORD_HDR."PICK_ORDER" IS NULL THEN ' ' ELSE PICK_ORD_HDR."PICK_ORDER" END AS PICK_ORD_HDR_PICK_ORDER,
     CASE WHEN WAVE_TASK_DET.PTCN IS NULL THEN ' ' ELSE WAVE_TASK_DET.PTCN END AS WAVE_TASK_DET_PTCN,
	  CASE WHEN PACK_HDR."OUTER_CARTON_NO" IS NULL THEN ' ' ELSE PACK_HDR."OUTER_CARTON_NO" END AS PACK_HDR_OUTER_CARTON,
    (select
        count(pack_det.carton_no) from pack_hdr,pack_det
       where pack_hdr.tran_id = pack_det.tran_id
     )as "Total no of carton"

FROM
     "SITE" SITE ,
     "DESPATCH" DESPATCH ,
     "DESPATCHDET" DESPATCHDET ,
     "ITEM" ITEM ,
     "SORDER" SORDER,
     "PACK_HDR" PACK_HDR,
     "PICK_ORD_HDR" PICK_ORD_HDR,
       WAVE_TASK_DET
where
	 SORDER.SALE_ORDER =  DESPATCH.SORD_NO
	AND SITE.SITE_CODE = SORDER.SITE_CODE
	AND DESPATCHDET.DESP_ID = DESPATCH.DESP_ID
	AND DESPATCHDET.ITEM_CODE = ITEM.ITEM_CODE
    AND PACK_HDR.WAVE_ID = DESPATCH.WAVE_ID
    AND PICK_ORD_HDR.WAVE_ID = DESPATCH.WAVE_ID
  AND WAVE_TASK_DET.WAVE_ID = DESPATCH.WAVE_ID
    AND trim(DESPATCH.WAVE_ID) =trim('$P!{WaveID}')]]>
	</queryString>
	<field name="SORDER_CUST_PORD" class="java.lang.String"/>
	<field name="SORDER_DLV_ADD1" class="java.lang.String"/>
	<field name="SORDER_DLV_ADD2" class="java.lang.String"/>
	<field name="SORDER_DLV_ADD3" class="java.lang.String"/>
	<field name="SORDER_DLV_CITY" class="java.lang.String"/>
	<field name="SORDER_STATE_CODE__DLV" class="java.lang.String"/>
	<field name="SORDER_DLV_PIN" class="java.lang.String"/>
	<field name="SORDER_FRT_TERM" 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="ITEM_DESCR" class="java.lang.String"/>
	<field name="DESPATCH_TRAN_ID" class="java.lang.String"/>
	<field name="DESPATCHDET_SSCC_18" class="java.lang.String"/>
	<field name="PICK_ORD_HDR_PICK_ORDER" class="java.lang.String"/>
	<field name="PACK_HDR_OUTER_CARTON" class="java.lang.String"/>
	<field name="Total no of carton" class="java.lang.String"/>
	<field name="SITE_DESCR" class="java.lang.String"/>
	<field name="DESPATCH_TRAN_CODE" class="java.lang.String"/>
	<field name="DESPATCH_SHIPMENT_ID" class="java.lang.String"/>
	<field name="WAVE_TASK_DET_PTCN" class="java.lang.String"/>
	<variable name="compute_1" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String($F{SITE_CITY}+" "+$F{SITE_STATE_CODE}+" "+$F{SITE_PIN})]]></variableExpression>
	</variable>
	<variable name="compute_2" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String($F{SORDER_DLV_CITY}.trim()+" "+$F{SORDER_STATE_CODE__DLV}.trim()+" "+$F{SORDER_DLV_PIN}.trim())]]></variableExpression>
	</variable>
	<variable name="compute_3" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String($F{SORDER_STATE_CODE__DLV}.trim()+" "+ibase.webitm.reports.utility.BaseReportMethods.trim($F{SORDER_DLV_PIN}.substring(0,4)) +"-01")]]></variableExpression>
	</variable>
	<variable name="compute_4" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String(ibase.webitm.reports.sun.BaseReportGFMethods.gf_bar_code(ibase.webitm.reports.utility.BaseReportMethods.trim($V{compute_3}) ) )]]></variableExpression>
	</variable>
	<variable name="COMPUTE_5" 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{DESPATCH_SHIPMENT_ID}) ) )]]></variableExpression>
	</variable>
	<group name="cartoon">
		<groupExpression><![CDATA[$F{Total no of carton}]]></groupExpression>
		<groupHeader>
			<band/>
		</groupHeader>
		<groupFooter>
			<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="415" splitType="Stretch">
			<textField isBlankWhenNull="true">
				<reportElement x="6" y="16" width="69" 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="6" y="36" width="88" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{compute_1}]]></textFieldExpression>
			</textField>
			<line>
				<reportElement x="1" y="414" width="242" height="1"/>
			</line>
			<textField isBlankWhenNull="true">
				<reportElement x="40" y="85" width="105" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{SORDER_STATE_CODE__DLV}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="40" y="95" width="105" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{SORDER_DLV_PIN}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement x="-116" y="72" width="36" height="11"/>
				<textElement>
					<font size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[TO:]]></text>
			</staticText>
			<staticText>
				<reportElement x="-112" y="266" width="36" height="11"/>
				<textElement>
					<font size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[LOCN:]]></text>
			</staticText>
			<staticText>
				<reportElement x="-112" y="246" width="36" height="11"/>
				<textElement>
					<font size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[SKU:]]></text>
			</staticText>
			<line>
				<reportElement x="1" y="204" width="242" height="1"/>
				<graphicElement>
					<pen lineWidth="6.0"/>
				</graphicElement>
			</line>
			<textField isBlankWhenNull="true">
				<reportElement x="39" y="54" width="105" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{SORDER_DLV_ADD1}]]></textFieldExpression>
			</textField>
			<line>
				<reportElement x="1" y="250" width="242" height="1"/>
			</line>
			<textField isBlankWhenNull="true">
				<reportElement x="40" y="75" width="105" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{SORDER_DLV_ADD3}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="39" y="64" width="105" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{SORDER_DLV_ADD2}]]></textFieldExpression>
			</textField>
			<line>
				<reportElement x="242" y="2" width="1" height="412"/>
			</line>
			<line>
				<reportElement x="1" y="129" width="242" height="1"/>
			</line>
			<line>
				<reportElement x="101" y="129" width="1" height="75"/>
			</line>
			<line>
				<reportElement x="1" y="2" width="242" height="1"/>
			</line>
			<textField isBlankWhenNull="true">
				<reportElement x="6" y="26" width="69" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{SITE_ADD2}]]></textFieldExpression>
			</textField>
			<line>
				<reportElement x="1" y="2" width="1" height="412"/>
			</line>
			<staticText>
				<reportElement x="6" y="54" width="22" height="21"/>
				<textElement textAlignment="Center">
					<font fontName="Times New Roman" size="8" isBold="true"/>
				</textElement>
				<text><![CDATA[SHIP
TO:]]></text>
			</staticText>
			<line>
				<reportElement x="1" y="322" width="242" height="1"/>
				<graphicElement>
					<pen lineWidth="6.0"/>
				</graphicElement>
			</line>
			<line>
				<reportElement x="1" y="366" width="242" height="1"/>
			</line>
			<line>
				<reportElement x="227" y="203" width="1" height="47"/>
				<graphicElement>
					<pen lineWidth="30.0"/>
				</graphicElement>
			</line>
			<staticText>
				<reportElement x="207" y="8" width="11" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<text><![CDATA[OF]]></text>
			</staticText>
			<textField evaluationTime="Group" evaluationGroup="cartoon" isBlankWhenNull="true">
				<reportElement x="219" y="8" width="14" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{Total no of carton}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement x="5" y="236" width="50" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[TRACKING#:]]></text>
			</staticText>
			<textField isBlankWhenNull="true">
				<reportElement x="4" y="211" width="156" height="18"/>
				<textElement>
					<font fontName="Times New Roman" size="10" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{DESPATCH_TRAN_CODE}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="55" y="236" width="160" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{DESPATCH_SHIPMENT_ID}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement x="7" y="327" width="36" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[BILLING: ]]></text>
			</staticText>
			<textField isBlankWhenNull="true">
				<reportElement x="45" y="327" width="105" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{SORDER_FRT_TERM}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement x="7" y="369" width="21" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<text><![CDATA[Ctl#:]]></text>
			</staticText>
			<staticText>
				<reportElement x="114" y="369" width="50" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<text><![CDATA[CARTON#:]]></text>
			</staticText>
			<staticText>
				<reportElement x="133" y="380" width="106" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="6" isBold="true"/>
				</textElement>
				<text><![CDATA[MA 04R2 ZTZ140XI12 27.0A 01/2004]]></text>
			</staticText>
			<textField isBlankWhenNull="true">
				<reportElement x="164" y="369" width="75" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{PACK_HDR_OUTER_CARTON}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="18" y="381" width="76" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{SORDER_CUST_PORD}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="28" y="369" width="76" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{WAVE_TASK_DET_PTCN}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="105" y="152" width="139" height="48"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font fontName="Code 128AB" size="30" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{compute_4}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="10" y="141" width="72" height="27"/>
				<textElement>
					<font fontName="Code 128AB" size="24" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["1234"]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="10" y="251" width="233" height="71"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font fontName="Code 128AB" size="54"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{COMPUTE_5}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement x="139" y="27" width="21" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[OS1]]></text>
			</staticText>
			<textField evaluationTime="Page" isBlankWhenNull="true">
				<reportElement x="195" y="8" width="14" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="6" y="6" width="69" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{SITE_DESCR}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="31" y="105" width="208" height="24"/>
				<textElement verticalAlignment="Bottom">
					<font fontName="Times New Roman" size="16" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{compute_2}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="105" y="130" width="139" height="38"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font fontName="Times New Roman" size="18" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{compute_3}]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<columnFooter>
		<band splitType="Stretch"/>
	</columnFooter>
	<pageFooter>
		<band splitType="Stretch"/>
	</pageFooter>
	<summary>
		<band splitType="Stretch"/>
	</summary>
</jasperReport>
