Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Why Journal Entry added successfully but JdtNum field return 0?

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

Former Member
replied

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

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question