Using Integration Manager with Analytical Accounting

David Meego - Click for blog homepageWhen you use Integration Manager on a system with Analytical Accounting (AA) installed, integrations often fail because Analytical Accounting will open windows which are unhandled by Integration Manager. However, there are time when you still want to use Integration Manager to import transactions where the Analytical Accounting information is left blank. This post provides three methods of how to make Integration Manager work when Analytical Accounting is installed.

Disclaimer: Methods 1 and 3 use an unsupported technique of calling Dexterity sanScript from Visual Basic for Applications (VBA) or VBScript. While Method 2 does not use an unsupported technique, it is important to note that none of the methods in this post are supported.

Note: The methods described in this post do not allow of the importing of Analytical Accounting data via Integration Manager. They only allow for Integration Manager to run by avoiding the usual dialogs that will open once Analytical Accounting is installed and activated.  Method 1 will not allow for any AA data; and Methods 2 and 3 only allow for default AA data.

 

Method 1: Disable Analytical Accounting from Integration Manager VBScript (not recommended)

This method disables the Analytical Accounting triggers which prevents the AA dialog boxes from opening.

Advantages

  • This method works for all transaction integrations where AA would normally cause an error.

Disadvantages

  • By disabling AA, no AA records are generated for the imported transactions. Normally AA generates records for all transactions even if there is no specific AA information. This allows AA reports to be able to report on all transactions.

Sample code

When you add the following sample code below and after an integration, you,can disable Analytical Accounting for the duration of the integration.

Before Integration Script

 Dim DynamicsApp
Dim ErrVal

Set DynamicsApp = CreateObject("Dynamics.Application")

If DynamicsApp Is Nothing Then
   CancelIntegration "Failed to create GreatPlains object"
End If

'Disable Analytical Accounting Triggers so that integration functions OK
ErrVal = DynamicsApp.ExecuteSanScript("Trigger_Enable(3180, false);","wrgerr")
If ErrVal <> 0 Then
    CancelIntegration "Failed to disable triggers"
End If

'Set variable to be accessed from After Integration script
SetVariable "GPApp", DynamicsApp

After IntegrationScript

 Dim ErrVal

'Enable Analytical Accounting Triggers
ErrVal = GetVariable("GPApp").ExecuteSanScript("Trigger_Enable(3180, true);", "wrgerr")

If ErrVal <> 0 Then
 CancelIntegration "Failed to enable triggers"
End If

 

Method 2: Automatically accept the default Analytical Accounting dialogs

Advantages

  • This method does not disable AA, so default AA records are created.

Disadvantages

  • Visual Basic for Applications (VBA) must be registered.
  • AA information must have default values for any required fields.
  • VBA code is always active, so a separate client is needed for use with Integration Manager.
  • Does not work with modified windows. As Integration Manager disables modified windows, the VBA code must be on the original window.

Sample code

The sample instructions code illustrates how a sales transaction can be entered with default Analytical Accounting information.

Add the Sales Transaction Entry window to VBA and add the following script:

 Private Sub Window_BeforeModalDialog(ByVal DlgType As DialogType, PromptString As String, Control1String As String, Control2String As String, Control3String As String, Answer As DialogCtrl)
    Select Case PromptString
        Case "The Analytical Transaction Entry window has not been opened even once.  Do you want to open the window before saving/posting?"
            Answer = dcButton2
        Case Else
    End Select
End Sub

Add the Analytical Accounting Sales Transaction Entry window to VBA and add the Distribution field and OK Button to VBA, then add the following scripts to the main window:

 Private Sub Window_BeforeOpen(OpenVisible As Boolean)
    OpenVisible = False
End Sub

Private Sub DistID_AfterGotFocus()
    OK = 1
End Sub

Add the following Script to both of the grid windows associated with the parent window:

 Private Sub Grid_AfterLineGotFocus()
    AnalyticalSalesTransactionE.OK = 1
End Sub

 

Method 3: Automatically accept default Analytical Accounting dialogs only when running integrations

Advantages

  • This method does not disable AA, so the default AA records are created.
  • VBA code is only active when integrations are running, no separate client needed.

