Creating a Customer Shipment Pack using C#

Hey everyone! I am having an issue here. I have code that will create a pack list automatically from a button click. This is the scenario:

We have a dashboard that displays items that are shipping to the customer for the day. There can be 2 kinds of shipments, shipments from jobs, and shipments from stock. I have a button that allows for them to create a pack list automatically on the record that is currently selected. This works great for items that are job shipments. However, when it is a stock shipment, I have an issue.

The packlist is created just fine, and the pack line is created just fine, but it will not put in the inventory shipment qty. When I do the same code, but for a job shipment, everything works great. What is going on?!?!?!

Here is my code for creating the PackList Header:

private void createpack(int cust,int bt,string shipnum,int order)
{
	// Declare and create an instance of the Adapter.
		CustShipAdapter adapterCustShip = new CustShipAdapter(this.oTrans);
		adapterCustShip.BOConnect();
		
		adapterCustShip.GetNewShipHead();

		DataRow ship = adapterCustShip.CustShipData.ShipHead[adapterCustShip.CustShipData.ShipHead.Rows.Count - 1];
		ship["Company"] = "NET";
		ship["CurrencyCode"] = "US";
		ship["CustNum"] = cust;
		ship["BTCustNum"] = bt;
		ship["ShipToCustNum"] = cust;
		ship["ShipToNum"] = shipnum;
		ship["OrderNum"] = order;
		ship["ShipStatus"] = "OPEN";
		ship["Invoiced"] = 0;
		ship["ReadyToInvoice"] = 0;
		ship["ShipToNum"] = "";
		ship["ShipDate"] = DateTime.Now;
		ship["ShipViaCode"] = "FDXG";
		ship["ShipPerson"] = "Tablet1";
		ship["EntryPerson"] = "Tablet1";
		ship["Plant"] = "MfgSys";
		adapterCustShip.Update();

		// Cleanup Adapter Reference
		adapterCustShip.Dispose();
		oTrans.Update();
}

This works great, Here is my code for creating a stock shipment line:

private void newline(string job, string order, string line, string rel, string part, string rev, string desc,int qty,int pack,int cust, string shipto)
	{
		try
		{
			// Declare and create an instance of the Adapter.
			CustShipAdapter adapterCustShip = new CustShipAdapter(this.oTrans);
			adapterCustShip.BOConnect();
						
			adapterCustShip.GetByID(pack);
			adapterCustShip.GetNewShipDtl(pack);
			adapterCustShip.GetNewOrdrShipDtl(pack,Convert.ToInt32(order));

				DataRow ship = adapterCustShip.CustShipData.ShipDtl[adapterCustShip.CustShipData.ShipDtl.Rows.Count - 1];
				ship["Company"] = "NET";
				ship["CustNum"] = cust;
				ship["ShipToCustNum"] = cust;
				ship["MFCustNum"] = cust;
				ship["MFShipToNum"] = shipto;
				ship["JobNum"] = job;
				ship["OrderNum"] = order;
				ship["OrderLine"] = line;
				ship["OrderRelNum"] = rel;
				ship["PartNum"] = part;
				ship["RevisionNum"] = rev;
				ship["LineDesc"] = desc;
				ship["WIPWarehouseCode"] = "SHIP";
				ship["WIPWarehouseCodeDescription"] = "Shipping Area";
				ship["WIPBinNum"] = "SHIP-OUT";
				ship["JobShipUOM"] = "EA";
				ship["SellingShipmentUM"] = "EA";
				ship["SellingReqUM"] = "EA";
				ship["SellingRemainUM"] = "EA";
				ship["SalesUM"] = "EA";
				ship["IUM"] = "EA";
				ship["WUM"] = "LB";
				ship["SellingShipmentQty"] = qty;
				ship["OurJobShipQty"] = qty;
				adapterCustShip.Update();
	
				// Cleanup Adapter Reference
			adapterCustShip.Dispose();
			oTrans.Update();

		} catch (System.Exception ex)
		{
			ExceptionBox.Show(ex);
		}
	}

Again, this works great, no issues. Finally, here is my code for creating a stock shipment line:

