Hi Anyone,
We are trying to create the Packslip using BPM. We are having issue when adding the serial number through BPM. Has anyone faced the same Issue and rectified?
It would be great if you could help me with this.
Hello Nika,
Can you elaborate a little further what issues exactly are you facing. Thanks.
Hello @stoyanlevakov,
I am trying to create the packslip and lines from the UD table,using the BPM code as shown below. with this code I am able to create packslip and lines for non serialized parts. We have included the methods and business objects in the BPM code for serialized parts as provided in the tracing.
Whenever I am trying to create a packslip lines for serialized part I am getting the following error.
Error message:Number of selected Serial Numbers does not match quantities shipped for Part/Line: 0SC1/1 Serial Numbers selected from Inventory: 0 Serial Numbers selected from Job : 0 Total Serial Numbers required: 10
// This BPM is used to create the Packslip ( UD101- Datadirective -> In Tran).
var ttrow = (from row in ttUD101 where (row.RowMod == "A" || row.RowMod =="U") select row).FirstOrDefault();
if(ttrow != null)
{
int orderNum = Convert.ToInt32(ttrow.Key2);//5631;
int custNum = 0;
var dbOrderHed = (from row in Db.OrderHed where row.Company == Session.CompanyID && row.OrderNum == orderNum select row).FirstOrDefault();
if(dbOrderHed != null)
{
custNum= Convert.ToInt32(dbOrderHed.CustNum);
}
string creditMessage = "";
string shipToCustomerList = "";
int iShipToCustNum = custNum;//13331;
string shipToList = "";
int ipPackNum = 0;
bool opPromptForNum = false;
int lineNum = 0;
bool belongToAnotherPC = false;
string pcOutsideMessage= "";
bool cError,compError,updateComplete,checkComplianceError,changeStatusError,checkShipDtlAgain = false;
string opReleaseMessage,opCompleteMessage,opShippingMessage,opLotMessage,opInventoryMessage,opLockQtyMessage,opAllocationMessage,opPartListNeedsAttr,opLotListNeedsAttr,shipCreditMsg,msg,opPostUpdMessage = "";
string partNum = "";
string vMsgText,vMsgType,origPartNum = "";
bool vSubAvail = false;
int ipBTCustNum = custNum;//13331;
var svc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.CustShipSvcContract>(Db);
Erp.Tablesets.CustShipTableset CT;
CT = new Erp.Tablesets.CustShipTableset();
svc.GetNewShipHead(ref CT);
svc.GetHeadOrderInfo(orderNum,out creditMessage,ref CT);
svc.BuildShipToCustomerList(orderNum,out shipToCustomerList);
svc.BuildShipToList(orderNum,iShipToCustNum,out shipToList);
svc.GetLegalNumGenOpts(ipPackNum,ref CT, out opPromptForNum);
svc.CheckPCBinOutLocation(ref CT,out lineNum,out belongToAnotherPC, out pcOutsideMessage);
CT.ShipHead[0].ShipDate = Convert.ToDateTime(DateTime.Now);
//CT.ShipHead[0].ShipViaCode = "UPS";
CT.ShipHead[0].CustNum = custNum;//13331;
CT.ShipHead[0].Plant = Session.PlantID.ToString();
CT.ShipHead[0].RowMod = "A";
svc.UpdateMaster(ref CT,false,false,false,false,false,false,false,ipPackNum,iShipToCustNum,out opReleaseMessage,out opCompleteMessage,out opShippingMessage,out opLotMessage,out opInventoryMessage,out opLockQtyMessage,out opAllocationMessage,out opPartListNeedsAttr,out opLotListNeedsAttr,out shipCreditMsg,out cError,out compError,out msg,out opPostUpdMessage,out updateComplete,out checkComplianceError,out changeStatusError,out checkShipDtlAgain);
int Packnum = CT.ShipHead[0].PackNum;
string company = CT.ShipHead[0].Company;
int ipOrderNum = 0;
string pcWarningMsg,cWarning,ipPCID= "";
// string ipPCID = "";
svc.POGetNew(ipOrderNum,Packnum,out pcWarningMsg);
string ipPackMode = "PACK";
svc.POGetDtlList(Packnum,ipPCID,orderNum,ipPackMode,out cWarning);
svc.GetNewOrdrShipDtl(ref CT,Packnum,0);
svc.GetOrderInfo(orderNum,out creditMessage,ref CT);
//svc.GetManifestInfo(orderNum,Packnum,ref CT);
svc.BuildShipToList(orderNum,iShipToCustNum,out shipToList);
//svc.GetListFilterShipped();
int orderLine = Convert.ToInt32(ttrow.Key3);
svc.CheckPrePartInfo(ref partNum,orderNum,orderLine,out vMsgText,out vSubAvail,out vMsgType,out origPartNum);
int packLine = 0;
int orderRelNum = Convert.ToInt32(ttrow.Key4);
string subsPart = "";//"8700-1251-900";
var dbOrderRel = (from row in Db.OrderRel where row.Company == Session.CompanyID && row.OrderNum == orderNum && row.OrderLine == orderLine && row.OrderRelNum == orderRelNum select row).FirstOrDefault();
if(dbOrderRel != null)
{
subsPart = Convert.ToString(dbOrderRel.PartNum);
}
svc.GetOrderLineInfo(ref CT,packLine,orderLine,subsPart);
bool allowNewShipTo = true;
svc.GetOrderRelInfo(ref CT,packLine,orderRelNum,allowNewShipTo);
// svc.BuildShipToList();
//SERIAL TRACKED PART CODE START
var dbPart = (from row in Db.Part where row.Company == Session.CompanyID && row.PartNum == subsPart select row).FirstOrDefault();
if(dbPart != null)
{
if(dbPart.TrackSerialNum == true)
{
string ipPartNum = dbPart.PartNum.ToString();
decimal ipQuantity = CT.ShipDtl[0].OurInventoryShipQty;
string ipUOM = CT.ShipDtl[0].InventoryShipUOM.ToString();
//int ipPackNum = CT.ShipDtl[0].PackNum;
int ipPackLine = CT.ShipDtl[0].PackLine;
string ipTranType = "STK-PCK";
string ipJobNum = CT.ShipDtl[0].JobNum.ToString();//"";
string ipWhseCode = CT.ShipDtl[0].WarehouseCode.ToString();
string ipBinNum = CT.ShipDtl[0].BinNum.ToString();
string ipLotNum = CT.ShipDtl[0].LotNum.ToString();
bool ipFromPO = false;
//int ipOrderNum = CT.ShipDtl[0].OrderNum;
int ipOrderLine = CT.ShipDtl[0].OrderLine;
int ipOrderRelNum = CT.ShipDtl[0].OrderRelNum;
Guid ipSysRowID = new Guid("00000000-0000-0000-0000-000000000000");
//ipSysRowID = "00000000-0000-0000-0000-000000000000";
svc.GetSelectSerialNumbersParams(ipPartNum,ipQuantity,ipUOM,ipPackNum,ipPackLine,ipTranType,ipJobNum,ipWhseCode,ipBinNum,ipLotNum,ipFromPO,ipOrderNum,ipOrderLine,ipOrderRelNum,ipSysRowID);
var SSNBO = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SelectedSerialNumbersSvcContract>(Db);
Erp.Tablesets.SelectedSerialNumbersTableset ssnTs = new Erp.Tablesets.SelectedSerialNumbersTableset();
string xrefPartNum = string.Empty;
string xrefPartType = string.Empty;
int xrefCustNum = 0;
SSNBO.GetSerialNumFormat(ref ssnTs, ipPartNum, xrefPartNum, xrefPartType, xrefCustNum, Session.PlantID.ToString());
string snPartNum = ipPartNum;
string nextBaseSN = string.Empty;
string snPrefix = string.Empty;
string nextFullSN = string.Empty;
bool snCounterMax = false;
SSNBO.GetNextSN(ref ssnTs, ipPartNum, xrefPartNum, xrefPartType, xrefCustNum, Session.PlantID.ToString(), out nextBaseSN, out snPrefix, out nextFullSN, out snCounterMax);
SSNBO.Dispose();
}
}
//------ SERIAL TRACKED PART CODE END
/*var dbPart = (from row in Db.Part where row.Company == Session.CompanyID && row.PartNum == subsPart select row).FirstOrDefault();
if(dbPart != null)
{
// TRACKLOT PART CODE START
if(dbPart.TrackLots == true)
{
//InfoMessage.Publish("Adding LotNum to TrackLot Part");
var LSUBO = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.LotSelectUpdateSvcContract>(Db);
Erp.Tablesets.PartLotListTableset partlotlistTs = new Erp.Tablesets.PartLotListTableset();
string ipWhseCode = CT.ShipDtl[0].WarehouseCode.ToString();
string ipBinNum = CT.ShipDtl[0].BinNum.ToString();
string whereClause = "(PartNum = '"+subsPart+"') AND Onhand = true";//(PartNum = '00M3') AND OnHand = true
int pageSize = 100;
int absolutePage = 0;
bool morePages = false;
partlotlistTs = LSUBO.GetListByBinNum(ipWhseCode,ipBinNum,whereClause,pageSize,absolutePage, out morePages);
//InfoMessage.Publish("LotNum - "+partlotlistTs.PartLotList[0].LotNum.ToString());
CT.ShipDtl[0].LotNum = partlotlistTs.PartLotList[0].LotNum.ToString();
LSUBO.Dispose();
}
//--------- TRACKLOT PART CODE END
}*/
svc.CheckPCBinOutLocation(ref CT,out lineNum,out belongToAnotherPC,out pcOutsideMessage);
bool doValidateCreditHold,doCheckShipDtl = false;
CT.ShipHead[0].RowMod = "U";
CT.ShipDtl[0].PackNum = Packnum;
CT.ShipDtl[0].PackLine = packLine;
CT.ShipDtl[0].OrderLine = orderLine;
CT.ShipDtl[0].OrderRelNum = orderRelNum;
CT.ShipDtl[0].LineType = "PART";
CT.ShipDtl[0].OurInventoryShipQty = Convert.ToDecimal(ttrow.Number01);
CT.ShipDtl[0].Packages = 1;
CT.ShipDtl[0].PartNum = subsPart;
// CT.ShipDtl[0].WarehouseCode = "CHI";
// CT.ShipDtl[0].BinNum = "01-01-02";
CT.ShipDtl[0].RowMod = "A";
svc.UpdateMaster(ref CT,false,false,false,false,false,false,false,Packnum,ipBTCustNum,out opReleaseMessage,out opCompleteMessage,out opShippingMessage,out opLotMessage,out opInventoryMessage,out opLockQtyMessage,out opAllocationMessage,out opPartListNeedsAttr,out opLotListNeedsAttr,out shipCreditMsg,out cError,out compError,out msg,out opPostUpdMessage,out updateComplete,out checkComplianceError,out changeStatusError,out checkShipDtlAgain);
InfoMessage.Publish("packslip created.");
}
The serial numbers need to end up into your CustShip dataset - in your case is CT.SelectedSerialNumbers (I used tsCustShip instead of CT). Here is what I did:
First, I use the SelectedSerialNumbersSvcContract to create the table with all the serials (note below is from a function). Something like this (I have the serials incoming from a 3rd party system in a string vSerials separated by commas):
// call ssn service
this.CallService<Erp.Contracts.SelectedSerialNumbersSvcContract>(ssnc => {
// get sn format
ssnc.GetSerialNumFormat(ref tsSelSerials, vPartNo, String.Empty, String.Empty, 0, "yourplanthere");
// split the serials string by ,
tstr = ",";
char[] splto = tstr.ToCharArray();
string[] snos = vSerials.Split(splto, System.StringSplitOptions.RemoveEmptyEntries);
// add each serial to the tableset
int acnt = 0;
foreach (string sno in snos)
{
ssnc.AddSerialNum(ref tsSelSerials, vPartNo, String.Empty, String.Empty, 0, sno, Guid.Empty.ToString(), "STK-PCK", "yourplanthere");
acnt = acnt + 1;
}
Note that the SelectedSerialNumbers.SelectedSerialNumbers is NOT the same as CustShip.SelectedSerialNumbers. So, just before I call the second UpdateMaster to save the line, I populate the serials in the CustShip dataset based on the one above:
// copy all selected serials to custship tableset
for (int i=0; i<tsSelSerials.SelectedSerialNumbers.Count; i++)
{
var ssnrow = tsCustShip.SelectedSerialNumbers.NewRow();
ssnrow["Company"] = tsSelSerials.SelectedSerialNumbers[i].Company;
ssnrow["SerialNumber"] = tsSelSerials.SelectedSerialNumbers[i].SerialNumber;
ssnrow["Scrapped"] = tsSelSerials.SelectedSerialNumbers[i].Scrapped;
ssnrow["ScrappedReasonCode"] = tsSelSerials.SelectedSerialNumbers[i].ScrappedReasonCode;
ssnrow["Voided"] = tsSelSerials.SelectedSerialNumbers[i].Voided;
ssnrow["Reference"] = tsSelSerials.SelectedSerialNumbers[i].Reference;
ssnrow["ReasonCodeType"] = tsSelSerials.SelectedSerialNumbers[i].ReasonCodeType;
ssnrow["ReasonCodeDesc"] = tsSelSerials.SelectedSerialNumbers[i].ReasonCodeDesc;
ssnrow["PartNum"] = tsSelSerials.SelectedSerialNumbers[i].PartNum;
ssnrow["SNPrefix"] = tsSelSerials.SelectedSerialNumbers[i].SNPrefix;
ssnrow["SNBaseNumber"] = tsSelSerials.SelectedSerialNumbers[i].SNBaseNumber;
ssnrow["SourceRowID"] = Guid.Empty; //tsSelSerials.SelectedSerialNumbers[i].SourceRowID;
ssnrow["TransType"] = tsSelSerials.SelectedSerialNumbers[i].TransType;
ssnrow["PassedInspection"] = tsSelSerials.SelectedSerialNumbers[i].PassedInspection;
ssnrow["Deselected"] = tsSelSerials.SelectedSerialNumbers[i].Deselected;
ssnrow["KitWhseList"] = tsSelSerials.SelectedSerialNumbers[i].KitWhseList;
ssnrow["RawSerialNum"] = tsSelSerials.SelectedSerialNumbers[i].RawSerialNum;
ssnrow["KBLbrAction"] = tsSelSerials.SelectedSerialNumbers[i].KBLbrAction;
ssnrow["KBLbrActionDesc"] = tsSelSerials.SelectedSerialNumbers[i].KBLbrActionDesc;
ssnrow["PreventDeselect"] = tsSelSerials.SelectedSerialNumbers[i].PreventDeselect;
ssnrow["XRefPartNum"] = tsSelSerials.SelectedSerialNumbers[i].XRefPartNum;
ssnrow["XRefPartType"] = tsSelSerials.SelectedSerialNumbers[i].XRefPartType;
ssnrow["PreDeselected"] = tsSelSerials.SelectedSerialNumbers[i].PreDeselected;
ssnrow["poLinkValues"] = tsSelSerials.SelectedSerialNumbers[i].poLinkValues;
ssnrow["SNMask"] = tsSelSerials.SelectedSerialNumbers[i].SNMask;
ssnrow["NotSavedToDB"] = tsSelSerials.SelectedSerialNumbers[i].NotSavedToDB;
ssnrow["RowSelected"] = tsSelSerials.SelectedSerialNumbers[i].RowSelected;
ssnrow["SysRowID"] = Guid.Empty; //tsSelSerials.SelectedSerialNumbers[i].SysRowID;
ssnrow["RowMod"] = "A";
tsCustShip.SelectedSerialNumbers.Add(ssnrow);
}
Or you could just create the serials directly into the CustShip dataset (if possible or easier for you).