We decided we wanted to know the QTY in DMR during time phase.
I created a Customization on Time Phase and a Method Directive BPM.
This works with multiple DMR for same PN and sum’s all the Qty.
Attached is BAQ showing DMR Qty for TotDiscrepantQty, TotRejectedQty, totalAcceptedQty and a calculated field for validating.
totalDiscrepantQty - (totalRejectedQty + totalAcceptedQty)
I used this to verify my results.
kpDMRBins.baq (14.3 KB)
Optional message pop-up for debug.
Create a Text Box in customization and bind to
callContextBpmData.Number06
Method directive - Post Processing
Erp.BO.TimePhas.GoProcessTimePhase
/*
10-17-24
This uses BPM CallToContext Number06 - Change if needed
*/
string combinedMessage = "";
callContextBpmData.Number06 = 0;
// Specify which DMR bin if you like
// var tempBin = "DMR";
// Iterate through the first 'TimePhas' object in the 'result' collection
var ttTimePhas = result.TimePhas.FirstOrDefault();
if (ttTimePhas != null)
{
// Query the database to sum up all Qty's for the current 'PartNum'
var dbDMRHeadResults = (from row in Db.DMRHead
where row.PartNum == ttTimePhas.PartNum &&
// row.BinNum == tempBin
row.OpenDMR == true
select row).ToList();
// Check if any database results were found
if (dbDMRHeadResults.Any())
{
// Sum all the necessary fields
var totalDiscrepantQty = dbDMRHeadResults.Sum(r => r.TotDiscrepantQty);
var totalRejectedQty = dbDMRHeadResults.Sum(r => r.TotRejectedQty);
var totalAcceptedQty = dbDMRHeadResults.Sum(r => r.TotAcceptedQty);
// Create a formatted message with the sums if using Pop-up message
string message = $"PartNum: {ttTimePhas.PartNum}, TotDiscrepantQty: {totalDiscrepantQty}, TotRejectedQty: {totalRejectedQty}, TotAcceptedQty: {totalAcceptedQty}\n";
// Concatenate the formatted message to the 'combinedMessage' string
combinedMessage += message;
// Store ONH Value for BPM CallToContext Number06 | DMR Total - (Rejec + Accepted) to show remaining in DMR
callContextBpmData.Number06 = totalDiscrepantQty - (totalRejectedQty + totalAcceptedQty);
}
}
/*
// Pop up message
// Create a final message to display in the message box, including the combined results
string body = "Combined Results:\n\n" + combinedMessage;
// Display the combined results in a message box using the 'PublishInfoMessage' method
this.PublishInfoMessage(body, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "FirstVar", "SecondVar");
*/