/**
 * PURPOSE : Validation and Itemchange for Picking Issue
 * AUTHOR : Gulzar
 * DATE : 13/09/11
 */

package ibase.webitm.ejb.wms;

import ibase.system.config.*;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;

import org.w3c.dom.*;

@javax.ejb.Stateless
public class PickIssIC extends ValidatorEJB implements PickIssICLocal, PickIssICRemote 
{
	/**
	 * The method is defined without any parameter and returns blank string
	 */
	@Override
	public String wfValData() throws RemoteException, ITMException
	{
		return "";
	}

	/**
	 * The public method is used for converting the current form data into a document(DOM)
	 * The dom is then given as argument to the overloaded function wfValData to perform validation
	 * Returns validation string if exists else returns null in XML format
	 * @param xmlString contains the current form data in XML format
	 * @param xmlString1 contains all the header information in the XML format
	 * @param xmlString2 contains the data of all the forms in XML format
	 * @param objContext represents the form number
	 * @param editFlag represents the mode of transaction(A-Add or E-Edit)
	 * @param xtraParams contains additional information such as loginEmpCode,loginCode,chgTerm etc
	 */	
	@Override
	public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext,String editFlag, String xtraParams) throws RemoteException, ITMException
	{
		Document currFormDataDom = null;
		Document hdrDataDom = null;
		Document allFormDataDom = null;
		String errString = null;
		GenericUtility genericUtility = GenericUtility.getInstance();    

		try
		{
			System.out.println( "xmlString ::" + xmlString);
			System.out.println( "xmlString1 ::" + xmlString1);
			System.out.println( "xmlString2 ::" + xmlString2);
			if(xmlString != null && xmlString.trim().length()!=0)
			{
				currFormDataDom = genericUtility.parseString(xmlString); 
			}
			if(xmlString1 != null && xmlString1.trim().length()!=0)
			{
				hdrDataDom = genericUtility.parseString(xmlString1); 
			}
			if(xmlString2 != null && xmlString2.trim().length()!=0)
			{
				allFormDataDom = genericUtility.parseString(xmlString2); 
			}
			errString = wfValData( currFormDataDom, hdrDataDom, allFormDataDom, objContext, xtraParams);
			System.out.println( "ErrString: " + errString);
		}
		catch(Exception e)
		{
			errString = genericUtility.createErrorString(e);
			e.printStackTrace();
			throw new ITMException(e);
		}
		return (errString); 
	}

	/**
	 * The public overloaded method takes a document as input and is used for the validation of required fields 
	 * Returns validation string if exist otherwise returns null in XML format
	 * @param currFormDataDom contains the current form data as a document object model
	 * @param hdrDataDom contains all the header information
	 * @param allFormDataDom contains the field data of all the forms 
	 * @param objContext represents form number
	 * @param editFlag represents the mode of transaction(A-Add or E-Edit)
	 * @param xtraParams contains additional information such as loginEmpCode,loginCode,chgTerm etc
	 */
	@Override
	public String wfValData(Document currFormDataDom, Document hdrDataDom, Document allFormDataDom, String objContext, String xtraParams) throws RemoteException, ITMException
	{   				
		String pickOrder = "";
		String columnValue = "";			
		String errString = "";
		String lpnNo = "";
		String itemCode = "";
		String siteCode = "";		
		String lotNo = "";
		String lotSl = "";
		String locCodeTo = "";
		String confirmed = "";
		String singleLotSl = "";
		String itemLotOpt = "";
		String rowCountStr = "";
		String pickType = "";
		String sql = "",sql1= "";
		String lineNoPick = "";
		String locCodeSys = "";
		String sugLocInvstat = "";
		String objName = "";
		String cartonNo = "";
		String caseLabel = "";
		String tranID =  "";//Gulzar - 12/13/2011
		String intrLocInvstat =  "";//Gulzar - 12/28/2011
		String replOrder =  "",ptcn = "";//Gulzar - 1/12/2012
		String palletStatus = "";
		//changed by sankara on 10-08-12[start]
		String waveId="";
		String holdStatus="";
		//changed by sankara on 10-08-12[end]
		
		//Changed by Rohan on 06-10-12 for define variable.start
		String sqlitem = "";
		String hazMaterial = "";
		String sqlPtcn = "";
		String ptcnReport = "";
		PreparedStatement pstmtitem = null;
		ResultSet rsitem = null;
		String sqlTran = "";
		String pickOrd = "";
		String transMode = "";
		String itemCd = "";
		String sqlptcn = "";
		String ptcnHaz = "";
		String waveIdHaz = "";
		//Changed by Rohan on 06-10-12 for define variable.end
		//Chnaged by Rohan on 29-10-12 to define variable.start
		String pickOrdIss = "";
		String linNoOrder = "";
		String selReplCnt = "";
		int cntRepl = 0;
		String replOrderPick = "";
		String lineNoRepl = "";
		String sqlPick = "";
		java.util.Date tranDate = null;
		String prdCode = "";
		//Chnaged by Rohan on 29-10-12 to define variable.end
		int count = 0, cnt = 0;
		int rowCount = 0;
		int noOfChilds = 0;
		int noOfParent = 0;
		int lineNoOrd = 0;
		
		double quantity = 0.0;
		double shipperSize = 0.0; //changed by sumit on 13/03/13
		GenericUtility genericUtility = GenericUtility.getInstance();
		DistCommon distCommon = new DistCommon();
		//Changed By Pragyan 11-AUG-14 To check and Facility Master implementation.start
        ibase.webitm.utility.wms.CommonWmsUtil commonWmsUtility =ibase.webitm.utility.wms.CommonWmsUtil.getInstance();
		Connection conn = null;
		PreparedStatement pstmt = null,pstmt1 = null;
		PreparedStatement pstmtPickLotNo = null;
		PreparedStatement pstmtPickLotSl = null;
		PreparedStatement pstmtLoc = null;
		PreparedStatement pstmtStock = null;
		PreparedStatement pstmtLoc1 = null;
		PreparedStatement pstmtStock1 = null;
		PreparedStatement pstmtStock2 = null;
		PreparedStatement pstmtStock3 = null;

		ResultSet rs = null, rs1 = null;		

		StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
		String errorType = "", errCode = "", docLocCode = "" ,statusPkord= "", status = "O",locCode = "";
		ArrayList errList = new ArrayList();
		ArrayList errFields = new ArrayList();
		//Changed by sumit on 13/03/13 initialize itmVolumeMap object
		HashMap itmVolumeMap = new HashMap();
		//changed by sankara on 18/11/13 validation for different assign user
		String assignTo = "";
		
		try
		{	
			int currentFormNo = 0;				
			ConnDriver connDriver = new ConnDriver();
			conn = connDriver.getConnectDB( "DriverITM" );
			connDriver = null;
			SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getApplDateFormat());
			String userId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );

			if ( objContext != null && objContext.trim().length() > 0 )
			{
				currentFormNo = Integer.parseInt( objContext );
			}
			NodeList parentList = currFormDataDom.getElementsByTagName( "Detail" + currentFormNo );
			NodeList childList = null;	
			noOfParent = parentList.getLength();
			

			//changes added to get the obj_name and to distinguish betwwen active pick and case pick
			//Gulzar - 28/11/11
			objName = checkNullAndTrim(getObjNameFromDom( currFormDataDom, "objName", objContext ));
			System.out.println(" objName =[" + objName + "]");

			//Changes by gulzar on 12/28/2011
			intrLocInvstat = distCommon.getDisparams( "999999", "INTR_LOCATION", conn );
			//End changes by gulzar on 12/28/2011
			
			switch ( currentFormNo )  // Switch Case for form number
			{
			case 1:
			{	
				childList = parentList.item(0).getChildNodes();
				noOfChilds = childList.getLength();

				for ( int ctr = 0; ctr < noOfChilds; ctr++ ) //Loop for each node of current detail
				{	
					Node childNode = childList.item( ctr );
					if( childNode.getNodeType() != Node.ELEMENT_NODE )
					{
						continue;
					}
					String childNodeName = childNode.getNodeName();
					if ( childNode != null && childNode.getFirstChild() != null )
					{
						columnValue = childNode.getFirstChild().getNodeValue();
					}
					System.out.println(" columnName [" + childNodeName + "] columnValue [" + columnValue + "]");
					if ( "pick_order".equalsIgnoreCase( childNodeName ) )
					{
						if ( childNode.getFirstChild() == null)
						{
							// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
							//errString = getErrorString( "pick_order", "NULPICKORD", userId );
							//break;
							errList.add( "NULPICKORD" );
							errFields.add( childNodeName.toLowerCase() );
							// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
						}
						pickOrder = genericUtility.getColumnValue( "pick_order", currFormDataDom );
						
						//Changed by sumit on 22/01/13 adding validation where user going to do this task which is already processing by other user start
						sql = "SELECT CONFIRMED, CHG_USER FROM PICK_ISS_HDR WHERE PICK_ORDER = ? ";
						pstmt = conn.prepareStatement( sql );
						pstmt.setString( 1, pickOrder );
						rs = pstmt.executeQuery();
						if( rs.next() )
						{
							System.out.println(" confirmed ["+rs.getString("CONFIRMED")+"] userid ["+rs.getString("CHG_USER")+"]");
							if( "N".equalsIgnoreCase(rs.getString("CONFIRMED")) && !userId.trim().equalsIgnoreCase(rs.getString("CHG_USER").trim()))
							{
								errList.add( "VMPICKORDU" );
								errFields.add( childNodeName.toLowerCase() );
							}
						}
						rs.close();
						rs = null;
						pstmt.close();
						pstmt = null;						
						//Changed by sumit on 22/01/13 adding validation where user going to do this task which is already processing by other user END
						
						//Changed by sumit on 28/02/13 adding validation where pick deallocated start
						//Changed by sumit on 12/03/13 changing sql
						//sql = "SELECT QUANTITY FROM PICK_ORD_DET WHERE PICK_ORDER = ? ";
						sql =   " SELECT SUM(QUANTITY - CASE WHEN DEALLOC_QTY IS NULL THEN 0 ELSE DEALLOC_QTY END) AS QUANTITY " +
								" FROM PICK_ORD_DET WHERE PICK_ORDER = ? ";
					    quantity = 0.0;
						pstmt = conn.prepareStatement( sql );
						pstmt.setString( 1, pickOrder );
						rs = pstmt.executeQuery();
						if( rs.next() )
						{
							quantity = rs.getDouble("QUANTITY");
							System.out.println(" quantity ["+quantity+"]");
							if( quantity <= 0)
							{
								errList.add( "PICKDEALOC" );
								errFields.add( childNodeName.toLowerCase() );
							}
						}
						rs.close();
						rs = null;
						pstmt.close();
						pstmt = null;						
						//Changed by sumit on 28/02/13 adding validation where pick deallocated end
						
						//Changed by sumit on 05/04/13 adding validation where pick deallocated start							
						sql =   "SELECT STATUS FROM WAVE_TASK_DET WHERE REF_ID = ? ";					    
						pstmt = conn.prepareStatement( sql );
						pstmt.setString( 1, pickOrder );
						rs = pstmt.executeQuery();
						if( rs.next() )
						{				
							status = rs.getString("STATUS");
							System.out.println(" status ["+status+"]");
							if("Y".equalsIgnoreCase(status))
							{
								errList.add( "VTPKORDC" );
								errFields.add( childNodeName.toLowerCase() );
							}
						}
						rs.close();
						rs = null;
						pstmt.close();
						pstmt = null;						
						//Changed by sumit on 05/04/13 adding validation where pick deallocated end
						

						// added by cpatil on 11-sept-12 start for pick_id validate
						sql = "SELECT count(1) FROM PICK_ORD_HDR WHERE PICK_ORDER = ?";
						pstmt = conn.prepareStatement( sql );
						pstmt.setString( 1, pickOrder );
						rs = pstmt.executeQuery();
						if( rs.next() )
						{
							cnt = rs.getInt(1);
						}
						rs.close();
						rs = null;
						pstmt.close();
						pstmt = null;
						if( cnt == 0)
						{
							errList.add( "VMPICKORD" );
							errFields.add( childNodeName.toLowerCase() );
						}
						//Changed by sumit on 28/09/12 validating in case of wave canceled start.
						else
						{
							sql = " SELECT WAVE_TASK.CANCEL FROM WAVE_TASK, PICK_ORD_HDR " +
									" WHERE PICK_ORD_HDR.WAVE_ID = WAVE_TASK.WAVE_ID " +
									" AND PICK_ORD_HDR.PICK_ORDER = ? ";
							pstmt = conn.prepareStatement(sql);
							pstmt.setString(1, pickOrder);
							rs = pstmt.executeQuery();
							if( rs.next())
							{
								if( "Y".equalsIgnoreCase(rs.getString("CANCEL")))
								{
									errList.add( "PICKCANCEL" );
									errFields.add( childNodeName.toLowerCase() );
								}
							}
						}
						//Changed by sumit on 28/09/12 validating in case of wave canceled end.
						// cpatil end
						// 13/09/12 manoharan status checking added
						status = "O";
						sql = "SELECT PICK_TYPE, CASE WHEN STATUS IS NULL THEN 'O' ELSE STATUS END AS STATUS FROM PICK_ORD_HDR WHERE PICK_ORDER = ?";
						pstmt = conn.prepareStatement( sql );
						pstmt.setString( 1, pickOrder );
						rs = pstmt.executeQuery();

						if( rs.next() )
						{
							pickType = checkNull(rs.getString("PICK_TYPE"));
							status  = checkNull(rs.getString("STATUS"));
						}
						else
						{
							// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
							//errString = getErrorString( "repl_order", "INVPICKORD", userId );
							//break;
							errList.add( "INVPICKORD" );
							errFields.add( childNodeName.toLowerCase() );
							// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
						}
						rs.close(); rs = null;
						pstmt.close(); pstmt = null;
						if("C".equals(status))
						{
							errList.add( "VTPKORDC" );
							errFields.add( childNodeName.toLowerCase() );
							
						}

						//Changed by sankara on 10-08-2012 for proces hold[start]
						sql=" SELECT WAVE_ID FROM PICK_ORD_HDR WHERE PICK_ORDER = ? ";
						pstmt = conn.prepareStatement( sql );
						pstmt.setString( 1, pickOrder );
						rs = pstmt.executeQuery();

						if( rs.next() )
						{
							waveId = rs.getString("WAVE_ID");
						}

						rs.close();
						rs = null;
						pstmt.close();
						pstmt = null;

						if(waveId != null && waveId.trim().length() > 0)
						{
							sql= "SELECT HOLD_STATUS FROM WAVE_TASK WHERE WAVE_ID = ? ";
							pstmt = conn.prepareStatement( sql );
							pstmt.setString( 1, waveId );
							rs = pstmt.executeQuery();
							if( rs.next() )
							{
								holdStatus = rs.getString("HOLD_STATUS");
							}
							rs.close();
							rs = null;
							pstmt.close();
							pstmt = null;
						}
						
						if("Y".equalsIgnoreCase(holdStatus))
						{
							errList.add( "PRCESHLD" );
							errFields.add( childNodeName.toLowerCase() );
						}
						
						//Changed by sankara on 10-08-2012 for proces hold[end]

						if ( pickType.trim().length() == 0  )
						{
							// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
							//errString = getErrorString( "pick_type", "NULPICKTYP", userId );
							//break;
							errList.add( "NULPICKTYP" );
							errFields.add( childNodeName.toLowerCase() );
							// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
						}
						/*--commented by chaitali on 30/11/11
							else if ( pickType.trim().equalsIgnoreCase("M") )
							{
								// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
								//errString = getErrorString( "pick_type", "INVPICKTYP", userId );
								//break;
								errList.add( "MASTERPICK" );
								errFields.add( childNodeName.toLowerCase() );
								// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
							}
						 */
						//changes added to get the obj_name and to distinguish betwwen active pick and case pick
						//Gulzar - 28/11/11
						if ( "active_pick".equalsIgnoreCase(objName) && ! pickType.trim().equalsIgnoreCase("A") )
						{
							errList.add( "ACTIVEPICK" );
							errFields.add( childNodeName.toLowerCase() );
						}
						else if ( "case_pick".equalsIgnoreCase(objName) && (! pickType.trim().equalsIgnoreCase("C") &&  ! pickType.trim().equalsIgnoreCase("M")) )
						{
							errList.add( "CASEPICK" );
							errFields.add( childNodeName.toLowerCase() );
						}
						/*else if ( "master_pick".equalsIgnoreCase(objName) && ! pickType.trim().equalsIgnoreCase("M") )
							{
								errList.add( "MASTERPICK" );
								errFields.add( childNodeName.toLowerCase() );
							}*/
						//sql = "SELECT CONFIRMED FROM PICK_ISS_HDR WHERE PICK_ORDER = ? ";
						sql = "SELECT STATUS FROM PICK_ORD_HDR WHERE PICK_ORDER = ? ";
						pstmt = conn.prepareStatement( sql );
						pstmt.setString( 1, pickOrder );
						rs = pstmt.executeQuery();

						if( rs.next() )
						{
							statusPkord = checkNull(rs.getString("STATUS"));
						}
						rs.close(); rs = null;
						pstmt.close(); pstmt = null;
						if ( "C".equalsIgnoreCase(statusPkord.trim()) )
						{
							errList.add( "CLSPCKORD" ); //commented by Ashish Sonawane on 11-sep-12 
							errFields.add( childNodeName.toLowerCase() ); //commented by Ashish Sonawane on 11-sep-12 
						}
						//End changes by gulzar - 28/11/11

						//Changes made by gulzar to check if any unconfirmed replenishment is present or not on 1/12/2012
						//							sql = "SELECT HDR.REPL_ORDER AS REPL_ORDER FROM REPL_ORD_HDR HDR, REPL_ORD_DET DET, PICK_ORD_DET DET1  "
						//								+ "WHERE HDR.REPL_ORDER = DET.REPL_ORDER AND DET.PICK_ORDER= ? ";
						//changes done by cpandey pick order from pick_iss_det repl_iss_det 
						sql = "SELECT HDR.REPL_ORDER AS REPL_ORDER FROM REPL_ORD_HDR HDR, REPL_ORD_DET DET, PICK_ORD_DET DET1 WHERE" +
								" HDR.REPL_ORDER = DET.REPL_ORDER AND DET1.REPL_ORDER = HDR.REPL_ORDER AND DET.PICK_ORDER= ? ";

						pstmt = conn.prepareStatement( sql );
						pstmt.setString( 1,pickOrder);
						rs = pstmt.executeQuery();
						if( rs.next() )
						{
							replOrder = checkNull(rs.getString("REPL_ORDER"));
						}
						rs.close(); rs = null;
						pstmt.close(); pstmt = null;

						if ( replOrder.trim().length() > 0 )
						{
							sql = "SELECT CONFIRMED FROM REPL_ISS_HDR WHERE REPL_ORDER = ? ";

							pstmt = conn.prepareStatement( sql );
							pstmt.setString( 1, replOrder );
							rs = pstmt.executeQuery();

							if( rs.next() )
							{
								confirmed = checkNull(rs.getString("CONFIRMED"));
							}
							rs.close(); rs = null;
							pstmt.close(); pstmt = null;

							if ( confirmed.trim().length() == 0 || "N".equalsIgnoreCase(confirmed.trim()) )
							{
								//Replenishment task is not performed or un-confirmed task is present , please complete the replenishment task first
								errList.add( "VTREPLISS1" );
								errFields.add( childNodeName.toLowerCase() );
							}
						}

						//End changes by gulzar on 1/12/2012
						//Changed by sumit on 23/03/13 changed sql
						/*sql = "SELECT DISTINCT REPL_ORDER FROM PICK_ORD_DET "
								+ "WHERE  PICK_ORDER= ? AND REPL_ORDER IS NOT NULL";*/
						
						sql = " SELECT DISTINCT POD.REPL_ORDER FROM PICK_ORD_DET POD, REPL_ORD_DET ROD WHERE  POD.PICK_ORDER= ? " +
								" AND ROD.REPL_ORDER IS NOT NULL AND POD.REPL_ORDER = ROD.REPL_ORDER " +
								" AND (CASE WHEN ROD.CANCEL_MODE IS NULL THEN 'N' ELSE ROD.CANCEL_MODE END) <> 'Y'" +
								" AND (POD.QUANTITY - CASE WHEN POD.DEALLOC_QTY IS NULL THEN 0 ELSE POD.DEALLOC_QTY END ) > 0 ";

						pstmt = conn.prepareStatement( sql );
						pstmt.setString( 1, pickOrder );
						rs = pstmt.executeQuery();

						while( rs.next() )
						{
							replOrder = checkNull(rs.getString(1));
							if ( replOrder.trim().length() > 0 )
							{
								sql1 = "SELECT CONFIRMED FROM REPL_ISS_HDR WHERE REPL_ORDER = ? ";
								confirmed = "N";
								pstmt1 = conn.prepareStatement( sql1 );
								pstmt1.setString( 1, replOrder );
								rs1 = pstmt1.executeQuery();

								if( rs1.next() )
								{
									confirmed = checkNull(rs1.getString("CONFIRMED"));
								}
								rs1.close(); rs1 = null;
								pstmt1.close(); pstmt1 = null;

								if ( confirmed.trim().length() == 0 || "N".equalsIgnoreCase(confirmed.trim()) )
								{
									//Replenishment task is not performed or un-confirmed task is present , please complete the replenishment task first
									errList.add( "VTREPLISS1" );
									errFields.add( childNodeName.toLowerCase() );
								}
							}


						}
						rs.close(); rs = null;
						pstmt.close(); pstmt = null;
						
						// cpatil start on 23-AUG-12 [WM1FSUN002]
						
						System.out.println("@@@@@ item validation in pick_order executed.......");
						pickOrder = checkNull(genericUtility.getColumnValue( "pick_order", currFormDataDom  ));
						// 14/09/12 manoharan commented as not required in header
						/*
						sql = " select count (*) from stock where (item_code, site_code, loc_code, lot_no, lot_sl ) in  " +
							  " ( select item_code, site_code, loc_code, lot_no, lot_sl from pick_ord_det where pick_order = ? ) and ( hold_qty > 0 ) ";
						pstmt =  conn.prepareStatement(sql);
						pstmt.setString(1,pickOrder);
						rs = pstmt.executeQuery();
						if (rs.next())
						{
							cnt = rs.getInt(1);
						}
						rs.close();
						rs = null;
						pstmt.close();
						pstmt = null;
						if( cnt > 0 )
						{
							errList.add( "INVITMQTST" );
							errFields.add( childNodeName.toLowerCase() );
						}
						// cpatil end on 23-AUG-12
						*/
						//changed by sankara on 18/11/13 validation for different assign user start.
						sql = " SELECT ASSIGN_TO FROM PICK_ORD_HDR WHERE PICK_ORDER = ? ";
						pstmt = conn.prepareStatement( sql );
						pstmt.setString( 1, pickOrder );
						rs = pstmt.executeQuery();
						if( rs.next() )
						{
							assignTo = checkNull (rs.getString("ASSIGN_TO"));
						}
						
						rs.close();
						rs = null;
						pstmt.close();
						pstmt = null;
						
						System.out.println("UESRID:"+userId);
						System.out.println("ASSIGNTO:"+assignTo);
						if( assignTo !=null && assignTo.trim().length() > 0 && !assignTo.trim().equalsIgnoreCase(userId) )
						{
							errList.add( "INVREPKTSK" );
							errFields.add( childNodeName.toLowerCase() );
						}
						//changed by sankara on 18/11/13 validation for different assign user end.
						//Changed By Pragyan 23-MAY-14 To put a validation/warning message as pallet no exist.start
						String palletNoDom = checkNull(genericUtility.getColumnValue( "pallet_no", currFormDataDom ));;
						String palletNoDb = "";
						sql = "SELECT P.PALLET_NO FROM PICK_ISS_HDR P WHERE P.PICK_ORDER = ? " 
								+" AND P.TRAN_ID  NOT IN (SELECT TRAN_ID FROM PICK_ISS_DET WHERE PICK_ORDER = ?)";       // commented by cpatil on 11-sept-12
							pstmt = conn.prepareStatement( sql );
							pstmt.setString( 1, pickOrder );
							pstmt.setString( 2, pickOrder );

							rs = pstmt.executeQuery();

							if( rs.next() )
							{
								palletNoDb = checkNull(rs.getString("PALLET_NO"));
								System.out.println("pallet no db ="+palletNoDb);
								if ( (palletNoDom.trim().length() > 0 &&  palletNoDb.length() > 0 && ! palletNoDom.trim().equalsIgnoreCase(palletNoDb))  )
								{
									System.out.println("Unmatch PALLET NO ");
									errList.add( "VTAPLTEXST" );
									errFields.add( childNodeName.toLowerCase() );
								}
							}
							
							rs.close();
							rs = null;
							pstmt.close();
							pstmt = null;
							//Changed By Pragyan 23-MAY-14 To put a validation/warning message as pallet no exist.end
					}
					else if ( "pallet_no".equalsIgnoreCase( childNodeName ) )   // && ! "master_pick".equalsIgnoreCase(objName) )
					{
						if ( childNode.getFirstChild() == null)
						{
							// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
							//errString = getErrorString( "pick_order", "NULPICKORD", userId );
							//break;
							errList.add( "NULLPLTNO" );
							errFields.add( childNodeName.toLowerCase() );
							// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
						}
						else //Added by gulzar - 30/11/11
						{
							String palletNoDom = "";
							String palletNoDb = "";
							palletNoDom = checkNull(genericUtility.getColumnValue( "pallet_no", currFormDataDom ));
							pickOrder = checkNull(genericUtility.getColumnValue( "pick_order", currFormDataDom ));

							sql = "SELECT PICK_TYPE FROM PICK_ORD_HDR WHERE PICK_ORDER = ?";
							pstmt = conn.prepareStatement( sql );
							pstmt.setString( 1, pickOrder );
							rs = pstmt.executeQuery();

							if( rs.next() )
							{
								pickType = checkNull(rs.getString("PICK_TYPE"));
							}
							rs.close(); rs = null;
							pstmt.close(); pstmt = null;

							sql = "SELECT PTCN FROM WAVE_TASK_DET WHERE REF_ID = ?";
							pstmt = conn.prepareStatement( sql );
							pstmt.setString( 1, pickOrder );
							rs = pstmt.executeQuery();

							if( rs.next() )
							{
								ptcn = checkNull(rs.getString("PTCN"));
							}
							rs.close(); rs = null;
							pstmt.close(); pstmt = null;

							//Changed by sumit on 04/04/13 adding validation , user can asign same pallet_no to other pick of same ptcn start.
							sql = "SELECT DISTINCT PTCN FROM WAVE_TASK_DET WHERE REF_ID IN (SELECT DISTINCT PICK_ORDER FROM PICK_ISS_HDR WHERE PALLET_NO = ?)";
							pstmt = conn.prepareStatement( sql );
							pstmt.setString(1, palletNoDom.trim());
							rs = pstmt.executeQuery();
							while( rs.next())
							{
								String tempPTCN = "";
								tempPTCN = rs.getString("PTCN");
								if( !tempPTCN.equalsIgnoreCase(ptcn))
								{
									errList.add( "INVPALLFPI" );
									errFields.add( childNodeName.toLowerCase() );
								}								
							}
							rs.close(); rs = null;
							pstmt.close(); pstmt = null;
							//Changed by sumit on 04/04/13 adding validation , user can asign same pallet_no to other pick of same ptcn  end.

							// added by cpatil for validate pallet_no from pallet_no on 10-Jun-12  start
							//if (!"M".equals(pickType))
							//{
							sql="select count(1) from pallet_no where pallet_no = ? ";
							pstmt = conn.prepareStatement(sql);
							pstmt.setString(1, palletNoDom.trim());
							//}
							//else
							//{
							//	sql="select count(1) from carton_master where carton_no = ? and ptcn = ? ";
							//	pstmt = conn.prepareStatement(sql);
							//	pstmt.setString(1, palletNoDom.trim());
							//	pstmt.setString(2, ptcn.trim());
							//}								
							rs = pstmt.executeQuery();
							if(rs.next())
							{
								cnt=rs.getInt(1);
							}
							rs.close();
							rs = null;
							pstmt.close();
							pstmt = null;
							if(cnt == 0)
							{
								errList.add( "INVPLTNOM" );
								errFields.add( childNodeName.toLowerCase() );
							}
							//added by cpatil for validate pallet_no from pallet_no on 10-Jun-12  end

							//if ( pickOrder.trim().length() > 0 )
							//{
								//sql = "SELECT PALLET_NO FROM PICK_ISS_HDR WHERE PICK_ORDER = ?";       // commented by cpatil on 11-sept-12
								//pstmt = conn.prepareStatement( sql );
								//pstmt.setString( 1, pickOrder );
								//rs = pstmt.executeQuery();

								//if( rs.next() )
								//{
									//palletNoDb = checkNull(rs.getString("PALLET_NO"));
									//System.out.println("pallet no db ="+palletNoDb);
									//if(palletNoDb.trim().length() > 0)									
									if( palletNoDom != null )
									{
										sql1="select status from pallet_no where pallet_no =  ? ";//change by Kunal M on 30/07/12 as per S Manoharan Sir intruction
										pstmt1 = conn.prepareStatement(sql1);
										pstmt1.setString(1, palletNoDom.trim());
										rs1 = pstmt1.executeQuery();
										if(rs1.next())
										{
											palletStatus = checkNull(rs1.getString(1));
										}
										rs1.close();
										rs1 = null;
										pstmt1.close();
										pstmt1 = null;
									}
									//System.out.println("pallet no db status = "+palletStatus);
									if ( palletNoDom.trim().length() > 0 &&  !"A".equalsIgnoreCase(palletStatus.trim()))
									//( (palletNoDom.trim().length() > 0 && !palletNoDom.trim().equalsIgnoreCase(palletNoDb) && !"A".equalsIgnoreCase(palletStatus.trim())))
									{
										System.out.println("USED PALLET NO ");
										//Changed by sumit on 07/12/12 changing msg id
										//errList.add( "INVPLTNOU" );
										errList.add( "INVPLTNUS" );
										errFields.add( childNodeName.toLowerCase() );
									}									
									/*else if ( (palletNoDom.trim().length() > 0 &&  ! palletNoDom.trim().equalsIgnoreCase(palletNoDb))  )
									{
										System.out.println("Unmatch PALLET NO ");
										errList.add( "INVPLTNO" );
										errFields.add( childNodeName.toLowerCase() );
									}*/
								//}
								//rs.close();
								//rs = null;
								//pstmt.close();
								//pstmt = null;

							//}
									
							/*sql = "SELECT P.PALLET_NO FROM PICK_ISS_HDR P WHERE P.PICK_ORDER = ? " 
									+" AND P.TRAN_ID  NOT IN (SELECT TRAN_ID FROM PICK_ISS_DET WHERE PICK_ORDER = ?)";       // commented by cpatil on 11-sept-12
								pstmt = conn.prepareStatement( sql );
								pstmt.setString( 1, pickOrder );
								pstmt.setString( 2, pickOrder );

								rs = pstmt.executeQuery();

								if( rs.next() )
								{
									palletNoDb = checkNull(rs.getString("PALLET_NO"));
									System.out.println("pallet no db ="+palletNoDb);
									if ( (palletNoDom.trim().length() > 0 &&  palletNoDb.length() > 0 && ! palletNoDom.trim().equalsIgnoreCase(palletNoDb))  )
									{
										System.out.println("Unmatch PALLET NO ");
										errList.add( "VTAPLTEXST" );
										errFields.add( childNodeName.toLowerCase() );
									}
								}
								
								rs.close();
								rs = null;
								pstmt.close();
								pstmt = null;*/
						}

					}//palet_no case
					/*-- not required
						else if ( "outer_carton_no".equalsIgnoreCase( childNodeName ) && "master_pick".equalsIgnoreCase(objName) )
						{
							if ( childNode.getFirstChild() == null)
							{
								errList.add( "NULLCARTNO" );
								errFields.add( childNodeName.toLowerCase() );
							}
							else 
							{
								cartonNo = checkNull(genericUtility.getColumnValue( "outer_carton_no", currFormDataDom ));

								sql = "SELECT COUNT(*) AS COUNT FROM CARTON_MASTER WHERE STATUS = 'Y' AND CARTON_NO = ? ";
								pstmt = conn.prepareStatement( sql );
								pstmt.setString( 1, cartonNo );
								rs = pstmt.executeQuery();	
								if( rs.next() )
								{
									count = rs.getInt("COUNT");
								}
								rs.close(); rs = null;
								pstmt.close(); pstmt = null;
								if ( count == 0 )
								{
									errList.add( "INVCARTNO" );
									errFields.add( childNodeName.toLowerCase() );
								}
							}
						}//outer_carton_no case
					 */
					
					//Changed By Pragyan 15/MAY/14 to allow only one pallet will allowed at any time for picking but there  should be no detail for the pallet.start
					
					
					
					//Changed By Pragyan 15/MAY/14 to allow only one pallet will allowed at any time for picking but there  should be no detail for the pallet.end
				}
			} //End of case 1 Validation
			break;
			case 2:
			{	
				childList = parentList.item(0).getChildNodes();
				noOfChilds = childList.getLength();

				for ( int ctr = 0; ctr < noOfChilds; ctr++ ) //Loop for each node of current detail
				{	
					Node childNode = childList.item( ctr );
					if( childNode.getNodeType() != Node.ELEMENT_NODE )
					{
						continue;
					}
					String childNodeName = childNode.getNodeName();
					if ( childNode != null && childNode.getFirstChild() != null )
					{
						columnValue = childNode.getFirstChild().getNodeValue();
					}
					System.out.println(" columnName [" + childNodeName + "] columnValue [" + columnValue + "]");
					if ( "tran_date".equalsIgnoreCase( childNodeName ) )
					{
						if ( childNode.getFirstChild() == null )
						{
							// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
							//errString = getErrorString( "tran_date", "NULLTRANDT", userId );
							//break;
							errList.add( "NULLTRANDT" );
							errFields.add( childNodeName.toLowerCase() );
							// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
						}

					}//End of tran_date validation
					else if( "site_code".equalsIgnoreCase( childNodeName ) )
					{
						if ( childNode.getFirstChild() == null)
						{
							// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
							//errString = getErrorString( "site_code", "NULLSITECD", userId );
							//break;
							errList.add( "NULLSITECD" );
							errFields.add( childNodeName.toLowerCase() );
							// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
						}
						siteCode = genericUtility.getColumnValue( "site_code", currFormDataDom );
						sql = "SELECT COUNT(*) AS COUNT FROM SITE WHERE SITE_CODE = ?";
						pstmt = conn.prepareStatement( sql );
						pstmt.setString( 1, siteCode );
						rs = pstmt.executeQuery();

						if( rs.next() )
						{
							count = rs.getInt("COUNT");
						}
						rs.close(); rs = null;
						pstmt.close(); pstmt = null;

						if( count == 0 )
						{
							// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
							//errString = getErrorString( "site_code", "INVDSITECD", userId );
							//break;
							errList.add( "INVDSITECD" );
							errFields.add( childNodeName.toLowerCase() );
							// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
						}
						else //added by kunal on 15-feb-14 for period code
						{
							
							siteCode = genericUtility.getColumnValue("site_code", currFormDataDom);
							
							System.out.println("364 site code ="+siteCode);
							if (genericUtility.getColumnValue("tran_date", currFormDataDom) != null)
							{
								tranDate = sdf1.parse(genericUtility.getColumnValue("tran_date", currFormDataDom));
								sql = "select code from period where ?  between fr_date and to_date";
								pstmt = conn.prepareStatement(sql);
								pstmt.setDate(1, new java.sql.Date(tranDate.getTime()));
								rs = pstmt.executeQuery();
								if (rs.next())
								{
									prdCode = rs.getString(1);

								}
								rs.close();
								rs = null;
								pstmt.close();
								pstmt = null;

								sql = "select count(*) from period_stat where site_code = ? and prd_code = ? ";
								pstmt = conn.prepareStatement(sql);
								pstmt.setString(1, siteCode);
								pstmt.setString(2, prdCode);
								rs = pstmt.executeQuery();
								if (rs.next())
								{
									count = rs.getInt(1);

								}
								rs.close();
								rs = null;
								pstmt.close();
								pstmt = null;
								if (count == 0)
								{
									errList.add( "VTSITEPD" );
									errFields.add( childNodeName.toLowerCase() );
									break;
								}
								// nvo_functions_adv.nf_check_period('SAL',mdate1,msite_code)
								errCode = nfCheckPeriod("IC", tranDate, siteCode);
								System.out.println("425 Error Code = " + errCode);
								if (errCode != null && errCode.trim().length() > 0)
								{
									errList.add( errCode );
									errFields.add( childNodeName.toLowerCase() );
				
								}
							} 							 
						}//end 
					}//End of site_code validation
					else if ( "pick_order".equalsIgnoreCase( childNodeName ) )
					{
						if ( childNode.getFirstChild() == null)
						{
							// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
							//errString = getErrorString( "pick_order", "NULPICKORD", userId );
							//break;
							errList.add( "NULPICKORD" );
							errFields.add( childNodeName.toLowerCase() );
							// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
						}
						pickOrder = genericUtility.getColumnValue( "pick_order", currFormDataDom );
						
						//Changed by sumit on 22/01/13 adding validation where user going to do this task which is already processing by other user start
						sql = "SELECT CONFIRMED, CHG_USER FROM PICK_ISS_HDR WHERE PICK_ORDER = ? ";
						pstmt = conn.prepareStatement( sql );
						pstmt.setString( 1, pickOrder );
						rs = pstmt.executeQuery();
						if( rs.next() )
						{
							System.out.println(" confirmed ["+rs.getString("CONFIRMED")+"] userid ["+rs.getString("CHG_USER")+"]");
							if( "N".equalsIgnoreCase(rs.getString("CONFIRMED")) && !userId.trim().equalsIgnoreCase(rs.getString("CHG_USER").trim()))
							{
								errList.add( "VMPICKORDU" );
								errFields.add( childNodeName.toLowerCase() );
							}
						}
						rs.close();
						rs = null;
						pstmt.close();
						pstmt = null;						
						//Changed by sumit on 22/01/13 adding validation where user going to do this task which is already processing by other user END

						sql = "SELECT COUNT(*) AS COUNT FROM PICK_ORD_HDR WHERE PICK_ORDER = ?";
						pstmt = conn.prepareStatement( sql );
						pstmt.setString( 1, pickOrder );
						rs = pstmt.executeQuery();

						if( rs.next() )
						{
							count = rs.getInt("COUNT");
						}
						rs.close(); rs = null;
						pstmt.close(); pstmt = null;

						if( count == 0 )
						{
							// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
							//errString = getErrorString( "repl_order", "INVPICKORD", userId );
							//break;
							errList.add( "INVPICKORD" );
							errFields.add( childNodeName.toLowerCase() );
							// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
						}
						
						
					}//End pick_order validation
					else if ( "pick_type".equalsIgnoreCase( childNodeName ) )
					{
						pickType = checkNull(genericUtility.getColumnValue( "pick_type", currFormDataDom ));
						if ( childNode.getFirstChild() == null)
						{
							// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
							//errString = getErrorString( "pick_type", "NULPICKTYP", userId );
							//break;
							errList.add( "NULPICKTYP" );
							errFields.add( childNodeName.toLowerCase() );
							// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
						}
						//
						else 
						{
							sql = "SELECT COUNT(*) AS COUNT FROM PICK_ORD_HDR WHERE pick_type = ?";
							pstmt = conn.prepareStatement( sql );
							pstmt.setString( 1, pickType.trim() );
							rs = pstmt.executeQuery();

							if( rs.next() )
							{
								count = rs.getInt("COUNT");
							}
							rs.close(); rs = null;
							pstmt.close(); pstmt = null;
							if( count == 0 )
							{
								errList.add( "INVPICKTYP" );
								errFields.add( childNodeName.toLowerCase() );
							}
						}

						//
						/* -- Commented by Gulzar - on 30/11/11
							else if ( pickType.trim().equalsIgnoreCase("M") )
							{
								// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
								//errString = getErrorString( "pick_type", "INVPICKTYP", userId );
								//break;
								errList.add( "INVPICKTYP" );
								errFields.add( childNodeName.toLowerCase() );
								// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
							}
						 */
					}//End pick_type validation
					/*--Not required
						else if ( "outer_carton_no".equalsIgnoreCase( childNodeName ) && "master_pick".equalsIgnoreCase(objName) )
						{
							if ( childNode.getFirstChild() == null)
							{
								errList.add( "NULLCARTNO" );
								errFields.add( childNodeName.toLowerCase() );
							}
							else 
							{
								cartonNo = checkNull(genericUtility.getColumnValue( "outer_carton_no", currFormDataDom ));

								sql = "SELECT COUNT(*) AS COUNT FROM CARTON_MASTER WHERE STATUS = 'Y' AND CARTON_NO = ? ";
								pstmt = conn.prepareStatement( sql );
								pstmt.setString( 1, cartonNo );
								rs = pstmt.executeQuery();	
								if( rs.next() )
								{
									count = rs.getInt("COUNT");
								}
								rs.close(); rs = null;
								pstmt.close(); pstmt = null;
								if ( count == 0 )
								{
									errList.add( "INVCARTNO" );
									errFields.add( childNodeName.toLowerCase() );
								}
							}
						}//outer_carton_no validation
					 */
				}
			} //End of case 2 Validation
			break;
			case 3:
			{
				sql = "SELECT COUNT(*) AS COUNT FROM PICK_ORD_DET WHERE PICK_ORDER = ? AND LINE_NO = ? AND LOT_NO = ? ";
				pstmtPickLotNo = conn.prepareStatement( sql );

				sql = "SELECT COUNT(*) AS COUNT FROM PICK_ORD_DET WHERE PICK_ORDER = ? AND LINE_NO = ? AND LOT_SL = ? ";
				pstmtPickLotSl = conn.prepareStatement( sql );

				sql = "SELECT SINGLE_LOT_SL, ITEM_LOT_OPT FROM LOCATION WHERE LOC_CODE = ?";
				pstmtLoc = conn.prepareStatement( sql );

				sql = "SELECT QUANTITY FROM STOCK WHERE  SITE_CODE = ? AND LOC_CODE = ? ";
				pstmtStock = conn.prepareStatement( sql );

				//for single item_code and single lot_no
				//changed by sankara on 13/09/2012 add quantity.
				//sql = "SELECT COUNT(*) AS COUNT FROM STOCK WHERE ITEM_CODE <> ? AND SITE_CODE = ? AND LOC_CODE = ? AND LOT_NO <> ?";
				sql = "SELECT COUNT(*) AS COUNT FROM STOCK WHERE (ITEM_CODE <> ? OR LOT_NO <> ?) AND SITE_CODE = ? AND LOC_CODE = ? AND QUANTITY > 0";
				pstmtStock1 = conn.prepareStatement( sql );

				//for single item_code and single lot_no
				//sql = "SELECT COUNT(*) AS COUNT FROM STOCK WHERE ITEM_CODE = ? AND SITE_CODE = ? AND LOC_CODE = ? AND LOT_NO <> ?";
				//pstmtStock2 = conn.prepareStatement( sql );

				//for single item_code and multiple lot_no
				//changed by sankara on 13/09/2012 add quantity.
				//sql = "SELECT COUNT(*) AS COUNT FROM STOCK WHERE  ITEM_CODE <> ? AND SITE_CODE = ? AND LOC_CODE = ? AND LOT_NO = ? ";
				sql = "SELECT COUNT(*) AS COUNT FROM STOCK WHERE  ITEM_CODE <> ? AND SITE_CODE = ? AND LOC_CODE = ? AND QUANTITY > 0";
				pstmtStock3 = conn.prepareStatement( sql );

				//checking for correct picking location
				sql = "SELECT COUNT(*) COUNT FROM LOCATION LOC, INVSTAT ISTAT WHERE LOC.INV_STAT = ISTAT.INV_STAT " +
						"AND LOC.LOC_CODE = ? AND LOC.INV_STAT = ? AND ISTAT.AVAILABLE = 'Y' "+
						"AND (CASE WHEN ISTAT.STAT_TYPE IS NULL THEN ' ' ELSE ISTAT.STAT_TYPE END) <> 'S' ";
				pstmtLoc1 = conn.prepareStatement( sql );

				childList = parentList.item(0).getChildNodes();
				noOfChilds = childList.getLength();

				for ( int ctr = 0; ctr < noOfChilds; ctr++ ) //Loop for each node of current detail
				{	
					Node childNode = childList.item( ctr );
					if( childNode.getNodeType() != Node.ELEMENT_NODE )
					{
						continue;
					}
					String childNodeName = childNode.getNodeName();
					if ( childNode != null && childNode.getFirstChild() != null )
					{
						columnValue = checkNull(childNode.getFirstChild().getNodeValue());
					}
					System.out.println(" columnName [" + childNodeName + "] columnValue [" + columnValue + "]");
					if( "lot_no".equalsIgnoreCase( childNodeName ) )
					{
						
						pickOrder =  genericUtility.getColumnValue("pick_order", allFormDataDom, objContext );
						lineNoPick = checkNull(genericUtility.getColumnValue("line_no__ord", allFormDataDom, objContext ));
						if(lineNoPick != null && lineNoPick.length() > 0)
						{
							lotNo = genericUtility.getColumnValue("lot_no", allFormDataDom, objContext );
	
							pstmtPickLotNo.setString( 1, pickOrder );
							pstmtPickLotNo.setInt( 2, Integer.parseInt(lineNoPick) );
							pstmtPickLotNo.setString( 3, lotNo );
	
							rs = pstmtPickLotNo.executeQuery();
							if( rs.next() )
							{
								count = rs.getInt("COUNT");
							}
							pstmtPickLotNo.clearParameters();
							if ( count == 0 )
							{
								// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
								//errString = getErrorString( "lot_no", "INVLOTNO", userId );
								//break;
								errList.add( "INVLOTNO" );
								errFields.add( childNodeName.toLowerCase() );
								// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
							}
							rs.close(); rs = null;
						}
					}
					else if( "lot_sl".equalsIgnoreCase( childNodeName ) )
					{
						pickOrder =  genericUtility.getColumnValue("pick_order", allFormDataDom, objContext );
						lineNoPick = checkNull(genericUtility.getColumnValue("line_no__ord", allFormDataDom, objContext ));
						lpnNo = genericUtility.getColumnValue("lot_sl", allFormDataDom, objContext );

						
						if(lineNoPick != null && lineNoPick.length() > 0)
						{
							pstmtPickLotSl.setString( 1, pickOrder );
							pstmtPickLotSl.setInt( 2, Integer.parseInt(lineNoPick) );
							pstmtPickLotSl.setString( 3, lpnNo );
	
							rs = pstmtPickLotSl.executeQuery();
							if( rs.next() )
							{
								count = rs.getInt("COUNT");
							}
							pstmtPickLotSl.clearParameters();
	
							if ( count == 0 )
							{
								// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
								//errString = getErrorString( "lot_no", "INVLPNNO", userId );
								//break;
								errList.add( "INVLPNNO" );
								errFields.add( childNodeName.toLowerCase() );
								// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
							}
							rs.close(); rs = null;
						}
						//////////////////////////////////////////////
						// 14/09/12 manoharan validate hold status
						itemCode = checkNull(genericUtility.getColumnValue("item_code", allFormDataDom, objContext ));
						siteCode = checkNull(genericUtility.getColumnValue("site_code", allFormDataDom, objContext ));
						locCode = checkNull(genericUtility.getColumnValue("loc_code", allFormDataDom, objContext ));
						lotNo = checkNull(genericUtility.getColumnValue("lot_no", allFormDataDom, objContext ));
						lotSl = checkNull(genericUtility.getColumnValue("lot_sl", allFormDataDom, objContext ));
						sql = " select count (*) from stock "
						+ " where item_code = ? "
						+ " and site_code = ? "
						+ " and loc_code = ? "
						+ " and lot_no = ? "
						+ " and lot_sl = ? "
						+ " and case when hold_qty is null then 0 else hold_qty end > 0  ";
						pstmt =  conn.prepareStatement(sql);
						pstmt.setString(1,itemCode);
						pstmt.setString(2,siteCode);
						pstmt.setString(3,locCode);
						pstmt.setString(4,lotNo);
						pstmt.setString(5,lotSl);
						rs = pstmt.executeQuery();
						if (rs.next())
						{
							cnt = rs.getInt(1);
						}
						rs.close();
						rs = null;
						pstmt.close();
						pstmt = null;
						if( cnt > 0 )
						{
							errList.add( "INVITMQTST" );
							errFields.add( childNodeName.toLowerCase() );
						}
						// end 14/09/12 manoharan
						//////////////////////////////////////////////
					}
					else if( "loc_code__to".equalsIgnoreCase( childNodeName ) )
					{								
						itemCode = checkNull(genericUtility.getColumnValue("item_code", allFormDataDom, objContext ));
						siteCode = checkNull(genericUtility.getColumnValue("site_code", allFormDataDom, objContext ));
						locCodeTo = checkNull(genericUtility.getColumnValue("loc_code__to", allFormDataDom, objContext ));
						lotNo = checkNull(genericUtility.getColumnValue("lot_no", allFormDataDom, objContext ));
						lpnNo = checkNull(genericUtility.getColumnValue("lot_sl", allFormDataDom, objContext ));
						pickOrder =  checkNull(genericUtility.getColumnValue("pick_order", allFormDataDom, objContext ));

						pstmtLoc.setString( 1, locCodeTo );
						rs = pstmtLoc.executeQuery();
						if( rs.next() )
						{
							singleLotSl = checkNull(rs.getString("SINGLE_LOT_SL"));
							itemLotOpt = checkNull(rs.getString("ITEM_LOT_OPT"));
						}
						else
						{
							// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
							//errString = getErrorString( "loc_code__to", "INVLOCCODE", userId );
							//break;
							errList.add( "INVLOCCODE" );
							errFields.add( childNodeName.toLowerCase() );
							// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
						}
						pstmtLoc.clearParameters();
						rs.close(); rs = null;
						
						//Changed By Pragyan 11-AUG-14 To check and Facility Master implementation.start
						if(!commonWmsUtility.isValFacLocation(locCodeTo, siteCode, conn))
						{
							errList.add( "VMFACI2" ); // 'Diffrent Loc Code from location and site' (set same error Code @base)
							errFields.add( childNodeName.toLowerCase() );
							break;
						}
						//Changed By Pragyan 11-AUG-14 To check and Facility Master implementation.end

						pickType = checkNull(genericUtility.getColumnValue("pick_type", allFormDataDom, "2" ));
						String varName = "";
						if ( "A".equalsIgnoreCase(pickType.trim()) )//Active pick
						{
							varName = "ACTIVE_PICK_INVSTAT";
						}
						else if ( "C".equalsIgnoreCase(pickType.trim()) || "M".equalsIgnoreCase(pickType.trim()) )//Case pick
						{
							varName = "CASE_PICK_INVSTAT";
						}
						DistCommon distComm = new DistCommon();

						String disparmVal = distComm.getDisparams( "999999", varName, conn );
						System.out.println(" disparmVal =[" + disparmVal + "]");

						count = 0;

						//if ( "NULLFOUND".equalsIgnoreCase(disparmVal) )//Commented by gulzar on 12/28/2011
						// 12/06/12 manoharan commented as loc_code__to to be be taken from transporter
						//if ( "NULLFOUND".equalsIgnoreCase(intrLocInvstat) )//Changes added by gulzar on 12/28/2011
						//{
						//	// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
						//	//errString = getErrorString( "loc_code__to", "INVDISPARM", userId );
						//	//break;
						//	//errList.add( "PICKDPARM" );//Commented by gulzar on 12/28/2011
						//	errList.add( "DOCKDPARM" );//Changes added by gulzar on 12/28/2011
						//	errFields.add( childNodeName.toLowerCase() );
						//	// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
						//}
						// 12/06/12 maanoharan commentd as loc_code__to wil be loc_code__dock from transporter
						//pstmtLoc1.setString( 1, locCodeTo );//Commented by gulzar on 12/28/2011
						//pstmtLoc1.setString( 2, disparmVal );
						//pstmtLoc1.setString( 2, intrLocInvstat );//Changes added by gulzar on 12/28/2011
						//rs = pstmtLoc1.executeQuery();	
						//if( rs.next() )
						//{
						//	count = rs.getInt("COUNT");
						//}
						/*
							sql="select t.loc_code__dock from transporter t, despatch d "
								+ " where t.tran_code = d.tran_code "
								+ " and d.desp_id in ( "
								+ " select wt.ref_id from wave_task_det wt where wt.ref_ser = 'S-DSP' and wt.ptcn in (select i.ptcn from wave_task_det i "
								+ " where i.ref_id = ? ) )  ";
							pstmt = conn.prepareStatement( sql );
							pstmt.setString( 1, pickOrder );
							rs = pstmt.executeQuery();
							if ( rs.next() )
							{
								docLocCode = rs.getString(1);
							}
							rs.close();
							rs = null;
							pstmt.close();
							pstmt = null;
							System.out.println(" locCodeTo [" + locCodeTo + "] docLocCode [" + docLocCode + "]");
							//if ( count == 0 )
							if (!docLocCode.trim().equals(locCodeTo.trim()))
							{
								// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
								//errString = getErrorString( "loc_code__to", "VTLOCCODE5", userId );
								//break;
								errList.add( "VTLOCCODE5" );
								errFields.add( childNodeName.toLowerCase() );
								// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
							}
						 */
						if( singleLotSl.trim().equalsIgnoreCase("Y") )
						{
							pstmtStock.setString( 1, siteCode );
							pstmtStock.setString( 2, locCodeTo );
							rs = pstmtStock.executeQuery();	
							if( rs.next() )
							{
								quantity = rs.getDouble("QUANTITY");
							}
							pstmtStock.clearParameters();
							rs.close(); rs = null;

							if( quantity != 0 )
							{
								// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
								//errString = getErrorString( "loc_code__to", "VTLOCCODE1", userId );
								//break;
								errList.add( "VTLOCCODE1" );
								errFields.add( childNodeName.toLowerCase() );
								// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
							}
						}
						else
						{
							if( itemLotOpt.trim().equals("0") )  // Validation for single item_code and single lot_no
							{
								//changed by sankara on 13/09/2012 to set string in a row based on sql [Start]
								/*	pstmtStock1.setString( 1, itemCode );
									pstmtStock1.setString( 2, siteCode );
									pstmtStock1.setString( 3, locCodeTo );
									pstmtStock1.setString( 4, lotNo );  */
									pstmtStock1.setString( 1, itemCode );
									pstmtStock1.setString( 2, lotNo ); 
									pstmtStock1.setString( 3, siteCode );
									pstmtStock1.setString( 4, locCodeTo );
									//changed by sankara on 13/09/2012 to set string in a row based on sql [End]
								rs = pstmtStock1.executeQuery();
								if( rs.next() )
								{
									count = rs.getInt("COUNT");
								}
								pstmtStock1.clearParameters();
								rs.close(); rs = null;

								if( count > 0 )
								{
									// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
									//errString = getErrorString("loc_code__to", "VTLOCCODE2", userId );
									//break;
									errList.add( "VTLOCCODE2" );
									errFields.add( childNodeName.toLowerCase() );
									// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
								}
								/* -- Commented by gulzar - 29/11/11 - for single item and single lot it is not required
									pstmtStock2.setString( 1, itemCode );
									pstmtStock2.setString( 2, siteCode );
									pstmtStock2.setString( 3, locCodeTo );
									pstmtStock2.setString( 4, lotNo );
									rs = pstmtStock2.executeQuery();
									if( rs.next() )
									{
										count = rs.getInt("COUNT");
									}
									pstmtStock2.clearParameters();
									rs.close(); rs = null;

									if( count > 0 )
									{
										// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
										//errString = getErrorString("loc_code__to", "VTLOCCODE3", userId );
										//break;
										errList.add( "VTLOCCODE3" );
										errFields.add( childNodeName.toLowerCase() );
										// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
									}
								 */
							}
							else if( itemLotOpt.trim().equals("1") )  //Validation for single item_code and multiple lot_no
							{
								//changed by sankara on 13/09/2012 to set string in a row based on sql [Start]	
								/*	pstmtStock3.setString( 1, itemCode );
									pstmtStock3.setString( 2, siteCode );
									pstmtStock3.setString( 3, locCodeTo );
									pstmtStock3.setString( 4, lotNo ); */
									pstmtStock3.setString( 1, itemCode );
									pstmtStock3.setString( 2, siteCode );
									pstmtStock3.setString( 3, locCodeTo );
								//changed by sankara on 13/09/2012 to set string in a row based on sql [Start]	
								rs = pstmtStock3.executeQuery();
								if( rs.next() )
								{
									count = rs.getInt("COUNT");
								}
								pstmtStock3.clearParameters();
								rs.close(); rs = null;

								if( count > 0 )
								{
									// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
									//errString = getErrorString("loc_code__to", "VTLOCCODE4", userId );
									//break;
									errList.add( "VTLOCCODE4" );
									errFields.add( childNodeName.toLowerCase() );
									// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
								}
							}//itemLotOpt = '1'
						}//singleLotSl != 'Y'
					}//loc_code__to case
					//case added by gulzar - 30/11/11 - to case should not assigned to same case label

					else if( "case_label".equalsIgnoreCase( childNodeName ) )
					{

						if ( childNode.getFirstChild() == null)
						{
							//errList.add( "VTCASELBL1" );  //change done by C Pandey on 08/08/12 
							//errFields.add( childNodeName.toLowerCase() );
						}
						else
						{
							//caseLabel =  genericUtility.getColumnValue("case_label", allFormDataDom, objContext );
							caseLabel =  genericUtility.getColumnValue("case_label", currFormDataDom, objContext );

							//changes added by gulzar on 12/13/2011
							tranID =  genericUtility.getColumnValue("tran_id", currFormDataDom, objContext );
							//End changes by gulzar on 12/13/2011

							//changes by gulzar - 08/12/11
							String caseLabelPrev = "";
							NodeList caseLabelList = null;
							int caseLblCntDb = 0;
							int recCnt = 0;
							caseLabelList = allFormDataDom.getElementsByTagName("case_label");
							int noOfLabel = caseLabelList.getLength();

							/*
								for( int idx = 0; idx < noOfLabel; idx++ )
								{
									if ( caseLabelList.item( idx ).getFirstChild() != null )
									{
										caseLabelPrev = ( caseLabelList.item( idx ).getFirstChild() ).getNodeValue();
									}
									System.out.println( "caseLabelPrev =[ " + caseLabelPrev + "] AND CURR caseLabel =[" + caseLabel + " ]" );
									if( caseLabelPrev.equals( caseLabel ) )
									{
										recCnt++;
									}
								}
							 */
							ArrayList caseList = new ArrayList();
							for( int idx = 0; idx < noOfLabel; idx++ )
							{
								if ( caseLabelList.item( idx ).getFirstChild() != null )
								{
									caseList.add(( caseLabelList.item( idx ).getFirstChild() ).getNodeValue());
								}
							}
							int listLen = caseList.size();
							if ( listLen > 0 )
							{
								recCnt = 1;
								for( int i = 0; i < listLen - 1; i++ )
								{
									for ( int j = i+1; j < listLen; j++ )
									{
										if ( ((String)caseList.get(i)).equalsIgnoreCase((String)caseList.get(j)) )
										{
											recCnt++;
											break;
										}
									}
									if( recCnt > 1 )
									{
										break;
									}
								}
							}
							System.out.println("recCnt = ["+recCnt+"]");

							if( recCnt > 1 )
							{
								errList.add( "DUPCASELBL" );
								errFields.add( childNodeName.toLowerCase() );
							}
							else if ( tranID != null && tranID.trim().length() > 0 )
							{
								sql = "SELECT count(*) AS COUNT FROM PICK_ISS_DET WHERE TRAN_ID <> ? AND CASE_LABEL = ? ";
								pstmt = conn.prepareStatement(sql);

								for( int idx = 0; idx < noOfLabel; idx++ )
								{
									if ( caseLabelList.item( idx ).getFirstChild() != null )
									{
										caseLabelPrev = ( caseLabelList.item( idx ).getFirstChild() ).getNodeValue();

										pstmt.setString( 1, tranID );
										pstmt.setString( 2, caseLabelPrev );
										rs = pstmt.executeQuery();
										if( rs.next() )
										{
											caseLblCntDb = rs.getInt("COUNT");
										}
										rs.close(); rs = null;
										pstmt.clearParameters();
										System.out.println( "caseLblCntDb =[" +caseLblCntDb+ "]" );
										if ( caseLblCntDb > 0 )
										{
											errList.add( "VTCASELBL2" );
											errFields.add( childNodeName.toLowerCase() );
											break;
										}
									}
								}
								pstmt.close(); pstmt = null;
							}
							else if ( tranID == null || tranID.trim().length() == 0 )
							{
								sql = "SELECT count(*) AS COUNT FROM PICK_ISS_DET WHERE CASE_LABEL = ? ";
								pstmt = conn.prepareStatement(sql);

								for( int idx = 0; idx < noOfLabel; idx++ )
								{
									if ( caseLabelList.item( idx ).getFirstChild() != null )
									{
										caseLabelPrev = ( caseLabelList.item( idx ).getFirstChild() ).getNodeValue();

										pstmt.setString( 1, caseLabelPrev );
										rs = pstmt.executeQuery();
										if( rs.next() )
										{
											caseLblCntDb = rs.getInt("COUNT");
										}
										rs.close(); rs = null;
										pstmt.clearParameters();
										System.out.println( "caseLblCntDb =[" +caseLblCntDb+ "]" );
										if ( caseLblCntDb > 0 )
										{
											errList.add( "VTCASELBL2" );
											errFields.add( childNodeName.toLowerCase() );
											break;
										}
									}
								}
								pstmt.close(); pstmt = null;
							}
							//End changes by gulzar - 08/12/11
						}
					}
					else if ( "carton_no".equalsIgnoreCase( childNodeName ) && "master_pick".equalsIgnoreCase(objName) )
					{
						if ( childNode.getFirstChild() == null)
						{
							errList.add( "NULLCARTNO" );
							errFields.add( childNodeName.toLowerCase() );
						}
						else 
						{
							//String status = "";
							String lineNo = "";
							String cartonNoDb = "";
							int lineNoIss = 0;

							tranID =  checkNull(genericUtility.getColumnValue("tran_id", currFormDataDom, objContext ));
							lineNo =  checkNull(genericUtility.getColumnValue("line_no", currFormDataDom, objContext ));
							if ( lineNo.trim().length() > 0 )
							{
								//lineNoIss = Integer.parseInt(lineNo);
							}

							cartonNo = checkNull(genericUtility.getColumnValue( "carton_no", currFormDataDom, objContext ));

							if ( tranID.trim().length() > 0 )
							{
								/*
									sql = "SELECT CARTON_NO FROM PICK_ISS_DET WHERE TRAN_ID = ? AND LINE_NO = ? ";
									pstmt = conn.prepareStatement( sql );
									pstmt.setString( 1, tranID );
									pstmt.setInt( 2, lineNoIss );
									rs = pstmt.executeQuery();	
									if( rs.next() )
									{
										cartonNoDb = checkNull(rs.getString("CARTON_NO"));
									}
									if ( ! cartonNoDb.trim().equalsIgnoreCase(cartonNo.trim()) )
									{
										sql = "SELECT STATUS FROM CARTON_MASTER WHERE CARTON_NO = ? ";
										pstmt = conn.prepareStatement( sql );
										pstmt.setString( 1, cartonNo );
										rs = pstmt.executeQuery();	
										if( rs.next() )
										{
											status = checkNull(rs.getString("STATUS"));
										}
										else
										{
											errList.add( "VTCARTNO4" );
											errFields.add( childNodeName.toLowerCase() );
										}
										rs.close(); rs = null;
										pstmt.close(); pstmt = null;
										if ( ! "A".equalsIgnoreCase(status.trim()) )
										{
											errList.add( "VTCARTNO2" );
											errFields.add( childNodeName.toLowerCase() );
										}
									}
								 */
								int ctnCount = 0;

								sql = "SELECT COUNT(*) AS COUNT FROM PICK_ISS_DET WHERE TRAN_ID = ? AND CARTON_NO = ? ";
								pstmt = conn.prepareStatement( sql );
								pstmt.setString( 1, tranID );
								pstmt.setString( 2, cartonNo );
								rs = pstmt.executeQuery();	
								if( rs.next() )
								{
									ctnCount = rs.getInt("COUNT");
								}
								if ( ctnCount == 0 )
								{
									sql = "SELECT STATUS FROM CARTON_MASTER WHERE CARTON_NO = ? ";
									pstmt = conn.prepareStatement( sql );
									pstmt.setString( 1, cartonNo );
									rs = pstmt.executeQuery();	
									if( rs.next() )
									{
										status = checkNull(rs.getString("STATUS"));
									}
									else
									{
										errList.add( "VTCARTNO4" );
										errFields.add( childNodeName.toLowerCase() );
									}
									rs.close(); rs = null;
									pstmt.close(); pstmt = null;
									if ( ! "A".equalsIgnoreCase(status.trim()) )
									{
										errList.add( "VTCARTNO2" );
										errFields.add( childNodeName.toLowerCase() );
									}
								}
							}
							else if ( tranID.trim().length() == 0 )
							{
								sql = "SELECT STATUS FROM CARTON_MASTER WHERE CARTON_NO = ? ";
								pstmt = conn.prepareStatement( sql );
								pstmt.setString( 1, cartonNo );
								rs = pstmt.executeQuery();	
								if( rs.next() )
								{
									status = checkNull(rs.getString("STATUS"));
								}
								else
								{
									errList.add( "VTCARTNO4" );
									errFields.add( childNodeName.toLowerCase() );
								}
								rs.close(); rs = null;
								pstmt.close(); pstmt = null;
								if ( ! "A".equalsIgnoreCase(status.trim()) )
								{
									errList.add( "VTCARTNO2" );
									errFields.add( childNodeName.toLowerCase() );
								}
							}
						}
					}//carton_no case
					//End changes made by gulzar on 30/11/11
					// added by cpatil for validate quantity on 10-Jun-12  start
					else if ( "quantity".equalsIgnoreCase( childNodeName ) )
					{
						pickType = checkNull(genericUtility.getColumnValue("pick_type", allFormDataDom, "2" ));
						String quantity2 =  genericUtility.getColumnValue("quantity", currFormDataDom, objContext );
						double ordQty = 0;
						if (quantity2 == null || "null".equals(quantity2) || quantity2.trim().length() == 0)
						{
							quantity2 = "0";
						}
						quantity  = Double.parseDouble(quantity2);
						if(quantity2 == null || quantity2.trim().length() == 0)
						{
							errList.add( "VTQUNT2" );
							errFields.add( childNodeName.toLowerCase() );
						}
						else
						{
							// 12/06/12 manoharan validate quantity for active
							pickOrder =  genericUtility.getColumnValue("pick_order", currFormDataDom, objContext );
							String lineNo = genericUtility.getColumnValue("line_no__ord", currFormDataDom, objContext );
							//Changed by sumit on 12/03/13 changing sql as QUANTITY = QUANTITY - DEALLOC_QTY
							//sql = "SELECT quantity,no_art FROM PICK_ORD_DET WHERE PICK_ORDER = ? AND LINE_NO = " + lineNo;
							sql = "SELECT (QUANTITY - CASE WHEN DEALLOC_QTY IS NULL THEN 0 ELSE DEALLOC_QTY END ) AS QUANTITY " +
									" ,NO_ART FROM PICK_ORD_DET WHERE PICK_ORDER = ? AND LINE_NO = " + lineNo;
							pstmt = conn.prepareStatement(sql);
							pstmt.setString(1, pickOrder);
							rs = pstmt.executeQuery();
							if(rs.next())
							{
								ordQty = rs.getDouble(1);
							}
							rs.close();
							rs = null;
							pstmt.close();
							pstmt = null;
							if ("A".equals(pickType) && ordQty != quantity)
							{
								errList.add( "VQUANTI" );
								errFields.add( childNodeName.toLowerCase() );
							}
						}
					}
					else if ( "no_art".equalsIgnoreCase( childNodeName ) )
					{
						pickType = checkNull(genericUtility.getColumnValue("pick_type", allFormDataDom, "2" ));
						String noArtStr =  genericUtility.getColumnValue("no_art", currFormDataDom, objContext );
						int ordNoArt = 0, noArt = 0;
						if (noArtStr == null || "null".equals(noArtStr) || noArtStr.trim().length() == 0)
						{
							noArtStr = "0";
						}
						//noArt  = Integer.parseInt(noArtStr);
						noArt  =  (int)Double.parseDouble(noArtStr); //change done by Kunal on 13/09/12 
						
						if(noArt == 0)
						{
							errList.add( "VTQUNT2" );
							errFields.add( childNodeName.toLowerCase() );
						}
						else
						{
							// 12/06/12 manoharan validate quantity for active
							pickOrder =  genericUtility.getColumnValue("pick_order", currFormDataDom, objContext );
							String lineNo = genericUtility.getColumnValue("line_no__ord", currFormDataDom, objContext );
							//Changed by sumit on 12/03/13 changing sql as QUANTITY = QUANTITY - DEALLOC_QTY
							//sql = "SELECT quantity,no_art FROM PICK_ORD_DET WHERE PICK_ORDER = ? AND LINE_NO = " + lineNo;
							sql = "SELECT (QUANTITY - CASE WHEN DEALLOC_QTY IS NULL THEN 0 ELSE DEALLOC_QTY END ) AS QUANTITY " +
									" ,NO_ART FROM PICK_ORD_DET WHERE PICK_ORDER = ? AND LINE_NO = " + lineNo;
							pstmt = conn.prepareStatement(sql);
							pstmt.setString(1, pickOrder);
							rs = pstmt.executeQuery();
							if(rs.next())
							{
								ordNoArt = rs.getInt(2);
							}
							rs.close();
							rs = null;
							pstmt.close();
							pstmt = null;
							
							//Changed by sumit on 12/03/13 for changing no_art start.
							lotNo = genericUtility.getColumnValue("lot_no", currFormDataDom, objContext );
							quantity = Double.parseDouble(genericUtility.getColumnValue("quantity", currFormDataDom, objContext ));
							itmVolumeMap.clear();
							itmVolumeMap = getItemVoumeMap(itemCode,lotNo,conn);
							shipperSize = (Double) itmVolumeMap.get("SHIPPER_SIZE");
							ordNoArt = (int) (quantity / shipperSize);
							System.out.println(" ordNoArt ->["+ordNoArt+"] noArt ->["+noArt+"] pickType ->["+pickType+"]");
							//Changed by sumit on 12/03/13 for changing no_art end.
							
							if (!"A".equals(pickType) && ordNoArt != noArt)
							{
								errList.add( "VQUANTI" );
								errFields.add( childNodeName.toLowerCase() );
							}
						}
						//changed by sankara on 10/06/14 for picking not allowed if pick deallocation done start.
						String lineNo = genericUtility.getColumnValue("line_no__ord", currFormDataDom, objContext );
						System.out.println("lineNo:::::::"+lineNo);
						sql = " SELECT COUNT(*) AS COUNT FROM PICK_ORD_DET PO WHERE (PO.QUANTITY - (CASE WHEN PO.DEALLOC_QTY IS NULL THEN 0 ELSE PO.DEALLOC_QTY END )) > 0 "+
						      " AND PO.PICK_ORDER = ? AND PO.LINE_NO = ? ";	
						pstmt = conn.prepareStatement(sql);
						pstmt.setString(1, pickOrder);
						pstmt.setString(2, lineNo);
						rs = pstmt.executeQuery();
						if(rs.next())
						{
							cnt = rs.getInt("COUNT");
							System.out.println("pickCount::::::"+cnt);
						}
						if(cnt == 0)
						{
							errList.add( "VTINVQUNAT" );
							errFields.add( childNodeName.toLowerCase() );	
						}
						rs.close();
						rs = null;
						pstmt.close();
						pstmt = null;
						//changed by sankara on 10/06/14 for picking not allowed if pick deallocation done end.
					}
					//Changed by Rohan on 06-10-12 to generate hazardous material report.start
					else if("item_code".equalsIgnoreCase( childNodeName ))
					{
						
						//to check item is hazarous.start
						itemCd = checkNull(genericUtility.getColumnValue( "item_code", currFormDataDom, objContext ));
						pickOrd =  genericUtility.getColumnValue("pick_order", currFormDataDom, objContext );
						
						sqlitem = "SELECT HAZARDOUS FROM ITEM WHERE ITEM_CODE=? ";
						pstmtitem = conn.prepareStatement(sqlitem);
						
						pstmtitem.setString(1,itemCd);
						
						rsitem = pstmtitem.executeQuery();
						if(rsitem.next())
						{
							hazMaterial = rsitem.getString("HAZARDOUS") == null?"":rsitem.getString("HAZARDOUS");
										
							System.out.println("hazardous*"+hazMaterial);
						}
						if(pstmtitem != null)
						{
							pstmtitem.close();
							pstmtitem = null;
						}
						if(rsitem != null)
						{
							rsitem.close();
							rsitem = null;
						}
						//to check item is hazarous.end
						//to check transporter mode.start
						
						
						sqlptcn ="SELECT PTCN,WAVE_ID FROM WAVE_TASK_DET WHERE REF_ID = ?";
						pstmtitem = conn.prepareStatement(sqlptcn);
						
						pstmtitem.setString(1,pickOrd);
						
						rsitem = pstmtitem.executeQuery();
						if(rsitem.next())
						{
							ptcnHaz = rsitem.getString("PTCN") == null?"":rsitem.getString("PTCN");
							waveIdHaz = rsitem.getString("WAVE_ID") == null?"":rsitem.getString("WAVE_ID");
										
							System.out.println("ptcnHaz*"+ptcnHaz+"waveIdHaz"+waveIdHaz);
						}
						if(pstmtitem != null)
						{
							pstmtitem.close();
							pstmtitem = null;
						}
						if(rsitem != null)
						{
							rsitem.close();
							rsitem = null;
						}
						
						/*
						sqlTran  = "SELECT TRANS_MODE FROM DESPATCH WHERE DESP_ID IN(SELECT REF_ID FROM WAVE_TASK_DET "
								   +" WHERE REF_SER = ? AND WAVE_ID  IN(SELECT WAVE_ID FROM WAVE_TASK_DET WHERE REF_ID = ?) )";
						*/
						sqlTran  = "SELECT TRANS_MODE FROM DESPATCH WHERE DESP_ID IN(SELECT REF_ID FROM WAVE_TASK_DET "
								   +" WHERE REF_SER = ? AND WAVE_ID = ? AND PTCN = ?)";
						pstmtitem = conn.prepareStatement(sqlTran);
						
						pstmtitem.setString(1,"S-DSP");
						pstmtitem.setString(2,waveIdHaz);
						pstmtitem.setString(3,ptcnHaz);
						
						rsitem = pstmtitem.executeQuery();
						if(rsitem.next())
						{
							transMode = rsitem.getString("TRANS_MODE") == null?"":rsitem.getString("TRANS_MODE");
										
							System.out.println("transMode*"+transMode);
						}
						if(pstmtitem != null)
						{
							pstmtitem.close();
							pstmtitem = null;
						}
						if(rsitem != null)
						{
							rsitem.close();
							rsitem = null;
						}
						//to check transporter mode.end
						if("Y".equalsIgnoreCase(hazMaterial) && "A".equalsIgnoreCase(transMode))
						{
							errList.add( "VTHAZMAT" );
							errFields.add( childNodeName.toLowerCase() );		
						}	
						
					}
					//Changed by Rohan on 06-10-12 to generate hazardous material report.end
					//Changed by Rohan on 29-10-12 to add warinig message in depended repanishment not scan.start
					else if("pick_order".equalsIgnoreCase( childNodeName ))
					{
						
						tranID =  genericUtility.getColumnValue("tran_id", currFormDataDom, objContext );
						String palletNo =  genericUtility.getColumnValue("pallet_no", hdrDataDom, "1" );
						System.out.println("DATA FOUND IN PICKING TRAN_ID ["+tranID+"]["+palletNo+"]");
						
						pickOrdIss = checkNull(genericUtility.getColumnValue( "pick_order", currFormDataDom, objContext ));
						linNoOrder =  genericUtility.getColumnValue("line_no__ord", currFormDataDom, objContext );
						
						sqlPick = "SELECT REPL_ORDER,LINE_NO__REPL FROM PICK_ORD_DET WHERE PICK_ORDER = ? AND LINE_NO = ?";
						pstmt = conn.prepareStatement(sqlPick);
						pstmt.setString(1,pickOrdIss);
						pstmt.setString(2,linNoOrder);
						rs = pstmt.executeQuery();
						if(rs.next())
						{
							replOrderPick = checkNull(rs.getString("REPL_ORDER"));
							lineNoRepl = checkNull(rs.getString("LINE_NO__REPL"));
						}
						rs.close();
						rs = null;
						pstmt.close();
						pstmt = null;
						
						
						//Changed by sumit on 05/12/12 changing sql for dependable replenishment task confirm or not  
						//selReplCnt = "SELECT COUNT(*) AS COUNT FROM REPL_ORD_DET WHERE PICK_ORDER = ? AND LINE_NO__PICK = ?";
						selReplCnt = "SELECT COUNT(*) AS COUNT FROM WAVE_TASK_DET WHERE REF_ID = ? AND STATUS = ?";
						pstmt = conn.prepareStatement(selReplCnt);
						pstmt.setString(1,replOrderPick);
						//Changed by sumit on 05/12/12 Changing input parameter as per sql.
						//pstmt.setString(2,lineNoRepl);
						pstmt.setString(2,"N");
						rs = pstmt.executeQuery();
						if(rs.next())
						{
							cntRepl = rs.getInt("COUNT");
						}
						if(cntRepl > 0)
						{
							errList.add( "PRVREPLSCN" );
							errFields.add( childNodeName.toLowerCase() );	
						}
						rs.close();
						rs = null;
						pstmt.close();
						pstmt = null;
						
						String comleteStatus = "";
						//sql = "SELECT STATUS FROM PICK_ORD_HDR WHERE PICK_ORDER = ?";
						sql = "SELECT CONFIRMED FROM PICK_ISS_HDR WHERE TRAN_ID = ? AND PALLET_NO = ?";
						pstmt = conn.prepareStatement( sql );
						pstmt.setString( 1, tranID );
						pstmt.setString( 2, palletNo );
						
						rs = pstmt.executeQuery();

						if( rs.next() )
						{
							comleteStatus = rs.getString("CONFIRMED");
						}
						rs.close(); rs = null;
						pstmt.close(); pstmt = null;
						System.out.println("Current Pick Status ["+comleteStatus+"]["+pickOrdIss+"]");
						if("Y".equalsIgnoreCase(comleteStatus))
						{
							errList.add( "VTPICKCOMP" );
							errFields.add( childNodeName.toLowerCase() );
						}
						
					}	
					//Changed by Rohan on 29-10-12 to add warinig message in depended repanishment not scan.end
				
					// added by cpatil for validate quantity on 10-Jun-12  end	
				}
				////////////////////////////////////////////////////
				/*----------
					for( int prnt = 0; prnt < noOfParent; prnt++ )  // Loop for multiple details in allFormDataDom
					{
						childList = parentList.item(prnt).getChildNodes();
						noOfChilds = childList.getLength();

						rowCountStr = ""+(prnt+1);
						System.out.println("rowCountStr=["+rowCountStr+"]");

						for ( int ctr = 0; ctr < noOfChilds; ctr++ )  //Loop for each node of current detail
						{	
							Node childNode = childList.item( ctr );
							if( childNode.getNodeType() != Node.ELEMENT_NODE )
							{
								continue;
							}
							String childNodeName = childNode.getNodeName();
							if ( childNode != null && childNode.getFirstChild() != null )
							{
								columnValue = childNode.getFirstChild().getNodeValue();
							}
							System.out.println(" columnName [" + childNodeName + "] columnValue [" + columnValue + "]");
							if( "lot_no".equalsIgnoreCase( childNodeName ) )
							{
								pickOrder =  genericUtility.getColumnValue("pick_order", allFormDataDom, "3", rowCountStr );
								lineNoPick = genericUtility.getColumnValue("line_no__ord", allFormDataDom, "3", rowCountStr );
								lotNo = genericUtility.getColumnValue("lot_no", allFormDataDom, "3", rowCountStr );

								pstmtPickLotNo.setString( 1, pickOrder );
								pstmtPickLotNo.setInt( 2, Integer.parseInt(lineNoPick) );
								pstmtPickLotNo.setString( 3, lotNo );

								rs = pstmtPickLotNo.executeQuery();
								if( rs.next() )
								{
									count = rs.getInt("COUNT");
								}
								pstmtPickLotNo.clearParameters();
								if ( count == 0 )
								{
									errString = getErrorString( "lot_no", "INVLOTNO", userId );
									break;
								}
								rs.close(); rs = null;
							}
							else if( "lot_sl".equalsIgnoreCase( childNodeName ) )
							{
								pickOrder =  genericUtility.getColumnValue("pick_order", allFormDataDom, "3", rowCountStr );
								lineNoPick = genericUtility.getColumnValue("line_no__ord", allFormDataDom, "3", rowCountStr );
								lpnNo = genericUtility.getColumnValue("lot_sl", allFormDataDom, "3", rowCountStr );

								pstmtPickLotSl.setString( 1, pickOrder );
								pstmtPickLotSl.setInt( 2, Integer.parseInt(lineNoPick) );
								pstmtPickLotSl.setString( 3, lpnNo );

								rs = pstmtPickLotSl.executeQuery();
								if( rs.next() )
								{
									count = rs.getInt("COUNT");
								}
								pstmtPickLotSl.clearParameters();

								if ( count == 0 )
								{
									errString = getErrorString( "lot_no", "INVLPNNO", userId );
									break;
								}
								rs.close(); rs = null;
							}
							else if( "loc_code__to".equalsIgnoreCase( childNodeName ) )
							{								
								itemCode = checkNull(genericUtility.getColumnValue("item_code", allFormDataDom, "3", rowCountStr ));
								siteCode = checkNull(genericUtility.getColumnValue("site_code", allFormDataDom, "3", rowCountStr ));
								locCodeTo = checkNull(genericUtility.getColumnValue("loc_code__to", allFormDataDom, "3", rowCountStr ));
								lotNo = checkNull(genericUtility.getColumnValue("lot_no", allFormDataDom, "3", rowCountStr ));
								lpnNo = checkNull(genericUtility.getColumnValue("lot_sl", allFormDataDom, "3", rowCountStr ));
								pickOrder =  checkNull(genericUtility.getColumnValue("pick_order", allFormDataDom, "3", rowCountStr ));

								pstmtLoc.setString( 1, locCodeTo );
								rs = pstmtLoc.executeQuery();
								if( rs.next() )
								{
									singleLotSl = checkNull(rs.getString("SINGLE_LOT_SL"));
									itemLotOpt = checkNull(rs.getString("ITEM_LOT_OPT"));
								}
								else
								{
									errString = getErrorString( "loc_code__to", "INVLOCCODE", userId );
									break;
								}
								pstmtLoc.clearParameters();
								rs.close(); rs = null;

								if( singleLotSl.trim().equalsIgnoreCase("Y") )
								{
									pstmtStock.setString( 1, itemCode );
									pstmtStock.setString( 2, siteCode );
									pstmtStock.setString( 3, locCodeTo );
									pstmtStock.setString( 4, lotNo );
									pstmtStock.setString( 5, lpnNo );
									rs = pstmtStock.executeQuery();	
									if( rs.next() )
									{
										quantity = rs.getDouble("QUANTITY");
									}
									pstmtStock.clearParameters();
									rs.close(); rs = null;

									if( quantity != 0 )
									{
										errString = getErrorString( "loc_code__to", "INVLOCCODE", userId );
										break;
									}
								}
								else
								{
									if( itemLotOpt.trim().equals("0") )  // Validation for single item_code and single lot_no
									{
										pstmtStock1.setString( 1, itemCode );
										pstmtStock1.setString( 2, siteCode );
										pstmtStock1.setString( 3, locCodeTo );
										pstmtStock1.setString( 4, lotNo );
										rs = pstmtStock1.executeQuery();
										if( rs.next() )
										{
											count = rs.getInt("COUNT");
										}
										pstmtStock1.clearParameters();
										rs.close(); rs = null;

										if( count > 0 )
										{
											errString = getErrorString("loc_code__to", "INVLOCCODE", userId );
											break;
										}
										pstmtStock2.setString( 1, itemCode );
										pstmtStock2.setString( 2, siteCode );
										pstmtStock2.setString( 3, locCodeTo );
										pstmtStock2.setString( 4, lotNo );
										rs = pstmtStock2.executeQuery();
										if( rs.next() )
										{
											count = rs.getInt("COUNT");
										}
										pstmtStock2.clearParameters();
										rs.close(); rs = null;

										if( count > 0 )
										{
											errString = getErrorString("loc_code__to", "INVLOCCODE", userId );
											break;
										}
									}
									else if( itemLotOpt.trim().equals("1") )  //Validation for single item_code and multiple lot_no
									{
										pstmtStock3.setString( 1, itemCode );
										pstmtStock3.setString( 2, siteCode );
										pstmtStock3.setString( 3, locCodeTo );
										pstmtStock3.setString( 4, lotNo );
										rs = pstmtStock3.executeQuery();
										if( rs.next() )
										{
											count = rs.getInt("COUNT");
										}
										pstmtStock3.clearParameters();
										rs.close(); rs = null;

										if( count > 0 )
										{
											errString = getErrorString("loc_code__to", "INVLOCCODE", userId );
											break;
										}
									}
								}

								pstmt.setString( 1, itemCode );
								pstmt.setString( 2, siteCode );
								pstmt.setString( 3, locCodeTo );
								pstmt.setString( 4, lotNo );
								pstmt.setString( 5, lpnNo );
								rs = pstmt.executeQuery();	

								if( rs.next() )
								{
									confirmed = checkNull(rs.getString("CONFIRMED"));
								}
								pstmt.clearParameters();
								rs.close(); rs = null;

								if( confirmed.trim().equalsIgnoreCase("N") )
								{
									errString = getErrorString( "loc_code__to", "INVLOCCODE", userId );
									break;
								}									
							}
						}
						if ( errString != null && errString.trim().length() > 0 )
						{
							break;
						}
					}
				 */
				////////////////////////////////////
			} //End of Case 3 Validation		
			case 4:
			//Changed By Rohan on 2-11-12 to add validation if Suggested location blank.start	
			{
				
				childList = parentList.item(0).getChildNodes();
				noOfChilds = childList.getLength();

				for ( int ctr = 0; ctr < noOfChilds; ctr++ ) 
				{	
					Node childNode = childList.item( ctr );
					if( childNode.getNodeType() != Node.ELEMENT_NODE )
					{
						continue;
					}
					String childNodeName = childNode.getNodeName();
					if ( childNode != null && childNode.getFirstChild() != null )
					{
						columnValue = childNode.getFirstChild().getNodeValue();
					}
					if ( "loc_code__to".equalsIgnoreCase( childNodeName ) )
					{
						locCodeTo = genericUtility.getColumnValue( "loc_code__to", currFormDataDom );
						if( locCodeTo == null || locCodeTo.trim().length() == 0 )
						{
							errList.add( "INVSUGLOC" );
							errFields.add( childNodeName.toLowerCase() );
						}
						//Changed by sumit on 18/12/12 checking loc code in location master start.
						else
						{
							sql = "SELECT LOC_CODE FROM LOCATION WHERE LOC_CODE = ?";  
							pstmt = conn.prepareStatement(sql);
							pstmt.setString(1, locCodeTo);
							rs = pstmt.executeQuery();
							if( !rs.next())
							{
								errList.add( "VTLOC1" );
								errFields.add( childNodeName.toLowerCase() );
							}
							if( rs != null)
							{
								rs.close();
								rs = null;
							}
							if( pstmt != null)
							{
								pstmt.close();
								pstmt = null;
							}							
						}
						//Changed by sumit on 18/12/12 checking loc code in location master start.
					}
					
				}
				

			}
			//Changed By Rohan on 2-11-12 to add validation if Suggested location blank.end
				//				{
				//					//for single item_code and multiple lot_no
				//					//checking for correct picking location
				//					sql = "SELECT COUNT(*) COUNT FROM LOCATION LOC, INVSTAT ISTAT WHERE LOC.INV_STAT = ISTAT.INV_STAT " +
				//							"AND LOC.LOC_CODE = ? AND LOC.INV_STAT = ? AND ISTAT.AVAILABLE = 'Y' "+
				//							"AND (CASE WHEN ISTAT.STAT_TYPE IS NULL THEN ' ' ELSE ISTAT.STAT_TYPE END) <> 'S' ";
				//					pstmtLoc1 = conn.prepareStatement( sql );
				//
				//					childList = parentList.item(0).getChildNodes();
				//					noOfChilds = childList.getLength();
				//					
				//					for ( int ctr = 0; ctr < noOfChilds; ctr++ ) //Loop for each node of current detail
				//					{	
				//						Node childNode = childList.item( ctr );
				//						if( childNode.getNodeType() != Node.ELEMENT_NODE )
				//						{
				//							continue;
				//						}
				//						String childNodeName = childNode.getNodeName();
				//						if ( childNode != null && childNode.getFirstChild() != null )
				//						{
				//							columnValue = checkNull(childNode.getFirstChild().getNodeValue());
				//						}
				//						System.out.println(" columnName [" + childNodeName + "] columnValue [" + columnValue + "]");
				//						if( "loc_code__to".equalsIgnoreCase( childNodeName ) )
				//						{								
				//							itemCode = checkNull(genericUtility.getColumnValue("item_code", allFormDataDom, "3" ));
				//							siteCode = checkNull(genericUtility.getColumnValue("site_code", allFormDataDom, "3" ));
				//							locCodeTo = checkNull(genericUtility.getColumnValue("loc_code__to", allFormDataDom, objContext ));
				//							lotNo = checkNull(genericUtility.getColumnValue("lot_no", allFormDataDom, "3" ));
				//							lpnNo = checkNull(genericUtility.getColumnValue("lot_sl", allFormDataDom, "3" ));
				//							pickOrder =  checkNull(genericUtility.getColumnValue("pick_order", allFormDataDom, "3" ));
				//							docLocCode = checkNull(genericUtility.getColumnValue("loc_code__sys", allFormDataDom, objContext ));
				//							sql = "SELECT SINGLE_LOT_SL, ITEM_LOT_OPT FROM LOCATION WHERE LOC_CODE = ?";
				//							pstmtLoc = conn.prepareStatement( sql );
				//							pstmtLoc.setString( 1, locCodeTo );
				//							rs = pstmtLoc.executeQuery();
				//							if( rs.next() )
				//							{
				//								singleLotSl = checkNull(rs.getString("SINGLE_LOT_SL"));
				//								itemLotOpt = checkNull(rs.getString("ITEM_LOT_OPT"));
				//							}
				//							else
				//							{
				//								// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
				//								//errString = getErrorString( "loc_code__to", "INVLOCCODE", userId );
				//								//break;
				//								errList.add( "INVLOCCODE" );
				//								errFields.add( childNodeName.toLowerCase() );
				//								// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
				//							}
				//							pstmtLoc.clearParameters();
				//							rs.close(); rs = null;
				//
				//							pickType = checkNull(genericUtility.getColumnValue("pick_type", allFormDataDom, "2" ));
				//							String varName = "";
				//							if ( "A".equalsIgnoreCase(pickType.trim()) )//Active pick
				//							{
				//								varName = "ACTIVE_PICK_INVSTAT";
				//							}
				//							else if ( "C".equalsIgnoreCase(pickType.trim()) || "M".equalsIgnoreCase(pickType.trim()) )//Case pick
				//							{
				//								varName = "CASE_PICK_INVSTAT";
				//							}
				//							DistCommon distComm = new DistCommon();
				//
				//							String disparmVal = distComm.getDisparams( "999999", varName, conn );
				//							System.out.println(" disparmVal =[" + disparmVal + "]");
				//							
				//							count = 0;
				//
				//							
				//							/*sql="select t.loc_code__dock from transporter t, despatch d "
				//								+ " where t.tran_code = d.tran_code "
				//								+ " and d.desp_id in ( "
				//								+ " select wt.ref_id from wave_task_det wt where wt.ref_ser = 'S-DSP' and wt.ptcn in (select i.ptcn from wave_task_det i "
				//								+ " where i.ref_id = ? ) )  ";
				//							pstmt = conn.prepareStatement( sql );
				//							pstmt.setString( 1, pickOrder );
				//							rs = pstmt.executeQuery();
				//							if ( rs.next() )
				//							{
				//								docLocCode = rs.getString(1);
				//							}
				//							rs.close();
				//							rs = null;
				//							pstmt.close();
				//							pstmt = null;
				//							System.out.println(" locCodeTo [" + locCodeTo + "] docLocCode [" + docLocCode + "]");
				//							//if ( count == 0 )
				//							if (!docLocCode.trim().equals(locCodeTo.trim()))
				//							{
				//								// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
				//								//errString = getErrorString( "loc_code__to", "VTLOCCODE5", userId );
				//								//break;
				//								errList.add( "VTLOCCODE5" );
				//								errFields.add( childNodeName.toLowerCase() );
				//								// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
				//							}*/
				//							if( singleLotSl.trim().equalsIgnoreCase("Y") )
				//							{
				//								sql = "SELECT QUANTITY FROM STOCK WHERE ITEM_CODE = ? AND SITE_CODE = ? AND LOC_CODE = ? AND lOT_NO = ? AND LOT_SL = ?";
				//								pstmtStock = conn.prepareStatement( sql );
				//								pstmtStock.setString( 1, itemCode );
				//								pstmtStock.setString( 2, siteCode );
				//								pstmtStock.setString( 3, locCodeTo );
				//								pstmtStock.setString( 4, lotNo );
				//								pstmtStock.setString( 5, lpnNo );
				//								rs = pstmtStock.executeQuery();	
				//								if( rs.next() )
				//								{
				//									quantity = rs.getDouble("QUANTITY");
				//								}
				//								pstmtStock.clearParameters();
				//								rs.close(); rs = null;
				//								
				//								if( quantity != 0 )
				//								{
				//									// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
				//									//errString = getErrorString( "loc_code__to", "VTLOCCODE1", userId );
				//									//break;
				//									errList.add( "VTLOCCODE1" );
				//									errFields.add( childNodeName.toLowerCase() );
				//									// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
				//								}
				//							}
				//							else
				//							{
				//								if( itemLotOpt.trim().equals("0") )  // Validation for single item_code and single lot_no
				//								{
				//									sql = "SELECT COUNT(*) AS COUNT FROM STOCK WHERE ITEM_CODE <> ? AND SITE_CODE = ? AND LOC_CODE = ? AND LOT_NO <> ?";
				//									pstmtStock1 = conn.prepareStatement( sql );
				//									pstmtStock1.setString( 1, itemCode );
				//									pstmtStock1.setString( 2, siteCode );
				//									pstmtStock1.setString( 3, locCodeTo );
				//									pstmtStock1.setString( 4, lotNo );
				//									rs = pstmtStock1.executeQuery();
				//									if( rs.next() )
				//									{
				//										count = rs.getInt("COUNT");
				//									}
				//									pstmtStock1.clearParameters();
				//									rs.close(); rs = null;
				//
				//									if( count > 0 )
				//									{
				//										// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
				//										//errString = getErrorString("loc_code__to", "VTLOCCODE2", userId );
				//										//break;
				//										errList.add( "VTLOCCODE2" );
				//										errFields.add( childNodeName.toLowerCase() );
				//										// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
				//									}
				//								}
				//								else if( itemLotOpt.trim().equals("1") )  //Validation for single item_code and multiple lot_no
				//								{
				//									sql = "SELECT COUNT(*) AS COUNT FROM STOCK WHERE  ITEM_CODE <> ? AND SITE_CODE = ? AND LOC_CODE = ? AND LOT_NO = ? ";
				//									pstmtStock3 = conn.prepareStatement( sql );
				//
				//									pstmtStock3.setString( 1, itemCode );
				//									pstmtStock3.setString( 2, siteCode );
				//									pstmtStock3.setString( 3, locCodeTo );
				//									pstmtStock3.setString( 4, lotNo );
				//									rs = pstmtStock3.executeQuery();
				//									if( rs.next() )
				//									{
				//										count = rs.getInt("COUNT");
				//									}
				//									pstmtStock3.clearParameters();
				//									rs.close(); rs = null;
				//
				//									if( count > 0 )
				//									{
				//										// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
				//										//errString = getErrorString("loc_code__to", "VTLOCCODE4", userId );
				//										//break;
				//										errList.add( "VTLOCCODE4" );
				//										errFields.add( childNodeName.toLowerCase() );
				//										// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
				//									}
				//								}//itemLotOpt = '1'
				//							}//singleLotSl != 'Y'
				//						}//loc_code__to case
				//						// added by cpatil for validate quantity on 10-Jun-12  end	
				//					}
				//				} //End of Case 4 Validation		
			}//End of switch statement
			int errListSize = errList.size();
			cnt =0;
			String errFldName = null;
			if ( errList != null && errListSize > 0 )
			{
				for (cnt = 0; cnt < errListSize; cnt++ )
				{
					errCode = (String)errList.get(cnt);
					errFldName = (String)errFields.get(cnt);
					System.out.println("errCode .........."+errCode);
					//String errMsg = hashMap.get(errCode)!=null ? hashMap.get(errCode).toString():"";
					//System.out.println("errMsg .........."+errMsg);
					errString = getErrorString( errFldName, errCode, userId );
					errorType =  errorType( conn , errCode );
					if ( errString.length() > 0)
					{
						String bifurErrString = errString.substring( errString.indexOf("<Errors>") + 8,errString.indexOf("<trace>"));
						bifurErrString =bifurErrString;//+"<trace>"+errMsg+"</trace>";
						bifurErrString =bifurErrString+errString.substring( errString.indexOf("</trace>") + 8,errString.indexOf("</Errors>"));
						errStringXml.append(bifurErrString);
						System.out.println("errStringXml .........."+errStringXml);
						errString = "";
					}
					if ( errorType.equalsIgnoreCase("E"))
					{
						break;
					}
				}
				errList.clear();
				errList = null;
				errFields.clear();
				errFields = null;

				errStringXml.append("</Errors></Root>\r\n");
			}
			else
			{
				errStringXml = new StringBuffer( "" );
			}
			errString = errStringXml.toString();
		}
		catch ( Exception e )
		{
			System.out.println ( "Exception: PickIssIC: wfValData( Document currFormDataDom ): " + e.getMessage() + ":" );
			//throw new ITMException(e);
			e.printStackTrace();
			errString = generateErrorString( genericUtility.createErrorString( e ) ) ;
		}
		finally
		{
			try
			{
				if (rs!=null)
				{
					rs.close();
					rs = null;
				}				
				if (pstmt!=null)
				{
					pstmt.close(); pstmt = null;
				}
				if (pstmtPickLotNo!=null)
				{
					pstmtPickLotNo.close(); pstmtPickLotNo = null;
				}
				if (pstmtPickLotSl!=null)
				{
					pstmtPickLotSl.close(); pstmtPickLotSl = null;
				}
				if (pstmtLoc!=null)
				{
					pstmtLoc.close(); pstmtLoc = null;
				}
				if (pstmtLoc1!=null)
				{
					pstmtLoc1.close(); pstmtLoc1 = null;
				}
				if (pstmtStock!=null)
				{
					pstmtStock.close(); pstmtStock = null;
				}
				if (pstmtStock1!=null)
				{
					pstmtStock1.close(); pstmtStock1 = null;
				}
				if (pstmtStock2!=null)
				{
					pstmtStock2.close(); pstmtStock2 = null;
				}
				if( pstmtStock3 != null  )
				{
					pstmtStock3.close(); pstmtStock3 = null;
				}
				if( conn != null  )
				{
					conn.close(); conn = null;
				}
			}
			catch(Exception e)
			{
				System.out.println( "Exception : PickIssIC:wfValData : " + e.getMessage() );
				throw new ITMException(e);
			}
		}
		System.out.println( "errString>>>>>>>::"+errString );
		return errString;
	}
	private String errorType( Connection conn , String errorCode )
	{
		String msgType = "";
		PreparedStatement pstmt = null ; 
		ResultSet rs = null;
		try
		{			
			String  sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO =   ? ";

			pstmt = conn.prepareStatement( sql );			
			pstmt.setString(1, errorCode);			
			rs = pstmt.executeQuery();
			while( rs.next() )
			{
				msgType = rs.getString("MSG_TYPE");
			}			
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}		
		finally
		{
			try
			{
				if ( rs != null )
				{
					rs.close();
					rs = null;
				}
				if ( pstmt != null )
				{
					pstmt.close();
					pstmt = null;
				}
			}
			catch ( Exception e )
			{
				e.printStackTrace();
			}
		}		
		return msgType;
	}


	/**
	 * The public method is defined without any parameters and returns blank string
	 */
	@Override
	public String itemChanged() throws RemoteException, ITMException
	{
		return "";
	}

	/**
	 * The public method is used for converting the current form data into a document(dom)
	 * The dom is then given as argument to the overloaded function wfValData to perform validation
	 * Returns validation string if exists else returns null in XML format
	 * @param xmlString contains the current form data in XML format
	 * @param xmlString1 contains all the header information in the XML format
	 * @param xmlString2 contains the data of all the forms in XML format
	 * @param objContext represents the form number
	 * @param editFlag represents the mode of transaction(A-Add or E-Edit)
	 * @param xtraParams contains additional information such as loginEmpCode,loginCode,chgTerm etc
	 */
	@Override
	public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
	{
		Document currFormDataDom = null;
		Document hdrDataDom = null;
		Document allFormDataDom = null;
		String errString = null;
		GenericUtility genericUtility = GenericUtility.getInstance();
		System.out.println("xmlString ["+xmlString+"]");
		System.out.println("xmlString1 ["+xmlString1+"]");
		System.out.println("xmlString2 ["+xmlString2+"]");
		try
		{
			if (xmlString != null && xmlString.trim().length()!=0)
			{
				currFormDataDom = genericUtility.parseString(xmlString); 
			}
			if (xmlString1 != null && xmlString1.trim().length()!=0)
			{
				hdrDataDom = genericUtility.parseString(xmlString1); 
			}
			if (xmlString2 != null && xmlString2.trim().length()!=0)
			{
				allFormDataDom = genericUtility.parseString(xmlString2); 
			}
			System.out.println ( "Calling  itemChanged( currFormDataDom, hdrDataDom, allFormDataDom, objContext, currentColumn, editFlag, xtraParams )");
			errString = itemChanged( currFormDataDom, hdrDataDom, allFormDataDom, objContext, currentColumn, editFlag, xtraParams );
			System.out.println ( "ErrString :" + errString);
		}
		catch (Exception e)
		{
			System.out.println ( "Exception :PickIssIC :itemChanged(String,String):" + e.getMessage() + ":" );
			throw new ITMException(e);
		}
		System.out.println ( "returning from PickIssIC itemChanged \n[" + errString + "]" );

		return errString;
	}

	/**
	 * The public overloaded method takes a document as input and is used for the validation of required fields 
	 * Returns validation string if exist otherwise returns null in XML format
	 * @param currFormDataDom contains the current form data as a document object model
	 * @param hdrDataDom contains all the header information
	 * @param allFormDataDom contains the field data of all the forms 
	 * @param objContext represents form number
	 * @param currentColumn represents the current field 
	 * @param editFlag represents the mode of transaction(A-Add or E-Edit)
	 * @param xtraParams contains additional information
	 */
	@Override
	public String itemChanged( Document currFormDataDom, Document hdrDataDom, Document allFormDataDom, String objContext, String currentColumn,String editFlag, String xtraParams ) throws RemoteException,ITMException
	{		
		String retString = "";		
		String siteCode = "";
		String itemCode = "";
		String locCode = "";
		String lotNo = "";
		String lpnNo = "";
		String pickOrder = "";
		String siteDescr = "";
		String tranID = "";
		String tranDate = "";
		String sql = "";
		String locCodeTo = "";
		String itemDescr = "";
		String unit = "";
		String pickType = "";
		String palletNo = "";
		String pickLocInvstat = "";
		String cartonNo = "";
		String pickLocCode = "";
		String stockSql = "",docLocCode = "";
		String userId = "";
		String actCartonNo = "";
		String actPackCode = "";
		//changed by sankara on 22/09/14 for site transporter
		String siteCodeShip = "";
		int currentFormNo = 0;
		int lineNoOrd = 0;
		int lineNoIss = 0;
		int domID = 0;
		int locListSize = 0;
		int count = 0;

		double quantity = 0;
		double noArt = 0;
		double qtyPerArt = 0;
		double shipperSize = 0.0; //changed by sumit on 13/03/13
		
		Connection conn = null;
		PreparedStatement pstmt = null;
		PreparedStatement pstmtOrd = null;
		PreparedStatement pstmtIss = null;
		PreparedStatement pstmtStock = null;

		ResultSet rs = null ;
		ResultSet rsOrd = null ;
		ResultSet rsIss = null ;
		ResultSet rsStock = null ;
		ArrayList pickLocList = null;
		//Changed by sumit on 13/03/13 initialize itmVolumeMap object
		HashMap itmVolumeMap = new HashMap();
		StringBuffer valueXmlString;

		System.out.println("xtraParams=["+xtraParams+"]");
		DistCommon distCommon = new DistCommon();

		GenericUtility genericUtility = GenericUtility.getInstance();
		genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );

		String objName = checkNullAndTrim(getObjNameFromDom( currFormDataDom, "objName", objContext ));

		valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<editFlag>").append( editFlag );

		try
		{
			DateFormat dtFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());

			String dbDateFormat = genericUtility.getDBDateFormat();
			String applDateFormat = genericUtility.getApplDateFormat();

			ConnDriver connDriver = new ConnDriver();
			conn = connDriver.getConnectDB( "DriverITM" );	
			connDriver = null;

			if( objContext != null && objContext.trim().length() > 0 )
			{
				currentFormNo = Integer.parseInt( objContext );
			}
			System.out.println("current form no["+currentFormNo+"]");
			valueXmlString.append("</editFlag>\r\n</Header>\r\n");
			switch ( currentFormNo )  
			{
			case 1:
			{
				valueXmlString.append( "<Detail1 domID='1'>\r\n" );

				if( currentColumn.trim().equalsIgnoreCase( "itm_default" ) )
				{
					//valueXmlString.append( "<trans_mode><![CDATA[" ).append( "E" ).append( "]]></trans_mode>\r\n" );
				}
				valueXmlString.append("</Detail1>\r\n");
			} //Case 1. End
			break;
			case 2:
			{
				System.out.println("inside case 2 itemchange");
				//valueXmlString.append( "<Detail2 domID='1'>\r\n" );

				if( currentColumn.trim().equalsIgnoreCase( "itm_default" ) )
				{
					pickOrder = genericUtility.getColumnValue( "pick_order", hdrDataDom );

					java.sql.Date tranDateDb = null;

					java.util.Date currDate = new java.util.Date();
					tranDate = dtFormat.format( currDate );

					String loginCode = checkNull(genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" ));
					String chgTerm = checkNull(genericUtility.getValueFromXTRA_PARAMS( xtraParams, "chgTerm" ));
					siteCode = checkNull(genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginSiteCode" ));
					palletNo = genericUtility.getColumnValue( "pallet_no", hdrDataDom );
					if ( siteCode.trim().length() == 0 || "INVALID_SITE".equalsIgnoreCase(siteCode.trim()) )
					{
						siteCode = getSiteCode( xtraParams, conn );
					}
					System.out.println("siteCode = ["+siteCode+"]");

					sql = "SELECT TRAN_ID, TRAN_DATE, PICK_ORDER, SITE_CODE, PICK_TYPE, PALLET_NO FROM PICK_ISS_HDR WHERE PICK_ORDER = ? AND PALLET_NO = ? AND CHG_USER = ? AND case when confirmed is null then 'N' else confirmed end = 'N'";
					pstmt = conn.prepareStatement( sql );
					pstmt.setString( 1, pickOrder );
					pstmt.setString( 2, palletNo );
					pstmt.setString( 3, loginCode );
					rs = pstmt.executeQuery();	
					if( rs.next() )
					{
						tranID = rs.getString("TRAN_ID");
						tranDateDb = rs.getDate("TRAN_DATE");
						siteCode = rs.getString("SITE_CODE");
						pickType = checkNull(rs.getString("PICK_TYPE"));
						palletNo = rs.getString("PALLET_NO");
						//valueXmlString.append( "<tran_id><![CDATA[" ).append( checkNull( tranID )).append( "]]></tran_id>\r\n" );
						valueXmlString.append("<Detail2 domID='1' selected=\"Y\">\r\n");
						valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"E\" status=\"O\" pkNames=\"\" />\r\n"); //added by Kunal on 14/08/12
						valueXmlString.append( "<tran_id><![CDATA[" ).append( checkNull( tranID )).append( "]]></tran_id>\r\n" );  //commented by Ashish Sonawane on 11-sep-12 for generating pick_issue for each time 
					}
					else
					{
						tranID = genericUtility.getColumnValue( "tran_id", currFormDataDom );
						palletNo = genericUtility.getColumnValue( "pallet_no", hdrDataDom );
						valueXmlString.append("<Detail2 domID='1' selected=\"N\">\r\n");
						valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n"); //added by Kunal on 14/08/12
						valueXmlString.append( "<tran_id><![CDATA[" ).append( checkNull( tranID )).append( "]]></tran_id>\r\n" );
					}
					rs.close();rs = null;
					pstmt.close();pstmt = null;
					/*	
					if ( tranID == null || tranID.trim().length() == 0 ) //commented by Ashish Sonawane on 11-sep-12
					{ */

						//

						sql = "SELECT SITE_CODE, PICK_TYPE FROM PICK_ORD_HDR WHERE PICK_ORDER = ?";
						pstmt = conn.prepareStatement( sql );
						pstmt.setString( 1, pickOrder );
						rs = pstmt.executeQuery();	
						if( rs.next() )
						{
							pickType = checkNull(rs.getString("PICK_TYPE"));
						}
						rs.close();rs = null;
						pstmt.close();pstmt = null;
					//}
					if ( tranDateDb != null )
					{
					//	tranDate = genericUtility.getValidDateString( tranDateDb.toString() , dbDateFormat, applDateFormat ); //commented by Ashish Sonawane on 11-sep-12 
					}
					valueXmlString.append( "<tran_date protect ='1'><![CDATA[" ).append( checkNull( tranDate )).append( "]]></tran_date>\r\n" );
					valueXmlString.append( "<pick_type protect ='1'><![CDATA[" ).append( checkNull( pickType )).append( "]]></pick_type>\r\n" );
					valueXmlString.append( "<pallet_no><![CDATA[" ).append( checkNull( palletNo )).append( "]]></pallet_no>\r\n" );
					valueXmlString.append( "<pick_order><![CDATA[" ).append( checkNull( pickOrder )).append( "]]></pick_order>\r\n" );
					valueXmlString.append( "<site_code><![CDATA[" ).append( checkNull( siteCode )).append( "]]></site_code>\r\n" );

					sql = "SELECT DESCR FROM SITE WHERE SITE_CODE = ?";
					pstmt = conn.prepareStatement( sql );
					pstmt.setString( 1, siteCode );						
					rs = pstmt.executeQuery();	
					if( rs.next() )
					{
						siteDescr = rs.getString("DESCR");
					}
					rs.close();rs = null;
					pstmt.close();pstmt = null;

					valueXmlString.append( "<site_descr><![CDATA[").append( checkNull( siteDescr )).append( "]]></site_descr>\r\n" );
					valueXmlString.append( "<confirmed><![CDATA[").append("N").append( "]]></confirmed>\r\n" );
					valueXmlString.append( "<chg_user><![CDATA[").append( loginCode ).append( "]]></chg_user>\r\n" );
					valueXmlString.append( "<chg_date><![CDATA[").append( tranDate ).append( "]]></chg_date>\r\n" );
					valueXmlString.append( "<chg_term><![CDATA[").append( chgTerm ).append( "]]></chg_term>\r\n" );
				}
				valueXmlString.append("</Detail2>\r\n");
			} //Case 2. End
			break;
			case 3://Case 3. Start
			{
				if( currentColumn.trim().equalsIgnoreCase( "itm_default" ) )
				{
					HashMap pickIssMap = new HashMap();
					double noArtPickIss = 0d;
					String lineNoPickIss = "";
					String caseLabel = "";
					String transMode = "";
					String varName = "";
					String locCodeSys = "";
					String intrLocInvstat = "";//Gulzar on 5/13/2012
					String CasePickOption=""; //cpatil on 15/06/2012

					pickOrder = checkNull(genericUtility.getColumnValue( "pick_order", hdrDataDom ));
					//transMode = checkNull(genericUtility.getColumnValue( "trans_mode", hdrDataDom ));
					tranID = checkNull(genericUtility.getColumnValue("tran_id", allFormDataDom, "2"));
					pickType = checkNull(genericUtility.getColumnValue("pick_type", allFormDataDom, "2"));
					palletNo = checkNull(genericUtility.getColumnValue("pallet_no", allFormDataDom, "2"));
					
					String quantity2 = checkNull(genericUtility.getColumnValue("quantity", allFormDataDom, "3"));
					System.out.println("@@@@@@@ quantity : "+quantity2);
					
					
					if(tranID != null && tranID.length() == 0)
					{
						sql = "SELECT TRAN_ID FROM PICK_ISS_HDR WHERE PICK_ORDER = ? AND PALLET_NO = ?" ;
						pstmt = conn.prepareStatement( sql );
						pstmt.setString( 1, pickOrder );
						pstmt.setString( 2, palletNo );
						rs = pstmt.executeQuery();
	
						if( rs.next() )
						{
							tranID = rs.getString("TRAN_ID");
							System.out.println("YES I GOT THE TRAN_ID ["+tranID+"]");
						}
						rs.close(); rs = null;
						pstmt.close(); pstmt = null;

					}				
					
					
					//changes made by deepak - 25/11/11
					pickLocList = new ArrayList();
					if ( "A".equalsIgnoreCase(pickType.trim()) )//Active pick
					{
						varName = "ACTIVE_PICK_INVSTAT";
					}
					else if ( "C".equalsIgnoreCase(pickType.trim()) || "M".equalsIgnoreCase(pickType.trim()) )//Case pick
					{
						varName = "CASE_PICK_INVSTAT";
					}
					pickLocInvstat = distCommon.getDisparams( "999999", varName, conn );

					//Changes made for INTR Locationby Gulzar on 5/13/2012
					intrLocInvstat = distCommon.getDisparams( "999999", "INTR_LOCATION", conn );


					CasePickOption = distCommon.getDisparams( "999999", "CASE_PICK_OPTION", conn );  //cpatil on 15/06/2012
					System.out.println("@@@@@@ CasePickOption:["+CasePickOption+"]");
					//Changes by gulzar on 12/28/2011
					String intrLocCode = "";
					//intrLocInvstat = distCommon.getDisparams( "999999", "DOCKLOC_INVSTAT", conn );
					//End changes by gulzar on 12/28/2011

					//Commented and changes below by gulzar on 12/23/2011
					/*
						sql = "SELECT A.LOC_CODE FROM STOCK A , INVSTAT B, LOCATION C "
								+ " WHERE A.LOC_CODE = C.LOC_CODE AND C.INV_STAT = B.INV_STAT AND B.AVAILABLE = 'Y' "
								+ " AND (CASE WHEN B.STAT_TYPE IS NULL THEN ' ' ELSE B.STAT_TYPE END) <> 'S' " 
								+ " AND A.QUANTITY = 0 AND C.INV_STAT = ?  ORDER BY LOC_CODE ";

					 */

					sql = "SELECT A.LOC_CODE AS LOC_CODE FROM LOCATION A, INVSTAT B "
							+ " WHERE A.INV_STAT = B.INV_STAT AND B.AVAILABLE = 'Y' "
							+ " AND (CASE WHEN B.STAT_TYPE IS NULL THEN ' ' ELSE B.STAT_TYPE END) <> 'S' "
							+ " AND A.INV_STAT = ? ORDER BY LOC_CODE ";
					//
					//pstmt =  conn.prepareStatement(sql);
					//pstmt.setString(1, intrLocInvstat);
					//rs = pstmt.executeQuery();
					//if ( rs.next() )
					//{
					//	intrLocCode = checkNull(rs.getString("LOC_CODE") );
					//}
					//pstmt.clearParameters();
					//rs.close(); rs = null;
					//pstmt.close(); pstmt = null;

					double stockQty = 0d;
					//stockSql = "SELECT SUM(CASE WHEN QUANTITY IS NULL THEN 0 ELSE QUANTITY END) AS STOCK_QTY "
					//		+  " FROM STOCK WHERE LOC_CODE = ? ";

					//pstmtStock =  conn.prepareStatement(stockSql);

					//pstmt =  conn.prepareStatement(sql);
					//pstmt.setString(1, pickLocInvstat);//Commented  added by gulzar on 12/28/2011
					//pstmt.setString(1, intrLocInvstat);//Changes added by gulzar on 12/28/2011
					//rs = pstmt.executeQuery();
					//while (rs.next())
					//{
					//	pickLocCode = checkNull(rs.getString("LOC_CODE") );
					//
					//	pstmtStock.setString( 1, pickLocCode );
					//	rsStock = pstmtStock.executeQuery();
					//	if ( rsStock.next() )
					//	{
					//		stockQty = rsStock.getDouble("STOCK_QTY");/
					//
					//		if ( stockQty == 0 )
					//		{
					//			pickLocList.add(pickLocCode);
					//		}
					//	}
					//	else
					//	{
					//		pickLocList.add(pickLocCode);
					//	}
					//	pstmtStock.clearParameters();
					//	rsStock.close(); rsStock = null;
					//}
					//rs.close(); rs = null;						
					//pstmt.close(); pstmt = null;
					//pstmtStock.close(); pstmtStock = null;

					//End changes by gulzar on 12/23/2011

					System.out.println("pickLocList...>>>> "+pickLocList);
					locListSize = pickLocList.size();
					System.out.println("locListSize...>>>> "+locListSize);
					//End changes by deepak - 25/11/11

					if ( tranID.trim().length() > 0 )
					{
						sql = "SELECT PICK_ORDER, LINE_NO__ORD, SUM( CASE WHEN NO_ART IS NULL THEN 0 ELSE NO_ART END ) NO_ART  "//loc_code__to " +
								+" FROM PICK_ISS_DET WHERE TRAN_ID = ? GROUP BY PICK_ORDER, LINE_NO__ORD " ;
						pstmt = conn.prepareStatement( sql );
						pstmt.setString( 1, tranID );
						rs = pstmt.executeQuery();

						while ( rs.next() )
						{
							lineNoPickIss = rs.getString("LINE_NO__ORD");
							noArtPickIss = rs.getDouble("NO_ART");
							pickIssMap.put( lineNoPickIss, noArtPickIss );
							//locCodeTo = rs.getString("LOC_CODE__TO");
						}
						rs.close(); rs = null;
						pstmt.close(); pstmt = null;
						System.out.println("pickIssMap = ::"+pickIssMap);
						
					sql = "SELECT MAX(LINE_NO)  FROM PICK_ISS_DET WHERE TRAN_ID = ?";
					
					pstmt = conn.prepareStatement( sql );
					pstmt.setString( 1, tranID );
					rs = pstmt.executeQuery();

					if ( rs.next() )
					{
						domID = rs.getInt(1);
						//locCodeTo = rs.getString("LOC_CODE__TO");
					}
					rs.close(); rs = null;
					pstmt.close(); pstmt = null;
					}
					
					


					////  added by cpatil for loaction on 12-Jun-12 start
					//sql="select t.loc_code__dock from transporter t, despatch d "
					//	+ " where t.tran_code = d.tran_code "
					//	+ " and d.desp_id in ( "
					//	+ " select wt.ref_id from wave_task_det wt where wt.ref_ser = 'S-DSP' and wt.ptcn in (select i.ptcn from wave_task_det i "
					//	+ " where i.ref_id = ? ) )  ";
					//pstmt = conn.prepareStatement( sql );
					//pstmt.setString( 1, pickOrder );
					//rs = pstmt.executeQuery();
					//while ( rs.next() )
					//{
					//	locCodeTo = rs.getString(1);
					//}
					//rs.close();
					//rs = null;
					//pstmt.close();
					//pstmt = null;
					System.out.println("@@@@@@@@ locCodeTo : (loc_code_dock) = ::"+locCodeTo);						
					//    added by cpatil for loaction on 12-Jun-12 end


					sql = "SELECT QTY_PER_ART FROM STOCK WHERE ITEM_CODE = ? AND SITE_CODE = ? AND LOC_CODE = ? AND LOT_NO = ? AND LOT_SL = ? ";
					pstmtStock = conn.prepareStatement( sql );

					//Changed by sumit on 09/03/13 getting quantity , quantity-dealloc_qty
					//sql = "SELECT LINE_NO, PICK_ORDER, LINE_NO__ORD,NO_ART, LOC_CODE, LOT_NO, LOT_SL, CASE_LABEL, LOC_CODE__TO, LOC_CODE__SYS, CARTON_NO, QUANTITY " +
					sql = " SELECT LINE_NO, PICK_ORDER, LINE_NO__ORD,NO_ART, LOC_CODE, LOT_NO, LOT_SL, CASE_LABEL, LOC_CODE__TO, LOC_CODE__SYS, CARTON_NO, (QUANTITY - (CASE WHEN DEALLOC_QTY IS NULL THEN 0 ELSE DEALLOC_QTY END )) AS QUANTITY,PACK_CODE "+
							" FROM PICK_ISS_DET WHERE TRAN_ID = ? AND PICK_ORDER = ? AND LINE_NO__ORD = ? "+
							" AND (QUANTITY - (CASE WHEN DEALLOC_QTY IS NULL THEN 0 ELSE DEALLOC_QTY END )) > 0 "+
							" ORDER BY TRAN_ID, LINE_NO ";
					pstmtIss = conn.prepareStatement( sql );

					sql = "SELECT PODET.PICK_ORDER,PODET.LINE_NO,PODET.ITEM_CODE,PODET.SITE_CODE,PODET.LOC_CODE, " +
							//Changed by sumit on 09/03/13 getting quantity , quantity-dealloc_qty
							//"PODET.LOT_NO, PODET.LOT_SL, PODET.NO_ART, PODET.QUANTITY, ITEM.DESCR ITEM_DESCR, ITEM.UNIT UNIT, LOC_CODE__TO "+              //,PODET.LOC_CODE__TO 
							"PODET.LOT_NO, PODET.LOT_SL, PODET.NO_ART, (PODET.QUANTITY - (CASE WHEN PODET.DEALLOC_QTY IS NULL THEN 0 ELSE PODET.DEALLOC_QTY END )) AS QUANTITY ,PODET.CARTON_NO,PODET.PACK_CODE, ITEM.DESCR ITEM_DESCR, ITEM.UNIT UNIT, LOC_CODE__TO "+              //,PODET.LOC_CODE__TO
							"FROM PICK_ORD_DET PODET, ITEM ITEM WHERE PODET.PICK_ORDER = ? AND PODET.ITEM_CODE = ITEM.ITEM_CODE " +
							"AND (PODET.QUANTITY - (CASE WHEN PODET.DEALLOC_QTY IS NULL THEN 0 ELSE PODET.DEALLOC_QTY END )) > 0 "+
							//Changed by Rohan on 12-07-13 for sortion data of active picking as order by carton no and loc code
							//"ORDER BY PODET.LOC_CODE ";
							"ORDER BY PODET.CARTON_NO,PODET.LOC_CODE ";
					pstmtOrd = conn.prepareStatement( sql );
					pstmtOrd.setString( 1, pickOrder );
					rsOrd = pstmtOrd.executeQuery();

					int noArtCnt = 0;
					double pendNoArt = 0d;
					double perCaseQty = 0d;
					double issQty = 0d;//Gulzar on 12/26/2011
					int noOfArt = 0;
					String lineOrdStr = "";

					count = 0; //change added by deepak - 25/11/11
					ArrayList issDetSelList = new ArrayList();//Gulzar on 12/14/2011
					String keyStr = "";

					while ( rsOrd.next() )
					{
						pendNoArt = 0d;
						noArtPickIss = 0d;
						lineNoOrd = rsOrd.getInt("LINE_NO");
						itemCode = checkNullAndTrim(rsOrd.getString("ITEM_CODE"));
						itemDescr = checkNull(rsOrd.getString("ITEM_DESCR"));
						siteCode = checkNullAndTrim(rsOrd.getString("SITE_CODE"));
						quantity = rsOrd.getDouble("QUANTITY");  // commented by cpatil
						unit = rsOrd.getString("UNIT");
						noArt = rsOrd.getDouble("NO_ART");  // commented by cpatil
						//Changed by sumit on 27/09/12 getting SHIPPER_SIZE and calculating no_art start
						String tempLot = rsOrd.getString("LOT_NO");
						itmVolumeMap.clear();
						itmVolumeMap = getItemVoumeMap(itemCode,tempLot,conn);
						shipperSize = (Double) itmVolumeMap.get("SHIPPER_SIZE");
						noArt = quantity / shipperSize;
						//Changed by sumit on 27/09/12 getting SHIPPER_SIZE and calculating no_art end
						locCodeTo = rsOrd.getString("LOC_CODE__TO");
						actCartonNo = rsOrd.getString("CARTON_NO");
						actPackCode = rsOrd.getString("PACK_CODE");
						qtyPerArt = Math.floor(quantity / noArt);

						//noArtCnt = (int)noArt;
						lineOrdStr = ""+lineNoOrd;

						if ( pickIssMap.get(lineOrdStr) != null )
						{
							noArtPickIss = ((Double)pickIssMap.get(lineOrdStr)).doubleValue();
							System.out.println("noArtPickIss = ["+noArtPickIss+"]");
						}

						pendNoArt = (noArt - noArtPickIss);
						System.out.println("pendNoArt = ["+pendNoArt+"]");

						//if ( tranID.trim().length() > 0 && transMode.trim().equalsIgnoreCase("E") )
						if ( tranID.trim().length() > 0 )
						{
							pstmtIss.setString( 1, tranID );
							pstmtIss.setString( 2, pickOrder );
							pstmtIss.setInt( 3, lineNoOrd );
							rsIss = pstmtIss.executeQuery();
							while ( rsIss.next() )
							{
								//domID++;//Gulzar on  12/13/2011
								lotNo = checkNullAndTrim(rsIss.getString("LOT_NO"));
								lpnNo = checkNullAndTrim(rsIss.getString("LOT_SL"));
								locCode = checkNullAndTrim(rsIss.getString("LOC_CODE"));
								caseLabel = checkNull(rsIss.getString("CASE_LABEL"));
								locCodeTo = checkNullAndTrim(rsIss.getString("LOC_CODE__TO"));
								locCodeSys = checkNull(rsIss.getString("LOC_CODE__SYS"));//changes added by deepak - 25/11/11
								cartonNo = checkNull(rsIss.getString("CARTON_NO"));//changes added by gulzar for master picking - 25/11/11
								lineNoIss = rsIss.getInt("LINE_NO");//Gulzar on 12/13/2011
								issQty = rsIss.getDouble("QUANTITY");
								noOfArt = rsIss.getInt("NO_ART");
								//Changed by sumit on 27/09/12 getting SHIPPER_SIZE and calculating no_art start								
								itmVolumeMap.clear();
								itmVolumeMap = getItemVoumeMap(itemCode,lotNo,conn);
								shipperSize = (Double) itmVolumeMap.get("SHIPPER_SIZE");
								noOfArt = (int) (issQty / shipperSize);
								//Changed by sumit on 27/09/12 getting SHIPPER_SIZE and calculating no_art end
							
								 actPackCode = checkNull(rsIss.getString("PACK_CODE"));
								//domID = lineNoIss;
								//changes added by gulzar on 12/15/2011
								keyStr = domID + ":" + lineNoOrd + ":" + itemCode + ":" + siteCode + ":" + locCodeTo + ":" + lotNo + ":" + lpnNo ;
								issDetSelList.add(keyStr);
								//End changes by gulzar on 12/15/2011
								valueXmlString.append( "<Detail3 domID='"+ lineNoIss +"' objContext = '"+currentFormNo+"' objName='"+objName+"' selected=\"Y\">\r\n" );
								//valueXmlString.append( "<attribute selected=\"Y\"/>\r\n" );
								valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"E\" status=\"O\" pkNames=\"\" />\r\n"); //added by Kunal on 14/08/12

								//valueXmlString.append( "<Detail3 domID='"+ domID +"' objContext = '"+currentFormNo+"' objName='"+objName+"' selected=\"Y\">\r\n" );
								//valueXmlString.append( "<attribute selected=\"Y\"/>\r\n" );
								valueXmlString.append( "<tran_id><![CDATA[" ).append( tranID ).append( "]]></tran_id>\r\n" );
								valueXmlString.append( "<line_no><![CDATA[" ).append( lineNoIss ).append( "]]></line_no>\r\n" );
								valueXmlString.append( "<pick_order><![CDATA[" ).append( pickOrder ).append( "]]></pick_order>\r\n" );
								valueXmlString.append( "<line_no__ord><![CDATA[" ).append( lineNoOrd ).append( "]]></line_no__ord>\r\n" );
								valueXmlString.append( "<item_code><![CDATA[" ).append( itemCode ).append( "]]></item_code>\r\n" );
								valueXmlString.append( "<item_descr><![CDATA[" ).append( itemDescr ).append( "]]></item_descr>\r\n" );
								valueXmlString.append( "<site_code><![CDATA[" ).append( siteCode ).append( "]]></site_code>\r\n" );
								valueXmlString.append( "<loc_code><![CDATA[" ).append( locCode ).append( "]]></loc_code>\r\n" );
								valueXmlString.append( "<lot_no><![CDATA[" ).append( lotNo ).append( "]]></lot_no>\r\n" );
								valueXmlString.append( "<lot_sl><![CDATA[" ).append( lpnNo ).append( "]]></lot_sl>\r\n" );
								valueXmlString.append( "<quantity><![CDATA[" ).append( issQty).append( "]]></quantity>\r\n" );
								valueXmlString.append( "<unit><![CDATA[" ).append( unit).append( "]]></unit>\r\n" );
								//valueXmlString.append( "<no_art><![CDATA[" ).append( "1" ).append( "]]></no_art>\r\n" );
								//Changed by sumit on 14/03/13 setting no_art 1 for pick_type 'A' start
								//valueXmlString.append( "<no_art><![CDATA[" ).append( noOfArt).append( "]]></no_art>\r\n" );
								if( "A".equalsIgnoreCase(pickType))
								{
									valueXmlString.append( "<no_art><![CDATA[" ).append( "1" ).append( "]]></no_art>\r\n" );
								}
								else
								{
									valueXmlString.append( "<no_art><![CDATA[" ).append( noOfArt).append( "]]></no_art>\r\n" );
								}
								//valueXmlString.append( "<loc_code__sys><![CDATA[" ).append( locCodeTo ).append( "]]></loc_code__sys>\r\n" );//change added by deepak - 25/11/11
								valueXmlString.append( "<case_label><![CDATA[" ).append( caseLabel ).append( "]]></case_label>\r\n" );
								valueXmlString.append( "<loc_code__sys><![CDATA[" ).append( locCodeTo ).append( "]]></loc_code__sys>\r\n" );
								valueXmlString.append( "<loc_code__to><![CDATA[" ).append( locCodeTo ).append( "]]></loc_code__to>\r\n" );
								//changes done by cpandey on 07/08/12
								valueXmlString.append( "<user_id><![CDATA[" ).append(userId).append( "]]></user_id>\r\n" );
								//end of changes cpandey on 07/08/12
								if ( "M".equalsIgnoreCase(pickType.trim()) )
								{
									valueXmlString.append( "<carton_no><![CDATA[" ).append( cartonNo ).append( "]]></carton_no>\r\n" );
								}
								if ("A".equalsIgnoreCase(pickType.trim()))
								{
									valueXmlString.append("<carton_no><![CDATA[").append(cartonNo).append("]]></carton_no>\r\n");
									valueXmlString.append("<pack_code><![CDATA[").append(actPackCode).append("]]></pack_code>\r\n");
								}
								valueXmlString.append("</Detail3>\r\n");

								lotNo = ""; lpnNo = ""; locCode = ""; locCodeTo = ""; locCodeSys = ""; cartonNo = ""; issQty = 0d;
							}
							rsIss.close(); rsIss = null;
						}
					}
					rsOrd.close(); rsOrd = null;
					pstmtOrd.close(); pstmtOrd = null;
					pstmtIss.close(); pstmtIss = null;

					//Changed by Rohan on 12-07-13 for sortion data of active picking as order by carton no and loc code.start
					/*
					sql = "SELECT PODET.PICK_ORDER,PODET.LINE_NO,PODET.ITEM_CODE,PODET.SITE_CODE,PODET.LOC_CODE,"+
							//Changed by sumit on 09/03/13 getting quantity , quantity-dealloc_qty
							//" PODET.LOT_NO, PODET.LOT_SL, PODET.NO_ART, PODET.QUANTITY, ITEM.DESCR ITEM_DESCR, ITEM.UNIT UNIT, LOC_CODE__TO "+ 
							" PODET.LOT_NO, PODET.LOT_SL, PODET.NO_ART, (PODET.QUANTITY - (CASE WHEN PODET.DEALLOC_QTY IS NULL THEN 0 ELSE PODET.DEALLOC_QTY END )) AS QUANTITY ,PODET.CARTON_NO,PODET.PACK_CODE , ITEM.DESCR ITEM_DESCR, ITEM.UNIT UNIT, LOC_CODE__TO "+
							" FROM PICK_ORD_DET PODET, ITEM ITEM WHERE PODET.PICK_ORDER = ? AND PODET.ITEM_CODE = ITEM.ITEM_CODE "+
							" AND PODET.LINE_NO NOT IN (SELECT PICK_ISS_DET.LINE_NO__ORD FROM PICK_ISS_DET WHERE PICK_ISS_DET.PICK_ORDER =  ? ) "+
							" AND (PODET.QUANTITY - (CASE WHEN PODET.DEALLOC_QTY IS NULL THEN 0 ELSE PODET.DEALLOC_QTY END )) > 0 "+
							" ORDER BY PODET.LOC_CODE ";
					*/
					
					if ( "A".equalsIgnoreCase(pickType.trim()) )
					{
						sql = "SELECT PODET.PICK_ORDER,PODET.LINE_NO,PODET.ITEM_CODE,PODET.SITE_CODE,PODET.LOC_CODE,"+
								" PODET.LOT_NO, PODET.LOT_SL, PODET.NO_ART, (PODET.QUANTITY - (CASE WHEN PODET.DEALLOC_QTY IS NULL THEN 0 ELSE PODET.DEALLOC_QTY END )) AS QUANTITY ,PODET.CARTON_NO,PODET.PACK_CODE , ITEM.DESCR ITEM_DESCR, ITEM.UNIT UNIT, LOC_CODE__TO "+
								" FROM PICK_ORD_DET PODET, ITEM ITEM WHERE PODET.PICK_ORDER = ? AND PODET.ITEM_CODE = ITEM.ITEM_CODE "+
								" AND PODET.LINE_NO NOT IN (SELECT PICK_ISS_DET.LINE_NO__ORD FROM PICK_ISS_DET WHERE PICK_ISS_DET.PICK_ORDER =  ? ) "+
								" AND (PODET.QUANTITY - (CASE WHEN PODET.DEALLOC_QTY IS NULL THEN 0 ELSE PODET.DEALLOC_QTY END )) > 0 "+
								" ORDER BY PODET.CARTON_NO,PODET.LOC_CODE ";
					}
					else
					{
						sql = "SELECT PODET.PICK_ORDER,PODET.LINE_NO,PODET.ITEM_CODE,PODET.SITE_CODE,PODET.LOC_CODE,"+
								//Changed by sumit on 09/03/13 getting quantity , quantity-dealloc_qty
								//" PODET.LOT_NO, PODET.LOT_SL, PODET.NO_ART, PODET.QUANTITY, ITEM.DESCR ITEM_DESCR, ITEM.UNIT UNIT, LOC_CODE__TO "+ 
								" PODET.LOT_NO, PODET.LOT_SL, PODET.NO_ART, (PODET.QUANTITY - (CASE WHEN PODET.DEALLOC_QTY IS NULL THEN 0 ELSE PODET.DEALLOC_QTY END )) AS QUANTITY ,PODET.CARTON_NO,PODET.PACK_CODE , ITEM.DESCR ITEM_DESCR, ITEM.UNIT UNIT, LOC_CODE__TO "+
								" FROM PICK_ORD_DET PODET, ITEM ITEM WHERE PODET.PICK_ORDER = ? AND PODET.ITEM_CODE = ITEM.ITEM_CODE "+
								" AND PODET.LINE_NO NOT IN (SELECT PICK_ISS_DET.LINE_NO__ORD FROM PICK_ISS_DET WHERE PICK_ISS_DET.PICK_ORDER =  ? ) "+
								" AND (PODET.QUANTITY - (CASE WHEN PODET.DEALLOC_QTY IS NULL THEN 0 ELSE PODET.DEALLOC_QTY END )) > 0 "+
								" ORDER BY PODET.LOC_CODE ";
					}
					//Changed by Rohan on 12-07-13 for sortion data of active picking as order by carton no and loc code.end
					pstmtOrd = conn.prepareStatement( sql );
					pstmtOrd.setString( 1, pickOrder );
					pstmtOrd.setString(2 , pickOrder );
					rsOrd = pstmtOrd.executeQuery();
					while ( rsOrd.next() )
					{
						pendNoArt = 0d;
						noArtPickIss = 0d;
						lineNoOrd = rsOrd.getInt("LINE_NO");
						itemCode = checkNullAndTrim(rsOrd.getString("ITEM_CODE"));
						itemDescr = checkNull(rsOrd.getString("ITEM_DESCR"));
						siteCode = checkNullAndTrim(rsOrd.getString("SITE_CODE"));
						quantity = rsOrd.getDouble("QUANTITY");  // commented by cpatil
						unit = rsOrd.getString("UNIT");
						noArt = rsOrd.getDouble("NO_ART");  // commented by cpatil
						//Changed by sumit on 27/09/12 getting SHIPPER_SIZE and calculating no_art start
						lotNo = checkNullAndTrim(rsOrd.getString("LOT_NO"));
						itmVolumeMap.clear();
						itmVolumeMap = getItemVoumeMap(itemCode,lotNo,conn);
						shipperSize = (Double) itmVolumeMap.get("SHIPPER_SIZE");
						noArt = quantity / shipperSize;
						//Changed by sumit on 27/09/12 getting SHIPPER_SIZE and calculating no_art end
						locCodeTo = rsOrd.getString("LOC_CODE__TO");
						actCartonNo = checkNull(rsOrd.getString("CARTON_NO"));
						actPackCode = checkNull(rsOrd.getString("PACK_CODE"));
						
						qtyPerArt = Math.floor(quantity / noArt);

						//noArtCnt = (int)noArt;
						lineOrdStr = ""+lineNoOrd;

						if ( pickIssMap.get(lineOrdStr) != null )
						{
							noArtPickIss = ((Double)pickIssMap.get(lineOrdStr)).doubleValue();
							System.out.println("noArtPickIss = ["+noArtPickIss+"]");
						}

						pendNoArt = (noArt - noArtPickIss);
						System.out.println("pendNoArt = ["+pendNoArt+"]");


						//	if ( ("C".equalsIgnoreCase(pickType.trim()) || "M".equalsIgnoreCase(pickType.trim()) ) && pendNoArt > 0 )//Spliting in case of "Case" pick        // commented by cpatil
						if ( "M".equalsIgnoreCase(CasePickOption.trim()))       // added by cpatil 15/jun/12 start
						{
							perCaseQty = ( quantity / noArt );
							//String selectedDomStr = getSelectedDom( allFormDataDom, keyStr, domID );
							// commented by cpatil
							for ( int i = 1; i <= pendNoArt; i++ )
							{
								domID++;
								locCode = checkNullAndTrim(rsOrd.getString("LOC_CODE"));
								lotNo = checkNullAndTrim(rsOrd.getString("LOT_NO"));
								lpnNo = checkNullAndTrim(rsOrd.getString("LOT_SL"));

								//changed by gulzar on 21/12/11
								if ( qtyPerArt == 0 )
								{
									pstmtStock.setString( 1, itemCode );
									pstmtStock.setString( 2, siteCode );
									pstmtStock.setString( 3, locCode );
									pstmtStock.setString( 4, lotNo );
									pstmtStock.setString( 5, lpnNo );
									rsStock = pstmtStock.executeQuery();
									if ( rsStock.next() )
									{
										qtyPerArt = rsStock.getDouble("QTY_PER_ART");
									}
									rsStock.close();rsStock = null;
									pstmtStock.clearParameters();
								}
								//End changes by gulzar on 21/12/11
								valueXmlString.append( "<Detail3 domID='"+ domID +"' objContext = '"+currentFormNo+"' objName='"+objName+"' selected=\"N\">\r\n" );
								valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n"); //added by Kunal on 14/08/12

								//valueXmlString.append( "<Detail3 domID='"+ domID +"' objContext = '"+currentFormNo+"' objName='"+objName+"' selected=\"N\">\r\n" );
								valueXmlString.append( "<tran_id><![CDATA[" ).append( tranID ).append( "]]></tran_id>\r\n" );
								valueXmlString.append( "<line_no><![CDATA[" ).append( domID ).append( "]]></line_no>\r\n" );
								valueXmlString.append( "<pick_order><![CDATA[" ).append( pickOrder ).append( "]]></pick_order>\r\n" );
								valueXmlString.append( "<line_no__ord><![CDATA[" ).append( lineNoOrd ).append( "]]></line_no__ord>\r\n" );
								valueXmlString.append( "<item_code><![CDATA[" ).append( itemCode ).append( "]]></item_code>\r\n" );
								valueXmlString.append( "<item_descr><![CDATA[" ).append( itemDescr ).append( "]]></item_descr>\r\n" );
								valueXmlString.append( "<site_code><![CDATA[" ).append( siteCode ).append( "]]></site_code>\r\n" );
								valueXmlString.append( "<loc_code><![CDATA[" ).append( locCode ).append( "]]></loc_code>\r\n" );
								valueXmlString.append( "<lot_no><![CDATA[" ).append( lotNo ).append( "]]></lot_no>\r\n" );
								valueXmlString.append( "<lot_sl><![CDATA[" ).append( lpnNo ).append( "]]></lot_sl>\r\n" );
								valueXmlString.append( "<quantity><![CDATA[" ).append( qtyPerArt ).append( "]]></quantity>\r\n" );
								valueXmlString.append( "<unit><![CDATA[" ).append( unit).append( "]]></unit>\r\n" );
								valueXmlString.append( "<no_art><![CDATA[" ).append( "1" ).append( "]]></no_art>\r\n" );
								//Changes added by deepak - 25/11/11
								///--Commented by Gulzar on 5/13/2012
								//if ( locListSize > 0 && count < locListSize)
								//{
								//	valueXmlString.append("<loc_code__sys><![CDATA[").append( pickLocList.get(count) ).append("]]></loc_code__sys>\r\n");
								//}
								//else
								////	{
								///		valueXmlString.append( "<loc_code__sys><![CDATA[" ).append( "" ).append( "]]></loc_code__sys>\r\n" );
								///		}
								///
								if ( "M".equalsIgnoreCase(pickType.trim()) )//for master picking
								{
									valueXmlString.append( "<carton_no><![CDATA[" ).append( "" ).append( "]]></carton_no>\r\n" );
								}
								//End changes made by deepak - 25/11/11
								if ("A".equalsIgnoreCase(pickType.trim()))
								{
									valueXmlString.append("<carton_no><![CDATA[").append(actCartonNo).append("]]></carton_no>\r\n");
									valueXmlString.append("<pack_code><![CDATA[").append(actPackCode).append("]]></pack_code>\r\n");
								}
								valueXmlString.append( "<case_label><![CDATA[" ).append( "" ).append( "]]></case_label>\r\n" );
								//valueXmlString.append( "<loc_code__to><![CDATA[" ).append( "" ).append( "]]></loc_code__to>\r\n" );//Gulzar on 5/13/2012
								valueXmlString.append( "<loc_code__sys><![CDATA[" ).append( locCodeTo ).append( "]]></loc_code__sys>\r\n" );
								valueXmlString.append( "<loc_code__to><![CDATA[" ).append( locCodeTo ).append( "]]></loc_code__to>\r\n" );
								valueXmlString.append("</Detail3>\r\n");
							}
							count++;//change added by deepak - 25/11/11

						}              // commented by cpatil
						else if ( "S".equalsIgnoreCase(CasePickOption.trim()) )     // added by cpatil
						{       // commented by cpatil   15/jun/12 END
							domID++;
							locCode = checkNullAndTrim(rsOrd.getString("LOC_CODE"));
							lotNo = checkNullAndTrim(rsOrd.getString("LOT_NO"));
							lpnNo = checkNullAndTrim(rsOrd.getString("LOT_SL"));
							valueXmlString.append( "<Detail3 domID='"+ domID +"' objContext = '"+currentFormNo+"' objName='"+objName+"' selected=\"N\">\r\n" );
							valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n"); //added by Kunal on 14/08/12

							//valueXmlString.append( "<Detail3 domID='"+ domID +"' objContext = '"+currentFormNo+"' objName='"+objName+"' selected=\"N\">\r\n" );
							valueXmlString.append( "<tran_id><![CDATA[" ).append( tranID ).append( "]]></tran_id>\r\n" );
							valueXmlString.append( "<line_no><![CDATA[" ).append( domID ).append( "]]></line_no>\r\n" );
							valueXmlString.append( "<pick_order><![CDATA[" ).append( pickOrder ).append( "]]></pick_order>\r\n" );
							valueXmlString.append( "<line_no__ord><![CDATA[" ).append( lineNoOrd ).append( "]]></line_no__ord>\r\n" );
							valueXmlString.append( "<item_code><![CDATA[" ).append( itemCode ).append( "]]></item_code>\r\n" );
							valueXmlString.append( "<item_descr><![CDATA[" ).append( itemDescr ).append( "]]></item_descr>\r\n" );
							valueXmlString.append( "<site_code><![CDATA[" ).append( siteCode ).append( "]]></site_code>\r\n" );
							valueXmlString.append( "<loc_code><![CDATA[" ).append( locCode ).append( "]]></loc_code>\r\n" );
							valueXmlString.append( "<lot_no><![CDATA[" ).append( lotNo ).append( "]]></lot_no>\r\n" );
							valueXmlString.append( "<lot_sl><![CDATA[" ).append( lpnNo ).append( "]]></lot_sl>\r\n" );
							valueXmlString.append( "<unit><![CDATA[" ).append( unit).append( "]]></unit>\r\n" );
							valueXmlString.append( "<loc_code__sys><![CDATA[" ).append( locCodeTo ).append( "]]></loc_code__sys>\r\n" );
							valueXmlString.append( "<loc_code__to><![CDATA[" ).append( locCodeTo ).append( "]]></loc_code__to>\r\n" );
							if (!"A".equalsIgnoreCase(pickType.trim()))
							{
								valueXmlString.append( "<quantity><![CDATA[" ).append( quantity).append( "]]></quantity>\r\n" );
								valueXmlString.append( "<no_art><![CDATA[" ).append( noArt ).append( "]]></no_art>\r\n" );	

							}
							else //if ("C".equalsIgnoreCase(pickType.trim()))
							{
								valueXmlString.append( "<no_art><![CDATA[1]]></no_art>\r\n" );	
								valueXmlString.append( "<quantity><![CDATA[" + quantity + "]]></quantity>\r\n" );
							}
							//Changes added by deepak - 25/11/11
							/*
								if ( locListSize > 0 )
								{
									valueXmlString.append("<loc_code__sys><![CDATA[").append( pickLocList.get(0) ).append("]]></loc_code__sys>\r\n");
								}
							 */
							//End changes made by deepak - 25/11/11
							if ("A".equalsIgnoreCase(pickType.trim()))
							{
								valueXmlString.append("<carton_no><![CDATA[").append(actCartonNo).append("]]></carton_no>\r\n");
								valueXmlString.append("<pack_code><![CDATA[").append(actPackCode).append("]]></pack_code>\r\n");
							}
							valueXmlString.append( "<case_label><![CDATA[" ).append( "" ).append( "]]></case_label>\r\n" );
							//valueXmlString.append( "<loc_code__to><![CDATA[" ).append( "" ).append( "]]></loc_code__to>\r\n" );//Gulzar on 5/13/2012
							//valueXmlString.append( "<loc_code__to protect = '1'><![CDATA[" ).append( intrLocCode ).append( "]]></loc_code__to>\r\n" );//Gulzar on 5/13/2012

							//valueXmlString.append( "<loc_code__to protect = '1'><![CDATA[" ).append( locCodeTo ).append( "]]></loc_code__to>\r\n" );
							valueXmlString.append("</Detail3>\r\n");
						}
						
						//pstmtIss.clearParameters();
					}
					//Changed By Pragyan.start AN
					System.out.println("UPDATING THE TRAN ID FOR DETAIL2 AS IT IS NOT PRESENT["+tranID+"]");
					valueXmlString.append("<Detail2>\r\n");
					valueXmlString.append( "<tran_id><![CDATA[" ).append( checkNull( tranID )).append( "]]></tran_id>\r\n" );
					valueXmlString.append("</Detail2>\r\n");
					//Changed By Pragyan.end
					rsOrd.close(); rsOrd = null;
					pstmtOrd.close(); pstmtOrd = null;
					//pstmtIss.close(); pstmtIss = null;
					if ( pstmtStock != null )
					{
						pstmtStock.close();
						pstmtStock = null;
					}
					///////////
					String updatedDetailDomStr = setSelectedToDom( allFormDataDom, valueXmlString.toString(), issDetSelList );

					valueXmlString = null;
					valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<editFlag>").append( editFlag );
					valueXmlString.append("</editFlag>\r\n</Header>\r\n");
					updatedDetailDomStr = updatedDetailDomStr.substring(updatedDetailDomStr.indexOf("<Root>") + "<Root>".length(), updatedDetailDomStr.indexOf("</Root>") );
					valueXmlString.append(updatedDetailDomStr);

					System.out.println("\n**************************\n");
					System.out.println("updatedDetailDomStr[1]:>>>>>>>>>>> "+updatedDetailDomStr);

					///////////
				}

			} //Case 3. End
			break;
			case 4:
			{
				//changes done by cpandey on 27/08/12
				pickType = checkNull(genericUtility.getColumnValue("pick_type", allFormDataDom, "2"));
				System.out.println(" pickType--:["+pickType+"]");
				//				pickOrder =  checkNull(genericUtility.getColumnValue("pick_order", allFormDataDom, "3" ));
				//				sql = "SELECT PICK_TYPE FROM PICK_ORD_HDR WHERE PICK_ORDER = ?";
				//				pstmt = conn.prepareStatement( sql );
				//				pstmt.setString( 1, pickOrder );
				//				rs = pstmt.executeQuery();	
				//				if( rs.next() )
				//				{
				//					pickType = checkNull(rs.getString("PICK_TYPE"));
				//				}
				//				rs.close();rs = null;
				//				pstmt.close();pstmt = null;
				if (!("A".equalsIgnoreCase(pickType.trim()) ))//Active pick
				{

					if( currentColumn.trim().equalsIgnoreCase( "itm_default" ) )
					{
						locCodeTo = checkNull(genericUtility.getColumnValue("loc_code__to", allFormDataDom, "3" ));
						pickOrder =  checkNull(genericUtility.getColumnValue("pick_order", allFormDataDom, "3" ));
						
						//changed by sankara on 22/09/14 for site transporter start.
						/*sql="select t.loc_code__dock from transporter t, despatch d "
								+ " where t.tran_code = d.tran_code "
								+ " and d.desp_id in ( "
								+ " select wt.ref_id from wave_task_det wt where wt.ref_ser = 'S-DSP' and wt.ptcn in (select i.ptcn from wave_task_det i "
								+ " where i.ref_id = ? ) )  ";
						pstmt = conn.prepareStatement( sql );
						pstmt.setString( 1, pickOrder );
						rs = pstmt.executeQuery();
						if ( rs.next() )
						{
							docLocCode = rs.getString(1);
						}
						rs.close();
						rs = null;
						pstmt.close();
						pstmt = null;*/

						sql = " select s.site_code__ship from sorder s, pick_ord_hdr p where p.sale_order = s.sale_order " +
								" and p.pick_order = ? ";
						pstmt = conn.prepareStatement( sql );
						pstmt.setString( 1, pickOrder );
						rs = pstmt.executeQuery();
						if ( rs.next() )
						{
							siteCodeShip = checkNull(rs.getString(1));
							System.out.println("siteCodeShip::::::"+siteCodeShip);
						}
						rs.close();rs = null;
						pstmt.close();pstmt = null;

						sql="select st.loc_code__dock from despatch d, site_transporter st "
								+ " where st.tran_code = d.tran_code "
								+ " and st.site_code = ? "
								+ " and d.desp_id in ( "
								+ " select wt.ref_id from wave_task_det wt where wt.ref_ser = 'S-DSP' and wt.ptcn in (select i.ptcn from wave_task_det i "
								+ " where i.ref_id = ? ) )  ";
						pstmt = conn.prepareStatement( sql );
						pstmt.setString( 1, siteCodeShip );
						pstmt.setString( 2, pickOrder );
						rs = pstmt.executeQuery();
						if ( rs.next() )
						{
							docLocCode = rs.getString(1);
							System.out.println("docLocCode::::::::"+docLocCode);
						}
						else
						{
							sql="select t.loc_code__dock from transporter t, despatch d "
									+ " where t.tran_code = d.tran_code "
									+ " and d.desp_id in ( "
									+ " select wt.ref_id from wave_task_det wt where wt.ref_ser = 'S-DSP' and wt.ptcn in (select i.ptcn from wave_task_det i "
									+ " where i.ref_id = ? ) )  ";
							pstmt = conn.prepareStatement( sql );
							pstmt.setString( 1, pickOrder );
							rs = pstmt.executeQuery();
							if ( rs.next() )
							{
								docLocCode = rs.getString(1);
							}
						}
						//changed by sankara on 22/09/14 for site transporter end.
						
						System.out.println(" locCodeTo [" + locCodeTo + "] docLocCode [" + docLocCode + "]");

						valueXmlString.append( "<Detail4 domID='"+ domID +"' objContext = '"+currentFormNo+"' objName='"+objName+"' selected=\"Y\">\r\n" );
						//valueXmlString.append( "<attribute selected=\"Y\"/>\r\n" );
						if("M".equalsIgnoreCase(pickType))
						{
						
							locCodeTo = distCommon.getDisparams( "999999", "STAGING_LOC_MPK", conn)==null?"":distCommon.getDisparams( "999999", "STAGING_LOC_MPK", conn);
						}
						else if("A".equalsIgnoreCase(pickType))
						{
						
							locCodeTo = distCommon.getDisparams( "999999", "STAGING_LOC", conn)==null?"":distCommon.getDisparams( "999999", "STAGING_LOC", conn);
						}
						
						valueXmlString.append( "<loc_code__sys><![CDATA[" ).append( locCodeTo ).append( "]]></loc_code__sys>\r\n" );
						valueXmlString.append( "<loc_code__to><![CDATA[]]></loc_code__to>\r\n" );
						valueXmlString.append("</Detail4>\r\n");

					}
				} //end of changes by cpandey 27/08/12				
			}//Case 4. End
			}//End of switch block
			valueXmlString.append( "</Root>\r\n" );	 // 28/08/12 manoharan taken from above end of case 4
		}
		catch (Exception e)
		{				
			e.printStackTrace();
			//throw new ITMException(e);//Gulzar on 09/12/11
			valueXmlString = valueXmlString.append( generateErrorString( genericUtility.createErrorString( e ) ) );
		}
		finally
		{	
			try
			{
				if ( rsOrd != null )
				{
					rsOrd.close();
					rsOrd = null;
				}
				if ( rsIss != null )
				{
					rsIss.close();
					rsIss = null;
				}
				if ( pstmtOrd != null )
				{
					pstmtOrd.close();
					pstmtOrd = null;
				}
				if ( pstmtIss != null )
				{
					pstmtIss.close();
					pstmtIss = null;
				}
				if ( conn != null )
				{
					conn.close();
					conn = null;
				}
			}
			catch (Exception e)
			{
				e.printStackTrace();
				throw new ITMException(e);
			}
		}
		System.out.println( "valueXmlString.toString()>>>>>>>::"+valueXmlString.toString());
		return valueXmlString.toString();
	}

	/**
	 * The function checks whether the input string is null. 
	 * If null, the function returns blank string.  
	 * @param input
	 */
	private String checkNull( String input )	
	{
		if ( input == null )
		{
			input = "";
		}
		return input;
	}
	/**
	 * The function checks whether the input string is null. 
	 * If null, the function returns blank string otherwise trim the input string and return.  
	 * @param input
	 */
	private String checkNullAndTrim( String inputVal )
	{
		if ( inputVal == null )
		{
			inputVal = "";
		}
		else
		{
			inputVal = inputVal.trim();
		}
		return inputVal;
	}
	private String getSiteCode( String xtraParams, Connection conn ) throws ITMException
	{
		String defaultSite = "";
		String empSite = "";
		String workSite = "";
		String sql = "";
		String loginCode = "";

		PreparedStatement pstmt = null;
		ResultSet rs = null;

		try
		{
			GenericUtility genericUtility = GenericUtility.getInstance();
			loginCode = checkNull(genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" ));

			sql = "SELECT USERS.EMP_CODE, USERS.ENTITY_CODE, USERS.SITE_CODE__DEF, EMP.EMP_SITE, EMP.WORK_SITE "+
					"FROM USERS USERS, EMPLOYEE EMP WHERE USERS.EMP_CODE = EMP.EMP_CODE AND USERS.CODE = ? ";
			pstmt = conn.prepareStatement( sql );
			pstmt.setString( 1, loginCode );						
			rs = pstmt.executeQuery();	
			if( rs.next() )
			{
				defaultSite = checkNull(rs.getString("SITE_CODE__DEF"));
				empSite = checkNull(rs.getString("EMP_SITE"));
				workSite = checkNull(rs.getString("WORK_SITE"));
			}
			if ( defaultSite.trim().length() == 0 && empSite.trim().length() > 0 )
			{
				defaultSite = empSite;
			}
			rs.close();rs = null;
			pstmt.close();pstmt = null;
		}
		catch (Exception e)
		{				
			e.printStackTrace();
			throw new ITMException(e);
		}
		finally
		{	
			try
			{
				if ( rs != null )
				{
					rs.close();
					rs = null;
				}
				if ( pstmt != null )
				{
					pstmt.close();
					pstmt = null;
				}
			}
			catch (Exception e)
			{
				e.printStackTrace();
				throw new ITMException(e);
			}
		}
		System.out.println("defaultSite = ["+defaultSite+"]");
		return defaultSite;
	}
	//Method written to get the obj_name from the dom - Gulzar - 28/11/11
	private String getObjNameFromDom( Document dom, String attribute, String objContext ) throws RemoteException,ITMException
	{
		NodeList detailList = null;
		Node currDetail = null,reqDetail = null;
		String objName = "";
		int	detailListLength = 0;

		try
		{
			detailList = dom.getElementsByTagName("Detail"+objContext);
			detailListLength = detailList.getLength();
			for (int ctr = 0; ctr < detailListLength; ctr++)
			{
				currDetail = detailList.item(ctr);
				objName = currDetail.getAttributes().getNamedItem(attribute).getNodeValue();
			}
		}
		catch ( Exception e )
		{
			throw new ITMException(e);
		}
		return objName;
	}
	//End changes by gulzar - 28/11/11
	//method added by gulzar on 09/12/11 to get the error string
	public String generateErrorString( String errorString )
	{
		return ("<Errors><error id = \"xxxx\" type=\"E\">" + errorString.substring(errorString.indexOf("<message>") , errorString.indexOf("</description>") + "</description>".length()) + "<redirect>1</redirect><type>E</type></error></Errors>");
	}
	//changed by gulzar on 09/12/11 to get the seleted attribute value
	private String setSelectedToDom( Document allFormDataDom, String detailString, ArrayList issDetSelList ) throws Exception
	{
		ArrayList selectedList = new ArrayList();
		NodeList detailList = null;
		Node currDetail = null;
		NodeList currDetailList = null;
		String selectedVal = "", nodeName = "", updateStatus = "";
		String domIDVal = "";
		String updatedDetailDomStr = "";
		String attributeVal = "";
		String caseLabel = "";
		String locCodeTo = "";
		String cartonNo = "";
		String columnValue = "";

		HashMap toUpdateMap = new HashMap();

		Node elementName = null;

		int currDetailListLength = 0;
		int	detailListLength = 0;

		int selectedValCnt = 0;

		GenericUtility genericUtility = GenericUtility.getInstance();

		try
		{
			detailList = allFormDataDom.getElementsByTagName("Detail3");
			detailListLength = detailList.getLength();
			for ( int ctr = 0; ctr < detailListLength; ctr++ )
			{
				currDetail = detailList.item(ctr);
				currDetailList = currDetail.getChildNodes();
				currDetailListLength = currDetailList.getLength();

				attributeVal = "";
				columnValue = "";

				ArrayList toUpdNodeList = new ArrayList();
				HashMap dataMap = new HashMap();

				for ( int i=0; i< currDetailListLength; i++ )
				{
					Node childNode = currDetailList.item(i);
					nodeName = childNode.getNodeName();
					if (nodeName.equalsIgnoreCase("Attribute"))
					{
						attributeVal = checkNull(currDetailList.item(i).getAttributes().getNamedItem("selected").getNodeValue());
						System.out.println("attributeVal =["+attributeVal+"]");
					}//if (nodeName = Attribute
					else if (nodeName.equalsIgnoreCase("case_label"))
					{
						if ( childNode != null && childNode.getFirstChild() != null )
						{
							caseLabel = childNode.getFirstChild().getNodeValue();
							//toUpdNodeList.add( 0, childNode );
							dataMap.put("case_label", childNode);
						}
					}
					else if (nodeName.equalsIgnoreCase("loc_code__to"))
					{
						if ( childNode != null && childNode.getFirstChild() != null )
						{
							locCodeTo = childNode.getFirstChild().getNodeValue();
							//toUpdNodeList.add( 1, childNode );
							dataMap.put("loc_code__to", childNode);
						}
					}
					else if (nodeName.equalsIgnoreCase("carton_no"))
					{
						if ( childNode != null && childNode.getFirstChild() != null )
						{
							cartonNo = childNode.getFirstChild().getNodeValue();
							//toUpdNodeList.add( 2, childNode );
							dataMap.put("carton_no", childNode);
						}
					}
				}//End of inner for loop
				if ( "Y".equalsIgnoreCase(attributeVal.trim()) )
				{
					if ( currDetail.getAttributes().getNamedItem( "domID" ) != null )
					{
						domIDVal = checkNull(currDetail.getAttributes().getNamedItem( "domID" ).getNodeValue());
						System.out.println("domIDVal =["+domIDVal+"]");
					}
					toUpdateMap.put( domIDVal, dataMap );
				}
			}//End of for loop

			System.out.println("toUpdateMap:>>>>>>>>>>>: "+toUpdateMap);

			detailList = null;

			detailString = detailString + "</Root>\r\n" ;	
			System.out.println("detailString:>>>>>>>>>>> "+detailString);
			Document detailDom = genericUtility.parseString(detailString); 

			Element elementAttr = null;

			detailList = detailDom.getElementsByTagName("Detail3");
			detailListLength = detailList.getLength();
			for ( int ctr = 0; ctr < detailListLength; ctr++ )
			{
				currDetail = detailList.item(ctr);

				if ( currDetail.getAttributes().getNamedItem( "selected" ) != null )
				{
					selectedVal = checkNull(currDetail.getAttributes().getNamedItem( "selected" ).getNodeValue());
					System.out.println("selectedVal =["+selectedVal+"]");
					if ( "N".equalsIgnoreCase(selectedVal.trim()) )
					{
						if ( currDetail.getAttributes().getNamedItem( "domID" ) != null )
						{
							//ArrayList aList = null;

							HashMap dataMap = new HashMap();

							domIDVal = checkNull(currDetail.getAttributes().getNamedItem( "domID" ).getNodeValue());
							System.out.println("domIDVal =["+domIDVal+"]");
							System.out.println("toUpdateMap.containsKey(domIDVal) =["+toUpdateMap.containsKey(domIDVal)+"]");
							if ( toUpdateMap.containsKey(domIDVal) )
							{
								elementAttr = (Element)currDetail;
								elementAttr.setAttribute( "selected" , "Y" );

								Node caseLabelNode = null;
								Node locCodeToNode = null;
								Node cartonNoNode = null;

								dataMap = (HashMap)toUpdateMap.get(domIDVal);

								if ( dataMap.get("case_label") != null )
								{
									caseLabelNode = (Node)dataMap.get("case_label");
								}
								if ( dataMap.get("loc_code__to") != null )
								{
									locCodeToNode = (Node)dataMap.get("loc_code__to");
								}
								if ( dataMap.get("carton_no") != null )
								{
									cartonNoNode = (Node)dataMap.get("carton_no");
								}

								Node updatedNode = null;

								currDetailList = currDetail.getChildNodes();
								currDetailListLength = currDetailList.getLength();

								for ( int i = 0; i < currDetailListLength; i++ )
								{
									elementName = currDetailList.item(i);
									nodeName = elementName.getNodeName();
									if( elementName.getNodeType() != Node.ELEMENT_NODE || nodeName.equalsIgnoreCase("#text") )
									{
										continue;
									}
									System.out.println("nodeName =["+nodeName+"]");
									if (nodeName.equalsIgnoreCase("case_label"))
									{
										if(caseLabelNode != null)
										{
											//System.out.println("caseLabelNode =["+genericUtility.serializeDom( caseLabelNode )+"]");
											updatedNode = detailDom.importNode(caseLabelNode, true);
											//System.out.println("updatedNode =["+genericUtility.serializeDom( updatedNode )+"]");
											(detailDom.getElementsByTagName("Detail3").item(ctr)).replaceChild(updatedNode, elementName );
										}
										else
										{
											System.out.println("On Next Previous case label node null");
										}
									}
									else if ( nodeName.equalsIgnoreCase("loc_code__to") )
									{
										if(locCodeToNode != null)
										{
											//System.out.println("LocCodeToNode =["+genericUtility.serializeDom( LocCodeToNode )+"]");
											updatedNode = detailDom.importNode(locCodeToNode, true);
											//System.out.println("updatedNode =["+genericUtility.serializeDom( updatedNode )+"]");
											(detailDom.getElementsByTagName("Detail3").item(ctr)).replaceChild(updatedNode, elementName );
										}
										else
										{
											System.out.println("On Next Previous location code null");
										}
									}
									else if ( nodeName.equalsIgnoreCase("carton_no") )
									{
										if(cartonNoNode != null)
										{
											//System.out.println("cartonNoNode =["+genericUtility.serializeDom( cartonNoNode )+"]");
											updatedNode = detailDom.importNode(cartonNoNode, true);
											//System.out.println("updatedNode =["+genericUtility.serializeDom( updatedNode )+"]");
											(detailDom.getElementsByTagName("Detail3").item(ctr)).replaceChild(updatedNode, elementName );
										}
										else
										{
											System.out.println("On Next Previous cartonNoNode code null");
										}
									}
								}//inner for loop
							}//if ( toUpdateMap.containsKey(domIDVal) )
						}//if ( currDetail.getAttributes().getNamedItem( "domID" )
					}//if ( "N".equalsIgnoreCase(selectedVal.trim()) )
				}//if ( currDetail.getAttributes().getNamedItem( "selected" )
			}//outer for loop
			updatedDetailDomStr = genericUtility.serializeDom( detailDom );
			System.out.println("updatedDetailDomStr:>>>>>>>>>>> "+updatedDetailDomStr);
		}
		catch (Exception e)
		{
			e.printStackTrace();
			throw e;
		}

		return updatedDetailDomStr;
	}
	
	//Changed by sumit on 13/03/12 to reterive shipper size start
	private HashMap getItemVoumeMap(String itemCode,String lotNo,Connection con)throws Exception
	{
		double shipperSize = 0,itemVolume = 0,caseVolume = 0;
		PreparedStatement pstmt = null;
		String sql="";
		ResultSet rs = null;
		double itmLen = 0,itmWidth = 0,itmHeight = 0,itemGrossWeight = 0,lotLen = 0 ,lotHeight = 0,lotWidth = 0,caseGrossWeight = 0,itemNetWeight = 0, caseNetWeight = 0;
		HashMap dataVolumeMap = new HashMap();
		
		try {
			
			sql = "SELECT I.LENGTH ITEM_LEN,I.WIDTH ITEM_WID,I.HEIGHT ITEM_HEIGHT,I.GROSS_WEIGHT ITEM_GROSS_WEIGHT,I.NET_WEIGHT ITEM_NET_WEIGHT,"
				  +" L.LENGTH LITEM_LEN,L.WIDTH LITEM_WID,L.HEIGHT LITEM_HEIGHT,L.SHIPPER_SIZE SHIPSIZE,L.GROSS_WEIGHT CASE_GROSS_WEIGHT,L.NET_WEIGHT CASE_NET_WEIGHT FROM"
				  +" ITEM I,ITEM_LOT_PACKSIZE L"
				  +" WHERE I.ITEM_CODE = L.ITEM_CODE"
				  +" AND L.LOT_NO__FROM <= ? AND L.LOT_NO__TO >= ?"
				  +" AND  I.ITEM_CODE = ?";
				  
			
			pstmt = con.prepareStatement(sql);
			if(lotNo != null && lotNo.length() > 0)
			{
				pstmt.setString(1, lotNo);
				pstmt.setString(2, lotNo);
			}
			else
			{
				pstmt.setString(1, "00");
				pstmt.setString(2, "ZZ");
			}
			pstmt.setString(3, itemCode);
			rs = pstmt.executeQuery();
			
			if(rs.next())
			{
				itmLen = rs.getDouble("ITEM_LEN");
				itmWidth = rs.getDouble("ITEM_WID");
				itmHeight = rs.getDouble("ITEM_HEIGHT");
				itemGrossWeight = rs.getDouble("ITEM_GROSS_WEIGHT");
				lotLen = rs.getDouble("LITEM_LEN");
				lotWidth = rs.getDouble("LITEM_WID");
				lotHeight = rs.getDouble("LITEM_HEIGHT");				
				shipperSize = rs.getDouble("SHIPSIZE");				
				caseGrossWeight = rs.getDouble("CASE_GROSS_WEIGHT");				
				itemNetWeight = rs.getDouble("ITEM_NET_WEIGHT");				
				caseNetWeight = rs.getDouble("CASE_NET_WEIGHT");				
			}
			
			//shipperSize = (lotHeight * lotWidth * lotLen)/(itmLen * itmWidth * itmHeight);
			itemVolume = (itmLen * itmWidth * itmHeight);
			caseVolume = (lotHeight * lotWidth * lotLen);
			
			dataVolumeMap.put("SHIPPER_SIZE", shipperSize);
			dataVolumeMap.put("ITEM_VOLUME", itemVolume);
			dataVolumeMap.put("CASE_VOLUME", caseVolume);
			dataVolumeMap.put("ITEM_GROSS_WEIGHT", itemGrossWeight);
			dataVolumeMap.put("CASE_GROSS_WEIGHT", caseGrossWeight);
			dataVolumeMap.put("ITEM_NET_WEIGHT", itemNetWeight);
			dataVolumeMap.put("CASE_NET_WEIGHT", caseNetWeight);
			
			if(pstmt != null)
			{
				pstmt.close();
				pstmt = null;
		
			}
			if(rs != null)
			{
				rs.close();
				rs = null;
		
			}
			
			
			
		} catch (Exception e) {
			// TODO: handle exception

			throw e;
		}
		finally
		{
			if(pstmt != null)
			{
				pstmt.close();
				pstmt = null;
		
			}
			if(rs != null)
			{
				rs.close();
				rs = null;
		
			}
		}
		
		return dataVolumeMap;
	}
	//Changed by sumit on 13/03/12 to reterive shipper size end
}