I have been working for the past week on creating a BPM to massIssue all the material that was not issued through the process of completing a Job. The massIssueToMfg is the route I am on now, but I keep getting errors and at this point I am not sure if this is the correct way to go about it. I am testing this simply on when JobReleased goes from false to true fire the BPM. I feel like I am close but with the current error I am wondering if this is the way to go or if I should try to recreate the IssueReturn Process by looping through the Material on each assembly of the job. How would you go about this? Below is the code I have so far on a JobHead In-Tran Data Directive. Below that is the error I am getting.
using (var hMassIssue = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.MassIssueToMfgSvcContract>(Db))
{
var job = ttJobHead.Where(x => x.Updated()).FirstOrDefault();
//var jobAsm = Db.JobAsmbl.Where(y => y.Company == job.Company && y.JobNum == job.JobNum && y.Plant == job.Plant).FirstOrDefault();
string ipSysRowId = Convert.ToString(job.SysRowID);
string pcMessage;
string pcQuestion;
string pcError;
Hashtable htPrePerform = new Hashtable();
string jobNum = Convert.ToString(job.JobNum);
DateTime tranDate = DateTime.Today;
//Build table set for build
Erp.Tablesets.MassIssueInputTableset buildTS = new Erp.Tablesets.MassIssueInputTableset();
hMassIssue.GetNewMassIssueInput(ref buildTS, false);
buildTS.MassIssueInputJob[0].JobNum = job.JobNum;
buildTS.MassIssueInputJob[0].SysRowID = job.SysRowID;
buildTS.MassIssueInputJob[0].IsReturn = false;
buildTS.MassIssueInputJob[0].Company = job.Company;
buildTS.MassIssueInputJob[0].dummyKeyField = string.Empty;
buildTS.MassIssueInputJob[0].WarnMessage = string.Empty;
buildTS.MassIssueInputJob[0].RowMod = "A";
//creates the massTS data set from the buildMassIssueBrowse method.
Erp.Tablesets.MassIssueToMfgTableset massTS = hMassIssue.BuildMassIssueBrowse(ref buildTS, ipSysRowId, out pcMessage);
//Call The issue all, passes the dataset from previous line and looks for all open materials.
hMassIssue.IssueAll("Open", ref massTS);
//NegativeStokeCheck
hMassIssue.NegativeStockCheck(jobNum, ref massTS, out pcQuestion, out pcError);
//preperformMassIssue
hMassIssue.PrePerformMassIssueHT(ref massTS, ref htPrePerform);
//PerformMassIssue
hMassIssue.PerformMassIssue(jobNum, tranDate, 0, false, false, ref massTS, out pcMessage);
}
==========================================================================
Business Layer Exception
No action taken. No Quantity to issue for 048487-1-1.
Exception caught in: Epicor.ServiceModel
Error Detail
============
Correlation ID: e045b29f-b66b-457e-8281-ed0bd7f8f062
Description: No action taken. No Quantity to issue for 048487-1-1.
Program: Erp.Services.BO.MassIssueToMfg.dll
Method: NegativeStockCheck
Line Number: 2353
Column Number: 17
Table: MassIssue
Field: QtyIssued
Client Stack Trace
==================
at Epicor.ServiceModel.Channels.ImplBase`1.ShouldRethrowNonRetryableException(Exception ex, DataSet[] dataSets)
at Erp.Proxy.BO.JobEntryImpl.Update(JobEntryDataSet ds)
at Erp.Adapters.JobEntryAdapter.OnUpdate()
at Ice.Lib.Framework.EpiBaseAdapter.Update()
at Erp.UI.App.JobEntry.Transaction.Update()