We have a customer that wanted to ship items directly from the sales order without having to go through the shipment entry screen. The orders never change and the items are non-stock so they don’t need the functionality provided by that screen.
To streamline this process we created a button on the sales order entry screen that will automatically ship the order, it mimics the mass shipment functionality from the Shipment Entry screen. Below is the source code you can call from a button click event.
Here is the source.
private static void ShipSalesOrderMethod()
{
// Declare and Initialize EpiDataView Variables
EpiDataView edvOrderHed = ((EpiDataView)(oTrans.EpiDataViews[“OrderHed”]));
Epicor.Mfg.Core.Session session = (Epicor.Mfg.Core.Session)SalesOrderForm.Session;
Epicor.Mfg.BO.CustShipDataSet dsCustShip = new Epicor.Mfg.BO.CustShipDataSet();
Epicor.Mfg.BO.PackOutDataSet dsPackOut = new Epicor.Mfg.BO.PackOutDataSet();
System.String warnMsg = “”;
System.String creditMsg = “”;
// Check if valid EpiDataView Row(s) are selected
if ((edvOrderHed.Row < 0))
{
MessageBox.Show(“No Order Selected”);
return;
}
int salesOrder = ((int)(edvOrderHed.dataView[edvOrderHed.Row][“OrderNum”]));
Epicor.Mfg.BO.CustShip custShip = new Epicor.Mfg.BO.CustShip(session.ConnectionPool);
custShip.GetNewShipHead(dsCustShip);
try
{
custShip.GetHeadOrderInfo(salesOrder, out creditMsg, dsCustShip);
if (!””.Equals(creditMsg))
{
MessageBox.Show(creditMsg);
}
System.String shipToCustomerList = “”;
custShip.BuildShipToCustomerList(salesOrder, out shipToCustomerList);
custShip.BuildShipToList(salesOrder, 9, out shipToCustomerList);
custShip.Update(dsCustShip);
dsPackOut = custShip.POGetNew(salesOrder, dsCustShip.ShipHead[0].PackNum, out warnMsg);
dsPackOut = custShip.POGetDtlList(dsCustShip.ShipHead[0].PackNum, salesOrder, “PACK”, out warnMsg);
custShip.PreCreateMassShipDtl(dsCustShip.ShipHead[0].PackNum, salesOrder, out warnMsg, dsCustShip);
custShip.CreateMassShipDtl(dsCustShip.ShipHead[0].PackNum, salesOrder, dsCustShip);
MessageBox.Show(“” + dsCustShip.ShipHead[0].PackNum);
custShip.MarkShipmentLines(dsCustShip);
custShip.Update(dsCustShip);
System.Boolean compliant;
dsCustShip.ShipHead[0].ReadyToInvoice = true;
if (!””.Equals(creditMsg))
{
MessageBox.Show(warnMsg);
}
custShip.Update(dsCustShip);
custShip.PostUpdate(dsCustShip.ShipHead[0].PackNum, out warnMsg);
if (!””.Equals(creditMsg))
{
MessageBox.Show(warnMsg);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
MessageBox.Show(“Done”);
}
Suggested
- The Datix Blog
- Learn more about Datix ERP consulting services