Hi All,
Anyone able to review my code? I’m getting a few errors but ultimately don’t make sense.
foreach(var r in ttResults.Where(r => r.Updated()))
{
try
{
bool brequiresUserInput = false;
string spcMsg = "";
int piMsgType = 0;
string pcPCBinAction = "";
string pcPCBinMessage = "";
decimal pdSerialNoQty = 0;
bool bplNegQtyAction = true;
string pcMessage = "";
string pcPartTranPKs = "";
string pcProcessID = "RcptToInvEntry";
decimal dLaborQty = 0;
string errorMsg = "";
string strWarehouseCode = (r.RcvDtl_WareHouseCode);
string strBinNum = (r.RcvDtl_BinNum);
string strJobNum = (r.JobOper_JobNum);
int iAsmbSeq = 0;
string tranReference = "UBAQ Auto Receipt for PUR-SUB";
int lotNum = 0;
string strLaborQty = "0";
int poNum = (r.RcvHead_PONum);
using(var jobRcpttoInv = Ice.Assemblies.ServiceRenderer.GetService<ReceiptsFromMfgSvcContract>(Db))
{
if (!Decimal.TryParse(strLaborQty, out dLaborQty));
ReceiptsFromMfgTableset RcptfrMfgDS = new ReceiptsFromMfgTableset();
jobRcpttoInv.GetNewReceiptsFromMfgJobAsm(strJobNum,iAsmbSeq,"MFG-STK","RcptToInvEntry",ref RcptfrMfgDS);
RcptfrMfgDS.Tables["PartTran"].Rows[0]["WareHouseCode"] = strWarehouseCode;
jobRcpttoInv.OnChangeWareHouseCode(pcProcessID, ref RcptfrMfgDS);
RcptfrMfgDS.Tables["PartTran"].Rows[0]["ActTranQty"] = dLaborQty;
jobRcpttoInv.OnChangeActTranQty(ref RcptfrMfgDS,out spcMsg);
RcptfrMfgDS.Tables["PartTran"].Rows[0]["BinNum"] = strBinNum;
RcptfrMfgDS.Tables["PartTran"].Rows[0]["RowMod"] = "U";
RcptfrMfgDS.Tables["PartTran"].Rows[0]["ActTranQty"] = dLaborQty;
jobRcpttoInv.PreUpdate(ref RcptfrMfgDS, out brequiresUserInput);
RcptfrMfgDS.Tables["PartTran"].Rows[0]["TranQty"] = dLaborQty;
RcptfrMfgDS.Tables["PartTran"].Rows[0]["ThisTranQty"] = dLaborQty;
if (!String.IsNullOrEmpty(tranReference)) {
RcptfrMfgDS.Tables["PartTran"].Rows[0]["TranReference"] = tranReference;
}
/*
if (!String.IsNullOrEmpty(lotNum)) {
//RcptfrMfgDS.Tables["PartTran"].Rows[0]["LotNum"] = lotNum;
jobRcpttoInv.OnChangeLotNum(ref RcptfrMfgDS, true, lotNum, out spcMsg, out errorMsg);
}*/
jobRcpttoInv.VerifySerialMatchAndPlanContract(ref RcptfrMfgDS,out spcMsg,out piMsgType,out pcPCBinAction,out pcPCBinMessage);
jobRcpttoInv.ReceiveMfgPartToInventory(ref RcptfrMfgDS,pdSerialNoQty,bplNegQtyAction,out pcMessage,out pcPartTranPKs,pcProcessID);
Db.Validate();
}
using (var txScope = IceContext.CreateDefaultTransactionScope())
{
UD01 newRow = new UD01();
Db.UD01.Insert(newRow);
newRow.Company = Session.CompanyID;
newRow.Key1 = strJobNum;
newRow.Key2 = "";
newRow.Key3 = "";
newRow.Key4 = "";
newRow.Character01 = "AutoReceipt of PO";
newRow.CheckBox01 = true; // or false
Db.Validate();
txScope.Complete();
}
}
catch (Exception ex)
{
Ice.Diagnostics.Log.WriteEntry($"", "Auto RcptToInv"); //Write to server log file!
this.PublishInfoMessage(ex.Message, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "TEAGLE/TEAGLE_JobReceiptToInvFromPO", "Update");
}
}
Which refers to
ReceiptsFromMfgTableset RcptfrMfgDS = new ReceiptsFromMfgTableset();
jobRcpttoInv.GetNewReceiptsFromMfgJobAsm(strJobNum,iAsmbSeq,"MFG-STK","RcptToInvEntry",ref RcptfrMfgDS);
RcptfrMfgDS.Tables["PartTran"].Rows[0]["WareHouseCode"] = strWarehouseCode;
jobRcpttoInv.OnChangeWareHouseCode(pcProcessID, ref RcptfrMfgDS);
RcptfrMfgDS.Tables["PartTran"].Rows[0]["ActTranQty"] = dLaborQty;
jobRcpttoInv.OnChangeActTranQty(ref RcptfrMfgDS,out spcMsg);
RcptfrMfgDS.Tables["PartTran"].Rows[0]["BinNum"] = strBinNum;
RcptfrMfgDS.Tables["PartTran"].Rows[0]["RowMod"] = "U";
RcptfrMfgDS.Tables["PartTran"].Rows[0]["ActTranQty"] = dLaborQty;
jobRcpttoInv.PreUpdate(ref RcptfrMfgDS, out brequiresUserInput);
RcptfrMfgDS.Tables["PartTran"].Rows[0]["TranQty"] = dLaborQty;
RcptfrMfgDS.Tables["PartTran"].Rows[0]["ThisTranQty"] = dLaborQty;
section… I’m trying to create a ReceiptFromMfg from a BAQ data and update a UD Table with the data processed so I can use GetList to get the latest receipts and not reprocess the same records by using Checkbox01
as true and hide those rows.
Many thanks
Aaron.