/** * ************************************************************************ Initialize Table * access - create SQL, dateColumn. <br> * The driving table is "hdr", e.g. for hdr.C_BPartner_ID=.. The line table is "lin", e.g. for * lin.M_Product_ID=.. You use the dateColumn/qtyColumn variable directly as it is table specific. * <br> * The sql is dependent on MatchMode: - If Matched - all (fully or partially) matched records are * listed - If Not Matched - all not fully matched records are listed * * @param display (Invoice, Shipment, Order) see MATCH_* * @param matchToType (Invoice, Shipment, Order) see MATCH_* */ private static void tableInit() { m_sql = new StringBuffer(); if (tableInit_option == 0) { m_sql.append( "SELECT value,tab.M_Product_ID,tab.Name " + "FROM M_Product tab " + "WHERE XX_VMR_VENDORPRODREF_ID=" + LineRefProv.getXX_VMR_VendorProdRef_ID() + " " + "AND ISACTIVE='Y' " + "AND M_ATTRIBUTESET_ID = " + Env.getCtx().getContextAsInt("#XX_L_P_ATTRIBUTESETST_ID")); /*//Si caracteristica larga es null if(LineRefProv.getXX_VMR_LongCharacteristic_ID()!=0) { m_sql.append("AND XX_VMR_LONGCHARACTERISTIC_ID="+LineRefProv.getXX_VMR_LongCharacteristic_ID()+" "); } else{ m_sql.append("AND XX_VMR_LONGCHARACTERISTIC_ID IS NULL "); }*/ m_orderBy = " order by M_Product_ID"; } else if (tableInit_option == 1) { m_sql.append( "SELECT value,tab.M_Product_ID,tab.Name " + "FROM M_Product tab " + "WHERE tab.M_Product_ID IN " + "(select M_Product from XX_VMR_REFERENCEMATRIX where XX_VMR_PO_LINEREFPROV_ID=" + (Integer) LineRefProv.getXX_VMR_PO_LineRefProv_ID() + ")"); } else if (tableInit_option == 2) { m_sql.append( "SELECT value,tab.M_Product_ID,tab.Name " + "FROM M_Product tab " + "WHERE XX_VMR_VENDORPRODREF_ID = 0 AND M_PRODUCT_ID = 0"); } } // tableInit
/** * Fill the table using m_sql * * @param table table */ private static void tableLoad(MiniTable table) { // log.finest(m_sql + " - " + m_groupBy); String sql = MRole.getDefault() .addAccessSQL(m_sql.toString(), "tab", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO) + m_groupBy + m_orderBy; log.finest(sql); try { Statement stmt = DB.createStatement(); ResultSet rs = stmt.executeQuery(sql); table.loadTable(rs); stmt.close(); } catch (SQLException e) { log.log(Level.SEVERE, sql, e); } } // tableLoad