I’m trying to automate the process of adding a Job Misc Charge through AP Invoice Entry as it’s the same information every time. The goal is to type in the job number and have it do the rest upon tabbing.
I have it successfully going out and adding the new material sequence to the job, but my issue is the final few methods in the trace in AP Invoice Entry. After creating the new material sequence on the job, it comes back and changes the material sequence for the table APInvJob.
This is where I’m running into issues. I did apBO.GetRows(insert too many parameters); and it’s returning the proper information for the APInvHed and APInvDtl tables, but it appears like the APInvJob table doesn’t exist. Am I missing a step?
Trace: TraceData12808.txt (271.9 KB)
Code:
callContextBpmData.Character01 = "";
int newSeq = 0;
string grpID = "";
string jNum = "";
int assSeq = 0;
int vNum = 0;
string iNum = "";
var ttAPInvJobR = ttAPInvJob.FirstOrDefault(r=>r.Added() || r.Updated());
var ttAPInvHedR = ttAPInvHed.FirstOrDefault();
if( ttAPInvHedR != null )
{
grpID = callContextBpmData.Character01 =(string)ttAPInvHedR.GroupID;
}
if( ttAPInvJobR != null )
{
jNum = (string)ttAPInvJobR.JobNum;
vNum = (int)ttAPInvJobR.VendorNum;
assSeq = (int)ttAPInvJobR.AssemblySeq;
iNum = (string)ttAPInvJobR.InvoiceNum;
string PART = "FRT";
using( var jobBO = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.JobEntrySvcContract>(Db))
{
try
{
JobEntryTableset jTS = new JobEntryTableset();
//Get Rows Method
string whereClauseJobHead = "JobNum = '" + jNum + "' BY JobNum";
string whereClauseJobHeadAttch = "";
string whereClauseJobAsmbl = "JobAsmbl.AssemblySeq = " + assSeq;
string whereClauseJobAsmblAttch = "";
string whereClauseJobAsmblInsp = "";
string whereClauseJobMtl = "JobMtl.AssemblySeq = " + assSeq + " AND MtlSeq = 0";
string whereClauseJobMtlAttch = "";
string whereClauseJobMtlInsp = "";
string whereClauseJobMtlRefDes = "";
string whereClauseJobMtlRestriction = "";
string whereClauseJobMtlRestrictSubst = "";
string whereClauseJobOper = "";
string whereClauseJobOperAttch = "";
string whereClauseJobOperInsp = "";
string whereClauseJobOperMachParam = "";
string whereClauseJobOpDtl = "";
string whereClauseJobResources = "";
string whereClauseJobOperRestriction = "";
string whereClauseJobOperRestrictSubst = "";
string whereClauseJobAsmblRestriction = "";
string whereClauseJobAsmblRestrictSubst = "";
string whereClauseJobAsmRefDes = "";
string whereClauseJobAudit = "";
string whereClauseJobPart = "";
string whereClauseJobProd = "";
int pageSize = 0;
int absolutePage = 0;
bool morePages = false;
jTS = jobBO.GetRows(whereClauseJobHead,
whereClauseJobHeadAttch,
whereClauseJobAsmbl,
whereClauseJobAsmblAttch,
whereClauseJobAsmblInsp,
whereClauseJobMtl,
whereClauseJobMtlAttch,
whereClauseJobMtlInsp,
whereClauseJobMtlRefDes,
whereClauseJobMtlRestriction,
whereClauseJobMtlRestrictSubst,
whereClauseJobOper,
whereClauseJobOperAttch,
whereClauseJobOperInsp,
whereClauseJobOperMachParam,
whereClauseJobOpDtl,
whereClauseJobResources,
whereClauseJobOperRestriction,
whereClauseJobOperRestrictSubst,
whereClauseJobAsmblRestriction,
whereClauseJobAsmblRestrictSubst,
whereClauseJobAsmRefDes,
whereClauseJobAudit,
whereClauseJobPart,
whereClauseJobProd,
pageSize,
absolutePage,
out morePages);
//GetNewJobMtl Method
string jobNum = jNum;
int assemblySeq = (int)ttAPInvJobR.AssemblySeq;
jobBO.GetNewJobMtl(ref jTS, jobNum, assemblySeq);
newSeq = (
from jm in Db.JobMtl.With(LockHint.NoLock)
where jm.Company == Session.CompanyID &&
jm.JobNum == jNum &&
jm.AssemblySeq == assemblySeq
orderby jm.MtlSeq descending
select jm.MtlSeq).Take(1).DefaultIfEmpty(0).FirstOrDefault() + 10;
//ChangeJobMtlVendorNumVendorID Method
string ipProposedVendorNumVendorID = (
from v in Db.Vendor.With(LockHint.NoLock)
where v.Company == Session.CompanyID &&
v.VendorNum == vNum
select v.VendorID).DefaultIfEmpty("").FirstOrDefault();
jobBO.ChangeJobMtlVendorNumVendorID(ipProposedVendorNumVendorID, ref jTS);
//ChangeJobMtlPurPoint Method
jobBO.ChangeJobMtlPurPoint(ref jTS);
//CheckChangeJobMtlMiscCharge Method
bool ipMiscCharge = true;
jobBO.CheckChangeJobMtlMiscCharge(ipMiscCharge, jTS);
//ChangeJobMtlMiscCharge Method
jTS.JobMtl[0].MiscCharge = true;
jobBO.ChangeJobMtlMiscCharge(ref jTS);
//ChangeJobMtlQtyPer Method
jobBO.ChangeJobMtlQtyPer(ref jTS);
//ChangeJobMtlEstSplitCosts Method
jobBO.ChangeJobMtlEstSplitCosts(ref jTS);
//ChangeJobMtlFixedQty Method
jobBO.ChangeJobMtlFixedQty(ref jTS);
//ChangeJobMtlPartNum Method
bool ipValidatePart = true;
string ipPartNum = PART;
Guid SysRowID = Guid.Empty;
string xrefPartNum = "";
string xrefPartType = "";
string vMsgText = "";
bool vSubAvail = false;
string vMsgType = "";
bool multipleMatch = false;
bool opPartChgCompleted = false;
string opMtlIssuedAction = "";
jTS.JobMtl[0].Description = "Freight Charge";
jobBO.ChangeJobMtlPartNum(ref jTS,
ipValidatePart,
ref ipPartNum,
SysRowID,
xrefPartNum,
xrefPartType,
out vMsgText,
out vSubAvail,
out vMsgType,
out multipleMatch,
out opPartChgCompleted,
out opMtlIssuedAction);
//Update Method
jTS.JobMtl[0].MiscCode = "OUTF";
jTS.JobMtl[0].BuyIt = true;
jTS.JobMtl[0].AddedMtl = true;
jTS.JobMtl[0].RowMod = "A";
jobBO.Update(ref jTS);
}
catch(Exception e){callContextBpmData.Character01 += e.ToString();}
}
using( var apBO = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.APInvoiceSvcContract>(Db))
{
try
{
APInvoiceTableset apTS = new APInvoiceTableset();
//GetRows Method
string whereClauseAPInvHed = "InvoiceNum = '" + iNum + "' AND VendorNum = " + vNum.ToString() + " BY InvoiceNum";
string whereClauseAPInvHedAttch = "";
string whereClauseAPIHAPInvExp = "";
string whereClauseAPIHAPInvExpTGLC = "";
string whereClauseAPIHAPInvMsc = "";
string whereClauseRcvMisc = "";
string whereClauseAPIHAPLnTax = "";
string whereClauseAPInvDtl = "";//"APInvDtl.InvoiceLine = 1";
string whereClauseAPInvDtlAttch = "";
string whereClauseAPInvDtlDEASch = "";
string whereClauseAPInvExp = "";
string whereClauseAPInvExpTGLC = "";
string whereClauseGlbAPIETGLC = "";
string whereClauseAPInvJob = "";//"APInvJob.JobNum = '" + jNum + "' AND APInvJob.AssemblySeq = " + assSeq.ToString() + " AND APInvJob.MtlSeq = " + newSeq.ToString();
string whereClauseAPInvMsc = "";
string whereClauseAPInvLnMscTax = "";
string whereClauseAPInvPB = "";
string whereClauseAPLnTax = "";
string whereClauseAPInvDtlTGLC = "";
string whereClauseAPInvHedMscTax = "";
string whereClauseAPInvSched = "";
string whereClauseAPInvTax = "";
string whereClausePESUNATDtl = "";
string whereClauseEntityGLC = "";
string whereClausePEAPInvTax = "";
string whereClauseLegalNumGenOpts = "";
string whereClauseSupplierXRef = "";
string whereClauseTaxConnectStatus = "";
int pageSize = 0;
int absolutePage = 0;
bool morePages = false;
apTS = apBO.GetRows(whereClauseAPInvHed,
whereClauseAPInvHedAttch,
whereClauseAPIHAPInvExp,
whereClauseAPIHAPInvExpTGLC,
whereClauseAPIHAPInvMsc,
whereClauseRcvMisc,
whereClauseAPIHAPLnTax,
whereClauseAPInvDtl,
whereClauseAPInvDtlAttch,
whereClauseAPInvDtlDEASch,
whereClauseAPInvExp,
whereClauseAPInvExpTGLC,
whereClauseGlbAPIETGLC,
whereClauseAPInvJob,
whereClauseAPInvMsc,
whereClauseAPInvLnMscTax,
whereClauseAPInvPB,
whereClauseAPLnTax,
whereClauseAPInvDtlTGLC,
whereClauseAPInvHedMscTax,
whereClauseAPInvSched,
whereClauseAPInvTax,
whereClausePESUNATDtl,
whereClauseEntityGLC,
whereClausePEAPInvTax,
whereClauseLegalNumGenOpts,
whereClauseSupplierXRef,
whereClauseTaxConnectStatus,
pageSize,
absolutePage,
out morePages);
//ChangeMtlSeq Method
int ProposedMtlSeq = newSeq;
apTS.APInvJob[0].RowMod = "A";
apBO.ChangeMtlSeq(ProposedMtlSeq, ref apTS);
}
catch(Exception e){callContextBpmData.Character01 += e.ToString();}
}
}