API Forum

This forum is in read-only mode.
Please refer to our API support in case you have any questions.
We can be reached at api@e-conomic.com
e-conomic API developer forum

Getting all open entries

Im trying to get all open entries (i.e. ICreditorEntry with remainder 0)

I can do this by using session.creditor.getall, loop through all Icreditor and use Icreditor.Getopenentries.

The above is extremely inefficient.

Is it possible to get Icreditorentries for an array of creditors (or simply get all)
created Dec 9, 2009 by Claus Aaberg
0% Accept Rate
Q 10 A 10 C 0

4 Answers

Or i could ask if anybody knows a more efficient way than this:

 ' løb igennem alle kreditorer fra Economic og find åbne poster
            For Each ICreditor In EcKred
                EcKredOpEntry = ICreditorGetOpenEntries
                ' check om der er åbne poster for den aktuelle kreditorer hvis ikke så next
                If EcKredOpEntryCount  0 Then
                    ' check om den aktuelle kreditorer findes i den lokale db hvis ikke så tilføj
                    sqlcmdCommandText = SELECT Accountno FROM EconKreditor WHERE Accountno='  ICreditorNumber  ' and Agreementno=  Agreementno
                    Dim ChkKredNr = sqlcmdExecuteScalar
                    If ChkKredNr Is Nothing Then
                        sqlcmdCommandText = INSERT INTO EconKreditor (Accountno,Name,Banknavn,Agreementno) VALUES ('  ICreditorNumber  ','  ICreditorName  ','  ICreditorName  ','  Agreementno  ')
                        ' nothing
                    End If
                    ' tilføj de åbne poster fra Economic til lokal db
                    For Each ICreditorEntry In EcKredOpEntry
                        sqlcmdCommandText = INSERT INTO EconKredEntries (Accountno, Voucher,Date, Duedate,Amount,OpenAmount,Serial,Agreementno) VALUES ('  ICreditorEntryCreditorNumber  ','  ICreditorEntryVoucherNumber  ',convert(datetime,'  ICreditorEntryDate  ',105),convert(datetime,'  ICreditorEntryDueDate  ',105),'  Str(ICreditorEntryAmount)  ','  Str(ICreditorEntryRemainder)  ','  ICreditorEntrySerialNumber  ','  Agreementno  ')

                End If
answered Dec 16, 2009 by Claus Aaberg
This is a classic case of reading so many properties off proxy objects that the number of round-trips ends up being ridiculous.

In essence, every time you read a property on your ICreditor or ICreditorEntry objects, a round-trip happens.

Instead, you should:

1. Throw your ICreditor array at GetDataArray() - which will give you an array of ICreditorData, allowing you to access properties without round-trips.
2. Throw the ICreditorEntry array returned from GetOpenEntries() at GetDataArray() - same principle.

Best regards,

Christian Estrup
answered Dec 17, 2009 by Christian Estrup
Thanks for taking the time to help.

Im still not quite sure i understand.

I can throw the Session.Creditor.Getall at Session.CreditorData.GetDataArray and get an array of CreditorData.
I can also throw ICreditor.GetOpenEntries at Session.CreditorEntryData.GetDataArray and get an array of CreditorEntryData,
but i cant use my array of CreditData to get an array of CreditorEntryData.

In order to use Session.CreditorEntryData.GetDataArray () i would need an array of ICreditorEntry
To get an array of ICreditorEntry i would have to use one the ICreditor methods, which would mean a round trip for each ICreditor is that correct ?
answered Dec 17, 2009 by Claus Aaberg
That's correct.

What you'll end up with, round-trip-wise, is:

- 1 for GetAll() creditors
- 1 for GetDataArray() for CreditorData

And then, for each creditor:

- 1 for GetOpenEntries()
- 1 for GetDataArray() for the result from GetOpenEntries()

Thus, with N creditors, you'll have 2N+2 round-trips.

Best regards,

Christian Estrup
answered Dec 18, 2009 by Christian Estrup


Find all the documentation and resources you need to build great apps.
Go to Developer site


Get the latest news and important info from the e-conomic developer world.
Sign up now

Visma e-conomic A/S