cancel
Showing results for 
Search instead for 
Did you mean: 

Journal Entry Lines (Debit & Credit)

Former Member
0 Kudos

Hi,

I'm having problems when assigning values to Lines Credit or Debit in SDK. If i assign 1212.01 to lines.debit it changes the value to 1212.0006399 which is resulting to Unbalanced Transaction. By the way this a multi-company transaction.

Thanks!

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

I already tried that one and also cdec but still getting the same problem.

Regards,

Xtian

Former Member
0 Kudos

Hello

this could be an .Net convering error..

Try this, and save the result into XML for debugging.


'...
If CDec(oRecSet3.Fields.Item("Net").Value) > 0 Then
Dim dd as double  = Convert.ToDouble (oRecSet3.Fields.Item("Debit").Value.ToString())
dd  = math.Round(dd,2)
vJE.Lines.Debit = dd
'Line where the problem occurs. I already tried hardcoding the values but it still converts the decimal places from 2 to 9.
....
'Before you add, save the JE into XML for debugging
vJE..SaveXML("c:	est.xml")

Check the xml file for values....

For me same situation is works fine.

BR,

János

Former Member
0 Kudos

Here's the query:

"Select a.Account, b.FormatCode, sum(Debit) Debit, sum(Credit) * -1 Credit, Sum(Debit - Credit) Net, b.AcctName From JDT1 a INNER JOIN OACT b on a.Account = b.AcctCode WHERE a.RefDate Between '" & dtpFrom.Value.Date & "' And '" & dtpTo.Value.Date & "' Group By a.Account, b.FormatCode, b.AcctName"

Regards,

Xtian

Former Member
0 Kudos

Hello,

Use Math.Round(value,6) or Math.Round(value,NUmberofPricedecimalsdefinedinAdministration) to round the values.

Or use Decimal instead of double in in your code. This solves the problem.

Double at calculation if you not round can casues such kind of probelms...

Best Regards,

J.

Former Member
0 Kudos

Hi Yatsea,

My decimal settings in SAP under amounts is 2. Likewise in my regional settings the decimal is 2.

Here's the code:

vJE = objBI.oCompany2.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries) 'This is for the Destination Company

Dim oRecSet2 As SAPbobsCOM.Recordset = objBI.oCompany2.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

Dim oRecSet3 As SAPbobsCOM.Recordset = objBI.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

oRecSet3.DoQuery("some query to retrieve records")

oRecSet3.MoveFirst()

While Not oRecSet3.EoF

vJE.TaxDate = dtpTo.Value.Date

vJE.DueDate = dtpTo.Value.Date

vJE.ReferenceDate = dtpTo.Value.Date

oRecSet2.DoQuery("SELECT Top 1 AcctCode FROM OACT(NOLOCK) WHERE FormatCode = '" & oRecSet3.Fields.Item("FormatCode").Value & "'")

If oRecSet2.RecordCount = 0 Then

MsgBox("Invalid account code (" & oRecSet3.Fields.Item("FormatCode").Value & ").", vbCritical, "System Message")

Return

End If

vJE.Lines.AccountCode = oRecSet2.Fields.Item("AcctCode").Value

If CDec(oRecSet3.Fields.Item("Net").Value) > 0 Then

vJE.Lines.Debit = oRecSet3.Fields.Item("Debit").Value 'Line where the problem occurs. I already tried hardcoding the values but it still converts the decimal places from 2 to 9.

ElseIf CDec(oRecSet3.Fields.Item("Net").Value) < 0 Then

vJE.Lines.Credit oRecSet3.Fields.Item("Credit").Value 'Line where the problem occurs.

End If

vJE.Lines.Add()

oRecSet3.MoveNext()

End While

Regards,

Xtian

YatseaLi
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Christian,

Please specify the query below, thanks.

oRecSet3.DoQuery("some query to retrieve records")

Kind Regards, Yatsea

YatseaLi
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Christian,

It seems a double value representing problem by system.

Could you please post the code for analysis?

What is your decimal setting in B1?

As well as your regional setting in control panel?

Kind Regards, Yatsea