eConnect - GL Transaction with Analytical Accounting

I just finished a similar piece of code for PM. Here's the GL version - a GL Transaction with Analytical Accouting code. It took me quite a while to get the bugs out so this will be valuable in the future.

This article contains a complete working version of an eConnect GL transaction that has Binary Stream and Analytical Accounting code.

Related Articles

... and you 'll find more on the eConnect Menu

Public Sub IntegrateGLDocument(ByVal oGLHeader As GLHeader)
        'all the data that we need for the integration is present in 
        'the oGLHeader class that is passed in. The exact data is not important.
  
        'Note that this integration contains both Binary Stream and Analytical Accounting code.
        '
        Try
            Dim strReturnDoc As String
  
            'get the Server and Database from the configuration file
            Dim strSQLServer As String = System.Configuration.ConfigurationManager.AppSettings("SQLServer")
            Dim strDabase As String = System.Configuration.ConfigurationManager.AppSettings("Database")
  
  
            'declare our eConnect classes
            'this is our eConnect class, documented here: http://dyndeveloper.com/thread.aspx?Threadid=1117
            Dim oeConnectType As New Microsoft.Dynamics.GP.eConnect.Serialization.eConnectType
            Dim oGLTransactionType As New Microsoft.Dynamics.GP.eConnect.Serialization.GLTransactionType
            Dim oeConnectFunctions As New GP11.eConnectFunctions(strSQLServer, strDabase)
  
            'get a new journal number
            'this is our eConnect class, documented here: http://dyndeveloper.com/thread.aspx?Threadid=1117
            Dim intJournalEntry As Integer = oeConnectFunctions.GetNextGLJournalEntryNumber(IncrementDecrement.Increment)
  
            '============================================================================
            'create the document details
            '============================================================================
            Dim intCurrentLine As Int16 = 0
            Dim intAALine As Int16
  
            For Each oGLLines As GLLines In oGLHeader.GLLines
                'declare an object for the detail line
                Dim otaGLTransactionLineInsert As New Microsoft.Dynamics.GP.eConnect.Serialization.taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert
  
                'populate the detail line
                With otaGLTransactionLineInsert
                    .JRNENTRY = intJournalEntry
                    .BACHNUMB = oGLHeader.BatchNumber
                    If oGLLines.Amount < 0 Then
                        .CRDTAMNT = Math.Abs(oGLLines.Amount)
                    Else
                        .DEBITAMT = Math.Abs(oGLLines.Amount)
                    End If
                    .ACTNUMST = oGLLines.AccountNumber
                    .DSCRIPTN = oGLLines.DistributionReference
  
                    ReDim Preserve oGLTransactionType.taGLTransactionLineInsert_Items(intCurrentLine)
                    oGLTransactionType.taGLTransactionLineInsert_Items(intCurrentLine) = otaGLTransactionLineInsert
                End With
  
                'not all distrubution need AA codes. Check to see if this line needs one
                If oGLLines.AADimension > "" And oGLLines.AACode > "" Then
                    Dim otaAnalyticsDistribution As New Microsoft.Dynamics.GP.eConnect.Serialization.taAnalyticsDistribution_ItemsTaAnalyticsDistribution
                    'populate the aa line
                    With otaAnalyticsDistribution
                        .DOCNMBR = intJournalEntry
                        .DOCTYPE = 0
                        .DistSequence = intCurrentLine
                        .DistSequenceSpecified = 1
                        .aaTrxDim = oGLLines.AADimension
                        .aaTrxDimCode = oGLLines.AADimension
                        .ACTNUMST = oGLLines.AccountNumber
                        ReDim Preserve oGLTransactionType.taAnalyticsDistribution_Items(intAALine)
                        oGLTransactionType.taAnalyticsDistribution_Items(intAALine) = otaAnalyticsDistribution
                    End With
                    intAALine += 1
  
                End If
                intCurrentLine += 1
            Next
  
            '============================================================================
            'create the document header
            '============================================================================
            Dim otaGLTransactionHeaderInsert As New Microsoft.Dynamics.GP.eConnect.Serialization.taGLTransactionHeaderInsert
  
            'populate the header data
            'only the minimum fields are required
            With otaGLTransactionHeaderInsert
                .JRNENTRY = intJournalEntry
                .BACHNUMB = oGLHeader.BatchNumber
                .REFRENCE = oGLHeader.Reference
                .TRXTYPE = oGLHeader.TransactionType
                .RVRSNGDT = oGLHeader.ReversingDate
                .CURNCYID = oGLHeader.CurrencyID
                .TRXDATE = oGLHeader.TransactionDate
                .REFRENCE = oGLHeader.Reference
                .TRXTYPE = 0
            End With
  
            'assign the header to the master
            oGLTransactionType.taGLTransactionHeaderInsert = otaGLTransactionHeaderInsert
  
            'this is our eConnect class, documented here: http://dyndeveloper.com/thread.aspx?Threadid=1117
            ReDim Preserve oeConnectType.GLTransactionType(0)
            oeConnectType.GLTransactionType(0) = oGLTransactionType
            strReturnDoc = oeConnectFunctions.CreateTransactionEntity(oeConnectType)
  
        Catch ex As Exception
            Throw ex
        End Try
  
    End Sub

RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences