Example 1:
int count_ok = 0;
int count_err = 0;
POResultSet<MDepreciationExp> rs = new Query(getCtx(), MDepreciationExp.Table_Name,
"A_Asset_ID=? AND DateAcct <= '" + df.format(p_DateAcct) + "'", get_TrxName())
.setParameters(new Object[]{a.get_ID()})
.setOrderBy(MDepreciationExp.COLUMNNAME_A_Period)
.scroll();
rs.setCloseOnError(true);
while(rs.hasNext())
{
MDepreciationExp dep = rs.next();
try
{
//System.out.println(dep.get_ID());
MDepreciationExp depexp = new MDepreciationExp(getCtx(), dep.get_ID(), get_TrxName());
depexp.process();
count_ok++;
}
catch(Exception e)
{
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
count_err++;
}
}
rs.close();
return "@Ok@ #"+count_ok+" @Error@ #"+count_err;
Example 2:
boolean b = false;
List<MLocator> locs = new Query(Env.getCtx(), MLocator.Table_Name,MLocator.COLUMNNAME_Value + "=?", get_TrxName())
.setParameters(value)
.setClient_ID().setOnlyActiveRecords(true).list();
for (MLocator loc:locs)
{
//System.out.println(loc.getValue() + " EXISTS !!!");
b = true;
}
Example 3:
//delete old locators first?
List<MLocator> oldlocs = new Query(Env.getCtx(),MLocator.Table_Name,MLocator.COLUMNNAME_M_Warehouse_ID+"=? AND M_Locator_ID>999999 ",get_TrxName())
.setParameters(whse.get_ID())
.setClient_ID()
.list();
for (MLocator loc:oldlocs)
{
MStorageOnHand soh = new Query(Env.getCtx(),MStorageOnHand.Table_Name,MStorageOnHand.COLUMNNAME_M_Locator_ID+"=?",get_TrxName())
.setParameters(loc.get_ID())
.first();
if (soh==null)
{
log.info("Old locator deleted:"+loc.getValue());
//loc.delete(false);
}
}
No hay comentarios:
Publicar un comentario