//Inventory Item Registration in Transfer Order lines Auto in ax 2012
//Registering an Item , success only when On hand Avail physical Qty is greater than Zero
static void San_InvTransRegistrationCode(Args _args)
{
InventTransferTable transferTable;
InventTransferLine transferLine;
InventTransWMS_Register inventTransWMS_register;
InventTrans inventTrans;
TmpInventTransWMS tmpInventTransWMS;
InventDim inventDim,Dimtmp,inventDimCreate;
int i;
Name size,color,warehouse,wmslocation,site;
while select transferTable
where transferTable.InventLocationIdFrom == "<from warehouse number>" && transferTable.InventLocationIdTo == "<To Warehouse number>"
&& transferTable.TransferStatus == InventTransferStatus::Shipped
//&& transferTable.TransferId =="<Transfer Order id>"
{
while select transferLine where transferLine.TransferId == transferTable.TransferId
//&& transferLine.ItemId == "<Item number >"
{
Dimtmp.clear();
Dimtmp.InventSizeId = InventDim::find(transferLine.inventDimId).InventSizeId;
Dimtmp.InventColorId = InventDim::find(transferLine.inventDimId).InventColorId;
Dimtmp.InventLocationId = transferTable.InventLocationIdTo;
Dimtmp.wMSLocationId = "Default";
Dimtmp.InventSiteId = InventDim::find(transferLine.inventDimId).InventSiteId;
inventDimCreate = inventDim::findOrCreate(Dimtmp);
ttsBegin;
inventTrans = InventTrans::findTransId(transferLine.InventTransIdReceive,true);
if(inventTrans)
{
inventTrans.inventDimId = inventDimCreate.InventDimId;
inventTrans.update();
}
ttsCommit;
inventDim = inventDim::find(inventTrans.inventDimId);
inventTransWMS_register = inventTransWMS_register::newStandard(tmpInventTransWMS);
tmpInventTransWMS.clear();
tmpInventTransWMS.initFromInventTrans(inventTrans);
tmpInventTransWMS.InventQty = transferLine.QtyShipped;
tmpInventTransWMS.InventDimId = inventTrans.InventDimId;
tmpInventTransWMS.insert();
inventTransWMS_register.writeTmpInventTransWMS(tmpInventTransWMS,inventTrans,inventTrans.inventDim());
inventTransWMS_register.updateInvent(transferLine);
i++;
}
}
}
//Registering an Item , success only when On hand Avail physical Qty is greater than Zero
static void San_InvTransRegistrationCode(Args _args)
{
InventTransferTable transferTable;
InventTransferLine transferLine;
InventTransWMS_Register inventTransWMS_register;
InventTrans inventTrans;
TmpInventTransWMS tmpInventTransWMS;
InventDim inventDim,Dimtmp,inventDimCreate;
int i;
Name size,color,warehouse,wmslocation,site;
while select transferTable
where transferTable.InventLocationIdFrom == "<from warehouse number>" && transferTable.InventLocationIdTo == "<To Warehouse number>"
&& transferTable.TransferStatus == InventTransferStatus::Shipped
//&& transferTable.TransferId =="<Transfer Order id>"
{
while select transferLine where transferLine.TransferId == transferTable.TransferId
//&& transferLine.ItemId == "<Item number >"
{
Dimtmp.clear();
Dimtmp.InventSizeId = InventDim::find(transferLine.inventDimId).InventSizeId;
Dimtmp.InventColorId = InventDim::find(transferLine.inventDimId).InventColorId;
Dimtmp.InventLocationId = transferTable.InventLocationIdTo;
Dimtmp.wMSLocationId = "Default";
Dimtmp.InventSiteId = InventDim::find(transferLine.inventDimId).InventSiteId;
inventDimCreate = inventDim::findOrCreate(Dimtmp);
ttsBegin;
inventTrans = InventTrans::findTransId(transferLine.InventTransIdReceive,true);
if(inventTrans)
{
inventTrans.inventDimId = inventDimCreate.InventDimId;
inventTrans.update();
}
ttsCommit;
inventDim = inventDim::find(inventTrans.inventDimId);
inventTransWMS_register = inventTransWMS_register::newStandard(tmpInventTransWMS);
tmpInventTransWMS.clear();
tmpInventTransWMS.initFromInventTrans(inventTrans);
tmpInventTransWMS.InventQty = transferLine.QtyShipped;
tmpInventTransWMS.InventDimId = inventTrans.InventDimId;
tmpInventTransWMS.insert();
inventTransWMS_register.writeTmpInventTransWMS(tmpInventTransWMS,inventTrans,inventTrans.inventDim());
inventTransWMS_register.updateInvent(transferLine);
i++;
}
}
}