hey all, I recently asked for help for writing code to issue material from stock to a job in c#, and got that working. However, I now need code that returns material from a job, back to stock. Below is the working code for issuing material from stock to a job:
private void issuemtl(PartInfo thePart,string job,decimal Qty, string oper)
{
IssueReturnAdapter ia = new IssueReturnAdapter(oTrans);
ia.BOConnect();
string msg;
bool reqInput;
string lgl;
string partTran;
ia.GetNewIssueReturnToJob(job, 0, "STK-MTL", Guid.NewGuid(), out msg);
//ia.get
Erp.BO.IssueReturnDataSet.IssueReturnRow row = ia.IssueReturnData.IssueReturn[0];
row.FromWarehouseCode = "MSC";
row.FromBinNum = "CRIB";
row.ToBinNum = "PROD-IN";
row.ToJobNum = job;
row.ToWarehouseCode = "FST";
row.TranReference = "Operator: " + oper;
row.ToJobPartNum = thePart.PartNum;
row.ToJobSeqPartNum = thePart.PartNum;
row.ToJobSeq = thePart.MtlSeq; //has to be valid seq
row.PartNum = thePart.PartNum;
//row.FromAssemblyPartNum = thePart.PartNum;
row.PartIUM = thePart.UOM;
row.DimCode = thePart.UOM;
row.DUM = thePart.UOM;
row.UM = thePart.UOM;
row.TranQty = Qty;
row.RowMod = "U";
ia.PrePerformMaterialMovement(out reqInput);
ia.PerformMaterialMovement(true, out lgl, out partTran);
}
This is my modified code for Returning material from a job to stock:
private void unissuemtl(PartInfo thePart,string job,decimal Qty, string oper)
{
IssueReturnAdapter ia = new IssueReturnAdapter(oTrans);
ia.BOConnect();
string msg;
bool reqInput;
string lgl;
string partTran;
ia.GetNewIssueReturnFromJob(job, 0, "STK-MTL", Guid.NewGuid());
//ia.get
Erp.BO.IssueReturnDataSet.IssueReturnRow row = ia.IssueReturnData.IssueReturn[0];
row.ToWarehouseCode = "MSC";
row.ToBinNum = "CRIB";
row.FromBinNum = "PROD-IN";
row.FromJobNum = job;
row.FromWarehouseCode = "FST";
row.TranReference = "Operator: " + oper;
row.FromJobPartNum = thePart.PartNum;
row.FromJobSeqPartNum = thePart.PartNum;
row.FromJobSeq = thePart.MtlSeq; //has to be valid seq
row.PartNum = thePart.PartNum;
//row.FromAssemblyPartNum = thePart.PartNum;
row.PartIUM = thePart.UOM;
row.DimCode = thePart.UOM;
row.DUM = thePart.UOM;
row.UM = thePart.UOM;
row.TranQty = (-1) * Qty;
row.RowMod = "U";
ia.PrePerformMaterialMovement(out reqInput);
ia.PerformMaterialMovement(true, out lgl, out partTran);
}
I figured I could just switch the “GetNewIssueReturnToJob” to “GetNewIssueReturnFromJob”, and change the data that is being inputted, but it seems to want to use the same variables as the code for “GetNewIssueReturnToJob”. What I mean by this is that I keep getting an error that says “Valid ToJobNum is required”. If I use the same exact code as the issuematerial function, but change the module to “GetNewIssueReturnFromJob”, then it works, but it issues a positive qty to the job. Any suggestions on how to get this working?