Skip to Content

Time for making dreams come true…

 

Within the next days i will subsequently publish sourcecode for the SboTechDemo I specified a number of days ago.

 

This is the core class, the abstract class SboAddon. Have a look and tell me what you think.

Sorry, but it  is too late for the good introduction it deserves.

 

I will get this thing on the road, though.

 

Lutz Morrien

 

 

‘*********************************************************************

‘* TECHDEMO ADDON CLASS DESCRIPTION                                  *

‘* assembly name:       SboAddonBase                                 *

‘* classname:           SBOAddon                                     *

‘* classtype:           abstract                                     *

‘*********************************************************************

‘* created by:          Lutz Morrien                                 *

‘* company:             ocb GmbH, Ahaus                              *

‘*                                                                   *

‘* date of last change: 01-21-2004                                   *

‘* last change by:      Lutz Morrien                                 *

‘*                                                                   *

‘*********************************************************************

‘* Class description:                                                *

‘* The SboAddOn class is inherited by all AddOn subclasses (the      *

‘* AddOn classes). In this way any instance of an AddOn inherits     *

‘* basic addon functionality.                                        *

‘* Each Addon contains a collection of forms.                        *

‘* All item events (form events really) are handed to the            *

‘* corresponding form in the collection. The Addon class also is the *

‘* capable of creating or updating SAP Forms in the SAP Application  *

‘*                                                                   *

‘*********************************************************************

‘* list of changes and additions:                                    *

‘*                                                                   *

‘*********************************************************************

 

Imports System

Imports System.IO

Imports System.Xml

Imports System.Xml.XPath

Imports System.Windows.forms

 

Public MustInherit Class SBOAddOn

    Inherits Object

    Implements ISBOAddOn

 

# Region “variables”

    Const DEVELOPERSCONNECTIONSTRING As String = ” style=”font-size: 10.0pt; font-family: Courier New”>THESAPDELELOPERSTRINGISMADEAVAILABLEBYSAPONLY “

    Private Const EXTENSION = “.srf”

 

    Protected WithEvents m_SboApplication As SAPbouiCOM.Application

    Protected m_SboCompany As SAPbobsCOM.Company

 

    Protected m_SboAddons As Collection

    Protected m_StartUpPath As String

    Protected m_CompanyName As String

    Protected m_AddonName As String

     Protected m_AddOnHomePath As String

    Protected m_SBOForms As Collection

    Protected m_Connected As Boolean

    Protected colFormsCurrentlyOpen As Collection

 

    Protected m_AppConfig As AppConfig

    Protected m_EventsBlocked As Boolean

 

# End Region

 

# Region “properties”

    Public ReadOnly Property Connected() As Boolean Implements ISboAddOn.Connected

        Get

            Return m_Connected

        End Get

    End Property

 

    Public ReadOnly Property Name() As String Implements ISboAddOn.Name

        Get

            Return m_AddonName

        End Get

    End Property

 

    Public ReadOnly Property HomePath() As String Implements ISboAddOn.HomePath

        Get

            Return m_AddOnHomePath

        End Get

    End Property

 

    Public ReadOnly Property SboApplication() As SAPbouiCOM.Application Implements ISboAddOn.SboApplication

        Get

            Return m_SboCompany

        End Get

    End Property

 

    Public ReadOnly Property SboCompany() As SAPbobsCOM.Company Implements ISboAddOn.SBOCompany

        Get

            Return m_SboCompany

        End Get

    End Property

 

    Public ReadOnly Property SBOForms() As Collection Implements ISboAddOn.SBOForms

        Get

            Return m_SBOForms

        End Get

    End Property

 

    Public ReadOnly Property StartupPath() As String Implements ISboAddOn.StartupPath

        Get

            Return m_StartUpPath

        End Get

    End Property

 

    Public Property BlockEvents() As Boolean Implements ISboAddOn.BlockEvents

        Get

            Return m_EventsBlocked

        End Get

        Set( ByVal Value As Boolean)

            m_EventsBlocked = Value

        End Set

    End Property

 

    Public ReadOnly Property AppConfig() As AppConfig Implements ISboAddOn.AppConfig

        Get

             Return m_AppConfig

        End Get

    End Property

 

# End Region

 

# Region “constructor”

    Public Sub New( ByVal StartUpPath As String, ByVal AddOnName As String)

        m_AppConfig = New AppConfig

 

        ConnectToSBO()

        m_StartUpPath = StartUpPath

        m_AddonName = AddOnName

        m_SBOForms = New Collection

        m_EventsBlocked = False

    End Sub

# End Region

 