private void createstocklines(int pack, int order, int cust,int line, int rel,string part, string rev, string desc, int qty,string shipto)
{
	try
	{
		CustShipAdapter adapterCustShip = new CustShipAdapter(this.oTrans);
		adapterCustShip.BOConnect();
	
		adapterCustShip.GetByID(pack);
		adapterCustShip.GetNewShipDtl(pack);
		adapterCustShip.GetNewOrdrShipDtl(pack,order);

			DataRow ship = adapterCustShip.CustShipData.ShipDtl[adapterCustShip.CustShipData.ShipDtl.Rows.Count - 1];
			ship["Company"] = "NET";
			ship["CustNum"] = cust;
			ship["ShipToCustNum"] = cust;
			ship["MFCustNum"] = cust;
			ship["MFShipToNum"] = shipto;
			ship["OrderNum"] = order;
			ship["OrderLine"] = line;
			ship["OrderRelNum"] = rel;
			ship["PartNum"] = part;
			ship["RevisionNum"] = rev;
			ship["LineDesc"] = desc;
			ship["WarehouseCode"] = "SHIP";
			ship["WarehouseCodeDescription"] = "Shipping Area";
			ship["BinNum"] = "SHIP-OUT";
			ship["WarehouseCode"] = "VLM";
			ship["WarehouseCodeDescription"] = "VLM Storage";
			ship["BinNum"] = "FG";
			ship["InventoryShipUOM"] = "EA";
			ship["JobShipUOM"] = "EA";				
			ship["SellingShippedUM"] = "EA";
			ship["SellingShipmentUM"] = "EA";
			ship["SellingReqUM"] = "EA";
			ship["SellingRemainUM"] = "EA";
			ship["SalesUM"] = "EA";
			ship["IUM"] = "EA";
			ship["WUM"] = "LB";
			ship["SellingInventoryShipQty"] = qty;
			ship["OurInventoryShipQty"] = qty;
			adapterCustShip.Update();

			// Cleanup Adapter Reference
		adapterCustShip.Dispose();
		oTrans.Update();

	} catch (System.Exception ex)
	{
		ExceptionBox.Show(ex);
	}

}

Everything in this section works fine, but it will not put any data into the “OurInventoryShipQty” field. No errors, just doesn’t complete it. Sorry for the long post, but does anyone have any suggestions???

1 Like

Hello, do you resolved this??? Can you tell me…

Don’t actually know if I did or not. I think I just told our shipping guy to manually type in the qty. Not that much of an extra step!

Ok thanks

Hi, I know this is an old post but I’m working on something similar in a BPM at the moment. Have you considered trying to use the CustShip.GetQtyInfo method to change the shipment qty? This is working well for me. It takes the following parameters:

I actually no longer work at that company, so I cannot try. But, That sounds like a way easier solution than what I was trying. Thanks for the feedback :slight_smile:

May I know by using the same method how to create a sales kit line in customer shipment? can anyone advise?

Hi Vincent,
I used the trace and created the blow sequence, it works for stock/job and kit lines. Maybe it helps :wink:

      foreach(DataRow dr in dsResults.Tables[0].Rows)
      {
        myOrderLine = System.Convert.ToInt32(dsResults.Tables[0].Rows[CurrCount][0]);
        myOrderRelNum = System.Convert.ToInt32(dsResults.Tables[0].Rows[CurrCount][1]);            
        myPartNum = System.Convert.ToString(dsResults.Tables[0].Rows[CurrCount][2]);
        myPickingQty = System.Convert.ToDecimal(dsResults.Tables[0].Rows[CurrCount][3]);
        myShipBin = System.Convert.ToString(dsResults.Tables[0].Rows[CurrCount][4]);
                  
        //****************************Begin Shipment Detail Creation*********************************************

        myCustShipDataSet.ShipDtl.Clear();
        customerShipSvc.GetNewOrdrShipDtl(ref myCustShipDataSet, headerPackNum, curOrderNum);
        var currPackLine = myCustShipDataSet.ShipDtl.Where(w => w.PackLine == 0).FirstOrDefault();

        currPackLine.OrderNum = curOrderNum;
        currPackLine.OrderLine = myOrderLine;
        customerShipSvc.CheckPrePartInfo(ref prePartPartNum, currPackLine.OrderNum, currPackLine.OrderLine, out prePartvMsgText, out prePartVSubAvail, out prePartvMsgType, out prePartOrigPartNum);
        customerShipSvc.GetOrderLineInfo(ref myCustShipDataSet, currPackLine.PackLine, currPackLine.OrderLine, prePartOrigPartNum);
        currPackLine.OrderRelNum = myOrderRelNum;
        customerShipSvc.GetOrderRelInfo(ref myCustShipDataSet, currPackLine.PackLine, currPackLine.OrderRelNum, true);
        currPackLine.PartNum = prePartOrigPartNum;
        customerShipSvc.GetPartInfo(ref myCustShipDataSet, currPackLine.PackLine, ref prePartOrigPartNum, Guid.Empty, string.Empty, out getPartInfo, out getPartInfo, out getPartInfoB, out getPartInfo); 
        customerShipSvc.MarkShipmentLines(ref myCustShipDataSet);
        if (currPackLine.BinNum == "")
        {
          currPackLine.BinNum = myShipBin;
        }
        //this.PublishInfoMessage(currPackLine.BinNum, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "Auto Shipment BPM","Ship Line");  
        
        customerShipSvc.UpdateMaster(ref myCustShipDataSet, false, false, false, false, false, false, false, headerPackNum, 0, 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);
                  
                  
        //string body = Convert.ToString(myCustShipDataSet.ShipDtl);
        //this.PublishInfoMessage(body, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "Auto Shipment BPM","Ship Line");  
        CurrCount = CurrCount +1;             
      }
3 Likes

thanks @Wunschi and this is great sample for me, i will try on this.

Hi Vincent,
did you ship kits and serial numbers? Maybe you got a c # function that I could use.