<?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="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
	<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."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 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 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,
     "PACK_DET" PACK_DET,
     "PICK_ORD_HDR" PICK_ORD_HDR
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 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"/>
	<background>
		<band splitType="Stretch"/>
	</background>
	<title>
		<band splitType="Stretch"/>
	</title>
	<pageHeader>
		<band splitType="Stretch"/>
	</pageHeader>
	<columnHeader>
		<band splitType="Stretch"/>
	</columnHeader>
	<detail>
		<band height="802" splitType="Stretch">
			<staticText>
				<reportElement x="77" y="5" width="76" height="11"/>
				<textElement>
					<font size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[FROM:]]></text>
			</staticText>
			<textField>
				<reportElement x="79" y="18" width="69" height="10"/>
				<textElement>
					<font size="7"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{SITE_ADD1}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="79" y="38" width="69" height="10"/>
				<textElement>
					<font size="7"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{SITE_CITY}]]></textFieldExpression>
			</textField>
			<line>
				<reportElement x="72" y="433" width="286" height="1"/>
			</line>
			<textField>
				<reportElement x="79" y="58" width="69" height="10"/>
				<textElement>
					<font size="7"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{SITE_STATE_CODE}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="115" y="116" width="105" height="10"/>
				<textElement>
					<font size="7" isBold="true"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{SORDER_STATE_CODE__DLV}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="115" y="126" width="105" height="10"/>
				<textElement>
					<font size="7" isBold="true"/>
				</textElement>
				<textFieldExpression><![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="73" y="222" width="286" height="1"/>
				<graphicElement>
					<pen lineWidth="6.0"/>
				</graphicElement>
			</line>
			<textField>
				<reportElement x="114" y="85" width="105" height="10"/>
				<textElement>
					<font size="7" isBold="true"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{SORDER_DLV_ADD1}]]></textFieldExpression>
			</textField>
			<line>
				<reportElement x="72" y="268" width="286" height="1"/>
			</line>
			<textField>
				<reportElement x="79" y="48" width="69" height="10"/>
				<textElement>
					<font size="7"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{SITE_PIN}]]></textFieldExpression>
			</textField>
			<line>
				<reportElement x="-121" y="-5" width="1" height="432"/>
			</line>
			<textField>
				<reportElement x="115" y="106" width="105" height="10"/>
				<textElement>
					<font size="7" isBold="true"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{SORDER_DLV_ADD3}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="114" y="95" width="105" height="10"/>
				<textElement>
					<font size="7" isBold="true"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{SORDER_DLV_ADD2}]]></textFieldExpression>
			</textField>
			<line>
				<reportElement x="358" y="2" width="1" height="431"/>
			</line>
			<line>
				<reportElement x="73" y="147" width="286" height="1"/>
			</line>
			<line>
				<reportElement x="172" y="147" width="1" height="75"/>
			</line>
			<line>
				<reportElement x="73" y="2" width="286" height="1"/>
			</line>
			<textField>
				<reportElement x="79" y="28" width="69" height="10"/>
				<textElement>
					<font size="7"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{SITE_ADD2}]]></textFieldExpression>
			</textField>
			<line>
				<reportElement x="-121" y="-5" width="1" height="432"/>
			</line>
			<line>
				<reportElement x="73" y="2" width="1" height="431"/>
			</line>
			<staticText>
				<reportElement x="77" y="72" width="47" height="11"/>
				<textElement>
					<font size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[SHIP TO:]]></text>
			</staticText>
			<line>
				<reportElement x="72" y="340" width="286" height="1"/>
				<graphicElement>
					<pen lineWidth="6.0"/>
				</graphicElement>
			</line>
			<line>
				<reportElement x="72" y="384" width="286" height="1"/>
			</line>
			<line>
				<reportElement x="343" y="222" width="1" height="47"/>
				<graphicElement>
					<pen lineWidth="30.0"/>
				</graphicElement>
			</line>
			<textField>
				<reportElement x="286" y="8" width="12" height="10"/>
				<textElement>
					<font size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[String.valueOf($V{PAGE_NUMBER})]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement x="298" y="8" width="11" height="11"/>
				<textElement>
					<font size="7"/>
				</textElement>
				<text><![CDATA[OF]]></text>
			</staticText>
			<textField>
				<reportElement x="310" y="8" width="14" height="11"/>
				<textElement>
					<font size="7"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{Total no of carton}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement x="76" y="254" width="50" height="11"/>
				<textElement>
					<font size="7"/>
				</textElement>
				<text><![CDATA[TRACKING#:]]></text>
			</staticText>
			<textField>
				<reportElement x="75" y="236" width="105" height="18"/>
				<textElement>
					<font size="10"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{ITEM_DESCR}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="126" y="254" width="105" height="10"/>
				<textElement>
					<font size="7"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{DESPATCHDET_SSCC_18}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement x="78" y="345" width="32" height="11"/>
				<textElement>
					<font size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[BILLING: ]]></text>
			</staticText>
			<textField>
				<reportElement x="111" y="346" width="105" height="10"/>
				<textElement>
					<font size="7"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{SORDER_FRT_TERM}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement x="77" y="386" width="21" height="11"/>
				<textElement>
					<font size="7"/>
				</textElement>
				<text><![CDATA[Ctl#:]]></text>
			</staticText>
			<staticText>
				<reportElement x="192" y="387" width="50" height="11"/>
				<textElement>
					<font size="7"/>
				</textElement>
				<text><![CDATA[CARTON#:]]></text>
			</staticText>
			<staticText>
				<reportElement x="192" y="398" width="151" height="11"/>
				<textElement>
					<font size="7" isBold="true"/>
				</textElement>
				<text><![CDATA[MA 04R2 ZTZ140XI12.0A 01/2004]]></text>
			</staticText>
			<textField>
				<reportElement x="242" y="387" width="105" height="10"/>
				<textElement>
					<font size="7"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{PACK_HDR_OUTER_CARTON}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="77" y="399" width="76" height="10"/>
				<textElement>
					<font size="7"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{SORDER_CUST_PORD}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="99" y="387" width="76" height="10"/>
				<textElement>
					<font size="7"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{PICK_ORD_HDR_PICK_ORDER}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="191" y="159" width="152" height="48"/>
				<textElement>
					<font fontName="Code 128AB" size="24" isBold="true"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{SORDER_DLV_PIN}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="81" y="159" width="72" height="27"/>
				<textElement>
					<font fontName="Code 128AB" size="24" isBold="true"/>
				</textElement>
				<textFieldExpression><![CDATA["1234"]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="98" y="277" width="226" height="43"/>
				<textElement>
					<font fontName="Code 128AB" size="36"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{SORDER_DLV_PIN}]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<columnFooter>
		<band splitType="Stretch"/>
	</columnFooter>
	<pageFooter>
		<band splitType="Stretch"/>
	</pageFooter>
	<summary>
		<band splitType="Stretch"/>
	</summary>
</jasperReport>