# Region “MustOverrides”

    Public MustOverride Sub Handle_SBO_ItemEvent( ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean)

    Public MustOverride Sub Handle_SBO_AppEvent( ByVal EventType As SAPbouiCOM.BoAppEventTypes)

    Public MustOverride Sub Handle_SBO_MenuEvent( ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean)

# End Region

 

# Region “functions”

    Public Function UpdateSBOForm( ByVal XMLDocumentName As String, ByVal FormUID As String) As SAPbouiCOM.Form Implements ISBOAddOn.updateSBOForm

        style=”color:green”>’modify an existing form via xml

        Return CreateOrUpdateSBOForm(XMLDocumentName, FormUID)

    End Function

 

    Public Function CreateSBOForm( ByVal XMLDocumentName As String) As SAPbouiCOM.Form Implements ISBOAddOn.CreateSBOForm

        style=”color:green”>’create a new form via xml

        Return CreateOrUpdateSBOForm(XMLDocumentName)

    End Function

 

    Public Sub SendAddonBusy() Implements ISBOAddOn.SendAddonBusy

        m_SboApplication.SetStatusBarMessage(“AddOn busy”, SAPbouiCOM.BoMessageTime.bmt_Long, False)

    End Sub

 

    Private Function GetFormDefinitions( ByVal FileNamexml As String) As XmlDocument

        Dim oXMLDocument As XmlDocument = New XmlDocument

        Dim oFilename As String

 

# If Debug = True Then

        oFilename = Replace( Me.m_AddOnHomePath, “\bin\”, “\”)

        oFilename = oFilename & FileNamexml & EXTENSION

# Else

    oFilename = Me.MyPath & FileNamexml & EXTENSION

# End If

 

        If Me.m_AppConfig.AppMode = “DEBUG” Then

            m_SboApplication.MessageBox(“Loading form from xml file in path:” & vbCrLf & oFilename)

        End If

 

        oXMLDocument.Load(oFilename)

        Return oXMLDocument

    End Function

 

    Private Function CreateOrUpdateSBOForm( ByVal XMLDocumentName As String, Optional ByVal FormUID As String = “”) As SAPbouiCOM.Form

        Dim oXmlDocument As XmlDocument

        Dim XMLString As String

        Dim oXMLNode As XmlNode

        Dim uiFrmNewForm As SAPbouiCOM.Form

 

        Try

            Dim strLanguage As String

 

            Select Case m_SboApplication.Language

                Case SAPbouiCOM.BoLanguages.ln_German

                    strLanguage = “GER”

                Case SAPbouiCOM.BoLanguages.ln_English

                    strLanguage = “ENG”

                Case Else

                    style=”color:green”>’use standard language

                    strLanguage = “GER”

            End Select

 

            style=”color:green”>’get the definitions

            oXmlDocument = GetFormDefinitions(XMLDocumentName & “_” & strLanguage)

 

            Return BatchLoadForm(oXmlDocument, FormUID)

 

        Catch excE As System.Exception

            MsgBox(excE.ToString)

        End Try

    End Function

 

    Private Function BatchLoadForm( ByVal SBOXMLDocument As XmlDocument, Optional ByVal FormUID As String = “”) As SAPbouiCOM.Form

        Dim XMLString As String

        Dim oXMLNode As XmlNode

        Dim uiFrmNewForm As SAPbouiCOM.Form

        Dim strBatchResults As String

 

        Try

            style=”color:green”>’if FormUID is not given, then set dynamic uid

            If FormUID = “” Then

                FormUID = GetNewFormUID()

            End If

 

            style=”color:green”>’set form uid in xml string

            SBOXMLDocument.SelectSingleNode(“/Application/forms/action/form/@uid”).Value = FormUID

 

            style=”color:green”>’load form

            Me.m_SboApplication.LoadBatchActions(SBOXMLDocument.InnerXml)

 

            style=”color:green”>’get info on success or faliure

            strBatchResults = Me.m_SboApplication.GetLastBatchResults()

 

            If Me.AppConfig.AppMode = “DEBUG” Then

                m_SboApplication.MessageBox(strBatchResults)

            End If

 

            uiFrmNewForm = Me.m_SboApplication.Forms.Item(FormUID)

 

            Return uiFrmNewForm

 

        Catch excE As System.Exception

            MsgBox(excE.ToString)

        End Try

 

    End Function

 

    Private Function GetNewFormUID() As String

        Return m_CompanyName & m_AddonName & SboForm.Count.ToString

    End Function

 

    Private Sub AddRootMenu()       

        Const TECHDEMOFOLDER As String = “SboTechdemo”

        Dim formCmdCenter As SAPbouiCOM.Form

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply