I am doing order fulfillment process which already i created order for some customer now i need to allocate some serial number against this order.
In GP sales Serial Number Entry we have serial number in available list i want to allocate serial number based on the qty from available serial to allocated serial which thing i wanna achieve through asp.net application using econnect service.
I tried with following code but getting error
"7030- Payment term doesnot exist"
For order fulfillment process i checked with SOPTYPE=2 and 6 but failed to reach.
using System;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
using System.Text;
using Microsoft.Dynamics.GP.eConnect;
using Microsoft.Dynamics.GP.eConnect.Serialization;
using System.Web.UI.WebControls;
using System.Configuration;
using Microsoft.Dynamics.GP.eConnect.MiscRoutines;
namespace EconnectSample
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string salesOrderDocument;
string sConnectionString;
bool eResult;
eConnectMethods eConCall = new eConnectMethods();
try
{
// Call the SerializeSalesOrderObject subroutine and specify
// a file name
SerializeSalesOrderObject("SalesOrder.xml");
// Create an XML document object and load it with the XML from the
// file that the SerializeSalesOrder subroutine created
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load("SalesOrder.xml");
salesOrderDocument = xmldoc.OuterXml;
string csName = ConfigurationManager.AppSettings["eConnectConnStringName"];
string cs = ConfigurationManager.ConnectionStrings[csName].ToString();
eResult = eConCall.eConnect_EntryPoint(cs, EnumTypes.ConnectionStringType.SqlClient, salesOrderDocument, EnumTypes.SchemaValidationType.None, "");
if (eResult)
{
// logger.Debug("Magento Order Succecssfully integrated");
//SendMail(strSOPNumber, magentoOrder.order_id);
}
else
{
// LogManager.GetLogger("Mail").Error(ex);
}
}
catch (eConnectException exp)
{
}
catch (System.Exception ex)
{
}
finally
{
eConCall.Dispose();
}
}
public string GetNextSopNumber(int sopType, string docId, string strOrder)
{
string strSOPNumber = "";
string csName = ConfigurationManager.AppSettings["eConnectConnStringName"];
string cs = ConfigurationManager.ConnectionStrings[csName].ToString();
//EventLog.WriteEntry("Time", cs);
GetNextDocNumbers GetNxtNo = new GetNextDocNumbers();
if (strOrder == "Order")
{
strSOPNumber = GetNxtNo.GetNextSOPNumber(GetNextDocNumbers.IncrementDecrement.Increment, "ORDER", GetNextDocNumbers.SopType.SOPOrder, cs);
}
else
{
strSOPNumber = GetNxtNo.GetNextSOPNumber(GetNextDocNumbers.IncrementDecrement.Increment, "INV", GetNextDocNumbers.SopType.SOPInvoice, cs);
}
return strSOPNumber;
}
void SerializeSalesOrderObject(string filename)
{
SOPTransactionType salesOrder = new SOPTransactionType();
taSopSerial_ItemsTaSopSerial serialno = new taSopSerial_ItemsTaSopSerial();
taSopLineIvcInsert_ItemsTaSopLineIvcInsert salesLine = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert();
taSopLineIvcInsert_ItemsTaSopLineIvcInsert salesLine2 = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert();
taSopHdrIvcInsert salesHdr = new taSopHdrIvcInsert();
taSopLineIvcInsert_ItemsTaSopLineIvcInsert[] LineItems=new taSopLineIvcInsert_ItemsTaSopLineIvcInsert[1];
try
{
int countLine = 1;
GetNextDocNumbers GetNxtNo = new GetNextDocNumbers();
string strSalesDoc = "", strlocation = ""; ;
string csName = ConfigurationManager.AppSettings["eConnectConnStringName"];
string cs = ConfigurationManager.ConnectionStrings[csName].ToString();
bool eResult;
string strSOPNumber;
string strDociD = ConfigurationManager.AppSettings["GPOrderDocumentType"];
strSOPNumber = GetNextSopNumber(2, strDociD, "Order").Trim();
decimal dUnitPrice = 0;
string gpSku = null;
string gpSiteId = null;
gpSku = "BLB008330-10B2-ALBAL11A-0C/210";//magentoLineItem.sku;
string strValue = gpSku;
if (strValue.Contains("/"))
{
string[] strArray = strValue.Split('/');
gpSku = "BLB008330-10B2-ALBAL11A-0C";//strArray[0];
salesLine.SOPTYPE = Convert.ToByte(6);
salesLine.DOCID = "ORDER";
salesLine.SOPNUMBE = "ORD0010001";
salesLine.CUSTNMBR = "ABCP001";//OrderImportSettings.CustomerKey;
salesLine.DOCDATE = DateTime.Now.ToString("MM/dd/yyyy");
salesLine.ITEMNMBR = gpSku;
salesLine.QUANTITY = 1;
salesLine.AUTOALLOCATESERIAL = 1;
// ItemIVC.UOFM = "EACH";
strlocation = "FINGOODS";
gpSiteId = strlocation.Trim();
dUnitPrice = 100;//(Math.Round(magentoLineItem.price ?? (0), 2));
salesLine.XTNDPRCE = dUnitPrice * salesLine.QUANTITY;
salesLine.UNITPRCE = dUnitPrice;
salesLine.LOCNCODE = gpSiteId;
salesLine.NONINVEN = 0;
salesLine.PRCLEVEL = "DEFAULT";
salesLine.UpdateIfExists = 1;
salesLine.ADDRESS1 = "xxx";
salesLine.CITY = "xxx";
salesLine.STATE = "NC";
salesLine.COUNTRY = "USA";
// salesLine.p
// salesLine.SOPTYPE = 3;
salesLine.ITEMDESC = "";
LineItems[0] = salesLine;
object Preserve;
// salesOrder.taSopLineIvcInsert_Items(1);
salesOrder.taSopLineIvcInsert_Items = LineItems;
// Populate the elements of the taSopHdrIvcInsert XML node
// With...
// Today
salesHdr.SOPTYPE = Convert.ToByte(6);
salesHdr.PYMTRMID = "COMPANY CHECK";
salesHdr.ADDRESS1 = "703 SE GREENVILLE BLVD";
salesHdr.CITY = "GREENVILLE";
salesHdr.STATE = "NC";
salesHdr.COUNTRY = "USA";
salesHdr.CUSTNAME = "ABC";
salesHdr.CUSTNMBR = "ABCP001";
salesHdr.DOCID = "ORDER";
salesHdr.SOPNUMBE = "ORD0010001";
salesHdr.LOCNCODE = gpSiteId;
salesOrder.taSopHdrIvcInsert = salesHdr;
eConnectType eConnect = new eConnectType();
SOPTransactionType[] MySopTransactionType = { salesOrder };
eConnect.SOPTransactionType = MySopTransactionType;
FileStream fs = new FileStream(filename, FileMode.Create);
XmlTextWriter writer = new XmlTextWriter(fs, new UTF8Encoding());
// Serialize the eConnect document object to the file using the XmlTextWriter.
XmlSerializer serializer = new XmlSerializer(eConnect.GetType());
serializer.Serialize(writer, eConnect);
writer.Close();
}
}
catch (System.Exception ex)
{
//Console.Write(ex.ToString);
}
}
}
}
My Error:
Sql procedure error codes returned:
Error Number = 7030 Stored Procedure taSopHdrRecalc Error Description = Payment Term does not exist
Node Identifier Parameters: taSopHdrRecalc
SOPNUMBE = ORD0010665
SOPTYPE = 2
Related Error Code Parameters for Node : taSopHdrRecalc
PYMTRMID = Note: This parameter was not passed in, no value for the parameter will be returned.
Error Number = 1731 Stored Procedure taSopLineIvcInsert Error Description = Unable to update SOP Header values
Node Identifier Parameters: taSopLineIvcInsert
SOPNUMBE = ORD0010665
SOPTYPE = 2
Related Error Code Parameters for Node : taSopLineIvcInsert
UpdateIfExists = 1
<taSopLineIvcInsert><SOPTYPE>2</SOPTYPE><SOPNUMBE>ORD0010665</SOPNUMBE><CUSTNMBR>ACP001</CUSTNMBR><DOCDATE>03/27/2015</DOCDATE><LOCNCODE>FINGOODS</LOCNCODE><ITEMNMBR>BLB00330-10B2-ALBAL11A-0C</ITEMNMBR><UNITPRCE>100</UNITPRCE><XTNDPRCE>100</XTNDPRCE><QUANTITY>1</QUANTITY><PRCLEVEL>DEFAULT</PRCLEVEL><DOCID>ORDER</DOCID><ADDRESS1>703 SE GREENVILLE BLVD</ADDRESS1><CITY>XXXX</CITY><STATE>YYY</STATE><COUNTRY>ZZZ</COUNTRY><AUTOALLOCATESERIAL>1</AUTOALLOCATESERIAL><UpdateIfExists>1</UpdateIfExists></taSopLineIvcInsert>