Create Journal Entries using e Connect Store Procs

Obtain Next Journal Number:
USE [GP Company Database]
GO
DECLARE @return_value int,
@O_vJournalEntryNumber char(13),
@O_iErrorState int
EXEC @return_value = [dbo].[taGetNextJournalEntry]
@O_vJournalEntryNumber = @O_vJournalEntryNumber OUTPUT,
@O_iErrorState = @O_iErrorState OUTPUT
SELECT @O_vJournalEntryNumber as N’@O_vJournalEntryNumber’,
@O_iErrorState as N’@O_iErrorState’
SELECT ‘Return Value’ = @return_value >> This is the Journal number which should be used below
GO
*****************************************************************************************
Create GL Batch Record
USE [GP Company Database]
GO
DECLARE @return_value int,
@O_iErrorState int,
@oErrString varchar(255)

EXEC @return_value = [dbo].[taGLTransactionHeaderInsert]
@I_vBACHNUMB = N’batchnumb’,
@I_vJRNENTRY = 344, >> As queried above
@I_vREFRENCE = N’reference’,
@I_vTRXDATE = N’7/6/2015′,
@I_vTRXTYPE = 0,
@I_vSERIES = 2,
@O_iErrorState = @O_iErrorState OUTPUT,
@oErrString = @oErrString OUTPUT

SELECT @O_iErrorState as N’@O_iErrorState’,
@oErrString as N’@oErrString’

SELECT ‘Return Value’ = @return_value

GO
*****************************************************************************************
Create Debit Line of Journal:
USE [GP Company Database]
GO

DECLARE @return_value int,
@O_iErrorState int,
@oErrString varchar(255)

EXEC @return_value = [dbo].[taGLTransactionLineInsert]
@I_vBACHNUMB = N’batchnumb’,
@I_vJRNENTRY = 344,
@I_vACTINDX = 101,
@I_vCRDTAMNT = 0,
@I_vDEBITAMT = 100,
@I_vDSCRIPTN = N’desc’,
@O_iErrorState = @O_iErrorState OUTPUT,
@oErrString = @oErrString OUTPUT

SELECT @O_iErrorState as N’@O_iErrorState’,
@oErrString as N’@oErrString’

SELECT ‘Return Value’ = @return_value
*****************************************************************************************
Create Credit Line of Journal
USE [GP Company Database]
GO

DECLARE @return_value int,
@O_iErrorState int,
@oErrString varchar(255)

EXEC @return_value = [dbo].[taGLTransactionLineInsert]
@I_vBACHNUMB = N’batchnumb’,
@I_vJRNENTRY = 344,
@I_vACTINDX = 100,
@I_vCRDTAMNT = 100,
@I_vDEBITAMT = 0,
@I_vDSCRIPTN = N’desc’,
@O_iErrorState = @O_iErrorState OUTPUT,
@oErrString = @oErrString OUTPUT

SELECT @O_iErrorState as N’@O_iErrorState’,
@oErrString as N’@oErrString’

SELECT ‘Return Value’ = @return_value
*****************************************************************************************
This should create a valid journal entry in Dynamics GP.

Check stored proc for full parameter list.

Cheers!
Sanjay

eConnect GetNextDocNumbers Class vb.net example

Use left and right arrow keys to scroll horizontally

