here is a webservice function in .NET that creates sales order header and details.
Might help, might not.
private Boolean ProcessOrder(SalesOrderTransfer NewOrder)
{
//Create Epicor Link
//Process the Orderfile
try
{
using (var session = GetSessionID())
{
using (var OrderProxy = GetOrder(session))
{
Erp.BO.SalesOrderDataSet sods = new Erp.BO.SalesOrderDataSet();
//When we have more customers we will need to set the vaule differently???
bool blnOut;
string strResponseMsg;
string strCreditShipAction;
string strDisplayMsg;
string strCompliantMsg;
string strResponseMsgOrdRel;
/*This sets the defaults for each customer*/
var identity = (ClaimsIdentity)User.Identity;
Claim claimCustNum = identity?.FindFirst("CustomerNum");
Claim claimCustId = identity?.FindFirst("CustomerID");
Claim claimDefaultFOB = identity?.FindFirst("DefaultFOB");
Claim claimTermsCode = identity?.FindFirst("TermsCode");
string strCustId = claimCustId.Value;
int intCustomerNum = int.Parse(claimCustNum.Value);
string strDefaultFOB = claimDefaultFOB.Value;
string strTermsCode = claimTermsCode.Value;
int intSalesOrder = 0;
int intDetailCount = 0;
foreach (var salesorder in NewOrder.SalesOrderCreate)
{
//if (salesorder.OrderHeader.NeedByDate.ToString() == "") break;
//We first need to create the OrderHeader
//this should only be done once per file
if (intSalesOrder == 0)
{
//Create New Order
OrderProxy.GetNewOrderHed(sods);
intSalesOrder = sods.OrderHed[0].OrderNum;
//Default Fields Created
sods.OrderHed[0].Company = "HI";
sods.OrderHed[0].CustNum = intCustomerNum;
sods.OrderHed[0].CustomerCustID = strCustId;
sods.OrderHed[0].BTCustNum = intCustomerNum;
sods.OrderHed[0].ShipToCustNum = intCustomerNum;
OrderProxy.ChangeSoldToID(sods);
sods.OrderHed[0].FOB = strDefaultFOB;
sods.OrderHed[0].OrderDate = DateTime.Now;
sods.OrderHed[0].ShipViaCode = salesorder.OrderHeader.ShipViaCode.ToString(); //"FX1";
sods.OrderHed[0].TermsCode = strTermsCode;
sods.OrderHed[0].UseOTS = true;
OrderProxy.ChangeHedUseOTS(sods);
sods.OrderHed[0]["Date01"] = DateTime.Now;
//Fields from first record of file
//DateTime? myDateTime = DateTime.ParseExact(salesorder.OrderHeader.NeedByDate.ToString(), "MM/dd/yyyy", null);
if (salesorder.OrderHeader.NeedByDate.ToString() == "")
{
sods.OrderHed[0].NeedByDate = Convert.ToDateTime("01/01/2010");
}
else
{
sods.OrderHed[0].NeedByDate = Convert.ToDateTime(salesorder.OrderHeader.NeedByDate.ToString());
}
OrderProxy.ChangeNeedByDate(sods, "OrderHed");
sods.OrderHed[0].OrderComment = salesorder.OrderHeader.OrderComment.ToString();
sods.OrderHed[0].ShipComment = salesorder.OrderHeader.ShipComment.ToString();
sods.OrderHed[0].OTSAddress1 = salesorder.OrderHeader.OTSAddress1.ToString();
sods.OrderHed[0].OTSAddress2 = salesorder.OrderHeader.OTSAddress2.ToString();
sods.OrderHed[0].OTSAddress3 = salesorder.OrderHeader.OTSAddress3.ToString();
sods.OrderHed[0].OTSCity = salesorder.OrderHeader.OTSCity.ToString();
sods.OrderHed[0].OTSContact = salesorder.OrderHeader.OTSContact.ToString();
sods.OrderHed[0].OTSCountryNum = int.Parse(salesorder.OrderHeader.OTSCountryNum.ToString());
//sods.OrderHed[0].OTSFaxNum = row["OTSFaxNum"].ToString();
sods.OrderHed[0].OTSName = salesorder.OrderHeader.OTSName.ToString();
sods.OrderHed[0].OTSPhoneNum = salesorder.OrderHeader.OTSPhoneNum.ToString();
//sods.OrderHed[0].OTSResaleID = row["OTSResaleID"].ToString();
sods.OrderHed[0].OTSState = salesorder.OrderHeader.OTSState.ToString();
sods.OrderHed[0].OTSZIP = salesorder.OrderHeader.OTSZIP.ToString();
sods.OrderHed[0].PONum = salesorder.OrderHeader.PONum.ToString();
sods.OrderHed[0].RequestDate = Convert.ToDateTime(salesorder.OrderHeader.RequestDate.ToString());
sods.OrderHed[0]["ShortChar02"] = salesorder.OrderHeader.CustomerPONum.ToString();
sods.OrderHed[0]["ShortChar03"] = salesorder.OrderHeader.CustomerCustId.ToString();
sods.OrderHed[0]["CustRef_c"] = salesorder.OrderHeader.CustomerRefInfo.ToString();
sods.OrderHed[0]["NeedTrackingSent_c"] = 1;
sods.OrderHed[0]["OrderContact_c"] = salesorder.OrderHeader.OTSContact.ToString();
OrderProxy.MasterUpdate(true, true, "Orderhed", intCustomerNum, intSalesOrder, true, out blnOut, out strResponseMsg, out strCreditShipAction, out strDisplayMsg, out strCompliantMsg, out strResponseMsgOrdRel, sods);
intSalesOrder = sods.OrderHed[0].OrderNum;
}
foreach (var line in salesorder.LineItems)
{
//Create new Lines for the order
OrderProxy.GetNewOrderDtl(sods, intSalesOrder);
intDetailCount = sods.OrderDtl.Count - 1;
//sods.OrderDtl[intDetailCount].PartNum = line.PartNum.ToString();
//sods.OrderDtl[intDetailCount].PartNumPartDescription = line.PartNum.ToString();
OrderProxy.ChangePartNum(sods, false, "");
if (salesorder.OrderHeader.NeedByDate.ToString() == "")
{
sods.OrderDtl[intDetailCount].NeedByDate = Convert.ToDateTime("01/01/2010");
}
else
{
sods.OrderDtl[intDetailCount].NeedByDate = Convert.ToDateTime(salesorder.OrderHeader.NeedByDate.ToString());
}
OrderProxy.ChangeNeedByDate(sods, "OrderDtl");
sods.OrderDtl[intDetailCount].RequestDate = Convert.ToDateTime(salesorder.OrderHeader.RequestDate.ToString());
sods.OrderDtl[intDetailCount].SellingQuantity = decimal.Parse(line.SellingQuantity.ToString());
// sods.OrderDtl[intDetailCount].OrderLine = int.Parse(line.OrderLine.ToString());
sods.OrderDtl[intDetailCount].XPartNum = line.CustXPartNum.ToString();
//sods.OrderDtl[intDetailCount].XPartNum = "(" + line.CustXPartNum.ToString() + ")";
OrderProxy.ChangeXPartNum(sods);
OrderProxy.ChangeCommissionable(sods);
//Need to call masterupdate not update
OrderProxy.MasterUpdate(true, true, "OrderDtl", intCustomerNum, intSalesOrder, true, out blnOut, out strResponseMsg, out strCreditShipAction, out strDisplayMsg, out strCompliantMsg, out strResponseMsgOrdRel, sods);
//need to test
//if (line.Warehouse.ToString() == "Service")
//{
sods.OrderRel[intDetailCount].WarehouseCode = line.Warehouse.ToString();
OrderProxy.ChangeORelWarehouse(sods);
OrderProxy.MasterUpdate(true, true, "OrderRel", intCustomerNum, intSalesOrder, true, out blnOut, out strResponseMsg, out strCreditShipAction, out strDisplayMsg, out strCompliantMsg, out strResponseMsgOrdRel, sods);
//}
}
if (intSalesOrder != 0)
{
sods.OrderHed[0].UserChar1 = "PRINT";
sods.OrderHed[0].RowMod = "U";
//OrderProxy.Update(sods);
OrderProxy.MasterUpdate(true, true, "Orderhed", intCustomerNum, intSalesOrder, true, out blnOut, out strResponseMsg, out strCreditShipAction, out strDisplayMsg, out strCompliantMsg, out strResponseMsgOrdRel, sods);
}
}
// Email Ken that file was processed with Order and Line details
//SendMail();
}
}
return true;
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
return false;
}
} //private Boolean ProcessOrder(SalesOrderTransfer NewOrder)