Hey all,
In a function, I’m trying to move stock in a lot to a PCID container. It looks like it should work and gets no errors. The data I’m building in the source looks like what I see in a trace log.
But I get no stock moved to a PCID.
Code below. Note I’m setting a checkbox true on the UD detail row after the AddPartToPCID method at the bottom. It sets there, so I know it hit the method. It just doesn’t make the transfer.
I saw a reference to running the method inside/outside of a transaction scope. Taking out the transaction scope code doesn’t seem to make any difference.
Any ideas?
Thanks,
Joe
Code:
// process job receipt to inventory
var context = (Erp.ErpContext)Ice.Services.ContextFactory.CreateContext();
var erpContext = new Erp.Internal.Lib.CCredChk(context); // used this library/assembly only for erpContext
string jobHeatLotNum = String.Empty;
using(var txscope = IceDataContext.CreateDefaultTransactionScope()) //Start Transaction
{
var ud102_xRow = (from row in erpContext.Db.UD102
where row.Company == Session.CompanyID &&
row.Key1 == jobNum &&
row.Key2 == jobSeq
select row).FirstOrDefault();
if (ud102_xRow != null)
{
jobHeatLotNum = ud102_xRow.HeatLotNum_c;
}
bool updated = false;
// transfer on-hand coil qty for each part/lot/whse/bin
foreach(var ud102A_xRow in (from row in erpContext.Db.UD102A
where row.Company == Session.CompanyID &&
row.Key1 == jobNum &&
row.Key2 == jobSeq &&
row.Completed_c == true &&
row.Received_c == true &&
row.PCID_c != String.Empty &&
row.PCIDReceived_c != true
orderby row.Key1 ascending
orderby row.Key2 ascending
orderby row.ChildKey1 ascending
select row))
{
decimal weight = ud102A_xRow.Weight_c;
Erp.Contracts.PkgControlIDBuildSplitMergeSvcContract buildSplitMerge = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.PkgControlIDBuildSplitMergeSvcContract>(erpContext.Db, true);
var dsBuildSplitMerge = new Erp.Tablesets.PCIDBuildSplitMergeSourcePartTableset();
buildSplitMerge.GetNewPCIDPart(ref dsBuildSplitMerge);
var dsBuildSplitMergeDest = new Erp.Tablesets.PCIDBuildSplitMergeDestTableset();
// get the destination PCID dataset
buildSplitMerge.GetDestPCID(ud102A_xRow.PCID_c, true, ref dsBuildSplitMergeDest );
// read destination record if the PCID is empty
foreach(var ttBuildSplitMergeDest_xRow in (from row in dsBuildSplitMergeDest.PCIDBuildSplitMergeDest
where row.Company == Session.CompanyID &&
row.PkgControlStatus.ToUpper() == "EMPTY"
select row))
{
// set the values in the source side dataset
foreach(var ttBuildSplitMerge_xRow in (from row in dsBuildSplitMerge.PCIDBuildSplitMergeSourcePart
where row.Company == Session.CompanyID &&
string.Equals(row.RowMod, IceRow.ROWSTATE_ADDED, StringComparison.OrdinalIgnoreCase)
select row))
{
ttBuildSplitMerge_xRow.PartNum = ud102A_xRow.PartNum_c;
ttBuildSplitMerge_xRow.WarehouseCode = ud102A_xRow.CoilWarehouseCode_c;
ttBuildSplitMerge_xRow.BinNum = ud102A_xRow.CoilBinNum_c;
ttBuildSplitMerge_xRow.LotNum = ud102_xRow.HeatLotNum_c;
ttBuildSplitMerge_xRow.SourceQuantity = weight;
buildSplitMerge.OnChangeSourcePartNum(ud102A_xRow.PartNum_c, ud102A_xRow.CoilWarehouseCode_c, ref dsBuildSplitMerge);
buildSplitMerge.OnChangeSourcePartBinNum(ud102A_xRow.CoilBinNum_c, ref dsBuildSplitMerge);
buildSplitMerge.OnChangeSourcePartLotNum(ud102_xRow.HeatLotNum_c, ref dsBuildSplitMerge);
if (ttBuildSplitMerge_xRow.AvailableQuantity < weight)
{
ttBuildSplitMerge_xRow.SourceQuantity = ttBuildSplitMerge_xRow.AvailableQuantity;
weight = ttBuildSplitMerge_xRow.AvailableQuantity;
}
buildSplitMerge.OnChangeSourceQty(weight, ref dsBuildSplitMerge);
updated = true;
buildSplitMerge.AddPartToPCID(ref dsBuildSplitMerge, ref dsBuildSplitMergeDest); // this doesn't seem to do anything
ud102A_xRow.PCIDReceived_c = true; // this part is working okay
}
}
}
erpContext.Db.Validate();
txscope.Complete();
}