Imports System
Imports System.Xml
Imports System.Xml.Serialization
Imports System.IO
Imports System.Text
Imports Microsoft.VisualBasic
Imports Microsoft.Dynamics.GP.eConnect
Imports Microsoft.Dynamics.GP.eConnect.Serialization
Public Class econnectApplication
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim sConnectionString As String = "data source=[SQLSERVER];initial catalog=PDT;integrated security=SSPI; persist security info=False;packet size=4096"
        Dim NextNumberObject As New GetNextDocNumbers

        'Journal  # 
        MsgBox(NextNumberObject.GetNextGLJournalEntryNumber(IncrementDecrement.Increment, sConnectionString))

        'Inventory Document # IVDocType.IVAdjustment
        MsgBox(NextNumberObject.GetNextIVNumber(IncrementDecrement.Increment, IVDocType.IVAdjustment, sConnectionString))

        'Inventory Document # IVDocType.IVTransfer
        MsgBox(NextNumberObject.GetNextIVNumber(IncrementDecrement.Increment, IVDocType.IVTransfer, sConnectionString))

        'Inventory Document # IVDocType.IVVariance
        MsgBox(NextNumberObject.GetNextIVNumber(IncrementDecrement.Increment, IVDocType.IVVariance, sConnectionString))

        'Purchase Order # 
        MsgBox(NextNumberObject.GetNextPONumber(IncrementDecrement.Increment, sConnectionString))

        'PO Receipt #
        MsgBox(NextNumberObject.GetNextPOPReceiptNumber(IncrementDecrement.Increment, sConnectionString))

        'Receivable # - RMPaymentType.RMCreditMemo
        MsgBox(NextNumberObject.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMCreditMemo, sConnectionString))

        'Receivable # - RMPaymentType.RMDebitMemos
        MsgBox(NextNumberObject.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMDebitMemos, sConnectionString))

        'Receivable # - RMPaymentType.RMFinanceCharges
        MsgBox(NextNumberObject.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMFinanceCharges, sConnectionString))

        'Receivable # - RMPaymentType.RMInvoices
        MsgBox(NextNumberObject.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMInvoices, sConnectionString))

        'Receivable # - RMPaymentType.RMPayments
        MsgBox(NextNumberObject.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMPayments, sConnectionString))

        'Receivable # - RMPaymentType.RMReturn
        MsgBox(NextNumberObject.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMReturn, sConnectionString))

        'Receivable # - RMPaymentType.RMScheduledPayments
        MsgBox(NextNumberObject.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMScheduledPayments, sConnectionString))

        'Receivable # - RMPaymentType.RMServiceRepairs
        MsgBox(NextNumberObject.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMServiceRepairs, sConnectionString))

        'Receivable # - RMPaymentType.RMWarranty
        MsgBox(NextNumberObject.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMWarranty, sConnectionString))

        'SOP # -SopType.SOPInvoice
        MsgBox(NextNumberObject.GetNextSOPNumber(IncrementDecrement.Increment, "DOCID", SopType.SOPBackOrder, sConnectionString))

        'SOP # - SopType.SOPBackOrder
        MsgBox(NextNumberObject.GetNextSOPNumber(IncrementDecrement.Increment, "DOCID", SopType.SOPInvoice, sConnectionString))

        'SOP # - SopType.SOPOrder
        MsgBox(NextNumberObject.GetNextSOPNumber(IncrementDecrement.Increment, "DOCID", SopType.SOPOrder, sConnectionString))

        'SOP # - SopType.SOPQuote
        MsgBox(NextNumberObject.GetNextSOPNumber(IncrementDecrement.Increment, "DOCID", SopType.SOPQuote, sConnectionString))

        'SOP # - SopType.SOPReturn
        MsgBox(NextNumberObject.GetNextSOPNumber(IncrementDecrement.Increment, "DOCID", SopType.SOPReturn, sConnectionString))

        'Payable Voucher # 
        MsgBox(NextNumberObject.GetPMNextVoucherNumber(IncrementDecrement.Increment, sConnectionString))

        NextNumberObject.Dispose()

    End Sub
End Class

Summary Reference:

GetNextDocNumbers Class

The GetNextDocNumbers class allows you to retrieve the next valid document   number for several Microsoft Dynamics GP document types.

Methods
Name Return Value Description
Dispose void Releases the   resources of the GetNextDocNumbers object.
GetNextGLJournalEntryNumber string Retrieves the next   general ledger journal entry document number.
GetNextIVNumber string Retrieves the next   document number for a specified type of inventory document.
GetNextPONumber string Retrieves the next   purchase order number.
GetNextPOPReceiptNumber string Retrieves the next   purchase order receipt document number.
GetNextRMNumber string Retrieves the next   document number for a specified type of receivable document.
GetNextSOPNumber string Retrieves the next   document number for a specified type of sales order document.
GetPMNextVoucherNumber string Retrieves the next   payables management document number.
RollBackDocumentList   Method void Returns one or more   unused document numbers.
SortAndRollBackDocumentList   Method void Sorts and rolls back   a list of document numbers.

 

 

Dynamics GP eConnect – Create Journal Entry – VB.net example

