Hi Judy,
thank you but the solution works for InventUpd_reservation (in the updateReserveMore method) but in my solution the class is the InventUpd_WHSReservation that use strategies for search the batch...
I found an article that i have used for my issue
cloudblogs.microsoft.com/.../
Here i share my solution
I create an extension of the class whsInventBatchReserveQueryBuilder
In this class I CoC for add the filter in the query ...
Here my code:
[ExtensionOf(classStr(whsInventBatchReserveQueryBuilder))]
public final class whsInventBatchReserveQueryBuilder_MB9870_Extension
{
private VendAccount _VendAccount;
private boolean _FilterByVendAccount = false;
public VendAccount parmVendAccount(VendAccount _value = _VendAccount)
{
_VendAccount = _value;
return _VendAccount;
}
public boolean parmFilterByVendAccount(boolean _value = _FilterByVendAccount)
{
_FilterByVendAccount = _value;
return _FilterByVendAccount;
}
public Query buildOnHandQuery()
{
Query query = next buildOnHandQuery();
if(_FilterByVendAccount && _VendAccount != "")
{
QueryBuildDataSource qbdsInventBatch = query.dataSourceTable(tableNum(InventBatch));
qbdsInventBatch.addRange(fieldNum(InventBatch,VendAccount)).value(_VendAccount);
}
return query;
}
}
and I use this method for call the reservation
-------------------------------------------------------------------
public void ReserveSalesLine(SalesLine salesLine, InventQty reserveQty)
{
InventUpd_Reservation reservation;
List strategyList;
InventMovement movement;
movement = InventMovement::construct(salesLine);
reservation = InventUpd_Reservation::newMovement(movement,-reserveQty, true, false);
strategyList = new List(Types::Class);
whsReservationHierarchyLevelStrategy marketStrategy =
WHSReservationHierarchyLevelStrategy::newFromStrategyType(WHSReservationHierarchyLevelStrategyType::AllNotAllowedBlank,
movement.inventTable(), movement.inventdim());
strategyList.addEnd(marketStrategy);
WHSReservationHierarchyLevel reservationHierarchyLevel = marketStrategy.getReservationHierarchyLevel();
reservation.setWHSReservationHierarchyStrategyList(strategyList);
// we could also take control of the queries used to find on-hand, for example adding some ordering on Status using :
whsInventBatchReserveQueryBuilder query = whsInventBatchReserveQueryBuilder::construct();
query.parmItemId(movement.itemId());
query.parmInventDimCriteria(reservation.parmInventDimCriteria());
query.parmInventDimParmCriteria(reservation.parmInventDimParm());
query.parmReservationHierarchyLevel(reservationHierarchyLevel);
query.parmIncludePhysical(true);
query.parmVendAccount(salesLine.VendAccount);
query.parmFilterByVendAccount(true);
reservation.setWHSInventReserveQueryBuilder(query);
//now we are reserving with all dimensions above location
reservation.updateNow();
}
}