Below is sample code (I removed code in order to simply) that uses CoC when a report as finished journal is posted. When this is called for the second journal that is posted for the same production order, the query will return the serial numbers for the first journal that was posted earlier.
If I can't find a query that returns the serial numbers for the given journal, then one solution is to flag the serial numbers that have already been processed and skip those on the future calls.
Thank you for your time.
[ExtensionOf(classStr(ProdJournalCheckPostProd))]
final class ProdJournalCheckPostProd_Extension
{
void run()
{
next run();
ProdJournalTable prodJournalTable = journalTableData.journalTable();
if (prodJournalTable.JournalType != ProdJournalType::ReportFinished)
{
return;
}
ProdTable prodTable = ProdTable::find(prodJournalTable.ProdId);
List serialNumbers = new List(Types::String);
InventTrans inventTrans;
InventDim inventDim;
InventTransOrigin inventTransOrigin;
InventSerial inventSerial;
while select InventSerialId from inventDim
join RecId, StatusReceipt from inventTrans
where inventTrans.inventDimId == inventDim.inventDimId
join ItemId from inventTransOrigin
where inventTransOrigin.RecId == inventTrans.InventTransOrigin
&& inventTransOrigin.InventTransId == prodTable.InventTransId
{
serialNumbers.AddEnd(inventDim.InventSerialId);
}
}
}