我希望使用econnect在Dynamics GP中输入单个gltransaction。
下面的代码确实生成了一个XML文件。但是,它在XML文件中放置三个相同的GL行项目,每个25美元,留下不平衡的条目。
我希望它能做的是根据下面的代码提供75美元的借记,50美元的信用和25美元的信用。你能帮我解决一下我做错的事情,这样我就没有三个25美元的物品进入档案吗?
提前致谢。
string DTime = DateTime.Today.ToString();
string CurrentDatabase = "OCITE";
string NextJEno = GetNextJournal.GetNextJournalEntry(CurrentDatabase);
eConnectType eConnect = new eConnectType();
GLTransactionType myGLTrxType = new GLTransactionType();
taGLTransactionHeaderInsert myGLHeader = new taGLTransactionHeaderInsert();
taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert [] myGLDetail = new taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert[3];
taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert myGLDetailLine = new taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert();
myGLDetailLine.BACHNUMB = CurrentDatabase;
myGLDetailLine.JRNENTRY = Int32.Parse(NextJEno);
myGLDetailLine.CRDTAMNT = (decimal)0;
myGLDetailLine.DEBITAMT = (decimal)75.00;
myGLDetailLine.ACTNUMST = "1000-0000-C";
myGLDetail[0] = myGLDetailLine;
myGLDetailLine.BACHNUMB = CurrentDatabase;
myGLDetailLine.JRNENTRY = Int32.Parse(NextJEno);
myGLDetailLine.CRDTAMNT = (decimal)50;
myGLDetailLine.DEBITAMT = (decimal)0;
myGLDetailLine.ACTNUMST = "6560-0000-C";
myGLDetail[1] = myGLDetailLine;
myGLDetailLine.BACHNUMB = CurrentDatabase;
myGLDetailLine.JRNENTRY = Int32.Parse(NextJEno);
myGLDetailLine.CRDTAMNT = (decimal)25;
myGLDetailLine.DEBITAMT = (decimal)0;
myGLDetailLine.ACTNUMST = "5120-0000-C";
myGLDetail[2] = myGLDetailLine;
myGLHeader.BACHNUMB = CurrentDatabase;
myGLHeader.JRNENTRY = Int32.Parse(NextJEno);
myGLHeader.REFRENCE = "REFRENCE";
myGLHeader.TRXDATE = DTime;
myGLHeader.TRXTYPE = 0;
myGLTrxType.taGLTransactionLineInsert_Items = myGLDetail;
myGLTrxType.taGLTransactionHeaderInsert = myGLHeader;
GLTransactionType[] myGLType = { myGLTrxType };
eConnect.GLTransactionType = myGLType;
FileStream streamFile = new FileStream(filename, FileMode.Create);
XmlTextWriter Xmlwriter = new XmlTextWriter(streamFile, new UTF8Encoding());
XmlSerializer serializer = new XmlSerializer(eConnect.GetType());
serializer.Serialize(Xmlwriter, eConnect);
Xmlwriter.Close();
XML文件
<eConnect xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GLTransactionType>
<eConnectProcessInfo xsi:nil="true" />
<taRequesterTrxDisabler_Items xsi:nil="true" />
<taGLTransactionLineInsert_Items>
<taGLTransactionLineInsert>
<BACHNUMB>OCITE</BACHNUMB>
<JRNENTRY>1750</JRNENTRY>
<CRDTAMNT>25</CRDTAMNT>
<DEBITAMT>0</DEBITAMT>
<ACTNUMST>5120-0000-C</ACTNUMST>
</taGLTransactionLineInsert>
<taGLTransactionLineInsert>
<BACHNUMB>OCITE</BACHNUMB>
<JRNENTRY>1750</JRNENTRY>
<CRDTAMNT>25</CRDTAMNT>
<DEBITAMT>0</DEBITAMT>
<ACTNUMST>5120-0000-C</ACTNUMST>
</taGLTransactionLineInsert>
<taGLTransactionLineInsert>
<BACHNUMB>OCITE</BACHNUMB>
<JRNENTRY>1750</JRNENTRY>
<CRDTAMNT>25</CRDTAMNT>
<DEBITAMT>0</DEBITAMT>
<ACTNUMST>5120-0000-C</ACTNUMST>
</taGLTransactionLineInsert>
</taGLTransactionLineInsert_Items>
<taAnalyticsDistribution_Items xsi:nil="true" />
<taGLTransactionHeaderInsert>
<BACHNUMB>OCITE</BACHNUMB>
<JRNENTRY>1750</JRNENTRY>
<REFRENCE>REFRENCE</REFRENCE>
<TRXDATE>3/21/2013 12:00:00 AM</TRXDATE>
<TRXTYPE>0</TRXTYPE>
</taGLTransactionHeaderInsert>
<taMdaUpdate_Items xsi:nil="true" />
</GLTransactionType>
</eConnect>
答案 0 :(得分:0)
我找到了解决自己问题的方法。
即,为'every'单行创建myGLDetailLine对象的新实例将解决此问题。
taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert myGLDetailLine = new taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert();