Hi all,
I am still working on getting auto receive to split a lot with quantities over 1 into single piece lots with their own lot number when they are auto receive to inventory. I’ve been using the Epicor Support Bot in ChatGPT to get my head around this process. I think I am so close but don’t know why I’m getting the error below.
I have an In-Transaction Data Directive on the PartTran table to catch the transaction and split the lots.
Tran is required.
Asm is required.
Pack ID is required.
Line is required.
PO is required.
Line is required.
Release is required.
Order is required.
Line is required.
Rel is required.
Description is required.
Rev is required.
Supplier Number is required.
PO Receipt Qty is required.
Packing Slip is required.
Invoice is required.
Dimension is required.
Fiscal Period is required.
Journal is required.
DMR Number is required.
Action Number is required.
RMA is required.
Journal is required.
Call is required.
Line is required.
Line is required.
Customer is required.
RMA Line is required.
Rcv is required.
// Create an instance of the PartTran and LotSelectUpdate business objects
var partTranBO = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.PartTranSvcContract>(Db);
var lotSelectUpdateBO = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.LotSelectUpdateSvcContract>(Db); // LotSelectUpdateSvc to manage lots
// Get the original transaction details
var originalTran = ttPartTran.FirstOrDefault();
if (originalTran != null && !string.IsNullOrEmpty(originalTran.JobNum))
{
string jobNum = originalTran.JobNum;
int tranQty = (int)originalTran.TranQty;
DateTime sysDate = DateTime.Now; // Get the current system date for the transaction
// Loop through each piece and create a new PartTran record for each lot
for (int i = 1; i <= tranQty; i++)
{
// Step 1: Create a new lot using GetNewPartLot from LotSelectUpdateSvc
Erp.Tablesets.LotSelectUpdateTableset lotDataSet = new Erp.Tablesets.LotSelectUpdateTableset();
// Create a new lot using the PartNum from the original transaction
lotSelectUpdateBO.GetNewPartLot(ref lotDataSet, originalTran.PartNum); // Pass the part number as required
// Access the new lot row
var newLot = lotDataSet.PartLot[0]; // Access the new lot created
// Assign a custom lot number (e.g., Job-1, Job-2)
newLot.LotNum = $"{jobNum}-{i}";
// Save the new lot to the system
lotSelectUpdateBO.Update(ref lotDataSet); // This creates the lot in the system
// Step 2: Create a new PartTran transaction
Erp.Tablesets.PartTranTableset newTranDataSet = new Erp.Tablesets.PartTranTableset();
// Call the BO to create a new transaction and pass the required parameters
partTranBO.GetNewPartTran(ref newTranDataSet, sysDate, 0); // 0 could be a placeholder for a specific line, update as needed
// Access the newly created PartTran row
var newTran = newTranDataSet.PartTran[0];
// Copy values from the original transaction and set up the new lot number
newTran.JobNum = originalTran.JobNum;
newTran.PartNum = originalTran.PartNum;
newTran.WareHouseCode = originalTran.WareHouseCode;
newTran.BinNum = originalTran.BinNum;
newTran.Plant = originalTran.Plant;
newTran.TranType = originalTran.TranType;
newTran.TranDate = originalTran.TranDate;
// Step 3: Assign the created lot number to the transaction
newTran.LotNum = newLot.LotNum; // Use the lot number created in Step 1
// Set the transaction quantity to 1 for each lot
newTran.TranQty = 1;
// Step 4: Save the new PartTran record to the database via the BO Update method
partTranBO.Update(ref newTranDataSet);
}
}