on 10-10-2008 2:03 AM
Hi,
I'm using C# 2005 and SAP B1 DI-API 2007 to add in some journal entries. Although the entries are added successfully, connected via the client and made sure these are added, the JdtNum property kept showing 0 instead of the actual Journal Entry ID as expected. Looking through the DI-API documentation i should be able to use this property once added successfully. Does anyone know why this is not the case? Below is my sample code.
SAPbobsCOM.Company sboCompany; (sboCompany already connected to database)
SAPbobsCOM.JournalEntries oSBOJournalEntry;
int? JournalID = null;
oSBOJournalEntry = (SAPbobsCOM.JournalEntries)sboCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries);
oSBOJournalEntry.Memo = "Testing 3";
oSBOJournalEntry.DueDate = DateTime.Now;
oSBOJournalEntry.ReferenceDate = DateTime.Now;
oSBOJournalEntry.Lines.AccountCode = "_SYS00000000723";
oSBOJournalEntry.Lines.LineMemo = "test line 1.1";
oSBOJournalEntry.Lines.Credit = 30.25;
oSBOJournalEntry.Lines.Add();
oSBOJournalEntry.Lines.AccountCode = "_SYS00000000723";
oSBOJournalEntry.Lines.LineMemo = "test line 2.1";
oSBOJournalEntry.Lines.Debit = 30.25;
oSBOJournalEntry.Lines.Add();
if (oSBOJournalEntry.Add() = 0)
{
JournalID = oSBOJournalEntry.JdtNum
}
Many thanks
Tai Vu
Not "oSBOJournalEntry.Add() = 0"
not JdtNum
if (oSBOJournalEntry.Add() = 0)
{
JournalID = oSBOJournalEntry.JdtNum
}
But "oSBOJournalEntry.Add() == 0"
use Number in JE: Returns Number of entries in Journal.
if (oSBOJournalEntry.Add() == 0)
{
JournalID = oSBOJournalEntry.Number
}
Kind Regards
-Yatsea
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry that was a typo copying onto the web as you pointed out.
The actual code is as below but oSBOJournalEntry.JdtNum is still returning 0. I found a way using the around using the GetNewObjectCode but am still interested in why this is the case. Try it for yourself and see if you are getting 0 as a return value.
if (oSBOJournalEntry.Add() == 0)
{
JournalID = oSBOJournalEntry.JdtNum
}
Hello,
GetByKey() to retrievl it after you add it.
oCompany.StartTransaction()
If (oSBOJournalEntry.Add() = 0) Then
Dim JENumber As String = ""
oCompany.GetNewObjectCode(JENumber)
If oSBOJournalEntry.GetByKey(CInt(JENumber)) Then
JournalID = oSBOJournalEntry.Number
MsgBox(String.Format("Jounal Entry#{0} added.", JournalID))
oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit)
End If
oCompany.GetLastError(lErrCode, errMsg)
MsgBox(errMsg)
End If
Kind Regards
-Yatsea
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.