Commit 50354ad1 authored by prane's avatar prane

stmt changed to pstmt closed and nulled for multitenancy

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@195753 ce508802-f39f-4f6c-b175-0d175dae99d5
parent a263ea18
package ibase.webitm.ejb.dis.adv;
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.utility.ITMException;
import java.io.ByteArrayOutputStream;
......@@ -17,17 +14,14 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Properties;
import javax.ejb.Stateless;
import javax.naming.InitialContext;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
......@@ -143,6 +137,8 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
pstmt.setTimestamp(1,currDate);
pstmt.setString(2,tranId);
upcount =pstmt.executeUpdate();
pstmt.close();//added by Pavan R 10jan19[to handle open cursor issue]
pstmt = null;
if(upcount>0){
conn.commit();
retString = itmDBAccess.getErrorString("","VTDESHOLD ","","",conn);
......@@ -186,25 +182,22 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
{
try
{
if(conn!=null)
if( rs != null)
{
conn.commit();
conn.close();
conn = null;
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if( rs != null)
if(conn!=null)
{
rs.close();
rs = null;
conn.commit();
conn.close();
conn = null;
}
}
catch(Exception e)
{
......@@ -310,29 +303,25 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
{
try
{
if(conn!=null)
{
if(upcount>0)
if( rs != null)
{
conn.commit();
}
conn.close();
conn = null;
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if( rs != null)
if(conn!=null)
{
rs.close();
rs = null;
if(upcount>0)
{
conn.commit();
}
conn.close();
conn = null;
}
}
catch(Exception e)
{
......@@ -469,7 +458,8 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
String sql = "";
ResultSet rs = null;
Connection conn = null;
Statement stmt = null;
//Statement stmt = null;//Changed and added by Pavan R 10jan19[to handle open cursor issue]
PreparedStatement pstmt = null;
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
ibase.utility.E12GenericUtility genericUtility= new ibase.utility.E12GenericUtility();
ConnDriver connDriver = new ConnDriver();
......@@ -494,10 +484,15 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
+"SORDALLOC.QTY_ALLOC "
+"FROM SORDALLOC, ITEM "
+"WHERE SORDALLOC.ITEM_CODE = ITEM.ITEM_CODE "
+"AND SORDALLOC.SALE_ORDER = '"+ saleOrder +"'";
System.out.println("Sorder SQL :="+sql);
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
+"AND SORDALLOC.SALE_ORDER = ?";
//Changed and added by Pavan R 10jan19[to handle open cursor issue]
// +"AND SORDALLOC.SALE_ORDER = '"+ saleOrder +"'";
//System.out.println("Sorder SQL :="+sql);
//stmt = conn.createStatement();
//rs = stmt.executeQuery(sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, saleOrder);
rs = pstmt.executeQuery();
while (rs.next())
{
valueXmlString.append("<Detail>\r\n");
......@@ -511,7 +506,12 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
valueXmlString.append("<qty_alloc>").append("<![CDATA[").append(rs.getString(7)).append("]]>").append("</qty_alloc>\r\n");
valueXmlString.append("</Detail>\r\n");
}
stmt.close();
//Added by Pavan R 10jan19[to handle open cursor issue]
//stmt.close();
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("</Root>\r\n");
String retXmlString = serializeDom(genericUtility.parseString(valueXmlString.toString()));
valueXmlString = null;
......@@ -542,10 +542,23 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
finally
{
try
{
if (rs!=null)
{
rs.close();
rs=null;
}
if (pstmt!=null)
{
pstmt.close();
pstmt=null;
}
if(conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception e){}
}
System.out.println("valueXmlString.toString() "+valueXmlString.toString());
......@@ -665,7 +678,7 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
private String actionStock(Document dom,Document dom1, String objContext, String xtraParams) throws RemoteException , ITMException
{
Connection conn = null;
Statement stmt = null;
//Statement stmt = null;//Changed by Pavan R 10jan19[to handle open cursor issue]
ResultSet rs = null;
String sql = "";
PreparedStatement pstmt = null;
......@@ -723,8 +736,8 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
{
trackShelfLife = rs.getString(1);
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
if(locCode == null || locCode.trim().length() == 0)
{
locCode = "%";
......@@ -755,10 +768,10 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
{
orderType = rs.getString(1);
}
pstmt.close();
pstmt=null;
rs.close();
rs=null;
pstmt.close();
pstmt=null;
if("Y".equalsIgnoreCase(trackShelfLife.trim()))
{
......@@ -979,8 +992,22 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
{
try
{
if (rs!=null)
{
rs.close();
rs=null;
}
if (pstmt!=null)
{
pstmt.close();
pstmt=null;
}
System.out.println("Closing Connection.....");
if(conn != null)
{
conn.close();
conn = null;
}
}catch(Exception e){}
}
System.out.println("Despatch:actionStock:Final Value :valueXmlString.toString():"+valueXmlString.toString());
......@@ -1064,7 +1091,8 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
private String stockTransform(Document dom,Document dom1, String objContext, String xtraParams, Document selDataDom)throws ITMException
{
Connection conn = null;
Statement stmtTemp = null;
//Statement stmtTemp = null;//Changed and added by Pavan R 10jan19[to handle open cursor issue] End
PreparedStatement pstmt = null;
//Statement stmt = null;
ResultSet rsTemp = null;
......@@ -1182,7 +1210,7 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
unitStd1 = genericUtility.getColumnValue("unit__std", dom);
convQtyStduom = genericUtility.getColumnValue("conv__qty_stduom", dom);
stmtTemp = conn.createStatement();
//stmtTemp = conn.createStatement();//Changed by Pavan R 10jan19[to handle open cursor issue] End
sqlTemp ="SELECT SORDDET.SALE_ORDER, "
+"SORDDET.LINE_NO, "
+"SORDDET.SITE_CODE, "
......@@ -1277,11 +1305,16 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
+"WHERE SORDER.SALE_ORDER = SORDDET.SALE_ORDER "
+"AND SORDITEM.SALE_ORDER = SORDDET.SALE_ORDER "
+"AND SORDITEM.LINE_NO = SORDDET.LINE_NO "
+"AND SORDITEM.SALE_ORDER = '"+sordNo+"' "
+"AND SORDDET.LINE_NO = '" + lineNoSord + "' "
+"AND SORDITEM.SALE_ORDER = ?" //'"+sordNo+"' "
+"AND SORDDET.LINE_NO = ?" //'" + lineNoSord + "' "
+"AND SORDITEM.LINE_TYPE = 'I' ORDER BY SORDITEM.LINE_NO , SORDITEM.EXP_LEV";
System.out.println("sql1 :"+sqlTemp);
rsTemp = stmtTemp.executeQuery(sqlTemp);
//Changed and added by Pavan R 10jan19[to handle open cursor issue]
//System.out.println("sql1 :"+sqlTemp);
//rsTemp = stmtTemp.executeQuery(sqlTemp);
pstmt = conn.prepareStatement(sqlTemp);
pstmt.setString(1, sordNo);
pstmt.setString(2, lineNoSord);
rsTemp = pstmt.executeQuery();
if (rsTemp.next())
{
convRtuomStd = rsTemp.getDouble("CONV__RTUOM_STDUOM");
......@@ -1311,9 +1344,13 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
}
rsTemp.close();
rsTemp = null;
sqlTemp = "SELECT APPLY_PRICE FROM BOM WHERE BOM_CODE = '"+ itemCode +"' ";
System.out.println("sql1 :"+sqlTemp);
rsTemp = stmtTemp.executeQuery(sqlTemp);
pstmt.close();pstmt = null;//Added by Pavan R 10jan19[to handle open cursor issue]
sqlTemp = "SELECT APPLY_PRICE FROM BOM WHERE BOM_CODE = ?";//'"+ itemCode +"' ";
//System.out.println("sql1 :"+sqlTemp)//Changed and added by Pavan R 10jan19[to handle open cursor issue]
//rsTemp = stmtTemp.executeQuery(sqlTemp);
pstmt = conn.prepareStatement(sqlTemp);
pstmt.setString(1, itemCode);
rsTemp = pstmt.executeQuery();
if ( rsTemp.next() )
{
applyPrice = rsTemp.getString("APPLY_PRICE");
......@@ -1322,6 +1359,7 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
//stmtTemp = null;
rsTemp.close();
rsTemp = null;
pstmt.close();pstmt = null;//Changed and added by Pavan R 10jan19[to handle open cursor issue]
/* chandni shah - 02/02/11
if ( applyPrice == null )
{
......@@ -1331,19 +1369,25 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
*/
if ( packCode != null && packCode.trim().length() > 0 )
{
sqlTemp = "SELECT GROSS_WEIGHT, NETT_WEIGHT FROM PACKING WHERE PACK_CODE = '"+ packCode +"' ";
System.out.println("sqlTemp :: "+sqlTemp);
//Changed and added by Pavan R 10jan19[to handle open cursor issue] start
sqlTemp = "SELECT GROSS_WEIGHT, NETT_WEIGHT FROM PACKING WHERE PACK_CODE = ?";//'"+ packCode +"' ";
//System.out.println("sqlTemp :: "+sqlTemp);
//stmtTemp = conn.createStatement();
rsTemp = stmtTemp.executeQuery(sqlTemp);
//rsTemp = stmtTemp.executeQuery(sqlTemp);
pstmt = conn.prepareStatement(sqlTemp);
pstmt.setString(1, packCode);
rsTemp = pstmt.executeQuery();
if ( rsTemp.next() )
{
packGrossWeight = rsTemp.getDouble("GROSS_WEIGHT");
packNettWeight = rsTemp.getDouble("NETT_WEIGHT");
}
stmtTemp.close();
stmtTemp = null;
//stmtTemp.close();
//stmtTemp = null;
rsTemp.close();
rsTemp = null;
pstmt.close();pstmt = null;
//Changed and added by Pavan R 10jan19[to handle open cursor issue] End
}
NodeList detailList = selDataDom.getElementsByTagName("Detail");
......@@ -1404,15 +1448,23 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
+"A.GROSS_WT_PER_ART, "
+"A.TARE_WT_PER_ART ,"
+"A.PALLET_WT "
+"FROM STOCK A "
+"WHERE A.ITEM_CODE = '"+itemCode+"' "
+"AND A.SITE_CODE = '"+siteCodeDet+"' "
+"AND A.LOC_CODE = '"+locCode+"' "
+"AND A.LOT_NO = '"+lotNo+"' "
+"AND A.LOT_SL = '"+lotSl+"' ";
System.out.println("sql2 :"+sqlTemp);
stmtTemp = conn.createStatement();
rsTemp = stmtTemp.executeQuery(sqlTemp);
+"FROM STOCK A " //Changed and added by Pavan R 10jan19[to handle open cursor issue] start
+"WHERE A.ITEM_CODE = ?" //'"+itemCode+"' "
+"AND A.SITE_CODE = ?" //'"+siteCodeDet+"' "
+"AND A.LOC_CODE = ? " //'"+locCode+"' "
+"AND A.LOT_NO = ? " //'"+lotNo+"' "
+"AND A.LOT_SL = ? " ; //'"+lotSl+"' ";
//System.out.println("sql2 :"+sqlTemp);
//stmtTemp = conn.createStatement();
//rsTemp = stmtTemp.executeQuery(sqlTemp);
pstmt = conn.prepareStatement(sqlTemp);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCodeDet);
pstmt.setString(3, locCode);
pstmt.setString(4, lotNo);
pstmt.setString(5, lotSl);
rsTemp = pstmt.executeQuery();
//Changed and added by Pavan R 10jan19[to handle open cursor issue] End
if (rsTemp.next())
{
expDate = rsTemp.getDate("EXP_DATE");
......@@ -1431,10 +1483,16 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
}
rsTemp.close();
rsTemp = null;
//Changed and added by Pavan R 10jan19[to handle open cursor issue] start
pstmt.close();pstmt = null;
sqlTemp ="SELECT (CASE WHEN TRACK_SHELF_LIFE IS NULL THEN 'N' ELSE TRACK_SHELF_LIFE END) AS TRACK_SHELF_LIFE , DESCR "
+"FROM ITEM WHERE ITEM_CODE = '"+itemCode+"' ";
System.out.println("sql3 :"+sqlTemp);
rsTemp = stmtTemp.executeQuery(sqlTemp);
+"FROM ITEM WHERE ITEM_CODE = ? "; // '"+itemCode+"' ";
//System.out.println("sql3 :"+sqlTemp);
//rsTemp = stmtTemp.executeQuery(sqlTemp);
pstmt = conn.prepareStatement(sqlTemp);
pstmt.setString(1, itemCode);
rsTemp = pstmt.executeQuery();
//Changed and added by Pavan R 10jan19[to handle open cursor issue]End
if (rsTemp.next())
{
trackShelfLife = rsTemp.getString("TRACK_SHELF_LIFE");
......@@ -1442,6 +1500,7 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
}
rsTemp.close();
rsTemp = null;
pstmt.close();pstmt = null;
//start change 10-08-2010
System.out.println("palletWt.."+palletWt);
System.out.println("qtyStk.."+qtyStk+"..grossWeight.."+grossWeight+"..grossWtPerArt.."+grossWtPerArt);
......@@ -1495,9 +1554,14 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
}*/
//End Comment - Gulzar - 31/01/08
netWtPerArt = convRtuomStd;
sqlTemp = "SELECT ITEM_TYPE, UNIT__NETWT, UNIT__RATE FROM ITEM WHERE ITEM_CODE = '" + itemCodeOrd + "'";
System.out.println("sql4 :"+sqlTemp);
rsTemp = stmtTemp.executeQuery(sqlTemp);
//Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
sqlTemp = "SELECT ITEM_TYPE, UNIT__NETWT, UNIT__RATE FROM ITEM WHERE ITEM_CODE = ?"; //'" + itemCodeOrd + "'";
//System.out.println("sql4 :"+sqlTemp);
//rsTemp = stmtTemp.executeQuery(sqlTemp);
pstmt = conn.prepareStatement(sqlTemp);
pstmt.setString(1, itemCodeOrd);
rsTemp = pstmt.executeQuery();
//Changed and added by Pavan R 10jan19[to handle open cursor issue] End
if (rsTemp.next())
{
itemType = rsTemp.getString("ITEM_TYPE");
......@@ -1518,11 +1582,17 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
}
rsTemp.close();
rsTemp = null;
pstmt.close();pstmt = null;//Added by Pavan R 10jan19[to handle open cursor issue]
if (itemType.trim().length() > 0)
{
sqlTemp = "SELECT RATE_OPT FROM ITEM_TYPE WHERE ITEM_TYPE = '" + itemType + "'" ;
System.out.println("sql5 :"+sqlTemp);
rsTemp = stmtTemp.executeQuery(sqlTemp);
//Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
sqlTemp = "SELECT RATE_OPT FROM ITEM_TYPE WHERE ITEM_TYPE = ?"; //'" + itemType + "'" ;
//System.out.println("sql5 :"+sqlTemp);
//rsTemp = stmtTemp.executeQuery(sqlTemp);
pstmt = conn.prepareStatement(sqlTemp);
pstmt.setString(1, itemType);
rsTemp = pstmt.executeQuery();
//Changed and added by Pavan R 10jan19[to handle open cursor issue] End
if (rsTemp.next())
{
rateOpt = rsTemp.getString("RATE_OPT");
......@@ -1533,6 +1603,7 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
}
rsTemp.close();
rsTemp = null;
pstmt.close();pstmt = null;//Added by Pavan R 10jan19[to handle open cursor issue]
if (rateOpt == "1")
{
if ( netWtUnit.trim().equals(rateUnit.trim()))
......@@ -1604,7 +1675,7 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
mcode = genericUtility.getColumnValue("line_no__sord",dom);///genericUtility.
mVal = genericUtility.getColumnValue("sord_no",dom);
System.out.println("exp_lev CASE....:"+mVal1+"..."+mcode+"..."+mVal);
PreparedStatement pstmt=null;
//PreparedStatement pstmt=null;
ResultSet rs=null;
sql = "Select item_flg from sorddet "
......@@ -1853,10 +1924,20 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
try
{
System.out.println("Closing Connection................");
if (stmtTemp != null)
/*if (stmtTemp != null)
{
stmtTemp.close();
stmtTemp = null;
}*/
if(rsTemp != null)
{
rsTemp.close();
rsTemp = null;
}
if (pstmt!=null)
{
pstmt.close();
pstmt=null;
}
if (conn != null)
{
......@@ -2278,8 +2359,11 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
String detailCnt = "0",sExpDate= "",sMfgDate = "" ,sRetestDate = "";
ResultSet rs1 = null;
Connection conn = null;
Statement stmt = null;
Statement stmt1 = null;
//Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
//Statement stmt = null;
PreparedStatement pstmt = null;
//Statement stmt1 = null;
//Changed and added by Pavan R 10jan19[to handle open cursor issue]End
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
ibase.utility.E12GenericUtility genericUtility= new ibase.utility.E12GenericUtility();
ConnDriver connDriver = new ConnDriver();
......@@ -2294,7 +2378,7 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//Changes and Commented By Bhushan on 09-06-2016 :END
stmt = conn.createStatement();
//stmt = conn.createStatement();//Changed by Pavan R 10jan19[to handle open cursor issue]
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
saleOrder = genericUtility.getColumnValue("sord_no",dom);
despId = genericUtility.getColumnValue("desp_id",dom1);
......@@ -2305,12 +2389,15 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
//sqlOrderNoSo = "SELECT ORDER_NO FROM INV_PACK WHERE ORDER_NO ='"+saleOrder+"'"+" AND "
// +"ORDER_TYPE IN ('S','I') AND CONFIRMED ='Y'";
sqlOrderNoSo = "select order_no from inv_pack "
+ " where order_no = '" + saleOrder + "' "
+ " where order_no = ?" //'" + saleOrder + "' "//Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
+ " and order_type in ('S','I') "
+ " and confirmed = 'Y' ";
// 27/02/10 manoharan changed as per PB code
System.out.println("sqlOrderNoSo :"+sqlOrderNoSo);
rs = stmt.executeQuery(sqlOrderNoSo);
//System.out.println("sqlOrderNoSo :"+sqlOrderNoSo);
//rs = stmt.executeQuery(sqlOrderNoSo);
pstmt = conn.prepareStatement(sqlOrderNoSo);
pstmt.setString(1, saleOrder);
rs = pstmt.executeQuery();//Changed and added by Pavan R 10jan19[to handle open cursor issue] End
while (rs.next())
{
orderNoSo = rs.getString(1);
......@@ -2319,20 +2406,25 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
}
System.out.println("orderNoSo :"+orderNoSo);
}
stmt.close();
stmt = null;
rs.close();
rs = null;
pstmt.close();
pstmt = null;
// 27/02/10 manoharan changed as per PB code
//sqlOrderNoPo = "SELECT ORDER_NO FROM INV_PACK WHERE ORDER_NO IN (SELECT PURC_ORDER FROM PORDER WHERE "
// +"SALE_ORDER ='"+saleOrder+"'"+") AND ORDER_TYPE = 'P' AND CONFIRMED = 'Y'";
sqlOrderNoPo = "select order_no from inv_pack "
+ " where order_no in ( select purc_order from porder where sale_order = '" + saleOrder + "') "
+ " where order_no in ( select purc_order from porder where sale_order = ?) "//'" + saleOrder + "') "
+ " and order_type = 'I' "
+ " and confirmed = 'Y' ";
//+ " and order_type in ('P','I') "
// end 27/02/10 manoharan changed as per PB code
System.out.println("sqlOrderNoPo :"+sqlOrderNoPo);
stmt = conn.createStatement();
rs = stmt.executeQuery(sqlOrderNoPo);
//System.out.println("sqlOrderNoPo :"+sqlOrderNoPo);
//stmt = conn.createStatement();
//rs = stmt.executeQuery(sqlOrderNoPo);
pstmt = conn.prepareStatement(sqlOrderNoPo);
pstmt.setString(1, saleOrder);
rs = pstmt.executeQuery();
while (rs.next())
{
orderNoPo = rs.getString(1);
......@@ -2341,21 +2433,27 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
}
System.out.println("orderNoPo :"+orderNoPo);
}
stmt.close();
stmt = null;
rs.close();
rs = null;
pstmt.close();
pstmt = null;
// 27/02/10 manoharan changed as per PB code
//sqlOrderNoPo = "SELECT ORDER_NO FROM INV_PACK WHERE ORDER_NO IN (SELECT PURC_ORDER FROM PORDER WHERE "
// +"SALE_ORDER ='"+saleOrder+"'"+") AND ORDER_TYPE = 'P' AND CONFIRMED = 'Y'";
sqlOrderNoPo = " select order_no from inv_pack where order_no "
+ " in ( select sale_order from sorder where cust_pord "
+ " in (Select purc_order from porder where sale_order = '" + saleOrder + "')) "
+ " in (Select purc_order from porder where sale_order = ?))" //'" + saleOrder + "')) "
+ " and order_type in ('S') "
+ " and confirmed = 'Y' "
+ " and site_code in (select site_code__ship from sorder where sale_order = '" + saleOrder + "') ";
+ " and site_code in (select site_code__ship from sorder where sale_order = ?)"; //'" + saleOrder + "') ";
// end 27/02/10 manoharan changed as per PB code
System.out.println("sqlOrderNoPo :"+sqlOrderNoPo);
stmt = conn.createStatement();
rs = stmt.executeQuery(sqlOrderNoPo);
//System.out.println("sqlOrderNoPo :"+sqlOrderNoPo);
//stmt = conn.createStatement();
//rs = stmt.executeQuery(sqlOrderNoPo);
pstmt = conn.prepareStatement(sqlOrderNoPo);
pstmt.setString(1, saleOrder);
pstmt.setString(2, saleOrder);
rs = pstmt.executeQuery();
while (rs.next())
{
orderNoPo = rs.getString(1);
......@@ -2364,8 +2462,9 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
}
System.out.println("orderNoPo :"+orderNoPo);
}
stmt.close();
stmt = null;
rs.close(); rs = null;
pstmt.close();
pstmt = null;
// 27/02/10 manoharan changed as per PB code
//sqlOrderNoDo = "SELECT ORDER_NO FROM INV_PACK WHERE ORDER_NO IN (SELECT DIST_ORDER FROM DISTORDER "
// +"WHERE SALE_ORDER ='"+saleOrder+"' ) AND ORDER_TYPE ='D' AND CONFIRMED = 'Y'";
......@@ -2373,22 +2472,25 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
if( currentActionType.equalsIgnoreCase("Get SPack List"))
{
sqlOrderNoDo = "select order_no from inv_pack "
+ " where order_no in ( select dist_order from distorder where sale_order = '" + saleOrder + "') "
+ " where order_no in ( select dist_order from distorder where sale_order = ?)"//'" + saleOrder + "') "
+ " and order_type = 'S' "
+ " and confirmed = 'Y' ";
}
else
{
sqlOrderNoDo = "select order_no from inv_pack "
+ " where order_no in ( select dist_order from distorder where sale_order = '" + saleOrder + "') "
+ " where order_no in ( select dist_order from distorder where sale_order = ?)"//'" + saleOrder + "') "
+ " and order_type = 'I' "
+ " and confirmed = 'Y' ";
}
//+ " and order_type in ('D','I') "
// end 27/02/10 manoharan
System.out.println("sqlOrderNoDo :"+sqlOrderNoDo);
stmt = conn.createStatement();
rs = stmt.executeQuery(sqlOrderNoDo);
//System.out.println("sqlOrderNoDo :"+sqlOrderNoDo);
//stmt = conn.createStatement();
//rs = stmt.executeQuery(sqlOrderNoDo);
pstmt = conn.prepareStatement(sqlOrderNoDo);
pstmt.setString(1, saleOrder);
rs = pstmt.executeQuery();
while (rs.next())
{
orderNoDo = rs.getString(1);
......@@ -2397,8 +2499,9 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
}
System.out.println("orderNoDo :"+orderNoDo);
}
stmt.close();
stmt = null;
rs.close();rs = null;
pstmt.close();
pstmt = null;
int orderNoListSize = orderNoArrList.size();
String orderNoTemp = "";
for(int ctr = 0;ctr < orderNoListSize;ctr++){
......@@ -2442,16 +2545,19 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
+"AND INV_PACK_RCP.LOC_CODE = STOCK.LOC_CODE "
+"AND INV_PACK_RCP.LOT_NO = STOCK.LOT_NO "
+"AND INV_PACK_RCP.LOT_SL = STOCK.LOT_SL "
+"AND INV_PACK.ORDER_NO IN(" +orderNo+") "
+"AND INV_PACK.ORDER_NO IN(?) " //+orderNo+") " //Changed and added by Pavan R 10jan19[to handle open cursor issue] start
+"AND INV_PACK.ORDER_TYPE in ('S','I') "
+"AND INV_PACK.CONFIRMED = 'Y' "
+"AND STOCK.QUANTITY >= INV_PACK_RCP.QUANTITY "
+"ORDER BY INV_PACK.TRAN_DATE ,INV_PACK.TRAN_ID,INV_PACK_RCP.LINE_NO ASC ";
System.out.println("sql :"+sql);
//System.out.println("sql :"+sql);
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
//stmt = conn.createStatement();
//rs = stmt.executeQuery(sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, orderNo);
rs = pstmt.executeQuery();//Changed and added by Pavan R 10jan19[to handle open cursor issue] end
while (rs.next())// here in PB it opens a window and prompts the user to select records and then the procssing continues for the selected records
{
valueXmlString.append("<Detail>\r\n");
......@@ -2488,6 +2594,8 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
valueXmlString.append("</Detail>\r\n");
}//while end
rs.close(); rs = null;
pstmt.close();pstmt = null;
valueXmlString.append("</Root>\r\n");
//}//end if(detailCount)
}//try end
......@@ -2506,12 +2614,16 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
rs.close();
rs = null;
}
if (stmt != null)
if (pstmt != null)
{
stmt.close();
stmt = null;
pstmt.close();
pstmt = null;
}
if(conn != null)
{
conn.close();
conn = null;
}
}catch(Exception e){}
}
System.out.println("valueXmlString.toString() "+valueXmlString.toString());
......@@ -2543,10 +2655,10 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
DecimalFormat df = new DecimalFormat("#########.###");
//
Connection conn = null;
Statement stmt = null;
//Statement stmt = null;
ResultSet rs = null;
ResultSet rs1 = null,rs2=null;
Statement stmt1 = null;
//Statement stmt1 = null;
ConnDriver connDriver = new ConnDriver();
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
ibase.utility.E12GenericUtility genericUtility= new ibase.utility.E12GenericUtility();
......@@ -2557,7 +2669,7 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//Changes and Commented By Bhushan on 09-06-2016 :END
stmt = conn.createStatement();
//stmt = conn.createStatement();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
despId = genericUtility.getColumnValue("desp_id",dom1);
siteCode = genericUtility.getColumnValue("site_code",dom1);
......@@ -2568,42 +2680,62 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
currDetail = detailList.item(ctr);
invOrderNo = genericUtility.getColumnValueFromNode("order_no",currDetail);
origInvOrderNo = invOrderNo;
sqlStr = "SELECT ORDER_TYPE FROM INV_PACK WHERE ORDER_NO ='"+invOrderNo+"'";
rs = stmt.executeQuery(sqlStr);
sqlStr = "SELECT ORDER_TYPE FROM INV_PACK WHERE ORDER_NO = ? " ; //'"+invOrderNo+"'";//Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
//rs = stmt.executeQuery(sqlStr);
pstmt = conn.prepareStatement(sqlStr);
pstmt.setString(1, invOrderNo);
rs = pstmt.executeQuery();//Changed and added by Pavan R 10jan19[to handle open cursor issue] end
if(rs.next())
{
orderType = rs.getString("ORDER_TYPE");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
System.out.println("orderType :"+orderType);
if (orderType != null && orderType.equalsIgnoreCase("D"))
{
sqlStr = "SELECT SALE_ORDER FROM DISTORDER WHERE DIST_ORDER = '"+invOrderNo+"'";
rs = stmt.executeQuery(sqlStr);
sqlStr = "SELECT SALE_ORDER FROM DISTORDER WHERE DIST_ORDER = ?"; //'"+invOrderNo+"'";//Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
//rs = stmt.executeQuery(sqlStr);
pstmt = conn.prepareStatement(sqlStr);
pstmt.setString(1, invOrderNo);
rs = pstmt.executeQuery();//Changed and added by Pavan R 10jan19[to handle open cursor issue] end
if(rs.next())
{
saleOrd = rs.getString("SALE_ORDER");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
invOrderNo = saleOrd;
sorder = "Y";
}
else if (orderType != null && orderType.equalsIgnoreCase("P"))
{
sqlStr = "SELECT SALE_ORDER FROM PORDER WHERE PURC_ORDER = '"+invOrderNo+"'";
rs = stmt.executeQuery(sqlStr);
sqlStr = "SELECT SALE_ORDER FROM PORDER WHERE PURC_ORDER = ?"; // '"+invOrderNo+"'";//Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
//rs = stmt.executeQuery(sqlStr);
pstmt = conn.prepareStatement(sqlStr);
pstmt.setString(1, invOrderNo);
rs = pstmt.executeQuery();//Changed and added by Pavan R 10jan19[to handle open cursor issue] end
if(rs.next())
{
saleOrd = rs.getString("SALE_ORDER");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
invOrderNo = saleOrd;
}
else if(orderType != null && orderType.equalsIgnoreCase("I"))
{
sqlStr = "SELECT SALE_ORDER FROM DISTORDER WHERE DIST_ORDER = '"+invOrderNo+"'";
rs = stmt.executeQuery(sqlStr);
sqlStr = "SELECT SALE_ORDER FROM DISTORDER WHERE DIST_ORDER = ?"; //'"+invOrderNo+"'";//Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
//rs = stmt.executeQuery(sqlStr);
pstmt = conn.prepareStatement(sqlStr);
pstmt.setString(1, invOrderNo);
rs = pstmt.executeQuery();//Changed and added by Pavan R 10jan19[to handle open cursor issue] end
if(rs.next())
{
saleOrd = rs.getString("SALE_ORDER");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
if(saleOrd != null && saleOrd.trim().length() > 0){
invOrderNo = saleOrd;
sorder = "Y";
......@@ -2613,12 +2745,18 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
//if(sorder == "Y")
if("Y".equalsIgnoreCase(sorder))
{
sqlStr = "SELECT SALE_ORDER, LINE_NO__SORD FROM DISTORDER_DET WHERE DIST_ORDER = '"+origInvOrderNo+"' AND LINE_NO = '"+lineNoOrd+"'";
rs = stmt.executeQuery(sqlStr);
sqlStr = "SELECT SALE_ORDER, LINE_NO__SORD FROM DISTORDER_DET WHERE DIST_ORDER = ? AND LINE_NO = ?"; //'"+origInvOrderNo+"' AND LINE_NO = '"+lineNoOrd+"'";//Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
//rs = stmt.executeQuery(sqlStr);
pstmt = conn.prepareStatement(sqlStr);
pstmt.setString(1, origInvOrderNo);
pstmt.setString(2, lineNoOrd);
rs = pstmt.executeQuery();//Changed and added by Pavan R 10jan19[to handle open cursor issue] end
if(rs.next()){
invOrderNo = rs.getString("SALE_ORDER");
lineNoOrd = rs.getString("LINE_NO__SORD");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
}
// 03/12/10 manoharan
if (lineNoOrd.trim().length() == 1)
......@@ -2637,16 +2775,28 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
lineNoOrd = lineNoOrd.trim();
}
// end 03/12/10 manoharan
sqlStr = "SELECT EXP_LEV FROM SORDITEM WHERE SALE_ORDER ='"+invOrderNo+"'"
+"AND LINE_NO ='"+lineNoOrd+"'"+" AND LINE_TYPE = 'I'";
rs = stmt.executeQuery(sqlStr);
sqlStr = "SELECT EXP_LEV FROM SORDITEM WHERE SALE_ORDER = ?"//'"+invOrderNo+"'"
//+"AND LINE_NO ='"+lineNoOrd+"'"+" AND LINE_TYPE = 'I'";
+"AND LINE_NO = ? AND LINE_TYPE = 'I'";
//rs = stmt.executeQuery(sqlStr);
pstmt = conn.prepareStatement(sqlStr);
pstmt.setString(1, invOrderNo);
pstmt.setString(2, lineNoOrd);
rs = pstmt.executeQuery();
if(rs.next())
{
expLev = rs.getString("EXP_LEV");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
sqlStr = "SELECT TAX_CLASS,TAX_CHAP,TAX_ENV,UNIT,UNIT__STD FROM SORDDET "
+"WHERE SALE_ORDER = '"+invOrderNo+"'"+" AND LINE_NO = '"+lineNoOrd+"'";
rs = stmt.executeQuery(sqlStr);
//+"WHERE SALE_ORDER = '"+invOrderNo+"'"+" AND LINE_NO = '"+lineNoOrd+"'"; //Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
+"WHERE SALE_ORDER = ? AND LINE_NO = ?";
//rs = stmt.executeQuery(sqlStr);
pstmt = conn.prepareStatement(sqlStr);
pstmt.setString(1, invOrderNo);
pstmt.setString(2, lineNoOrd);
rs = pstmt.executeQuery();//Changed and added by Pavan R 10jan19[to handle open cursor issue] end
if(rs.next())
{
taxClass = rs.getString("TAX_CLASS");
......@@ -2655,6 +2805,8 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
unit = rs.getString("UNIT");
unitStd = rs.getString("UNIT__STD");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
valueXmlString.append("<Detail>\r\n");
valueXmlString.append("<desp_id isSrvCallOnChg='0'>").append("<![CDATA[").append((despId == null) ? "":despId).append("]]>").append("</desp_id>\r\n"); //44
setNodeValue( dom, "desp_id", (despId == null) ? "":despId );
......@@ -2966,22 +3118,35 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
rs.close();
rs = null;
}
if (stmt != null)
/*if (stmt != null)
{
stmt.close();
stmt = null;
}
}*/
if (rs1 != null)
{
rs1.close();
rs1 = null;
}if (rs2 != null)
{
rs2.close();
rs2 = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if(conn != null)
{
conn.close();
conn = null;
}
}catch(Exception e){}
}
System.out.println("10/12/10 manohar valueXmlString.toString() "+valueXmlString.toString());
......@@ -3871,7 +4036,8 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
String lineNo = "", expLev = "", itemCode = "", itemCodeOrd = "", itemCodeOld = "";
String sql = "", sql1 = "", sql2 = "", sql3 = "";
java.util.Date expDate1 = null, chkDate4 = null, chkDate3 = null;
Statement stmt = null, stmt1 = null, stmt2 = null, stmt3 = null;
//Statement stmt = null, stmt1 = null, stmt2 = null, stmt3 = null;//Changed and added by Pavan R 10jan19[to handle open cursor issue]
PreparedStatement pstmt1 = null, pstmt2 = null, pstmt3 = null;
Connection conn = null;
ResultSet rs = null, rs1 = null, rs2 = null, rs3 = null;
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
......@@ -3933,7 +4099,7 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
double OrdQty = 0;
ResultSet rsTemp =null;
DecimalFormat df = new DecimalFormat("#########.###");
Statement stmtTemp = null;
//Statement stmtTemp = null;
// End Addition - Gulzar - 23/01/08
try
{
......@@ -3961,11 +4127,11 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//Changes and Commented By Bhushan on 09-06-2016 :END
stmt = conn.createStatement();
stmt1 = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
stmt2 = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
stmt3 = conn.createStatement();
stmtTemp = conn.createStatement(); // Added - Gulzar - 23/01/08
//stmt = conn.createStatement(); //Changed by Pavan R 10jan19[to handle open cursor issue] Start
//stmt1 = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
//stmt2 = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
//stmt3 = conn.createStatement();
//stmtTemp = conn.createStatement(); // Added - Gulzar - 23/01/08
sordNo = genericUtility.getColumnValue("sord_no",dom1);
System.out.println("sordNo :"+sordNo);
......@@ -3987,10 +4153,13 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
System.out.println("siteCode :"+siteCode);
sql = "SELECT NO_OF_ITEMS FROM DOC_NO_ITEMS "
+"WHERE SITE_CODE = '"+siteCode+"' "
+"WHERE SITE_CODE = ? " //Changed and added by Pavan R 10jan19[to handle open cursor issue] Start // '"+siteCode+"' "
+"AND MOD_NAME = UPPER('W_DESPATCH')";
System.out.println("sql :"+sql);
rs = stmt.executeQuery(sql);
//System.out.println("sql :"+sql);
//rs = stmt.executeQuery(sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();//Changed and added by Pavan R 10jan19[to handle open cursor issue] end
if (rs.next())
{
noOfItems = rs.getInt(1);
......@@ -4001,8 +4170,8 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
noOfItems = 0;
System.out.println("noOfItems :"+noOfItems);
}
rs.close();
rs = null;
rs.close(); rs = null;
pstmt.close(); pstmt = null;
// Added - Gulzar - 23/01/08
despatchId = genericUtility.getColumnValue("desp_id",dom1);
System.out.println("Despatch Id :"+despatchId);
......@@ -4191,16 +4360,20 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
+" WHERE SORDER.SALE_ORDER = SORDDET.SALE_ORDER "
+" AND SORDITEM.SALE_ORDER = SORDDET.SALE_ORDER "
+" AND SORDITEM.LINE_NO = SORDDET.LINE_NO "
+" AND SORDITEM.SALE_ORDER = '"+sordNo+"'"
+" AND SORDITEM.SALE_ORDER = ? " //'"+sordNo+"'"//Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
+" AND SORDITEM.LINE_TYPE = 'I' "
+" ORDER BY SORDITEM.LINE_NO, SORDITEM.EXP_LEV " ;
//End Changes Gulzar 12/03/07
System.out.println("sql for all data ::"+sql);
rs = stmt.executeQuery(sql);
//System.out.println("sql for all data ::"+sql);
//rs = stmt.executeQuery(sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sordNo);
rs = pstmt.executeQuery();//Changed and added by Pavan R 10jan19[to handle open cursor issue] end
while (rs.next())
{
if (noOfItems > 0 && counter >= noOfItems)
{
{ pstmt.close(); pstmt = null; //Changed and added by Pavan R 10jan19[closed and nulled]
rs.close(); rs = null;
errCode = "VTITMGRZRO";
errString = itmDBAccess.getErrorString("",errCode,"","",conn);
return errString;
......@@ -4243,15 +4416,18 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
//End changes Gulzar 14/03/07
//Start - Added by Gulzar - 23/01/08
sql1 = "SELECT DESCR FROM ITEM WHERE ITEM_CODE = '"+itemCode+"'";
stmt1 = conn.createStatement();
rs1 = stmt1.executeQuery(sql1);
sql1 = "SELECT DESCR FROM ITEM WHERE ITEM_CODE = ?"; //'"+itemCode+"'";//Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
//stmt1 = conn.createStatement();
//rs1 = stmt1.executeQuery(sql1);
pstmt1 = conn.prepareStatement(sql1,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
pstmt1.setString(1, itemCode);
rs1 = pstmt1.executeQuery();//Changed and added by Pavan R 10jan19[to handle open cursor issue] End
if (rs1.next())
{
itemDescr = rs1.getString("DESCR");
}
rs1.close();
rs1 = null;
rs1.close();rs1 = null;
pstmt1.close(); pstmt1 = null;
rateClg = rs.getDouble("RATE__CLG");
orderedQty = rs.getDouble("QUANTITY");
OrdQty = rs.getDouble("ORD_QTY");
......@@ -4282,20 +4458,26 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
{
rateUnitSord = "";
}
sql1 = "SELECT SUM(QUANTITY__STDUOM) AS QUANTITY__STDUOM FROM DESPATCHDET WHERE SORD_NO = '" + sordNo + "'" +
" AND LINE_NO__SORD = '" + lineNoOrd + "'" +
" AND EXP_LEV = '" + expLev + "'" +
" AND DESP_ID <> '" + despatchId + "'";
sql1 = "SELECT SUM(QUANTITY__STDUOM) AS QUANTITY__STDUOM FROM DESPATCHDET WHERE SORD_NO = ?" + //'" + sordNo + "'" +
" AND LINE_NO__SORD = ?" +//'" + lineNoOrd + "'" +//Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
" AND EXP_LEV = ? " + //'" + expLev + "'" +
" AND DESP_ID <> ? "; //'" + despatchId + "'";
//stmt1 = conn.createStatement();
rs1 = stmt1.executeQuery(sql1);
//rs1 = stmt1.executeQuery(sql1);
pstmt1 = conn.prepareStatement(sql1,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
pstmt1.setString(1, sordNo);
pstmt1.setString(2, lineNoOrd);
pstmt1.setString(3, expLev);
pstmt1.setString(4, despatchId);
despatchedQty = 0d;
rs1 = pstmt1.executeQuery();//Changed and added by Pavan R 10jan19[to handle open cursor issue] end
if (rs1.next())
{
despatchedQty = rs1.getDouble("QUANTITY__STDUOM");
}
sql1 = "";
rs1.close();
stmt1 = null;
rs1.close();rs1 = null;
pstmt1.close();pstmt1 = null;
System.out.println("despatchedQty--["+despatchedQty+"]");
System.out.println("quantityStduom--["+quantityStduom+"]");
quantityStduom = quantityStduom - despatchedQty;
......@@ -4387,16 +4569,22 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
+"SORDALLOC.SITE_CODE__MFG "
+"FROM SORDALLOC, LOCATION "
+"WHERE SORDALLOC.LOC_CODE = LOCATION.LOC_CODE "
+"AND SORDALLOC.SALE_ORDER = '"+sordNo+"' "
+"AND SORDALLOC.LINE_NO = '"+lineNoOrd+"' "
+"AND SORDALLOC.EXP_LEV = '"+expLev+"' "
+"AND SORDALLOC.ITEM_CODE__ORD = '"+itemCodeOrd+"' "
+"AND SORDALLOC.ITEM_CODE = '"+itemCode+"' "
+"AND SORDALLOC.SALE_ORDER = ? " //'"+sordNo+"' " //Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
+"AND SORDALLOC.LINE_NO = ? " //'"+lineNoOrd+"' "
+"AND SORDALLOC.EXP_LEV = ? " //'"+expLev+"' "
+"AND SORDALLOC.ITEM_CODE__ORD = ? " //'"+itemCodeOrd+"' "
+"AND SORDALLOC.ITEM_CODE = ? " //'"+itemCode+"' "
+"AND CASE WHEN SORDALLOC.STATUS IS NULL THEN ' ' ELSE SORDALLOC.STATUS END <> 'D' ";
System.out.println("sql1 :"+sql1);
stmt1 = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs1 = stmt1.executeQuery(sql1);
//System.out.println("sql1 :"+sql1);
//stmt1 = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
//rs1 = stmt1.executeQuery(sql1);
pstmt1 = conn.prepareStatement(sql1, ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
pstmt1.setString(1, sordNo);
pstmt1.setString(2, lineNoOrd);
pstmt1.setString(3, expLev);
pstmt1.setString(4, itemCodeOrd);
pstmt1.setString(5, itemCode);
rs1 = pstmt1.executeQuery();//Changed and added by Pavan R 10jan19[to handle open cursor issue] End
if(!rs1.next())
{
if(locCode == null || locCode.trim().length() == 0)
......@@ -4549,9 +4737,14 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
+"ORDER BY a.partial_used,A.EXP_DATE, A.CREA_DATE, A.LOT_NO, A.LOT_SL ";
System.out.println("sql2 :"+sql2);
}
rs2 = stmt2.executeQuery(sql2);
//Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
//rs2 = stmt2.executeQuery(sql2);
pstmt2 = conn.prepareStatement(sql2, ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs2 = pstmt2.executeQuery();//Changed and added by Pavan R 10jan19[to handle open cursor issue] End
if (!rs2.next())
{
rs2.close(); rs2 = null;
pstmt2.close(); pstmt2 = null;
continue;
}
else
......@@ -4611,17 +4804,23 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
*/
// Added - Gulzar - 23/01/08
//Changed and added by Pavan R 10jan19[to handle open cursor issue]
sql3 = "SELECT CASE WHEN TRACK_SHELF_LIFE IS NULL THEN 'N' ELSE TRACK_SHELF_LIFE END , DESCR "
+"FROM ITEM WHERE ITEM_CODE = '"+itemCode+"' ";
+"FROM ITEM WHERE ITEM_CODE = ?"; //'"+itemCode+"' ";
// End Add - Gulzar - 23/01/08
System.out.println("sql3 :"+sql3);
rs3 = stmt3.executeQuery(sql3);
//System.out.println("sql3 :"+sql3);
//rs3 = stmt3.executeQuery(sql3);
pstmt3 = conn.prepareStatement(sql3);
pstmt3.setString(1, itemCode);
rs3 = pstmt3.executeQuery();
if (rs3.next())
{
trackShelfLife = rs3.getString(1);
System.out.println("trackShelfLife :"+trackShelfLife);
}
rs3.close(); rs3 = null;
pstmt3.close(); pstmt3 = null;
if (trackShelfLife.equals("Y"))
{
/*
......@@ -4817,9 +5016,12 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
*/
//End Comment - Gulzar - 31/01/08
//Added - Gulzar - 23/01/08
netWtPerArt = convRtuomStd;
sql3 = "SELECT ITEM_TYPE, UNIT__NETWT, UNIT__RATE FROM ITEM WHERE ITEM_CODE = '" + itemCodeOrd + "'";
rs3 = stmt3.executeQuery(sql3);
netWtPerArt = convRtuomStd;//Changed and added by Pavan R 10jan19[to handle open cursor issue]
sql3 = "SELECT ITEM_TYPE, UNIT__NETWT, UNIT__RATE FROM ITEM WHERE ITEM_CODE = ?" ; //'" + itemCodeOrd + "'";
//rs3 = stmt3.executeQuery(sql3);
pstmt3 = conn.prepareStatement(sql3);
pstmt3.setString(1, itemCodeOrd);
rs3 = pstmt3.executeQuery();
if (rs3.next())
{
itemType = rs3.getString(1);
......@@ -4840,10 +5042,14 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
}
rs3.close();
rs3 = null;
pstmt3.close();pstmt3 = null;
if (itemType.trim().length() > 0)
{
sql3 = "SELECT RATE_OPT FROM ITEM_TYPE WHERE ITEM_TYPE = '" + itemType + "'" ;
rs3 = stmt3.executeQuery(sql3);
{ //Changed and added by Pavan R 10jan19[to handle open cursor issue]
sql3 = "SELECT RATE_OPT FROM ITEM_TYPE WHERE ITEM_TYPE = ?"; //'" + itemType + "'" ;
//rs3 = stmt3.executeQuery(sql3);
pstmt3 = conn.prepareStatement(sql3);
pstmt3.setString(1, itemType);
rs3 = pstmt3.executeQuery();
if (rs3.next())
{
rateOpt = rs3.getString(1);
......@@ -4852,8 +5058,8 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
rateOpt = "";
}
}
rs3.close();
rs3 = null;
rs3.close();rs3 = null;
pstmt3.close();pstmt3 = null;
if (rateOpt == "1")
{
if ( netWtUnit.trim().equals(rateUnit.trim()))
......@@ -4960,17 +5166,20 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
qtyDetailStr = "Shipper Quantity = " + shipperQtyNew +" Integral Quantity = " + integralQtyNew + " Loose Quantity = " + looseQty ;
if ( packCode != null && packCode.trim().length() > 0 )
{
sqlTemp = " SELECT GROSS_WEIGHT,NETT_WEIGHT FROM PACKING WHERE PACK_CODE = '"+ packCode +"' ";
System.out.println("sqlTemp ::"+sqlTemp);
rsTemp = stmtTemp.executeQuery(sqlTemp);
{ //Changed and added by Pavan R 10jan19[to handle open cursor issue]
sqlTemp = " SELECT GROSS_WEIGHT,NETT_WEIGHT FROM PACKING WHERE PACK_CODE = ?"; //'"+ packCode +"' ";
//System.out.println("sqlTemp ::"+sqlTemp);
//rsTemp = stmtTemp.executeQuery(sqlTemp);
pstmt3 = conn.prepareStatement(sqlTemp);
pstmt3.setString(1, packCode);
rsTemp = pstmt3.executeQuery();
if ( rsTemp.next() )
{
packGrossWeight = rsTemp.getDouble("GROSS_WEIGHT");
packNettWeight = rsTemp.getDouble("NETT_WEIGHT");
}
rsTemp.close();
rsTemp = null;
rsTemp.close();rsTemp = null;
pstmt3.close();pstmt3 = null;
System.out.println("packGrossWeight ::"+packGrossWeight);
System.out.println("packNettWeight ::"+packNettWeight);
System.out.println("noArt ::"+noArt);
......@@ -4985,29 +5194,35 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
}
//End Gulzar - 29/01/08
}
sqlTemp = "SELECT APPLY_PRICE FROM BOM WHERE BOM_CODE = '"+ itemCode +"' ";
System.out.println("sqlTemp ::"+sqlTemp);
rsTemp = stmtTemp.executeQuery(sqlTemp);
//Changed and added by Pavan R 10jan19[to handle open cursor issue]
sqlTemp = "SELECT APPLY_PRICE FROM BOM WHERE BOM_CODE = ?"; //'"+ itemCode +"' ";
//System.out.println("sqlTemp ::"+sqlTemp);
//rsTemp = stmtTemp.executeQuery(sqlTemp);
pstmt3 = conn.prepareStatement(sqlTemp);
pstmt3.setString(1, itemCode);
rsTemp = pstmt3.executeQuery();
if ( rsTemp.next() )
{
applyPrice = rsTemp.getString("APPLY_PRICE");
}
rsTemp.close();
rsTemp = null;
rsTemp.close();rsTemp = null;
pstmt3.close();pstmt3 = null;
if ( applyPrice == null )
{
sqlTemp = "SELECT DISCOUNT FROM SORDDET WHERE SALE_ORDER = '"+ sordNo +"' AND "
+" LINE_NO = '"+ lineNoOrd +"' ";
System.out.println("sqlTemp ::"+sqlTemp);
rsTemp = stmtTemp.executeQuery(sqlTemp);
{ //Changed and added by Pavan R 10jan19[to handle open cursor issue]
sqlTemp = "SELECT DISCOUNT FROM SORDDET WHERE SALE_ORDER = ?" // '"+ sordNo +"' AND "
+" AND LINE_NO = ?"; //'"+ lineNoOrd +"' ";
//System.out.println("sqlTemp ::"+sqlTemp);
//rsTemp = stmtTemp.executeQuery(sqlTemp);
pstmt3 = conn.prepareStatement(sqlTemp);
pstmt3.setString(1, sordNo);
pstmt3.setString(2, lineNoOrd);
rsTemp = pstmt3.executeQuery();
if ( rsTemp.next() )
{
discAmt = rsTemp.getDouble("DISCOUNT");
}
rsTemp.close();
rsTemp = null;
rsTemp.close();rsTemp = null;
pstmt3.close();pstmt3 = null;
discAmt = (discAmt/100) * ( qtyStd * rateStduom );
System.out.println("qtyStd from actionDefault 2 ::::::::" + qtyStd);
System.out.println("rateStduom from actionDefault 2 ::::::::" + rateStduom);
......@@ -5187,6 +5402,8 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
*/
}
}
rs2.close(); rs2 = null;
pstmt2.close(); pstmt2 = null;
}
else
{
......@@ -5341,9 +5558,13 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
}
}//while end
}//end else
rs1.close(); rs1 = null;
pstmt1.close();pstmt1 = null;
itemCodeOld = itemCodeOld+ " "+itemCode;
System.out.println("itemCodeOld :"+itemCodeOld);
}// while end
rs.close(); rs = null;
pstmt.close();pstmt = null;
//valueXmlString.append("</Root>\r\n");
}
valueXmlString.append("</Root>\r\n");
......@@ -5365,9 +5586,52 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (rs1 != null)
{
rs1.close();
rs1 = null;
}
if (rs2 != null)
{
rs2.close();
rs2 = null;
}
if (rs3 != null)
{
rs3.close();
rs3 = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if (pstmt2 != null)
{
pstmt2.close();
pstmt2 = null;
}
if (pstmt3 != null)
{
pstmt3.close();
pstmt3 = null;
}
if(conn != null)
{
conn.close();
conn = null;
}
qtyMap = null;
}catch(Exception e){}
}
......@@ -5388,7 +5652,8 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
int count = 0;
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
Connection conn = null;
Statement stmt = null, stmt1 = null;
//Statement stmt = null, stmt1 = null;//Changed and added by Pavan R 10jan19[to handle open cursor issue]
PreparedStatement pstmt = null, pstmt1 = null;
ResultSet rs = null, rs1 = null;
ConnDriver connDriver = new ConnDriver();
ibase.utility.E12GenericUtility genericUtility= new ibase.utility.E12GenericUtility();
......@@ -5402,19 +5667,22 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//Changes and Commented By Bhushan on 09-06-2016 :END
stmt = conn.createStatement();
stmt1 = conn.createStatement();
//stmt = conn.createStatement();//Changed and added by Pavan R 10jan19[to handle open cursor issue]Start
//stmt1 = conn.createStatement();
siteCode = genericUtility.getColumnValue("site_code",dom1);
sordNo = genericUtility.getColumnValue("sord_no",dom1);
lotNo = genericUtility.getColumnValue("lot_no",dom);
sql = "SELECT LINE_NO,EXP_LEV FROM SORDITEM WHERE SALE_ORDER ='"+sordNo+"' AND LINE_TYPE = 'I'";
System.out.println("sql :"+sql);
rs = stmt.executeQuery(sql);
sql = "SELECT LINE_NO,EXP_LEV FROM SORDITEM WHERE SALE_ORDER = ? AND LINE_TYPE = 'I'"; //'"+sordNo+"' AND LINE_TYPE = 'I'";
//System.out.println("sql :"+sql);
//rs = stmt.executeQuery(sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sordNo);
rs = pstmt.executeQuery();//Changed and added by Pavan R 10jan19[to handle open cursor issue] End
while (rs.next())
{
AppConnectParm appConnect = new AppConnectParm();
Properties props = appConnect.getProperty();
InitialContext ctx = new InitialContext(props);
//AppConnectParm appConnect = new AppConnectParm();
//Properties props = appConnect.getProperty();
//InitialContext ctx = new InitialContext(props);
//DespatchHome despatchHome = (DespatchHome)ctx.lookup("Despatch");
//Despatch despatchRemote = despatchHome.create();
//ValidatorHome validatorHome = (ValidatorHome)ctx.lookup("Despatch");
......@@ -5449,20 +5717,27 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
}
//sql1 = "SELECT COUNT(A.ITEM_CODE) FROM STOCK A, INVSTAT B "
sql1 = "SELECT COUNT(*) FROM STOCK A, INVSTAT B "
+"WHERE A.INV_STAT = B.INV_STAT "
+"AND A.ITEM_CODE = '"+itemCode+"' "
+"AND A.SITE_CODE = '"+siteCode+"' "
+"AND A.LOC_CODE LIKE '"+locCode+"' "
+"WHERE A.INV_STAT = B.INV_STAT "//Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
+"AND A.ITEM_CODE = ? " //'"+itemCode+"' "
+"AND A.SITE_CODE = ? " //'"+siteCode+"' "
+"AND A.LOC_CODE LIKE ? " //"+locCode+"' "
+"AND B.AVAILABLE = 'Y' "
+"AND B.USABLE = 'Y' "
+"AND A.QUANTITY > 0 ";
System.out.println("sql1 :"+sql1);
rs1 = stmt1.executeQuery(sql1);
//System.out.println("sql1 :"+sql1);
//rs1 = stmt1.executeQuery(sql1);
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, itemCode);
pstmt1.setString(2, siteCode);
pstmt1.setString(3, locCode);
rs1 = pstmt1.executeQuery();//Changed and added by Pavan R 10jan19[to handle open cursor issue] End
if (rs1.next())
{
count = rs1.getInt(1);
System.out.println("count :"+count);
}
rs1.close(); rs1 = null;
pstmt1.close(); pstmt1 = null;
if (count == 0)
{
//errCode = "";//Commented code by Jiten 09/10/06 - if count is zero then break from loop.
......@@ -5471,17 +5746,23 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
sql1 = "SELECT A.LOT_NO, A.LOT_SL, A.QUANTITY, A.EXP_DATE,A.SITE_CODE__MFG, A.MFG_DATE, "
+"A.ALLOC_QTY, A.PACK_CODE, A.LOC_CODE, A.GROSS_WEIGHT, A.TARE_WEIGHT, "
+"A.NET_WEIGHT, A.DIMENSION,A.SUPP_CODE__MFG FROM STOCK A, INVSTAT B "
+"WHERE A.INV_STAT = B.INV_STAT "
+"AND A.ITEM_CODE = '"+itemCode+"' "
+"AND A.SITE_CODE = '"+siteCode+"' "
+"AND A.LOC_CODE LIKE '"+locCode+"' "
+"WHERE A.INV_STAT = B.INV_STAT " //Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
+"AND A.ITEM_CODE = ? " //'"+itemCode+"' "
+"AND A.SITE_CODE = ? " //'"+siteCode+"' "
+"AND A.LOC_CODE LIKE ? " //"+locCode+"' "
+"AND B.AVAILABLE = 'Y' "
+"AND B.USABLE = 'Y' "
+"AND A.QUANTITY - A.ALLOC_QTY > 0 "
+"AND A.LOT_NO = '"+lotNo+"' "
+"AND A.LOT_NO = ? " //'"+lotNo+"' "
+"ORDER BY A.EXP_DATE, A.LOT_NO, A.LOT_SL ";
System.out.println("sql1 :"+sql1);
rs1 = stmt1.executeQuery(sql1);
//System.out.println("sql1 :"+sql1);
//rs1 = stmt1.executeQuery(sql1);
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, itemCode);
pstmt1.setString(2, siteCode);
pstmt1.setString(3, locCode);
pstmt1.setString(4, lotNo);//Changed and added by Pavan R 10jan19[to handle open cursor issue] End
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
lotNo = rs1.getString(1);
......@@ -5567,13 +5848,18 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
netWeight = 0;
}//end if
}// end if
rs1.close(); rs1 = null;
pstmt1.close();pstmt1 = null;
}// while end
rs.close(); rs = null;
pstmt.close(); pstmt = null;
valueXmlString.append("</Root>\r\n");
System.out.println("valueXmlString2807...."+valueXmlString);
}
catch (SQLException sqx)
{
System.out.println("The SQLException occurs in DespatchAct :"+sqx);
sqx.printStackTrace();
}
catch (Exception e)
{
......@@ -5584,7 +5870,27 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
{
try
{
if(conn !=null)
if (rs != null)
{
rs.close();
rs = null;
}
if (rs1!=null)
{
rs1.close();
rs1 = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if(conn != null)
{
System.out.println("Closing Connection.....");
conn.close();
......@@ -5667,8 +5973,8 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
{
ResultSet rs = null;
Connection conn = null;
Statement stmt = null;
//Statement stmt = null;//Changed and added by Pavan R 10jan19[to handle open cursor issue]
PreparedStatement pstmt = null;
StringBuffer valueXmlString = null;
ibase.utility.E12GenericUtility genericUtility= new ibase.utility.E12GenericUtility();
ConnDriver connDriver = new ConnDriver();
......@@ -5688,7 +5994,7 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//Changes and Commented By Bhushan on 09-06-2016 :END
stmt = conn.createStatement();
//stmt = conn.createStatement();
saleOrder = genericUtility.getColumnValue("sord_no",dom);
......@@ -5700,15 +6006,18 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
"and sorder.confirmed = 'Y' and sorddet.status <> 'C' and " +
"case when sorddet.quantity is null then 0 else sorddet.quantity end - " +
"case when despatchdet.quantity is null then 0 else despatchdet.quantity end > 0 "+
"and sorder.sale_order = '"+saleOrder+"'";
System.out.println("SQL :"+sql);
rs = stmt.executeQuery(sql);
"and sorder.sale_order = ?"; //'"+saleOrder+"'";
//Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
/*System.out.println("SQL :"+sql);
rs = stmt.executeQuery(sql);*/
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, saleOrder);
rs = pstmt.executeQuery();//Changed and added by Pavan R 10jan19[to handle open cursor issue] End
while(rs.next()){
itemCodeList.add(rs.getString(2));
itemMap.put(rs.getString(2),rs.getString(1));
}
rs.close();
rs.close();rs = null; pstmt.close(); pstmt = null;
for(int i = 0;i < itemCodeList.size(); i++){
itemCodeStr = itemCodeStr+"'"+itemCodeList.get(i)+"',";
}
......@@ -5731,7 +6040,7 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
+" 'Y' AS PROCESS_YN "
+" FROM INV_PACK, INV_PACK_RCP, STOCK "
+" WHERE INV_PACK.TRAN_ID = INV_PACK_RCP.TRAN_ID "
+" AND INV_PACK_RCP.ITEM_CODE IN ("+itemCodeStr+") "
+" AND INV_PACK_RCP.ITEM_CODE IN (?) " //("+itemCodeStr+") "
+" AND INV_PACK_RCP.ITEM_CODE = STOCK.ITEM_CODE "
+" AND INV_PACK.SITE_CODE = STOCK.SITE_CODE "
+" AND INV_PACK_RCP.LOC_CODE = STOCK.LOC_CODE "
......@@ -5742,10 +6051,13 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
+" AND (STOCK.QUANTITY - STOCK.ALLOC_QTY) > 0 "
+" AND STOCK.PACK_REF IS NOT NULL "
+" ORDER BY INV_PACK_RCP.LINE_NO ASC";
//Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
//System.out.println("SQL "+sql);
System.out.println("SQL "+sql);
rs = stmt.executeQuery(sql);
//rs = stmt.executeQuery(sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCodeStr);
rs = pstmt.executeQuery();//Changed and added by Pavan R 10jan19[to handle open cursor issue] End
valueXmlString=new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
while (rs.next())
{
......@@ -5774,8 +6086,8 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
valueXmlString.append("</Root>\r\n");
rs.close();
rs=null;
stmt.close();
stmt = null;
pstmt.close();
pstmt = null;
System.out.println("[DespatchActforWo]valueXmlString=>"+valueXmlString.toString());
System.out.println("[DespatchActforWo]isFound=>"+isFound);
if(!isFound)
......@@ -5799,13 +6111,17 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
rs.close();
rs=null;
}
if(stmt!=null)
if(pstmt!=null)
{
stmt.close();
stmt=null;
pstmt.close();
pstmt=null;
}
System.out.println("Closing Connection.....");
if(conn != null)
{
conn.close();
conn = null;
}
}catch(Exception e){}
}
System.out.println("valueXmlString.toString() "+valueXmlString.toString());
......@@ -5901,8 +6217,31 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (rs1 != null)
{
rs1.close();
rs1 = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if(conn!=null)
{
conn.close();
conn = null;
}
}
catch (Exception e)
{
......@@ -5957,6 +6296,8 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
valueXmlString.append("<site_code>").append("<![CDATA[").append(siteCode).append("]]>").append("</site_code>\r\n");
valueXmlString.append("</Detail>");
}//end While loop
rs.close(); rs = null;
pstmt.close();pstmt = null;
valueXmlString.append("</Root>\r\n");
}
catch(Exception e)
......@@ -5969,8 +6310,22 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("Closing Connection.....");
if(conn != null)
{
conn.close();
conn = null;
}
}catch(Exception e){}
}
System.out.println("Despatch:actionStock:Final Value :valueXmlString.toString():"+valueXmlString.toString());
......@@ -6160,6 +6515,7 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
pstmtUpdate.setString(5, lotNo);
pstmtUpdate.setString(6, lotSl);
update = pstmtUpdate.executeUpdate();
pstmtUpdate.close(); pstmtUpdate = null;
System.out.println("Records updated in Stock for alloc_qty :: "+update);
}
rs.close(); rs=null;
......@@ -6254,8 +6610,11 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
ResultSet rsTemp = null;
ResultSet rsTemp1 = null;
ResultSet rsTemp2 = null;
Statement stmt = null;
//Changed and added by Pavan R 10jan19[to handle open cursor issue]
//Statement stmt = null;
PreparedStatement pstmt = null;
PreparedStatement pstmt1 = null;
PreparedStatement pstmt2 = null;
double capacity = 0d;
double reoQty = 0d;
double shipperQty1 = 0d;
......@@ -6265,12 +6624,15 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
double noArt1 = 0d, noArt2 = 0d, noArt = 0d;
try
{
stmt = conn.createStatement();
//stmt = conn.createStatement();
if (qtyType.equals("S"))
{
tempSql = "SELECT (CASE WHEN CAPACITY IS NULL THEN 0 ELSE CAPACITY END) AS CAPACITY FROM PACKING WHERE PACK_CODE = '" + packCode + "'";
System.out.println("SQL :: "+tempSql);
rsTemp = stmt.executeQuery(tempSql);
tempSql = "SELECT (CASE WHEN CAPACITY IS NULL THEN 0 ELSE CAPACITY END) AS CAPACITY FROM PACKING WHERE PACK_CODE = ?"; //'" + packCode + "'";
//System.out.println("SQL :: "+tempSql);
//rsTemp = stmt.executeQuery(tempSql);
pstmt = conn.prepareStatement(tempSql);
pstmt.setString(1, packCode);
rsTemp = pstmt.executeQuery();
if (rsTemp.next())
{
capacity = rsTemp.getDouble("CAPACITY");
......@@ -6280,32 +6642,40 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
capacity = 0d;
}
tempSql = "";
rsTemp.close();
rsTemp.close();rsTemp = null;
pstmt.close(); pstmt = null;
tempSql = "SELECT REO_QTY " +
" FROM SITEITEM WHERE SITE_CODE = '" + siteCode + "' " + //by jaimin
" AND ITEM_CODE = '" + itemCode + "' ";
System.out.println("SQL :: "+tempSql);
rsTemp = stmt.executeQuery(tempSql);
" FROM SITEITEM WHERE SITE_CODE = ?" //'" + siteCode + "' " + //by jaimin
+ " AND ITEM_CODE = ? "; //'" + itemCode + "' ";
//System.out.println("SQL :: "+tempSql);
//rsTemp = stmt.executeQuery(tempSql);
pstmt = conn.prepareStatement(tempSql);
pstmt.setString(1, siteCode);
pstmt.setString(2, itemCode);
rsTemp = pstmt.executeQuery();
if (rsTemp.next())
{
reoQty = rsTemp.getDouble("REO_QTY");
}
else
{
tempSql1 = "SELECT REO_QTY FROM ITEM WHERE ITEM_CODE = '"+ itemCode +"' ";
System.out.println("SQL :: "+tempSql1);
rsTemp1 = stmt.executeQuery(tempSql1);
tempSql1 = "SELECT REO_QTY FROM ITEM WHERE ITEM_CODE = ? "; //'"+ itemCode +"' ";
//System.out.println("SQL :: "+tempSql1);
//rsTemp1 = stmt.executeQuery(tempSql1);
pstmt1 = conn.prepareStatement(tempSql1);
pstmt1.setString(1, itemCode);
rsTemp1 = pstmt1.executeQuery();
if (rsTemp1.next())
{
reoQty = rsTemp1.getDouble("REO_QTY");
}
rsTemp1.close();
rsTemp1.close();rsTemp1= null;
tempSql1 = "";
pstmt1.close(); pstmt1 = null;
}
tempSql = "";
rsTemp.close();
rsTemp.close();rsTemp = null;
pstmt.close(); pstmt = null;
if ( capacity > 0 )
{
shipperQty1 = capacity;
......@@ -6324,43 +6694,57 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
}
}
else if ( qtyType.equals("I") )
{
tempSql = "SELECT INTEGRAL_QTY FROM CUSTOMERITEM WHERE CUST_CODE = '"+ custCode +"' "
+" AND ITEM_CODE = '"+ itemCode +"' ";
System.out.println("SQL :: "+tempSql);
rsTemp = stmt.executeQuery(tempSql);
{//Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
tempSql = "SELECT INTEGRAL_QTY FROM CUSTOMERITEM WHERE CUST_CODE = ?" //'"+ custCode +"' "
+" AND ITEM_CODE = ?"; //'"+ itemCode +"' ";
//System.out.println("SQL :: "+tempSql);
//rsTemp = stmt.executeQuery(tempSql);
pstmt = conn.prepareStatement(tempSql);
pstmt.setString(1, custCode);
pstmt.setString(2, itemCode);
rsTemp = pstmt.executeQuery();
if (rsTemp.next())
{
integralQty1 = rsTemp.getDouble("INTEGRAL_QTY");
}
else
{
tempSql1 = "SELECT INTEGRAL_QTY FROM SITEITEM WHERE SITE_CODE = '"+ siteCode +"' AND "
+" ITEM_CODE = '"+ itemCode +"' ";
System.out.println("SQL :: "+tempSql1);
rsTemp1 = stmt.executeQuery(tempSql1);
tempSql1 = "SELECT INTEGRAL_QTY FROM SITEITEM WHERE SITE_CODE = ?" //'"+ siteCode +"' " +
+ " AND ITEM_CODE = ?"; // '"+ itemCode +"' ";
//System.out.println("SQL :: "+tempSql1);
//rsTemp1 = stmt.executeQuery(tempSql1);
pstmt1 = conn.prepareStatement(tempSql1);
pstmt1.setString(1, siteCode);
pstmt1.setString(2, itemCode);
rsTemp1 = pstmt1.executeQuery();
if (rsTemp1.next())
{
integralQty1 = rsTemp1.getDouble("INTEGRAL_QTY");
}
else
{
tempSql2 = "SELECT INTEGRAL_QTY FROM ITEM WHERE ITEM_CODE = '"+ itemCode +"' ";
System.out.println("SQL :: "+tempSql2);
rsTemp2 = stmt.executeQuery(tempSql2);
tempSql2 = "SELECT INTEGRAL_QTY FROM ITEM WHERE ITEM_CODE = ?"; //'"+ itemCode +"' ";
//System.out.println("SQL :: "+tempSql2);
//rsTemp2 = stmt.executeQuery(tempSql2);
pstmt2 = conn.prepareStatement(tempSql2);
pstmt2.setString(1, itemCode);
rsTemp2 = pstmt2.executeQuery();
if ( rsTemp2.next() )
{
integralQty1 = rsTemp2.getDouble("INTEGRAL_QTY");
}
rsTemp2.close();
rsTemp2.close();rsTemp2 = null;
tempSql2 = "";
pstmt2.close();pstmt2 = null;
}
rsTemp1.close();
rsTemp1.close();rsTemp1 = null;
tempSql1 = "";
pstmt1.close();pstmt1 = null;
}
tempSql = "";
rsTemp.close();
rsTemp.close();rsTemp = null;
pstmt.close();pstmt = null;
//Changed and added by Pavan R 10jan19[to handle open cursor issue] End
if ( integralQty1 > 0 )
{
noArt = (qty - (qty % integralQty1)) / integralQty1;
......@@ -6371,10 +6755,13 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
}
}
else if ( qtyType.equals("B") )
{
tempSql = "SELECT (CASE WHEN CAPACITY IS NULL THEN 0 ELSE CAPACITY END) AS CAPACITY FROM PACKING WHERE PACK_CODE = '"+ packCode +"'";
System.out.println("SQL :: "+tempSql);
rsTemp = stmt.executeQuery(tempSql);
{ //Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
tempSql = "SELECT (CASE WHEN CAPACITY IS NULL THEN 0 ELSE CAPACITY END) AS CAPACITY FROM PACKING WHERE PACK_CODE = ?"; //'"+ packCode +"'";
//System.out.println("SQL :: "+tempSql);
//rsTemp = stmt.executeQuery(tempSql);
pstmt = conn.prepareStatement(tempSql);
pstmt.setString(1, packCode);
rsTemp = pstmt.executeQuery();//Changed and added by Pavan R 10jan19[to handle open cursor issue] End
if (rsTemp.next())
{
capacity = rsTemp.getDouble("CAPACITY");
......@@ -6383,34 +6770,43 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
{
capacity = 0d;
}
tempSql = "";
rsTemp.close();
tempSql = "";//Changed and added by Pavan R 10jan19[to handle open cursor issue] Start
rsTemp.close();rsTemp = null;
pstmt.close();pstmt = null;
tempSql = "SELECT REO_QTY "
+" FROM SITEITEM "
+" WHERE SITE_CODE = '"+ siteCode +"' " //jaimin
+" AND ITEM_CODE = '"+ itemCode +"' ";
System.out.println("SQL :: "+tempSql);
rsTemp = stmt.executeQuery(tempSql);
+" WHERE SITE_CODE = ?" //'"+ siteCode +"' " //jaimin
+" AND ITEM_CODE = ?"; // '"+ itemCode +"' ";
//System.out.println("SQL :: "+tempSql);
//rsTemp = stmt.executeQuery(tempSql);
pstmt = conn.prepareStatement(tempSql);
//Changed and added by Pavan R 10jan19[to handle open cursor issue] End
pstmt.setString(1, siteCode);
pstmt.setString(2, itemCode);
rsTemp = pstmt.executeQuery();
if (rsTemp.next())
{
reoQty = rsTemp.getDouble("REO_QTY");
}
else
{
tempSql1 = "SELECT REO_QTY FROM ITEM WHERE ITEM_CODE = '"+ itemCode +"' ";
System.out.println("SQL :: "+tempSql1);
rsTemp1 =stmt.executeQuery(tempSql1);
tempSql1 = "SELECT REO_QTY FROM ITEM WHERE ITEM_CODE = ?"; //'"+ itemCode +"' ";
//System.out.println("SQL :: "+tempSql1);//Changed and added by Pavan R 10jan19[to handle open cursor issue]
//rsTemp1 =stmt.executeQuery(tempSql1);
pstmt1 = conn.prepareStatement(tempSql1);
pstmt1.setString(1, itemCode);
rsTemp1 = pstmt1.executeQuery();
if (rsTemp1.next())
{
reoQty = rsTemp1.getDouble("REO_QTY");
}
rsTemp1.close();
rsTemp1.close();rsTemp1 = null;//Added by Pavan R 10jan19[to handle open cursor issue]
tempSql1 = "";
pstmt1.close();pstmt1 = null;
}
tempSql = "";
rsTemp.close();
rsTemp.close();rsTemp = null;//Added by Pavan R 10jan19[to handle open cursor issue]
pstmt.close();pstmt = null;
if ( capacity > 0 )
{
......@@ -6426,10 +6822,13 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
remainder = ( qty % shipperQty1 );
}
tempSql = "SELECT INTEGRAL_QTY FROM CUSTOMERITEM WHERE CUST_CODE = '"+ custCode +"' "
+" AND ITEM_CODE = '"+ itemCode +"' ";
System.out.println("SQL :: "+tempSql);
rsTemp = stmt.executeQuery(tempSql);
tempSql = "SELECT INTEGRAL_QTY FROM CUSTOMERITEM WHERE CUST_CODE = ? "//'"+ custCode +"' "
+" AND ITEM_CODE = ?"; //'"+ itemCode +"' ";//Changed and added by Pavan R 10jan19[to handle open cursor issue]
//System.out.println("SQL :: "+tempSql);
//rsTemp = stmt.executeQuery(tempSql);
pstmt = conn.prepareStatement(tempSql);
pstmt.setString(1, custCode);
pstmt.setString(2, itemCode);
if (rsTemp.next())
{
integralQty1 = rsTemp.getDouble("INTEGRAL_QTY");
......@@ -6439,26 +6838,35 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
tempSql1 = "SELECT INTEGRAL_QTY "
+" FROM SITEITEM WHERE SITE_CODE = '"+ siteCode +"' "
+" AND ITEM_CODE = '"+ itemCode +"' ";
System.out.println("SQL :: "+tempSql1);
rsTemp1 = stmt.executeQuery(tempSql1);
//System.out.println("SQL :: "+tempSql1);
//rsTemp1 = stmt.executeQuery(tempSql1);//Changed and added by Pavan R 10jan19[to handle open cursor issue]
pstmt = conn.prepareStatement(tempSql1);
pstmt.setString(1, custCode);
pstmt.setString(2, itemCode);
rsTemp1 = pstmt.executeQuery();
if ( rsTemp1.next() )
{
integralQty1 = rsTemp1.getDouble("INTEGRAL_QTY");
}
else
{
tempSql2 = "SELECT INTEGRAL_QTY FROM ITEM WHERE ITEM_CODE = '"+ itemCode +"' ";
System.out.println("SQL :: "+tempSql2);
rsTemp2 = stmt.executeQuery(tempSql1);
tempSql2 = "SELECT INTEGRAL_QTY FROM ITEM WHERE ITEM_CODE = ?"; //'"+ itemCode +"' ";
//System.out.println("SQL :: "+tempSql2);//Changed and added by Pavan R 10jan19[to handle open cursor issue]
//rsTemp2 = stmt.executeQuery(tempSql1);
pstmt1 = conn.prepareStatement(tempSql2);
pstmt1.setString(1, itemCode);
rsTemp2 = pstmt1.executeQuery();
if ( rsTemp2.next() )
{
integralQty1 = rsTemp2.getDouble("INTEGRAL_QTY");
}
tempSql2 = "";
rsTemp2.close();
rsTemp2.close(); rsTemp2 = null;
pstmt1.close();pstmt1 = null;//Added by Pavan R 10jan19[to handle open cursor issue]
}
tempSql1 = "";
rsTemp1.close();
rsTemp1.close();rsTemp1 = null;//Added by Pavan R 10jan19[to handle open cursor issue]
pstmt.close();pstmt = null;
}
if ( integralQty1 > 0 )
{
......@@ -6480,6 +6888,48 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
System.out.println("Exception in getNoArt :: "+e.getMessage());
e.printStackTrace();
}
finally
{
try
{
if (rsTemp != null)
{
rsTemp.close();
rsTemp = null;
}
if (rsTemp1 != null)
{
rsTemp1.close();
rsTemp1 = null;
}
if (rsTemp2 != null)
{
rsTemp2.close();
rsTemp2 = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if (pstmt2 != null)
{
pstmt2.close();
pstmt2 = null;
}
/*if(conn != null)
{
conn.close();
conn = null;
}*/
}
catch(Exception e){}
}
result[0] = noArt;
result[1] = shipperQty1;
result[2] = integralQty1;
......@@ -8515,6 +8965,33 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
System.out.println("The Exception occure in getChangeSord for Default button:"+e);
throw new ITMException(e);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (rs1 != null)
{
rs1.close();
rs1 = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
}
catch(Exception e){}
}
/*finally
{
try
......@@ -8742,6 +9219,22 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
e.printStackTrace();
System.out.println("Exception ::"+ e.getMessage());
throw new ITMException(e);
}finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e){}
}
......@@ -8756,4 +9249,5 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment