<?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="SSCC_Carton_Master_Label" pageWidth="283" pageHeight="425" columnWidth="263" leftMargin="10" rightMargin="10" topMargin="2" bottomMargin="2">
	<property name="ireport.zoom" value="1.5"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="23"/>
	<parameter name="PTCN" class="java.lang.String"/>
	<queryString>
		<![CDATA[SELECT
		DISTINCT
     CASE WHEN DESPATCH."BOL_NO" IS NULL THEN ' ' ELSE DESPATCH."BOL_NO" END AS DESPATCH_BOL_NO,
     CASE WHEN DESPATCH."PRO_NO" IS NULL THEN ' ' ELSE DESPATCH."PRO_NO" END AS DESPATCH_PRO_NO,
     CASE WHEN SORDER."CUST_PORD" IS NULL THEN ' ' ELSE SORDER."CUST_PORD" END AS SORDER_CUST_PORD,
    CASE WHEN SORDER."DLV_TO" IS NULL THEN ' ' ELSE SORDER."DLV_TO" END AS SORDER_DLV_TO,
     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."CUST_CODE" IS NULL THEN ' ' ELSE SORDER."CUST_CODE" END AS SORDER_CUST_CODE,
     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 DESPATCH."TRAN_CODE" IS NULL THEN ' ' ELSE DESPATCH."TRAN_CODE" END AS DESPATCH_TRAN_CODE,
     CASE WHEN DESPATCH."DESP_ID" IS NULL THEN ' ' ELSE DESPATCH."DESP_ID" END AS DESPATCH_TRAN_ID,
    CASE WHEN DESPATCHDET."QUANTITY" IS NULL THEN 0 ELSE DESPATCHDET."QUANTITY" END AS DESPATCHDET_QUANTITY,
	 CASE WHEN DESPATCHDET."LOC_CODE" IS NULL THEN ' ' ELSE DESPATCHDET."LOC_CODE" END AS DESPATCHDET_LOC_CODE,
     (select
        count(CARTON_MASTER.carton_no) from CARTON_MASTER
       where CARTON_MASTER.PTCN =  TRIM('$P!{PTCN}')
     )as "Total no of carton",
    CASE WHEN WAVE_TASK_DET.PTCN IS NULL THEN ' ' ELSE WAVE_TASK_DET.PTCN END AS WAVE_TASK_DET_PTCN,
	CASE WHEN CARTON_MASTER.SSCC_18 IS NULL THEN ' ' ELSE CARTON_MASTER.SSCC_18 END AS CARTON_MASTER_SSCC_18
   FROM
     "SITE" SITE ,
    "DESPATCH" DESPATCH ,
     "DESPATCHDET" DESPATCHDET ,
     "SORDER" SORDER,
     WAVE_TASK_DET,
		CARTON_MASTER
    where
     SORDER.SALE_ORDER =  DESPATCH.SORD_NO
   AND SITE.SITE_CODE = SORDER.SITE_CODE
   AND DESPATCHDET.DESP_ID = DESPATCH.DESP_ID
   AND WAVE_TASK_DET.PTCN = CARTON_MASTER.PTCN
    AND DESPATCH.DESP_ID = WAVE_TASK_DET.REF_ID
	AND TRIM(WAVE_TASK_DET.PTCN)	= TRIM('$P!{PTCN}')]]>
	</queryString>
	<field name="DESPATCH_BOL_NO" class="java.lang.String"/>
	<field name="DESPATCH_PRO_NO" class="java.lang.String"/>
	<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_CUST_CODE" 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="DESPATCH_TRAN_CODE" class="java.lang.String"/>
	<field name="DESPATCHDET_QUANTITY" class="java.lang.String"/>
	<field name="DESPATCHDET_LOC_CODE" class="java.lang.String"/>
	<field name="CARTON_MASTER_SSCC_18" class="java.lang.String"/>
	<field name="Total no of carton" class="java.lang.String"/>
	<field name="SORDER_DLV_TO" class="java.lang.String"/>
	<field name="WAVE_TASK_DET_PTCN" class="java.lang.String"/>
	<field name="SITE_DESCR" 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{SORDER_DLV_PIN}) ) )]]></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{CARTON_MASTER_SSCC_18}) ) )]]></variableExpression>
	</variable>
	<variable name="COMPUTE_3" 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_4" class="java.lang.String">
		<variableExpression><![CDATA[new java.lang.String($F{SITE_CITY}.trim() + " "+$F{SITE_STATE_CODE}.trim()+" "+$F{SITE_PIN}.trim())]]></variableExpression>
	</variable>
	<group name="cartoon">
		<groupExpression><![CDATA[$F{Total no of carton}]]></groupExpression>
		<groupHeader>
			<band/>
		</groupHeader>
	</group>
	<background>
		<band splitType="Stretch"/>
	</background>
	<title>
		<band splitType="Stretch"/>
	</title>
	<pageHeader>
		<band splitType="Stretch"/>
	</pageHeader>
	<columnHeader>
		<band splitType="Stretch"/>
	</columnHeader>
	<detail>
		<band height="344" splitType="Stretch">
			<line>
				<reportElement x="260" y="16" width="1" height="325"/>
			</line>
			<line>
				<reportElement x="3" y="341" width="257" height="1"/>
			</line>
			<staticText>
				<reportElement x="8" y="22" width="76" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="8" isBold="true"/>
				</textElement>
				<text><![CDATA[From:]]></text>
			</staticText>
			<line>
				<reportElement x="3" y="205" width="257" height="1"/>
			</line>
			<line>
				<reportElement x="3" y="16" width="257" height="1"/>
			</line>
			<line>
				<reportElement x="3" y="255" width="257" height="1"/>
			</line>
			<line>
				<reportElement x="3" y="142" width="257" height="1"/>
			</line>
			<line>
				<reportElement x="3" y="82" width="257" height="2"/>
			</line>
			<line>
				<reportElement x="3" y="17" width="1" height="324"/>
			</line>
			<staticText>
				<reportElement x="8" y="85" width="100" height="11"/>
				<textElement textAlignment="Left">
					<font fontName="Times New Roman" size="6" isBold="false"/>
				</textElement>
				<text><![CDATA[Ship To Postal Code:]]></text>
			</staticText>
			<line>
				<reportElement x="143" y="83" width="1" height="60"/>
			</line>
			<staticText>
				<reportElement x="16" y="146" width="38" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="7" isBold="false"/>
				</textElement>
				<text><![CDATA[PO#:]]></text>
			</staticText>
			<staticText>
				<reportElement x="62" y="169" width="166" height="17"/>
				<textElement textAlignment="Center">
					<font fontName="Times New Roman" size="12" isBold="true"/>
				</textElement>
				<text><![CDATA[Master Carton]]></text>
			</staticText>
			<staticText>
				<reportElement x="132" y="22" width="18" height="11"/>
				<textElement>
					<font fontName="Times New Roman" size="8" isBold="true"/>
				</textElement>
				<text><![CDATA[To:]]></text>
			</staticText>
			<staticText>
				<reportElement x="11" y="256" width="163" height="15"/>
				<textElement>
					<font fontName="Times New Roman" size="10" isBold="true"/>
				</textElement>
				<text><![CDATA[SSCC]]></text>
			</staticText>
			<textField isBlankWhenNull="true">
				<reportElement x="8" y="33" width="121" 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="8" y="53" width="122" 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="8" y="63" width="121" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{COMPUTE_4}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="8" y="43" 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="136" y="52" width="124" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{SORDER_DLV_ADD2}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="136" y="62" width="124" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{SORDER_DLV_ADD3}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="136" y="72" width="124" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{COMPUTE_3}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="136" y="42" width="124" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{SORDER_DLV_ADD1}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="41" y="146" width="174" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7" isBold="true"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{SORDER_CUST_PORD}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="5" y="274" width="255" height="49"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font fontName="Code 128AB" size="54"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$V{COMPUTE_2}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="5" y="106" width="138" height="35"/>
				<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="136" y="32" width="124" height="10"/>
				<textElement>
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{SORDER_DLV_TO}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="8" y="95" width="136" height="10"/>
				<textElement textAlignment="Center">
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["(420)  "+$F{SORDER_DLV_PIN}.trim()]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="true">
				<reportElement x="4" y="323" width="256" height="10"/>
				<textElement textAlignment="Center">
					<font fontName="Times New Roman" size="7"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["(00) "+$F{CARTON_MASTER_SSCC_18}.trim()]]></textFieldExpression>
			</textField>
			<line>
				<reportElement x="129" y="16" width="1" height="66"/>
			</line>
		</band>
	</detail>
	<columnFooter>
		<band splitType="Stretch"/>
	</columnFooter>
	<pageFooter>
		<band splitType="Stretch"/>
	</pageFooter>
	<summary>
		<band splitType="Stretch"/>
	</summary>
</jasperReport>
