//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++;
}
}
}
Hello!
ReplyDeleteits code is good, but it will be error if it does not send the item (tmpInventTransWMS.ItemId = transferLine.ItemId;) to take into account and because it updates the inventtrans table?
Hi,
DeletePlease find this code.
inventTrans = InventTrans::findTransId(transferLine.InventTransIdReceive,true);
This code of line, system will find inventTrans against InventTransId.
And also, for tmpInventTransWMS.itemId system will fetch automatically from this below line of code tmpInventTransWMS.initFromInventTrans(inventTrans);
In case, still if u any queries let me know.
Thanks and Regards
Sangeeth