cancel
Showing results for 
Search instead for 
Did you mean: 

Why Journal Entry added successfully but JdtNum field return 0?

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

YatseaLi
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

Former Member
0 Kudos

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

}

YatseaLi
Product and Topic Expert
Product and Topic Expert
0 Kudos

Yes, oSBOJournalEntry.JdtNum return 0

in my last reply, please use oSBOJournalEntry.Number instead of oSBOJournalEntry.JdtNum

Kind Regards

-Yatsea

Former Member
0 Kudos

Hi Yatsea,

Thanks for the reply again.

I tried using the Number property and it is also returning 0.

Regards

Tai

YatseaLi
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

Former Member
0 Kudos

Thanks Tai,

Journal Entry add Successfully.. but I using Indian Demo Database so that time Journal entry is not add. beacuse oSBOJournalEntry.Add() != 0 Came. so how to do this?

Answers (0)