BF2033057 Error during test of Multi Level BOM & Formula Detail
This commit is contained in:
parent
daaca91362
commit
4cbb4cc005
|
@ -22,6 +22,8 @@ import java.sql.SQLException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import javax.sql.RowSet;
|
||||||
|
|
||||||
import org.compiere.model.MQuery;
|
import org.compiere.model.MQuery;
|
||||||
import org.compiere.model.PrintInfo;
|
import org.compiere.model.PrintInfo;
|
||||||
import org.compiere.print.MPrintFormat;
|
import org.compiere.print.MPrintFormat;
|
||||||
|
@ -29,54 +31,51 @@ import org.compiere.print.ReportCtl;
|
||||||
import org.compiere.print.ReportEngine;
|
import org.compiere.print.ReportEngine;
|
||||||
import org.compiere.process.ProcessInfoParameter;
|
import org.compiere.process.ProcessInfoParameter;
|
||||||
import org.compiere.process.SvrProcess;
|
import org.compiere.process.SvrProcess;
|
||||||
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Language;
|
import org.compiere.util.Language;
|
||||||
|
import org.compiere.util.ValueNamePair;
|
||||||
import org.eevolution.model.X_RV_PP_Product_BOMLine;
|
import org.eevolution.model.X_RV_PP_Product_BOMLine;
|
||||||
import org.eevolution.model.X_T_BOMLine;
|
import org.eevolution.model.X_T_BOMLine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BOM lines explosion for print
|
* Multi-Level BOM & Formula Detail
|
||||||
*
|
*
|
||||||
* @author victor.perez@e-evolution.com,Sergio Ramazzina
|
* @author victor.perez@e-evolution.com,Sergio Ramazzina
|
||||||
* @version $Id: PrintBOM.java,v 1.2 2005/04/19 12:54:30 srama Exp $
|
* @version $Id: PrintBOM.java,v 1.2 2005/04/19 12:54:30 srama Exp $
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class PrintBOM extends SvrProcess {
|
public class PrintBOM extends SvrProcess
|
||||||
|
{
|
||||||
private static final Properties ctx = Env.getCtx();
|
private static final Properties ctx = Env.getCtx();
|
||||||
|
|
||||||
private int p_M_Product_ID = 0;
|
private int p_M_Product_ID = 0;
|
||||||
|
|
||||||
private boolean p_implosion = false;
|
private boolean p_implosion = false;
|
||||||
|
|
||||||
private int LevelNo = 1;
|
private int LevelNo = 1;
|
||||||
|
|
||||||
private int SeqNo = 0;
|
private int SeqNo = 0;
|
||||||
|
|
||||||
private String levels = new String("....................");
|
private String levels = new String("....................");
|
||||||
|
|
||||||
private int AD_PInstance_ID = 0;
|
private int AD_PInstance_ID = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare - e.g., get Parameters.
|
* Prepare - e.g., get Parameters.
|
||||||
*/
|
*/
|
||||||
protected void prepare() {
|
protected void prepare()
|
||||||
|
{
|
||||||
ProcessInfoParameter[] para = getParameter();
|
ProcessInfoParameter[] para = getParameter();
|
||||||
|
|
||||||
for (int i = 0; i < para.length; i++) {
|
for (int i = 0; i < para.length; i++)
|
||||||
|
{
|
||||||
String name = para[i].getParameterName();
|
String name = para[i].getParameterName();
|
||||||
|
|
||||||
if (para[i].getParameter() == null)
|
if (para[i].getParameter() == null)
|
||||||
;
|
;
|
||||||
else if (name.equals("M_Product_ID")) {
|
else if (name.equals("M_Product_ID"))
|
||||||
p_M_Product_ID = ((BigDecimal) para[i].getParameter())
|
{
|
||||||
.intValue();
|
p_M_Product_ID = ((BigDecimal) para[i].getParameter()).intValue();
|
||||||
|
}
|
||||||
} else if (name.equals("Implosion")) {
|
else if (name.equals("Implosion"))
|
||||||
p_implosion = ((String) para[i].getParameter()).equals("N") ? false
|
{
|
||||||
: true;
|
p_implosion = ((String) para[i].getParameter()).equals("N") ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
log.log(Level.SEVERE, "prepare - Unknown Parameter: " + name);
|
log.log(Level.SEVERE, "prepare - Unknown Parameter: " + name);
|
||||||
}
|
}
|
||||||
|
@ -84,55 +83,81 @@ public class PrintBOM extends SvrProcess {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform process.
|
* Perform process.
|
||||||
|
*
|
||||||
* @return Message (clear text)
|
* @return Message (clear text)
|
||||||
* @throws Exception if not successful
|
* @throws Exception
|
||||||
|
* if not successful
|
||||||
*/
|
*/
|
||||||
protected String doIt() throws Exception {
|
protected String doIt() throws Exception
|
||||||
|
{
|
||||||
AD_PInstance_ID = getAD_PInstance_ID();
|
AD_PInstance_ID = getAD_PInstance_ID();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
loadBOM();
|
loadBOM();
|
||||||
|
|
||||||
print();
|
print();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, "PrintBOM", e.toString());
|
||||||
|
throw new Exception(e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
String sql = "DELETE FROM T_BomLine WHERE AD_PInstance_ID = " + AD_PInstance_ID;
|
||||||
|
DB.executeUpdate(sql, null);
|
||||||
|
}
|
||||||
|
|
||||||
return "@ProcessOK@";
|
return "@OK@";
|
||||||
} // doIt
|
} // doIt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print result generate for this report
|
* Print result generate for this report
|
||||||
*/
|
*/
|
||||||
void print() {
|
void print() throws Exception
|
||||||
|
{
|
||||||
Language language = Language.getLoginLanguage(); // Base Language
|
Language language = Language.getLoginLanguage(); // Base Language
|
||||||
//try current client first, then system
|
MPrintFormat pf = null;
|
||||||
int pfid = MPrintFormat.getPrintFormat_ID("Multi Level BOM & Formula Detail",
|
int pfid = 0;
|
||||||
X_RV_PP_Product_BOMLine.Table_ID, getAD_Client_ID());
|
|
||||||
if (pfid < 0)
|
// get print format for client, else copy system to client
|
||||||
pfid = MPrintFormat.getPrintFormat_ID("Multi Level BOM & Formula Detail",
|
RowSet pfrs = MPrintFormat.getAccessiblePrintFormats(X_RV_PP_Product_BOMLine.Table_ID, -1, null);
|
||||||
X_RV_PP_Product_BOMLine.Table_ID, 0);
|
pfrs.next();
|
||||||
|
pfid = pfrs.getInt("AD_PrintFormat_ID");
|
||||||
|
|
||||||
|
if(pfrs.getInt("AD_Client_ID") != 0) pf = MPrintFormat.get(getCtx(), pfid, false);
|
||||||
|
else pf = MPrintFormat.copyToClient(getCtx(), pfid, getAD_Client_ID());
|
||||||
|
pfrs.close();
|
||||||
|
|
||||||
|
if (pf == null) raiseError("Error: ","No Print Format");
|
||||||
|
|
||||||
MPrintFormat pf = MPrintFormat.get(getCtx(), pfid, false);
|
|
||||||
pf.setLanguage(language);
|
pf.setLanguage(language);
|
||||||
pf.setTranslationLanguage(language);
|
pf.setTranslationLanguage(language);
|
||||||
// query
|
// query
|
||||||
MQuery query = MQuery.get(getCtx(), AD_PInstance_ID, "RV_PP_Product_BOMLine");
|
MQuery query = MQuery.get(getCtx(), AD_PInstance_ID, X_RV_PP_Product_BOMLine.Table_Name);
|
||||||
query.addRestriction("AD_PInstance_ID", MQuery.EQUAL, AD_PInstance_ID);
|
query.addRestriction("AD_PInstance_ID", MQuery.EQUAL, AD_PInstance_ID);
|
||||||
// Engine
|
|
||||||
PrintInfo info = new PrintInfo("RV_PP_Product_BOMLine", X_RV_PP_Product_BOMLine.Table_ID, getRecord_ID());
|
PrintInfo info = new PrintInfo(X_RV_PP_Product_BOMLine.Table_Name,
|
||||||
|
X_RV_PP_Product_BOMLine.Table_ID, getRecord_ID());
|
||||||
ReportEngine re = new ReportEngine(getCtx(), pf, query, info);
|
ReportEngine re = new ReportEngine(getCtx(), pf, query, info);
|
||||||
|
|
||||||
ReportCtl.preview(re);
|
ReportCtl.preview(re);
|
||||||
|
// wait for report window to be closed as t_bomline
|
||||||
String sql = "DELETE FROM T_BomLine WHERE AD_PInstance_ID = " + AD_PInstance_ID;
|
// records are deleted when process ends
|
||||||
DB.executeUpdate(sql, get_TrxName());
|
while (re.getView().isDisplayable())
|
||||||
|
{
|
||||||
|
Env.sleep(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: Fill Tree with all nodes
|
* Action: Fill Tree with all nodes
|
||||||
*/
|
*/
|
||||||
private void loadBOM() {
|
private void loadBOM() throws Exception
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
if (p_M_Product_ID == 0)
|
if (p_M_Product_ID == 0)
|
||||||
return;
|
raiseError("Error: ","Product ID not found");
|
||||||
|
|
||||||
X_T_BOMLine tboml = new X_T_BOMLine(ctx, 0, null);
|
X_T_BOMLine tboml = new X_T_BOMLine(ctx, 0, null);
|
||||||
tboml.setPP_Product_BOM_ID(0);
|
tboml.setPP_Product_BOM_ID(0);
|
||||||
|
@ -146,61 +171,93 @@ public class PrintBOM extends SvrProcess {
|
||||||
tboml.setAD_PInstance_ID(AD_PInstance_ID);
|
tboml.setAD_PInstance_ID(AD_PInstance_ID);
|
||||||
tboml.save();
|
tboml.save();
|
||||||
|
|
||||||
if (p_implosion) {
|
if (p_implosion)
|
||||||
|
{
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
String sql = new String(
|
String sql = "SELECT PP_Product_BOMLine_ID FROM PP_Product_BOMLine "
|
||||||
"SELECT PP_Product_BOMLine_ID FROM PP_Product_BOMLine WHERE IsActive = 'Y' AND M_Product_ID = ? ");
|
+ "WHERE IsActive = 'Y' AND M_Product_ID = ? ";
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
stmt = DB.prepareStatement(sql, get_TrxName());
|
stmt = DB.prepareStatement(sql, get_TrxName());
|
||||||
stmt.setInt(1, p_M_Product_ID);
|
stmt.setInt(1, p_M_Product_ID);
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next())
|
||||||
|
{
|
||||||
parentImplotion(rs.getInt(1));
|
parentImplotion(rs.getInt(1));
|
||||||
|
++count;
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
if (count == 0)
|
||||||
log.log(Level.SEVERE, "explodeBOM ", e);
|
raiseError("Error: ","Product is not a component");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
catch (SQLException e)
|
||||||
} else {
|
{
|
||||||
|
log.log(Level.SEVERE, e.getLocalizedMessage() + sql, e);
|
||||||
|
throw new Exception("SQLException: "+e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DB.close(rs, stmt);
|
||||||
|
rs = null;
|
||||||
|
stmt = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
String sql = new String(
|
String sql = "SELECT PP_Product_BOM_ID FROM PP_Product_BOM "
|
||||||
"SELECT PP_Product_BOM_ID FROM PP_Product_BOM WHERE IsActive = 'Y' AND M_Product_ID = ? ");
|
+ "WHERE IsActive = 'Y' AND M_Product_ID = ? ";
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
stmt = DB.prepareStatement(sql, get_TrxName());
|
stmt = DB.prepareStatement(sql, get_TrxName());
|
||||||
stmt.setInt(1, p_M_Product_ID);
|
stmt.setInt(1, p_M_Product_ID);
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next())
|
||||||
|
{
|
||||||
parentExplotion(rs.getInt(1));
|
parentExplotion(rs.getInt(1));
|
||||||
|
++count;
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
if (count == 0)
|
||||||
log.log(Level.SEVERE, "explodeBOM ", e);
|
raiseError("Error: ","Product is not a BOM");
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, e.getLocalizedMessage() + sql, e);
|
||||||
|
throw new Exception("SQLException: "+e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DB.close(rs, stmt);
|
||||||
|
rs = null;
|
||||||
|
stmt = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate an Implotion for this BOM Line
|
* Generate an Implotion for this BOM Line
|
||||||
* @param PP_Product_BOMLine_ID ID BOM Line
|
*
|
||||||
|
* @param PP_Product_BOMLine_ID
|
||||||
|
* ID BOM Line
|
||||||
*/
|
*/
|
||||||
public void parentImplotion(int PP_Product_BOMLine_ID) {
|
public void parentImplotion(int PP_Product_BOMLine_ID) throws Exception
|
||||||
|
{
|
||||||
|
int PP_Product_BOM_ID = 0;
|
||||||
|
int M_Product_ID = 0;
|
||||||
|
|
||||||
X_T_BOMLine tboml = new X_T_BOMLine(ctx, 0, null);
|
X_T_BOMLine tboml = new X_T_BOMLine(ctx, 0, null);
|
||||||
int PP_Product_BOM_ID = DB
|
|
||||||
.getSQLValue(
|
PP_Product_BOM_ID = DB.getSQLValue(null,
|
||||||
null,
|
"SELECT PP_Product_BOM_ID FROM PP_Product_BOMLine WHERE PP_Product_BOMLine_ID=?",PP_Product_BOMLine_ID);
|
||||||
"SELECT PP_Product_BOM_ID FROM PP_Product_BOMLine WHERE PP_Product_BOMLine_ID=?",
|
if (PP_Product_BOM_ID < 0)
|
||||||
PP_Product_BOMLine_ID);
|
throw new Exception(CLogger.retrieveErrorString("Error: PrintBOM.parentImplotion()"));
|
||||||
int M_Product_ID = DB
|
M_Product_ID = DB.getSQLValue(null,
|
||||||
.getSQLValue(
|
"SELECT M_Product_ID FROM PP_Product_BOM WHERE PP_Product_BOM_ID=?", PP_Product_BOM_ID);
|
||||||
null,
|
if (M_Product_ID < 0)
|
||||||
"SELECT M_Product_ID FROM PP_Product_BOM WHERE PP_Product_BOM_ID=?",
|
throw new Exception(CLogger.retrieveErrorString("Error: PrintBOM.parentImplotion()"));
|
||||||
PP_Product_BOM_ID);
|
|
||||||
tboml.setPP_Product_BOM_ID(PP_Product_BOM_ID);
|
tboml.setPP_Product_BOM_ID(PP_Product_BOM_ID);
|
||||||
tboml.setPP_Product_BOMLine_ID(PP_Product_BOMLine_ID);
|
tboml.setPP_Product_BOMLine_ID(PP_Product_BOMLine_ID);
|
||||||
tboml.setM_Product_ID(M_Product_ID);
|
tboml.setM_Product_ID(M_Product_ID);
|
||||||
|
@ -210,8 +267,7 @@ public class PrintBOM extends SvrProcess {
|
||||||
|
|
||||||
if (LevelNo >= 11)
|
if (LevelNo >= 11)
|
||||||
tboml.setLevels(levels + ">" + LevelNo);
|
tboml.setLevels(levels + ">" + LevelNo);
|
||||||
else if (LevelNo >= 1)
|
else if (LevelNo >= 1) tboml.setLevels(levels.substring(0, LevelNo) + LevelNo);
|
||||||
tboml.setLevels(levels.substring(0, LevelNo) + LevelNo);
|
|
||||||
|
|
||||||
tboml.setSeqNo(SeqNo);
|
tboml.setSeqNo(SeqNo);
|
||||||
tboml.setAD_PInstance_ID(AD_PInstance_ID);
|
tboml.setAD_PInstance_ID(AD_PInstance_ID);
|
||||||
|
@ -219,41 +275,52 @@ public class PrintBOM extends SvrProcess {
|
||||||
|
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
String sql = new String(
|
String sql = "SELECT PP_Product_BOM_ID, M_Product_ID FROM PP_Product_BOM "
|
||||||
"SELECT PP_Product_BOM_ID, M_Product_ID FROM PP_Product_BOM WHERE IsActive = 'Y' AND M_Product_ID = ? ");
|
+ "WHERE IsActive = 'Y' AND M_Product_ID = ? ";
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
stmt = DB.prepareStatement(sql, get_TrxName());
|
stmt = DB.prepareStatement(sql, get_TrxName());
|
||||||
stmt.setInt(1, M_Product_ID);
|
stmt.setInt(1, M_Product_ID);
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next())
|
||||||
|
{
|
||||||
SeqNo += 1;
|
SeqNo += 1;
|
||||||
component(rs.getInt(2));
|
component(rs.getInt(2));
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
|
||||||
log.log(Level.SEVERE, "explodeBOM ", e);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, e.getLocalizedMessage() + sql, e);
|
||||||
|
throw new Exception("SQLException: "+e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DB.close(rs, stmt);
|
||||||
|
rs = null;
|
||||||
|
stmt = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate an Explotion for this BOM
|
* Generate an Explotion for this BOM
|
||||||
* @param PP_Product_BOMLine_ID ID BOM Line
|
*
|
||||||
|
* @param PP_Product_BOMLine_ID
|
||||||
|
* ID BOM Line
|
||||||
*/
|
*/
|
||||||
public void parentExplotion(int PP_Product_BOM_ID) {
|
public void parentExplotion(int PP_Product_BOM_ID) throws Exception
|
||||||
|
{
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
String sql = new String(
|
String sql = "SELECT PP_Product_BOMLine_ID, M_Product_ID FROM PP_Product_BOMLine boml "
|
||||||
"SELECT PP_Product_BOMLine_ID, M_Product_ID FROM PP_Product_BOMLine boml "
|
+ "WHERE IsActive = 'Y' AND PP_Product_BOM_ID = ? ORDER BY Line ";
|
||||||
+ "WHERE IsActive = 'Y' AND PP_Product_BOM_ID = ? ORDER BY Line ");
|
try
|
||||||
try {
|
{
|
||||||
stmt = DB.prepareStatement(sql, get_TrxName());
|
stmt = DB.prepareStatement(sql, get_TrxName());
|
||||||
stmt.setInt(1, PP_Product_BOM_ID);
|
stmt.setInt(1, PP_Product_BOM_ID);
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
|
while (rs.next())
|
||||||
while (rs.next()) {
|
{
|
||||||
|
|
||||||
SeqNo += 1;
|
SeqNo += 1;
|
||||||
X_T_BOMLine tboml = new X_T_BOMLine(ctx, 0, null);
|
X_T_BOMLine tboml = new X_T_BOMLine(ctx, 0, null);
|
||||||
tboml.setPP_Product_BOM_ID(PP_Product_BOM_ID);
|
tboml.setPP_Product_BOM_ID(PP_Product_BOM_ID);
|
||||||
|
@ -268,75 +335,109 @@ public class PrintBOM extends SvrProcess {
|
||||||
tboml.save();
|
tboml.save();
|
||||||
component(rs.getInt(2));
|
component(rs.getInt(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
log.log(Level.SEVERE, "explodeBOM ", e);
|
|
||||||
}
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, e.getLocalizedMessage() + sql, e);
|
||||||
|
throw new Exception("SQLException: "+e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DB.close(rs, stmt);
|
||||||
|
rs = null;
|
||||||
|
stmt = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find if this product as component
|
* Find if this product as component
|
||||||
* @param M_Product_ID ID Component
|
*
|
||||||
|
* @param M_Product_ID
|
||||||
|
* ID Component
|
||||||
*/
|
*/
|
||||||
public void component(int M_Product_ID) {
|
public void component(int M_Product_ID) throws Exception
|
||||||
|
{
|
||||||
if (p_implosion) {
|
if (p_implosion)
|
||||||
|
{
|
||||||
LevelNo += 1;
|
LevelNo += 1;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
String sql = new String(
|
String sql = "SELECT PP_Product_BOMLine_ID FROM PP_Product_BOMLine "
|
||||||
"SELECT PP_Product_BOMLine_ID FROM PP_Product_BOMLine WHERE IsActive = 'Y' AND M_Product_ID = ? ");
|
+ "WHERE IsActive = 'Y' AND M_Product_ID = ? ";
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
stmt = DB.prepareStatement(sql, get_TrxName());
|
stmt = DB.prepareStatement(sql, get_TrxName());
|
||||||
stmt.setInt(1, M_Product_ID);
|
stmt.setInt(1, M_Product_ID);
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
boolean level = false;
|
while (rs.next())
|
||||||
while (rs.next()) {
|
{
|
||||||
parentImplotion(rs.getInt(1));
|
parentImplotion(rs.getInt(1));
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
LevelNo -= 1;
|
LevelNo -= 1;
|
||||||
return;
|
return;
|
||||||
} catch (SQLException e) {
|
|
||||||
log.log(Level.SEVERE, "explodeBOM ", e);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
catch (SQLException e)
|
||||||
} else {
|
{
|
||||||
|
log.log(Level.SEVERE, e.getLocalizedMessage() + sql, e);
|
||||||
|
throw new Exception("SQLException: "+e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DB.close(rs, stmt);
|
||||||
|
rs = null;
|
||||||
|
stmt = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
String sql = "SELECT PP_Product_BOM_ID FROM PP_Product_BOM "
|
||||||
|
+ "WHERE IsActive = 'Y' AND Value = ? ";
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
String sql = new String(
|
try
|
||||||
"SELECT PP_Product_BOM_ID FROM PP_Product_BOM WHERE IsActive = 'Y' AND Value = ? ");
|
{
|
||||||
try {
|
String Value = DB.getSQLValueString(get_TrxName(),
|
||||||
|
"SELECT Value FROM M_PRODUCT WHERE M_PRODUCT_ID=?", M_Product_ID);
|
||||||
|
if (Value == null)
|
||||||
|
{
|
||||||
|
throw new Exception(CLogger.retrieveErrorString("Error: PrintBOM.component()"));
|
||||||
|
}
|
||||||
stmt = DB.prepareStatement(sql, get_TrxName());
|
stmt = DB.prepareStatement(sql, get_TrxName());
|
||||||
String Value = DB.getSQLValueString(null,
|
|
||||||
"SELECT Value FROM M_PRODUCT WHERE M_PRODUCT_ID=?",
|
|
||||||
M_Product_ID);
|
|
||||||
stmt.setString(1, Value);
|
stmt.setString(1, Value);
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
boolean level = false;
|
boolean level = false;
|
||||||
while (rs.next()) {
|
while (rs.next())
|
||||||
if (!level)
|
{
|
||||||
LevelNo += 1;
|
if (!level) LevelNo += 1;
|
||||||
|
|
||||||
level = true;
|
level = true;
|
||||||
parentExplotion(rs.getInt(1));
|
parentExplotion(rs.getInt(1));
|
||||||
LevelNo -= 1;
|
LevelNo -= 1;
|
||||||
}
|
}
|
||||||
rs.close();
|
}
|
||||||
stmt.close();
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, e.getLocalizedMessage() + sql, e);
|
||||||
|
throw new Exception("SQLException: "+e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DB.close(rs, stmt);
|
||||||
|
rs = null;
|
||||||
|
stmt = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
} catch (SQLException e) {
|
private void raiseError(String string, String hint) throws Exception
|
||||||
log.log(Level.SEVERE, "explodeBOM ", e);
|
{
|
||||||
|
String msg = string;
|
||||||
}
|
ValueNamePair pp = CLogger.retrieveError();
|
||||||
|
if (pp != null) msg = pp.getName() + " - ";
|
||||||
}
|
msg += hint;
|
||||||
|
throw new Exception(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue