// Unreserves inventory

static void unreserveInventTrans(Args _args)

{

InventTrans             inventTrans;

InventDim               inventDim;

InventDimParm           inventDimParm;

;

setPrefix(funcName());

 

select firstOnly inventTrans

where inventTrans.StatusIssue == StatusIssue::ReservPhysical

join inventDim

where inventDim.inventDimId == inventTrans.inventDimId

&& inventDim.inventBatchId == “M0139812”;

 

if (inventTrans.RecID)

{

setPrefix(inventTrans.caption());

 

inventDimParm = InventDimParm::activeDimFlag(inventTrans.inventTable().DimGroupId);

 

if (inventTrans.TransType == InventTransType::ProdLine)

{

switch (inventTrans.TransChildType)

{

case InventTransChildType::ProdJournalBOM:

InventUpd_Reservation::updateReserveFromForm(inventTrans.prodJournalBOM(), inventDim, inventDimParm, inventTrans.Qty);

break;

default:

InventUpd_Reservation::updateReserveFromForm(inventTrans.prodBOM(), inventDim, inventDimParm, inventTrans.Qty);

break;

}

}

else if (inventTrans.TransType == InventTransType::Sales)

{

if (inventTrans.TransChildType == InventTransChildType::InventJournalPickingList)

InventUpd_Reservation::updateReserveFromForm(inventTrans.inventPickingListJournalLine(), inventDim, inventDimParm, inventTrans.Qty);

else

InventUpd_Reservation::updateReserveFromForm(inventTrans.salesLine(), inventDim, inventDimParm, inventTrans.Qty);

}

 

inventTrans.reread();

 

if (inventTrans.StatusIssue == StatusIssue::ReservPhysical)

error(“Did not work”);

else

info(“Reservation removed”);

}

else

warning(“No reservations found”);

}