Transfer order ( Shiped & received ) posting
// Class helps to shipped & received transfer order
class IHSProcessTransferOrder
{
InventTransferId transferID;
InventTransferUpdateType inventTransferUpdateType;
boolean success;
str output, message, localOutput;
protected void new()
{
}
/// <summary>
/// Creates a new instance of the <c>IHSEntAssetObjectItemCreate</c> class.
/// </summary>
/// <returns>A new instance of the <c>IHSEntAssetObjectItemCreate</c> class.</returns>
public static IHSProcessTransferOrder construct()
{
return new IHSProcessTransferOrder();
}
public static void main(Args _args)
{
IHSProcessTransferOrder processTransferOrder = new IHSProcessTransferOrder();
processTransferOrder.run();
}
public InventTransferId parmTransferID(InventTransferId _transferID = transferID)
{
transferID = _transferID;
return transferID;
}
public str parmOutput(str _output = output)
{
output = _output;
return output;
}
public InventTransferUpdateType parmInventTransferUpdateType(InventTransferUpdateType _InventTransferUpdateType = inventTransferUpdateType)
{
inventTransferUpdateType = _InventTransferUpdateType;
return inventTransferUpdateType;
}
public void run()
{
if (this.parmInventTransferUpdateType() == InventTransferUpdateType::Shipment)
{
this.shipTransferOrder();
}
else
{
this.ReceiveTransferOrder();
}
}
public void shipTransferOrder()
{
//// ship a transfer order
InventTransferMultiShip multiShip = InventTransferMultiShip::construct();
// // Id of transfer order to ship
// InventTransferId shipTransferId =;
InventTransferLine inventTransferLine;
InventTransferParmTable inventTransferParmTable;
ttsbegin;
while select inventTransferLine
where inventTransferLine.TransferId == transferID
{
//framework stuff to set parmId
RunBaseMultiParm::initParm(multiShip);
//get general values related to shipping set
// InventTransferParmTable inventTransferParmTable;
inventTransferParmTable.TransferId = transferID;
inventTransferParmTable.ParmId = multiShip.parmId();
multiShip.initParmBuffer(inventTransferParmTable);
inventTransferParmTable.UpdateType = InventTransferUpdateType::Shipment;
inventTransferParmTable.ShipUpdateQty = InventTransferShipUpdateQty::All;
inventTransferParmTable.EditLines = NoYes::Yes;
inventTransferParmTable.ExplodeLines = NoYes::No;
inventTransferParmTable.TransDate = today(); //shipment date
inventTransferParmTable.InventDimFixedReceiveList = 0;
InventTransferParmLine inventTransferParmLine;
inventTransferParmLine.initFromInventTransferLine(inventTransferLine);
inventTransferParmLine.ParmId = inventTransferParmTable.ParmId;
inventTransferParmLine.TransferId = inventTransferLine.TransferId;
inventTransferParmLine.InventTransId = inventTransferLine.InventTransId;
inventTransferParmLine.LineNum = InventTransferParmTable::lastLineNum(inventTransferParmTable.ParmId) + 1;
inventTransferParmLine.InventTransIdTransit = inventTransferLine.InventTransIdTransitFrom;
inventTransferParmLine.QtyShipNow = inventTransferLine.QtyRemainShip;
inventTransferParmLine.insert();
inventTransferParmTable.insert(false); //will create parmLines by default
//now do the update
multiShip.runUpdate(inventTransferParmTable);
}
if(InventTransferTable::find(transferID).TransferStatus == InventTransferStatus::Shipped)
{
message = "Transfer order is Shipped ";
localOutput = strFmt("%1 :- %2",message,transferID);
this.parmTransferID(transferID);
this.parmOutput(localOutput);
}
ttscommit;
}
public void ReceiveTransferOrder()
{
InventTransferParmTable inventTransferParmTable;
InventTransferLine inventTransferLine;
ttsbegin;
while select inventTransferLine
where inventTransferLine.TransferId == transferID
{
inventTransferParmTable.clear();
inventTransferParmTable.initParmDefault();
inventTransferParmTable.TransferId = transferID;//_inventTransferLine.TransferId;
inventTransferParmTable.UpdateType = InventTransferUpdateType::Receive;
// inventTransferParmTable.ShipUpdateQty = InventTransferShipUpdateQty::All;
inventTransferParmTable.ReceiveUpdateQty = InventTransferReceiveUpdateQty::All;
inventTransferParmTable.EditLines = true;
inventTransferParmTable.LineNum = 1;
inventTransferParmTable.JobStatus = ParmJobStatus::Executed;
inventTransferParmTable.ExecutedDateTime = DateTimeUtil::utcNow();
inventTransferParmTable.PickUpdateQty = InventTransferPickUpdateQty::ShipNow;
// inventTransferParmTable.ExplodeLines = true;
InventTransferMultiReceive inventTransferMultiReceive = InventTransferMultiReceive::construct();
inventTransferMultiReceive.init();
inventTransferMultiReceive.parmCalledFromWMS(false);
RunBaseMultiParm::initParm(inventTransferMultiReceive);
inventTransferParmTable.ParmId = inventTransferMultiReceive.parmId();
inventTransferParmTable.insert(false);
InventTransferParmLine inventTransferParmLine;
inventTransferParmLine.initFromInventTransferLine(inventTransferLine);
inventTransferParmLine.ParmId = inventTransferParmTable.ParmId;
inventTransferParmLine.TransferId = inventTransferLine.TransferId;
inventTransferParmLine.InventTransId = inventTransferLine.InventTransIdReceive;
inventTransferParmLine.LineNum = InventTransferParmTable::lastLineNum(inventTransferParmTable.ParmId) + 1;
inventTransferParmLine.InventTransIdTransit = inventTransferLine.InventTransIdTransitFrom;
inventTransferParmLine.QtyReceiveNow = inventTransferLine.QtyRemainReceive;
inventTransferParmLine.insert();
// //now do the update
inventTransferMultiReceive.runUpdate(inventTransferParmTable);
}
if(InventTransferTable::find(transferID).TransferStatus == InventTransferStatus::Received)
{
message = "Transfer order is Recevied";
localOutput = strFmt("%1 :- %2",message,transferID);
this.parmTransferID(transferID);
this.parmOutput(localOutput);
IHSUpdateReservedByOnToReceived updateReserveBy = IHSUpdateReservedByOnToReceived::construct();
updateReserveBy.parmTransferId(transferID);
updateReserveBy.run();
}
ttscommit;
}
}
Comments
Post a Comment