Disadvantages

  • Visual Basic for Applications (VBA) must be registered.
  • AA information must have default values for any required fields.
  • Does not work with modified windows. As Integration Manager disables modified windows, the VBA code must be on the original window.

Sample code

Method 3 is the same as Method 2 but it adds a IMMode variable to the Sales Transaction Entry window to specify whether the system is currently running an integration. The value of the IMMode variable is set when the Sales Transaction Entry window is opened. To read the value from Dexterity requires the use of pass through sanScript to get the value of the 'IMIntegrationMode' of globals system variable and store it into the table used by the Dynamic User Object Store (DUOS). This value is then read by the VBA code and the IMMode variable updated.

Add the Sales Transaction Entry window to VBA and add the following scripts:

 Public IMMode As Boolean

Private Sub Window_BeforeOpen(OpenVisible As Boolean)
    'Dim CompilerApp As New Dynamics.Application
    Dim CompilerApp As Object
    Dim CompilerMessage As String
    Dim CompilerError As Integer
    Dim Commands As String
    
    Dim ParamCollection As DUOSObjects
    Dim ParamObject As DUOSObject

    IMMode = False

    ' Create link without having reference marked
    Set CompilerApp = CreateObject("Dynamics.Application")
    
    Commands = ""
    Commands = Commands & "clear table SY_User_Object_Store; " & vbCrLf
    Commands = Commands & "'ObjectType' of table SY_User_Object_Store = """ & "VBA_PARAM" & """; " & vbCrLf
    Commands = Commands & "'ObjectID' of table SY_User_Object_Store = """ & "IMMode" & """; " & vbCrLf
    Commands = Commands & "'PropertyName' of table SY_User_Object_Store = """ & "Value" & """; " & vbCrLf
    Commands = Commands & "change table SY_User_Object_Store; " & vbCrLf
    Commands = Commands & "'PropertyValue' of table SY_User_Object_Store = str('IMIntegrationMode' of globals); " & vbCrLf
    Commands = Commands & "save table SY_User_Object_Store; " & vbCrLf
    Commands = Commands & "check error; " & vbCrLf
    
    ' Execute SanScript
    CompilerError = CompilerApp.ExecuteSanscript(Commands, CompilerMessage)
    If CompilerError <> 0 Then
        MsgBox CompilerMessage
    End If
    
    Set ParamCollection = DUOSObjectsGet("VBA_PARAM")
    Set ParamObject = ParamCollection.Item("IMMode")
    IMMode = (Val(ParamObject.Properties("Value")) > 0)

    ParamCollection.Remove ("IMMode")
End Sub

Private Sub Window_BeforeModalDialog(ByVal DlgType As DialogType, PromptString As String, Control1String As String, Control2String As String, Control3String As String, Answer As DialogCtrl)
    Select Case PromptString
        Case "The Analytical Transaction Entry window has not been opened even once.  Do you want to open the window before saving/posting?"
            If IMMode Then
                Answer = dcButton2
            End If
        Case Else
    End Select
End Sub

Private Sub Window_AfterClose()
    IMMode = False
End Sub

So that the Analytical Accounting Sales Transaction Entry window can also use the IMMode variable you will need add a reference from Analytical Accounting Module to the Microsoft Dynamics GP module. To do this, on the Tools menu, click References . Add the Analytical Accounting Sales Transaction Entry window to VBA, add the Distribution field and OK Button to VBA, and then add the following scripts to the main window:

 Private Sub Window_BeforeOpen(OpenVisible As Boolean)
    If SalesTransactionEntry.IMMode Then
        OpenVisible = False
    End If
End Sub

Private Sub DistID_AfterGotFocus()
    If SalesTransactionEntry.IMMode Then
        OK = 1
    End If
End Sub

Add the following Script to both of the grid windows associated with the parent window:

 Private Sub Grid_AfterLineGotFocus()
    If SalesTransactionEntry.IMMode Then
        AnalyticalSalesTransactionE.OK = 1
    End If
End Sub

Method 3 can work well when you just need to default the AA information.  If you need to actually import Analytical Accounting data you will need to look at using the eConnect objects which support AA data.

David