Imports System
Imports System.Xml
Imports System.Xml.Serialization
Imports System.IO
Imports System.Text
Imports Microsoft.VisualBasic
Imports Microsoft.Dynamics.GP.eConnect
Imports Microsoft.Dynamics.GP.eConnect.Serialization
Public Class econnectApplication
    Public Sub eConnectSend()
        'Serialized XML File         
        Dim xmldocument As String
        'Connection String         
        Dim sConnectionString As String
        'Result         
        Dim xmlobject As String
        Using eConCall As New eConnectMethods
            Try
                SerializeObject("c:\xmlfile.xml ")
                Dim xmldoc As New Xml.XmlDocument
                xmldoc.Load("c:\xmlfile.xml")
                xmldocument = xmldoc.OuterXml
                sConnectionString = "ConnectionString"
                xmlobject = eConCall.CreateTransactionEntity(sConnectionString, xmldocument)
            Catch exp As eConnectException
                MsgBox(exp.ToString)
            Catch ex As System.Exception
                MsgBox(ex.ToString)
            Finally
                eConCall.Dispose()
                MsgBox("done")
            End Try
        End Using
    End Sub
    Public Shared Sub SerializeObject(ByVal filename As String)
        Try
            Dim econnect As New eConnectType
            Dim _batchnumber As String
            Dim _jrnnumber As Integer
            Dim _description As String
            Dim _trxdate As Date
            Dim sConnectionString As String = "ConnectionString"
            Dim nextjrn As New GetNextDocNumbers

            _jrnnumber = nextjrn.GetNextGLJournalEntryNumber(IncrementDecrement.Increment, sConnectionString)
            _batchnumber = "Batch Number 1"
            _description = "Description"
            _trxdate = "mm/dd/yyy"

            'Journal Header
            Dim gltran As New GLTransactionType
            Dim jrnhead As New taGLTransactionHeaderInsert
            With jrnhead
                .BACHNUMB = _batchnumber
                .JRNENTRY = _jrnnumber
                .REFRENCE = "Referece #"
                .TRXDATE = _trxdate
                .TRXTYPE = 0
                .SERIES = 1
            End With
            gltran.taGLTransactionHeaderInsert = jrnhead

            'Journal Distribution
            Dim Jrnline(1) As taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert
            Dim jrnline1 As New taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert
            With jrnline1
                .BACHNUMB = _batchnumber
                .JRNENTRY = _jrnnumber
                .CRDTAMNT = 100
                .DEBITAMT = 0
                .ACTNUMST = "cr account"
                .DSCRIPTN = _description
                .DOCDATE = _trxdate
            End With
            Jrnline(0) = jrnline1

            Dim jrnline2 As New taGLTransactionLineInsert_ItemsTaGLTransactionLineInsert
            With jrnline2
                .BACHNUMB = _batchnumber
                .JRNENTRY = _jrnnumber
                .CRDTAMNT = 0
                .DEBITAMT = 100
                .ACTNUMST = "dr account"
                .DSCRIPTN = _description
                .DOCDATE = _trxdate
            End With
            Jrnline(1) = jrnline2
            gltran.taGLTransactionLineInsert_Items = Jrnline

            ReDim Preserve econnect.GLTransactionType(0)
            econnect.GLTransactionType(0) = gltran

            Dim fs As New FileStream(filename, FileMode.Create)
            Dim writer As New XmlTextWriter(fs, New UTF8Encoding)
            Dim serializer As New XmlSerializer(GetType(eConnectType))
            serializer.Serialize(writer, econnect)
            writer.Close()

        Catch ex As ApplicationException
            MsgBox(ex.ToString)
        End Try
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        eConnectSend()
    End Sub
End Class

Adapted from Microsoft Dynamics GP eConnect Samples installed during eConnect installation. Line breaks are issued to fit script within screen. Remove line breaks.

THIS CODE AND INFORMATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR  PURPOSE

XML Node Reference

