Hi ! I have a transfer order, and i need to make a receive of only some of the products. The code i have, marks the entire order as received.
If i only execute the last 2 lines of code "itur = InventTransferUpdReceive::newParmBuffer(itpt); itur.run(); ", then nothing gets marked as received. Here is the code:
private void receiveProducts(inventTransferId _transferId, Map mapQtyArtSFull)
{
InventTransferParmTable itpt;
InventTransferParmLine itpl;
InventTransferUpdReceive itur;
boolean transferHasPendingItems;//si aun faltan recibir otros productos, no completo el recibo
WMSJournalTrans wmsJournalTrans;
;
itpt.clear();
itpt.initParmDefault();
//add check to make sure this is only posted if it needs to be posted
itpt.ParmId = RunBaseMultiParm::getSysParmId();
itpt.TransferId = _transferId;
itpt.UpdateType = InventTransferUpdateType::Receive;
itpt.PrintTransferReceipt = NoYes::No;
itpt.ReceiveUpdateQty = InventTransferReceiveUpdateQty::All; //<--funciona con ALL, estaba registered
itpt.EditLines = NoYes::Yes;
itpt.ExplodeLines = NoYes::Yes;
//itpt.InventDimFixedReceiveList = 245; // See note below on how to compute this.
itpt.InventDimFixedReceiveList = 0; // See note below on how to compute this.
itpt.createLines(NoYes::Yes);
while select forUpdate itpl
where itpl.ParmId == itpt.ParmId
{
if (mapQtyArtSFull.exists(itpl.ItemId))
{
itpl.QtyReceiveNow = mapQtyArtSFull.lookup(itpl.ItemId);
}
else
{
itpl.QtyReceiveNow = 0;
}
itpl.update();
}
itur = InventTransferUpdReceive::newParmBuffer(itpt);
itur.run();
}
And this is the code that generates the order:
private InventTransferId inventJournalTransfer(Map mapQtyArtSFull, InventSiteId inventSiteId, InventLocationId inventLocationIdFrom, InventLocationId inventLocationIdTo, PackingSlipId packingList)
{
InventTransferTable inventTransferTable;
InventTransferLine inventTransferLine;
InventDim inventDim;
InventTable inventTable;
InventTransferParmLine inventTransferParmLine;
InventTransferParmTable inventTransferParmTable;
inventTransferUpdShip inventTransferUpdShip;
MapEnumerator mapEnumerator;
// Ctr_LogisticSeries ctr_LogisticSeries;
;
//Order headerInventTransferParmLine
inventTransferTable.clear();
inventTransferTable.initValue();
inventTransferTable.TransferId = InventTransferTable::numberSeq().num();
inventTransferTable.InventLocationIdFrom = inventLocationIdFrom;
inventTransferTable.InventLocationIdTo = inventLocationIdTo;
inventTransferTable.PackingList = PackingList;
inventTransferTable.DlvModeId = CustVendTransportPointLine::defaultDeliveryMode(inventTransferTable.InventLocationIdFrom,'','','','',inventTransferTable.InventLocationIdTo);
inventTransferTable.InventLocationIdTransit = InventLocation::find(inventTransferTable.InventLocationIdFrom).InventLocationIdTransit;
inventTransferTable.initFromAddress();
inventTransferTable.initToAddress();
inventTransferTable.ShipDate = SystemDateget();
inventTransferTable.ReceiveDate = SystemDateget();
if (inventTransferTable.validateWrite())
{
inventTransferTable.insert();
mapEnumerator = mapQtyArtSFull.getEnumerator();
while (mapEnumerator.moveNext())
{
select firstonly inventTable
where inventTable.itemId == mapEnumerator.currentKey();
//Order line
inventDim.clear();
inventDim.InventSiteId = inventSiteId;
inventDim.InventLocationId = inventLocationIdTo;
inventTransferLine.clear();
inventTransferLine.initValue();
inventTransferLine.ItemId = inventTable.ItemId;
inventTransferLine.InventDimId = InventDim::findOrCreate(inventDim).inventDimId;
inventTransferLine.QtyTransfer = mapEnumerator.currentValue();
//inventTransferLine.PackingList = packingList;
inventTransferLine.initFromInventTableModule(InventTableModule::find(inventTransferLine.ItemId,ModuleInventPurchSales::Invent));
inventTransferLine.QtyRemainReceive = inventTransferLine.QtyTransfer;
inventTransferLine.QtyRemainShip = inventTransferLine.QtyTransfer;
inventTransferLine.ShipDate = SystemDateget();
//inventTransferLine.ReceiveDate = str2Date(#ReceiveDate, 213);
inventTransferLine.ReceiveDate = SystemDateget();
inventTransferLine.initFromInventTransferTable(inventTransferTable, false);
inventTransferLine.LineNum = InventTransferLine::lastLineNum(inventTransferLine.TransferId) + 1.0;
if (inventTransferLine.validateWrite())
{
inventTransferLine.insert();
}
else
{
throw error("Order line");
}
}
}
else
throw error("Order header");
//
inventTransferParmTable.clear();
inventTransferParmTable.initParmDefault();
inventTransferParmTable.ParmId = RunBaseMultiParm::getSysParmId();
inventTransferParmTable.TransferId = inventTransferTable.TransferId;
inventTransferParmTable.UpdateType = InventTransferUpdateType::Shipment;
inventTransferParmTable.ShipUpdateQty = InventTransferShipUpdateQty::All;
//inventTransferParmTable.PickUpdateQty = InventTransferPickUpdateQty::AvailableQty;
inventTransferParmTable.EditLines = false;
this.createPickLines(inventTransferParmTable);
//inventTransferParmTable.ExecutedDateTime = systemDateGet()
inventTransferUpdShip = InventTransferUpdShip::newParmBuffer(inventTransferParmTable);
inventTransferUpdShip.run();
return inventTransferTable.TransferId;
}
I googles a lot, tried for days, dunno what else to try . Help please!!
Thanks,
Jorge
*This post is locked for comments
Hi,
For partial transfer order postings, i used the below approach-
1. Loop through Table/InventTransferLine(assuming you already have a transfer order ID) and check for fields QtyRemainShip & QtyRemainReceive. if they are not zero, that means either the lines are partially shipped or received or is not shipped and received at all.
2. Within the loop Table/InventTransferLine, update QtyShipNow with QtyRemainShip.
3. Now create records in Table/InventTransferParmTable.
4. Use Class/InventTransferUpd for final posting.
Below is an example-
InventTransferUpd invTranUpd;
InventTransferLine inventTransferLine, inventTransferLineLocal;
InventTransferParmTable invTransParmTable;
while select inventTransferLine
order by LineNum
where inventTransferLine.TransferId == "00001"
{
if(inventTransferLine.QtyRemainShip != 0)
{
inventTransferLineLocal = null;
ttsBegin;
select forUpdate inventTransferLineLocal
where inventTransferLineLocal.RecId == inventTransferLine.RecId;
inventTransferLineLocal.QtyShipNow = inventTransferLine.QtyRemainShip;
inventTransferLineLocal.update();
ttsCommit;
inventTransferLine.reread();
ttsBegin;
invTransParmTable.clear();
invTransParmTable.TransferId = inventTransferLine.TransferId;
invTransParmTable.EditLines = true;
invTransParmTable.AutoReceiveQty = true;
invTransParmTable.UpdateType = InventTransferUpdateType::Shipment;
invTransParmTable.PickUpdateQty = InventTransferPickUpdateQty::All;
invTransParmTable.TransDate = systemDateGet();
switch(invTransParmTable.UpdateType)
{
case InventTransferUpdateType::PickingList:
invTranUpd = InventTransferUpdPick::newParmBuffer(invTransParmTable);
break;
case InventTransferUpdateType::Shipment:
invTranUpd = InventTransferUpdShip::newParmBuffer(invTransParmTable);
break;
case InventTransferUpdateType::Receive:
invTranUpd = InventTransferUpdReceive::newParmBuffer(invTransParmTable);
break;
default:
}
invTranUpd.run();
ttsCommit;
}
inventTransferLine.reread();
if(inventTransferLine.QtyRemainReceive != 0)
{
inventTransferLineLocal = null;
ttsBegin;
select forUpdate inventTransferLineLocal
where inventTransferLineLocal.RecId == inventTransferLine.RecId;
inventTransferLineLocal.QtyReceiveNow = inventTransferLine.QtyRemainReceive;
inventTransferLineLocal.update();
ttsCommit;
inventTransferLine.reread();
ttsBegin;
invTransParmTable.clear();
invTransParmTable.TransferId = inventTransferLine.TransferId;
invTransParmTable.EditLines = true;
invTransParmTable.AutoReceiveQty = true;
invTransParmTable.UpdateType = InventTransferUpdateType::Receive;
invTransParmTable.PickUpdateQty = InventTransferPickUpdateQty::All;
invTransParmTable.TransDate = systemDateGet();
switch(invTransParmTable.UpdateType)
{
case InventTransferUpdateType::PickingList:
invTranUpd = InventTransferUpdPick::newParmBuffer(invTransParmTable);
break;
case InventTransferUpdateType::Shipment:
invTranUpd = InventTransferUpdShip::newParmBuffer(invTransParmTable);
break;
case InventTransferUpdateType::Receive:
invTranUpd = InventTransferUpdReceive::newParmBuffer(invTransParmTable);
break;
default:
}
invTranUpd.run();
ttsCommit;
}
}
I am not sure you found the solution, I come across the same situation and found a work around , Please share if you have a better solution
approach one :
Don't create line instead just update InventTransferLine.QtyReceiveNow with actual receive
Second one is little tricky as you are already create line and set edit lines set to true
instead your last line change like this
itpt.EditLines = NoYes::No ;
itur = InventTransferUpdReceive::newParmBuffer(itpt);
itpt.EditLines = NoYes::Yes ;
itur.run();
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156