Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

As some may know, I've written a procedure toBuild a VB.Net DataTable out of an SAPBouiCOM Matrix. Well, I just tried using that nice little method on the Sales Order form, and I ran into an error. Apparently, one of the objects in this particular matrix is a checkbox, and I didn't account for that, just assuming that everything could be obtained from the Object.Item.Specific.Value. Well, this is not the case. So, I'm going to modify that previous method to make use of this second method, another "generic" method that I wrote to try to get the value of an item thrown into it, no matter what type of item that is. Others may possibly find this useful. Note that I've only handled the items that "make sense" to me. I figure if we need to in the future, we can always add the extra cases.


''' <summary>


''' Throw an SAPbouiCOM Item into this procedure to get its value


''' </summary>


''' <param name="oItem">A reference to the SAPbouiCOM.Item</param>


''' <returns>A string value from the Item</returns>


''' <remarks>There are some unhandled Items, we may need to handle them in the future if we find they are needed</remarks>


Private Shared Function getItemValue(ByRef oItem As SAPbouiCOM.Item) As String


    Dim sType As String = "Undetermined"


    Dim oITBtn As SAPbouiCOM.ButtonCombo = Nothing


    Dim oChk As SAPbouiCOM.CheckBox = Nothing


    Dim oCbo As SAPbouiCOM.ComboBox = Nothing


    Dim oTxt As SAPbouiCOM.EditText = Nothing


    Dim oOpt As SAPbouiCOM.OptionBtn = Nothing


    Dim oStc As SAPbouiCOM.StaticText = Nothing


    Try



        Select Case oItem.Type


            Case SAPbouiCOM.BoFormItemTypes.it_BUTTON_COMBO


                'Return the ButtonCombo's currently selected value


                oITBtn = oItem.Specific


                sType = "ButtonCombo"


                Return oITBtn.Selected.Value


            Case SAPbouiCOM.BoFormItemTypes.it_CHECK_BOX


                'Return the appropriate value for this item depending on whether or not it's checked


                oChk = oItem.Specific


                sType = "CheckBox"


                If oChk.Checked Then


                    Return oChk.ValOn


                Else


                    Return oChk.ValOff


                End If


            Case SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX


                'Return the value chosen in the ComboBox


                oCbo = oItem.Specific


                sType = "ComboBox"


                Return oCbo.Value


            Case SAPbouiCOM.BoFormItemTypes.it_EDIT


                oTxt = oItem.Specific


                sType = "ExitText"


                Return oTxt.Value


            Case SAPbouiCOM.BoFormItemTypes.it_EXTEDIT


                oTxt = oItem.Specific


                sType = "ExtendedEditText"


                Return oTxt.Value


            Case SAPbouiCOM.BoFormItemTypes.it_OPTION_BUTTON


                'Return the value of the option buttons Val settings depending on whether or not it's selected


                oOpt = oItem.Specific


                sType = "OptionButton"


                If oOpt.Selected Then


                    Return oOpt.ValOn


                Else


                    Return oOpt.ValOff


                End If


            Case SAPbouiCOM.BoFormItemTypes.it_STATIC


                oStc = oItem.Specific


                sType = "StaticText"


                Return oStc.Caption


            Case Else


                'Below is a list of other object types that it doesn't make sense to make cases for. We may want to in the future, though


                'Case SAPbouiCOM.BoFormItemTypes.it_ACTIVE_X


                'Case SAPbouiCOM.BoFormItemTypes.it_BUTTON


                'Case SAPbouiCOM.BoFormItemTypes.it_FOLDER


                'Case SAPbouiCOM.BoFormItemTypes.it_GRID


                'Case SAPbouiCOM.BoFormItemTypes.it_LINKED_BUTTON


                'Case SAPbouiCOM.BoFormItemTypes.it_MATRIX


                'Case SAPbouiCOM.BoFormItemTypes.it_PANE_COMBO_BOX


                'Case SAPbouiCOM.BoFormItemTypes.it_PICTURE


                'Case SAPbouiCOM.BoFormItemTypes.it_RECTANGLE


                'Case SAPbouiCOM.BoFormItemTypes.it_WEB_BROWSER



                'In the case that we try to throw in an object that we're not currently handling, make sure we get a report about it


                Throw New NotImplementedException("Unhandled object type")


        End Select


    Catch ex As Exception


        ErrorLog.AddEntryWithTrace(ex, , "Object type was " & sType)


        Return Nothing


    Finally


        releaseCOMobject(oITBtn)


        releaseCOMobject(oChk)


        releaseCOMobject(oCbo)


        releaseCOMobject(oTxt)


        releaseCOMobject(oOpt)


        releaseCOMobject(oStc)


    End Try


End Function


Labels in this area