taGLTransactionHeaderInsert
Element name Data type Length Required Description
BACHNUMB string 15 Y Batch number
JRNENTRY i4 4 Y Journal entry number
REFRENCE string 30 Y Reference
TRXDATE datetime 16 Y Transaction date
RVRSNGDT datetime 16 N Reversing date
TRXTYPE i4 2 Y Transaction type:
0=Regular;
1=Reversing
SQNCLINE number 21 N Sequence line
SERIES i4 2 N Series:
1=All;
2=Financial;
3=Sales;
4=Purchasing;
5=Inventory;
6=Payroll;
7=Project
CURNCYID string 15 N Currency ID
XCHGRATE number 21 N Exchange rate
RATETPID string 15 N Rate type ID
EXPNDATE datetime 16 N Expiration date
EXCHDATE datetime 16 N Exchange date
EXGTBDSC string 30 N Exchange ID description
EXTBLSRC string 50 N Exchange rate source
RATEEXPR i4 2 N Rate expiration:
0=None
1=Daily;
2=Weekly;
3=Bi-weekly;
4=Semiweekly;
5=Monthly;
6=Quarterly;
7=Annually;
8=Miscellaneous;
9=None;
DYSTINCR i4 2 N Days to increment—used only when RATEEXPR=8
RATEVARC number 21 N Rate variance
TRXDTDEF i4 2 N Transaction date default:
0=Exact date;
1=Next date;
2=Previous date
RTCLCMTD i4 2 N Rate calculation method:
0=Multiply;
1=Divide
PRVDSLMT i4 2 N Previous day’s limits
DATELMTS i4 2 N Date limits:
0=Unlimited;
1=Limited
TIME1 datetime 16 N Time 1
RequesterTrx i4 2 N Requester transaction:
0=False;
1=True (if True, it populates the requester shadow table)
SOURCDOC string 11 N Source document
Ledger_ID i4 2 N Ledger ID
1=Base,
2=IFRS,
3=Local
USERID string 15 N User ID
taGLTransactionLineInsert
Element Datatype Length Required Description
BACHNUMB string 15 Y Batch number
JRNENTRY i4 4 Y Journal entry number
SQNCLINE number 21 N Sequence line
ACTINDX i4 4 N Account index
CRDTAMNT number 21 Y Credit amount
DEBITAMT number 21 Y Debit amount
ACTNUMST string 75 N Account string
DSCRIPTN string 30 N Description
ORCTRNUM string 20 N Originating control number
ORDOCNUM string 20 N Originating document number
ORMSTRID string 30 N Originating master ID
ORMSTRNM string 64 N Originating master name
ORTRXTYP i4 2 N Originating transaction type
OrigSeqNum i4 4 N Originating sequence number
ORTRXDESC string 30 N Originating transaction description
TAXDTLID string 15 N Tax detail ID
TAXAMNT number 21 N Tax amount
TAXACTNUMST string 75 N Tax account string
DOCDATE datetime 16 N Document date
CURNCYID string 15 N Currency ID
XCHGRATE number 21 N Exchange rate
RATETPID string 15 N Rate type ID
EXPNDATE datetime 16 N Expiration date
EXCHDATE datetime 16 N Exchange date
EXGTBDSC string 30 N Exchange ID description
EXTBLSRC string 50 N Exchange rate source
RATEEXPR i4 2 N Rate expiration:
0=None
1=Daily;
2=Weekly;
3=Bi-weekly;
4=Semiweekly;
5=Monthly;
6=Quarterly;
7=Annually;
8=Miscellaneous;
9=None;
DYSTINCR i4 2 N Days to increment—used only when RATEEXPR=8
RATEVARC number 21 N Rate variance
TRXDTDEF i4 2 N Transaction date default:
0=Exact date;
1=Next date;
2=Previous date
RTCLCMTD i4 2 N Rate calculation method:
0=Multiply;
1=Divide
PRVDSLMT i4 2 N Previous days limits
DATELMTS i4 2 N Date limits:
0=Unlimited;
1=Limited

Extracted from eConnect Programmers reference Guide for immediate reference.

<?xml version="1.0" ?>
<eConnect xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <GLTransactionType>
    <eConnectProcessInfo xsi:nil="true"/>
    <taRequesterTrxDisabler_Items xsi:nil="true"/>
    <taGLTransactionLineInsert_Items>
      <taGLTransactionLineInsert>
        <BACHNUMB>
          Batch Number 1
        </BACHNUMB>
        <JRNENTRY>
          2850253
        </JRNENTRY>
        <CRDTAMNT>
          100
        </CRDTAMNT>
        <DEBITAMT>
          0
        </DEBITAMT>
        <ACTNUMST>
          cr account
        </ACTNUMST>
        <DSCRIPTN>
          Description
        </DSCRIPTN>
        <DOCDATE>
          9/1/2013
        </DOCDATE>
      </taGLTransactionLineInsert>
      <taGLTransactionLineInsert>
        <BACHNUMB>
          Batch Number 1
        </BACHNUMB>
        <JRNENTRY>
          2850253
        </JRNENTRY>
        <CRDTAMNT>
          0
        </CRDTAMNT>
        <DEBITAMT>
          100
        </DEBITAMT>
        <ACTNUMST>
          dr account
        </ACTNUMST>
        <DSCRIPTN>
          Description
        </DSCRIPTN>
        <DOCDATE>
          9/1/2013
        </DOCDATE>
      </taGLTransactionLineInsert>
    </taGLTransactionLineInsert_Items>
    <taAnalyticsDistribution_Items xsi:nil="true"/>
    <taGLTransactionHeaderInsert>
      <BACHNUMB>
        Batch Number 1
      </BACHNUMB>
      <JRNENTRY>
        2850253
      </JRNENTRY>
      <REFRENCE>
        Referece #
      </REFRENCE>
      <TRXDATE>
        9/1/2013
      </TRXDATE>
      <TRXTYPE>
        0
      </TRXTYPE>
      <SERIES>
        1
      </SERIES>
    </taGLTransactionHeaderInsert>
    <taMdaUpdate_Items xsi:nil="true"/>
  </GLTransactionType>
</eConnect>

 

Cheers!
Sanjay