// check components availability in the specified warehouse and remove components from it...
ItemAvailabilityVO availVO = null;
java.util.List list = null;
BigDecimal availability = new BigDecimal(0);
BigDecimal qty,delta;
WarehouseMovementVO movVO = null;
int i;
ArrayList serialNumbers = new ArrayList();
for(int j=0;j<components.size();j++) {
compVO = (ProdOrderComponentVO)components.get(j);
qty = compVO.getQtyDOC24();
list = compVO.getAvailabilities();
availability = new BigDecimal(0);
for(i=0;i<list.size();i++) {
availVO = (ItemAvailabilityVO)list.get(i);
availability = availability.add(availVO.getAvailableQtyWAR03());
}
if (availability.doubleValue()<qty.doubleValue()) {
return new VOResponse(
compVO.getItemCodeItm01DOC24()+" "+
t1+".\n"+
t2+": "+availability.doubleValue()+" "+
t3+": "+qty.doubleValue()
);
}
// the current component is available: it will be removed...
i=0;
while(qty.doubleValue()>0) {
availVO = (ItemAvailabilityVO)list.get(i);
if (qty.doubleValue()>availVO.getAvailableQtyWAR03().doubleValue()) {
delta = availVO.getAvailableQtyWAR03();
qty = qty.subtract(delta);
}
else {
delta = qty;
qty = new BigDecimal(0);
}
// insert record in DOC24...
compVO.setProgressiveHie01DOC24(availVO.getProgressiveHie01WAR03());
compVO.setLocationDescriptionSYS10(availVO.getLocationDescriptionSYS10());
pstmt2.setString(1, vo.getCompanyCodeSys01DOC22());
pstmt2.setBigDecimal(2, vo.getDocYearDOC22());
pstmt2.setBigDecimal(3, vo.getDocNumberDOC22());
pstmt2.setString(4, compVO.getItemCodeItm01DOC24());
pstmt2.setBigDecimal(5, delta);
pstmt2.setBigDecimal(6, compVO.getProgressiveHie01DOC24());
pstmt2.setString(7,username);
pstmt2.setTimestamp(8,new java.sql.Timestamp(System.currentTimeMillis()));
pstmt2.execute();
// create a warehouse movement...
movVO = new WarehouseMovementVO(
availVO.getProgressiveHie01WAR03(),
delta,
vo.getCompanyCodeSys01DOC22(),
vo.getWarehouseCodeWar01DOC22(),
compVO.getItemCodeItm01DOC24(),