Journal Entry using eConnect
Filed under: Microsoft GP Author:
The following example shows GL transactions that uses eConnect to assign the GL journal entry
static void Main(string[] args)
{
Test t = new Test();
string sCustomerDocument;
bool bStatus ;
string sXsdSchema ;
string sConnectionString;
try
{
eConnectMethods e = new eConnectMethods();
t.SerializeJEObject ("JE.xml");
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load("JE.xml");
sCustomerDocument = xmldoc.OuterXml;
sConnectionString = @"Data Source=localhost;Initial Catalog=TWO;Persist Security Info=True;User ID=sa;Password=password";
XmlDocument XsdDoc = new XmlDocument();
//Default path to the eConnect.xsd file, change if eConnect 9.0.0.0 is installed in a location other than the default.
XsdDoc.Load("D:\\eConnect\\eConnect.xsd");
sXsdSchema = XsdDoc.OuterXml;
//Pass in xsdSchema to validate against.
try
{
bStatus = e.eConnect_EntryPoint(sConnectionString, EnumTypes.ConnectionStringType.SqlClient, sCustomerDocument, EnumTypes.SchemaValidationType.XSD, sXsdSchema);
}
catch (eConnectException exc) // The eConnectException class will catch any business logic releated errors from eConnect.
{
Console.Write(exc.ToString());
}
finally
{
e.Dispose();
}
}
catch (System.Exception ex) // Catch any system error that might occurr.
{
Console.Write(ex.ToString());
}
}
public void SerializeJEObject(string filename)
{
try
{
GLTransactionType GLJournalEntry = new
GLTransactionType();
taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert
JELine = new
taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert();
taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert
JELine2 = new
taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert();
taGLTransactionHeaderInsert JEHdr = new taGLTransactionHeaderInsert();
taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert[] LineItems = new taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert[2];
JELine.BACHNUMB = "TEST14";
JELine.JRNENTRY = 160532;
JELine.CRDTAMNT = 2200;
JELine.DEBITAMT = 0;
JELine.ACTNUMST = "000-2300-00";
JELine.SQNCLINE = 16384;
JELine.ACTINDX = 0;
LineItems[0] = JELine;
JELine2.BACHNUMB = "TEST14";
JELine2.JRNENTRY = 160532;
JELine2.CRDTAMNT = 0;
JELine2.DEBITAMT = 2200;
JELine2.ACTNUMST = "000-2310-00";
JELine.SQNCLINE = 32768;
JELine.ACTINDX = 0;
LineItems[1] = JELine2;
JEHdr.BACHNUMB = "TEST14";
JEHdr.JRNENTRY = 160532;
JEHdr.REFRENCE = "David test 1";
JEHdr.TRXDATE = "5/8/2017";// System.DateTime.Today.ToString("MM/dd/yyyy");
JEHdr.TRXTYPE = 0;
JEHdr.SQNCLINE = 16384;
GLJournalEntry.taGLTransactionLineInsert_Items =
LineItems;
GLJournalEntry.taGLTransactionHeaderInsert = JEHdr;
eConnectType eConnect = new eConnectType();
GLTransactionType[] MyGLTransactionType ={ GLJournalEntry };
eConnect.GLTransactionType = MyGLTransactionType;
//This is where it's wrong!! At least it appears!
FileStream fs = new FileStream(filename, FileMode.Create);
XmlTextWriter writer = new XmlTextWriter(fs, new
UTF8Encoding());
//Serialize using the XmlTextWriter.
XmlSerializer serializer = new
XmlSerializer(eConnect.GetType());
serializer.Serialize(writer, eConnect);
writer.Close();
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
}
static void Main(string[] args)
{
Test t = new Test();
string sCustomerDocument;
bool bStatus ;
string sXsdSchema ;
string sConnectionString;
try
{
eConnectMethods e = new eConnectMethods();
t.SerializeJEObject ("JE.xml");
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load("JE.xml");
sCustomerDocument = xmldoc.OuterXml;
sConnectionString = @"Data Source=localhost;Initial Catalog=TWO;Persist Security Info=True;User ID=sa;Password=password";
XmlDocument XsdDoc = new XmlDocument();
//Default path to the eConnect.xsd file, change if eConnect 9.0.0.0 is installed in a location other than the default.
XsdDoc.Load("D:\\eConnect\\eConnect.xsd");
sXsdSchema = XsdDoc.OuterXml;
//Pass in xsdSchema to validate against.
try
{
bStatus = e.eConnect_EntryPoint(sConnectionString, EnumTypes.ConnectionStringType.SqlClient, sCustomerDocument, EnumTypes.SchemaValidationType.XSD, sXsdSchema);
}
catch (eConnectException exc) // The eConnectException class will catch any business logic releated errors from eConnect.
{
Console.Write(exc.ToString());
}
finally
{
e.Dispose();
}
}
catch (System.Exception ex) // Catch any system error that might occurr.
{
Console.Write(ex.ToString());
}
}
public void SerializeJEObject(string filename)
{
try
{
GLTransactionType GLJournalEntry = new
GLTransactionType();
taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert
JELine = new
taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert();
taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert
JELine2 = new
taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert();
taGLTransactionHeaderInsert JEHdr = new taGLTransactionHeaderInsert();
taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert[] LineItems = new taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert[2];
JELine.BACHNUMB = "TEST14";
JELine.JRNENTRY = 160532;
JELine.CRDTAMNT = 2200;
JELine.DEBITAMT = 0;
JELine.ACTNUMST = "000-2300-00";
JELine.SQNCLINE = 16384;
JELine.ACTINDX = 0;
LineItems[0] = JELine;
JELine2.BACHNUMB = "TEST14";
JELine2.JRNENTRY = 160532;
JELine2.CRDTAMNT = 0;
JELine2.DEBITAMT = 2200;
JELine2.ACTNUMST = "000-2310-00";
JELine.SQNCLINE = 32768;
JELine.ACTINDX = 0;
LineItems[1] = JELine2;
JEHdr.BACHNUMB = "TEST14";
JEHdr.JRNENTRY = 160532;
JEHdr.REFRENCE = "David test 1";
JEHdr.TRXDATE = "5/8/2017";// System.DateTime.Today.ToString("MM/dd/yyyy");
JEHdr.TRXTYPE = 0;
JEHdr.SQNCLINE = 16384;
GLJournalEntry.taGLTransactionLineInsert_Items =
LineItems;
GLJournalEntry.taGLTransactionHeaderInsert = JEHdr;
eConnectType eConnect = new eConnectType();
GLTransactionType[] MyGLTransactionType ={ GLJournalEntry };
eConnect.GLTransactionType = MyGLTransactionType;
//This is where it's wrong!! At least it appears!
FileStream fs = new FileStream(filename, FileMode.Create);
XmlTextWriter writer = new XmlTextWriter(fs, new
UTF8Encoding());
//Serialize using the XmlTextWriter.
XmlSerializer serializer = new
XmlSerializer(eConnect.GetType());
serializer.Serialize(writer, eConnect);
writer.Close();
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
}



No response to "Journal Entry using eConnect"
Post a Comment