static void TransferOrdersXppImport(Args _args)
{
#define.WarehouseFrom("SEATTLE")
#define.WarehouseTo("NEWYORK")
#define.ShipDate("1/1/2014")
#define.ReceiveDate("1/1/2014")
#define.ItemId("0121")
#define.Qty(1)
#define.Site("WEST")
#define.Warehouse("SEATTLE")
InventTransferTable inventTransferTable;
InventTransferLine inventTransferLine;
InventDim inventDim;
try
{
ttsbegin;
//Order header
inventTransferTable.clear();
inventTransferTable.initValue();
inventTransferTable.TransferId = InventTransferTable::numberSeq().num();
inventTransferTable.InventLocationIdFrom = #WarehouseFrom;
inventTransferTable.InventLocationIdTo = #WarehouseTo;
inventTransferTable.DlvModeId = CustVendTransportPointLine::defaultDeliveryMode(inventTransferTable.InventLocationIdFrom,'','','','',inventTransferTable.InventLocationIdTo);
inventTransferTable.InventLocationIdTransit = InventLocation::find(inventTransferTable.InventLocationIdFrom).InventLocationIdTransit;
inventTransferTable.initFromAddress();
inventTransferTable.initToAddress();
inventTransferTable.ShipDate = str2Date(#ShipDate, 213);
inventTransferTable.ReceiveDate = str2Date(#ReceiveDate, 213);
if (inventTransferTable.validateWrite())
{
inventTransferTable.insert();
//Order line
inventDim.clear();
inventDim.InventSiteId = "WEST";
inventDim.InventLocationId = "SEATTLE";
inventTransferLine.clear();
inventTransferLine.initValue();
inventTransferLine.ItemId = #ItemId;
inventTransferLine.InventDimId = InventDim::findOrCreate(inventDim).inventDimId;
inventTransferLine.QtyTransfer = #Qty;
inventTransferLine.initFromInventTableModule(InventTableModule::find(inventTransferLine.ItemId,ModuleInventPurchSales::Invent));
inventTransferLine.QtyRemainReceive = inventTransferLine.QtyTransfer;
inventTransferLine.QtyRemainShip = inventTransferLine.QtyTransfer;
inventTransferLine.ShipDate = str2Date(#ShipDate, 213);
inventTransferLine.ReceiveDate = str2Date(#ReceiveDate, 213);
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");
ttscommit;
}
catch
{
error("Error!");
return;
}
info("Done!");
}
Tested the code by updating the static values in a job.
Friday, December 12, 2014
Subscribe to:
Posts (Atom)