cancel
Showing results for 
Search instead for 
Did you mean: 

bind data in matrix column automatically

Former Member
0 Kudos

Dear Experts

I want to Display(bind)  EmployeeCode,EmployeeName in first Two columns in Matrix automatically,when i open the screen,can you help for this and give me some ideas for steps to do

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Bharath,

     Please refer to this post. http://scn.sap.com/thread/3231623

Regards,

Former Member
0 Kudos

Hi Bryan

   I Used your query but no response in screen,i think i used your coding in wrong place can you help .I have attached my codings below,give me some ideas

Imports SAPbouiCOM

Public Class clsattreg

    Private oForm As SAPbouiCOM.Form

    Private oMatrix As SAPbouiCOM.Matrix

    Private matcol1, matcol2, matcol3 As SAPbouiCOM.Column

    Private oColumns As SAPbouiCOM.Columns

    Dim objRS As SAPbobsCOM.Recordset

    Dim strSQL As String

    Public Const formtype As String = "Frm_AG"

    Dim Fld1, Fld2, Fld3, Fld4, Fld5 As SAPbouiCOM.OptionBtn

    Dim oDT As SAPbouiCOM.DataTable

    Dim oCFLs As SAPbouiCOM.ChooseFromListCollection

    Private objCFLEvent As SAPbouiCOM.ChooseFromListEvent

    Dim oCFL, oCFL1 As SAPbouiCOM.ChooseFromList

    Dim oCons As SAPbouiCOM.Conditions

    Dim oCon As SAPbouiCOM.Condition

    Dim oMkcom, oTpcom, oSzcom, oGdcom, OAGENT, OA, oseries, oCombo, oCombo1, oCombo2, oCombo3 As SAPbouiCOM.ComboBox

    Dim Optn1, Optn2, Optn3, Optn4, Optn5 As SAPbouiCOM.OptionBtn

    Dim RowNo As Integer = 0

    Private Property oEdit1 As Object

    Private Property oEdit2 As Object

    Private Property oEdit3 As Object

    Private Property oEdit As Object

    Dim oColumn As SAPbouiCOM.Column

    Public Sub LoadScreen()

        Try

            oForm = objAddOn.objUIXml.LoadScreenXML("Attendancereg.xml", SST.enuResourceType.Embeded, formtype)

            oForm.Items.Item("12").Specific.value = objAddOn.objGenFunc.GetDocNum("SST_EI_EATR")

            oForm.Items.Item("10").Specific.string = objAddOn.objGenFunc.GetDateTimeValue(objAddOn.SBO_Application.Company.ServerDate).ToString("dd/MM/yy")

            oForm.DataBrowser.BrowseBy = "12"

            'OAGENT = oForm.Items.Item("1000003").Specific

            oTpcom = oForm.Items.Item("1000002").Specific

            oGdcom = oForm.Items.Item("14").Specific

            LoadCombo()

'*************************************

            FillItemGroupCode()

'******************************

            'oColumn = oMatrix.Columns.Item("V_9")

            'oMatrix = oForm.Items.Item("13").Specific

            'oColumns = oMatrix.Columns

            'matcol1 = oColumns.Item("V_9")

            'matcol2 = oColumns.Item("V_8")

            'LoadCombo(matcol1)

            oColumn = oMatrix.Columns.Item("V_9")

            oMatrix = oForm.Items.Item("13").Specific

            oColumns = oMatrix.Columns

            matcol1 = oColumns.Item("V_9")

            matcol2 = oColumns.Item("V_8")

            LoadCombo(matcol1)

        Catch ex As Exception

            objAddOn.SBO_Application.SetStatusBarMessage(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, True)

        End Try

    End Sub

    'Private Sub FillItemGroupCode()

    '    Try

    '        Dim oMatrix As SAPbouiCOM.Matrix = DirectCast(oForm.Items.Item(enControlName.mtxDetails).Specific, Matrix)

    '        Dim oColumns As SAPbouiCOM.Columns

    '        Dim oColumn As SAPbouiCOM.Column

    '        oColumns = oMatrix.Columns

    '        oMatrix.Clear()

    '        Dim strsql As String

    '        Dim oDataT As SAPbouiCOM.DataTable

    '        strsql = "Select firstName from OHEM"

    '        If oForm.DataSources.DataTables.Count.Equals(0) Then

    '            oForm.DataSources.DataTables.Add("firstName")

    '        Else

    '            oForm.DataSources.DataTables.Item("firstName").Clear()

    '        End If

    '        oDataT = oForm.DataSources.DataTables.Item("firstName")

    '        oDataT.Clear()

    '        oDataT.ExecuteQuery(strsql)

    '        If oDataT.Rows.Count > 0 Then

    '            oColumn = oColumns.Item("col_0")

    '            oColumn.DataBind.Bind("firstName", "firstName")

    '            oMatrix.LoadFromDataSource()

    '        Else

    '            objAddOn.SBO_Application.SetStatusBarMessage("No Data Found", SAPbouiCOM.BoMessageTime.bmt_Short, True)

    '        End If

    '    Catch ex As Exception

    '    End Try

    'End Sub

'*****************************

    Private Sub FillItemGroupCode()

       Try

    '      Dim oMatrix As SAPbouiCOM.Matrix = DirectCast(Me.m_SBO_Form.Items.Item(enControlName.mtxDetails).Specific, Matrix)

          Dim oColumns As SAPbouiCOM.Columns

           Dim oColumn As SAPbouiCOM.Column    '        oColumns = oMatrix.Columns

        oMatrix.Clear()

           Dim oDataT As SAPbouiCOM.DataTable

         strsql = "Select U_empcode from [@SST_EI_EMPD]"

         If Me.m_SBO_Form.DataSources.DataTables.Count.Equals(0) Then

              Me.m_SBO_Form.DataSources.DataTables.Add("U_empcode")

            Else

              Me.m_SBO_Form.DataSources.DataTables.Item("U_empcode").Clear()

    '      End If

    '        oDataT = Me.m_SBO_Form.DataSources.DataTables.Item("U_empcode")

    '        oDataT.Clear()

    '        oDataT.ExecuteQuery(strsql)

    '        If oDataT.Rows.Count > 0 Then

    '            oColumn = oColumns.Item("col_0")

    '            oColumn.DataBind.Bind("U_empcode", "U_empcode")

    '            oMatrix.LoadFromDataSource()

    '        Else

    '            Me.SBO_Application.SetStatusBarMessage("No Data Found", SAPbouiCOM.BoMessageTime.bmt_Short, True)

    '        End If

    '    Catch ex As Exception

    '    End Try

    'End Sub

    'Private Sub LoadCombo(ByVal ocombo11 As SAPbouiCOM.Column)

    '    Try

    '        oMatrix = oForm.Items.Item("13").Specific

    '        objRS = objAddOn.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

    '        strSQL = "select U_empcode,(U_MiddleName + U_Firstname) from [@SST_EI_EMPD]"

    '        'strSQL = " select Code,Name from [@SST_HR_CTRY]"

    '        objRS.DoQuery(strSQL)

    '        If objRS.RecordCount > 0 Then

    '            While Not objRS.EoF

    '                ocombo11.ValidValues.Add(objRS.Fields.Item(0).Value, objRS.Fields.Item(1).Value)

    '                objRS.MoveNext()

    '            End While

    '        End If

    '    Catch ex As Exception

    '    End Try

    'End Sub

    Private Sub LoadCombo(ByVal ocombo11 As SAPbouiCOM.Column)

        Try

            oMatrix = oForm.Items.Item("13").Specific

            objRS = objAddOn.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

            strSQL = "select U_empcode,(U_MiddleName + U_Firstname) from [@SST_EI_EMPD]"

            'strSQL = " select Code,Name from [@SST_HR_CTRY]"

            objRS.DoQuery(strSQL)

            If objRS.RecordCount > 0 Then

                While Not objRS.EoF

                    ocombo11.ValidValues.Add(objRS.Fields.Item(0).Value, objRS.Fields.Item(1).Value)

                    objRS.MoveNext()

                End While

            End If

        Catch ex As Exception

        End Try

    End Sub

    Private Sub LoadCombo()

        'Try

        '    objRS = objAddOn.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

        '    strSQL = "select Name,remarks from OUDP"

        '    objRS.DoQuery(strSQL)

        '    If objRS.RecordCount > 0 Then

        '        While Not objRS.EoF

        '            OAGENT.ValidValues.Add(objRS.Fields.Item(0).Value, objRS.Fields.Item(1).Value)

        '            'oForm.Items.Item("10").Specific.String = objRS.Fields.Item("0").values

        '            objRS.MoveNext()

        '        End While

        '    End If

        'Catch ex As Exception

        'End Try

        Try

            objRS = objAddOn.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

            strSQL = "select Name,Remarks from OUBR"

            objRS.DoQuery(strSQL)

            If objRS.RecordCount > 0 Then

                While Not objRS.EoF

                    oTpcom.ValidValues.Add(objRS.Fields.Item(0).Value, objRS.Fields.Item(1).Value)

                    'oForm.Items.Item("10").Specific.String = objRS.Fields.Item("0").values

                    objRS.MoveNext()

                End While

            End If

        Catch ex As Exception

        End Try

        Try

            objRS = objAddOn.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

            strSQL = "select Name,Code from [@ASST_HR_MNTH]"

            objRS.DoQuery(strSQL)

            If objRS.RecordCount > 0 Then

                While Not objRS.EoF

                    oGdcom.ValidValues.Add(objRS.Fields.Item(0).Value, objRS.Fields.Item(1).Value)

                    'oForm.Items.Item("10").Specific.String = objRS.Fields.Item("0").values

                    objRS.MoveNext()

                End While

            End If

        Catch ex As Exception

        End Try

    End Sub

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

        Try

            oMatrix = oForm.Items.Item("13").Specific

            If pVal.Before_Action = True Then

                Select Case pVal.EventType

                    Case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED

                        If pVal.ItemUID = "1" And oForm.Mode = SAPbouiCOM.BoFormMode.fm_ADD_MODE Then

                            If Validate() = False Then

                                BubbleEvent = False

                            End If

                        ElseIf pVal.ItemUID = "1" And oForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE Then

                            'If oForm.Items.Item("15").Specific.selected.value = "C" Then

                            '    objAddOn.SBO_Application.SetStatusBarMessage("Document is Closed.Cannot update.....", SAPbouiCOM.BoMessageTime.bmt_Short, True)

                            '    BubbleEvent = False

                            'Else

                            If Validate() = False Then

                                BubbleEvent = False

                            End If

                            'End If

                        End If

                        '**************add row in matrix*****

                        Try

                            If pVal.ItemUID = "1000001" Then

                                If oMatrix.RowCount = 0 Then

                                    oMatrix.AddRow()

                                    oMatrix.Columns.Item("V_-1").Cells.Item(oMatrix.RowCount).Specific.string = oMatrix.RowCount

                                ElseIf oMatrix.RowCount >= 1 Then

                                    Dim i As Integer

                                    For i = 1 To oMatrix.RowCount

                                        If oMatrix.Columns.Item("V_3").Cells.Item(i).Specific.string = "" Then

                                            objAddOn.SBO_Application.SetStatusBarMessage("Enter InTime", SAPbouiCOM.BoMessageTime.bmt_Short, True)

                                            Return

                                        End If

                                        If oMatrix.Columns.Item("V_2").Cells.Item(i).Specific.string = "" Then

                                            objAddOn.SBO_Application.SetStatusBarMessage("Enter OutTime", SAPbouiCOM.BoMessageTime.bmt_Short, True)

                                            Return

                                        End If

                                        If oMatrix.Columns.Item("V_5").Cells.Item(i).Specific.string < 0 Then

                                            objAddOn.SBO_Application.SetStatusBarMessage("Enter Correct Work Hours", SAPbouiCOM.BoMessageTime.bmt_Short, True)

                                            Return

                                        End If

                                    Next

                                    oForm.DataSources.DBDataSources.Item("@SST_EI_ATRDTL").Clear()

                                    oMatrix.AddRow()

                                    oMatrix.Columns.Item("V_-1").Cells.Item(oMatrix.RowCount).Specific.string = oMatrix.RowCount

                                End If

                            End If

                        Catch ex As Exception

                        End Try

                        Try

                            If oMatrix.RowCount = 0 Then

                                objAddOn.SBO_Application.SetStatusBarMessage("No line Items, please enter the values....")

                                Return

                            End If

                        Catch ex As Exception

                        End Try

                        '   '*************automatic display in matrix*********

                        'Case SAPbouiCOM.BoEventTypes.et_EDIT_REPORT

                        '    oMatrix = oForm.Items.Item("13").Specific

                        '    For i = 1 To oMatrix.RowCount

                        '        oMatrix.Columns.Item("V_3").Cells.Item(i).Specific.Value = "0900"

                        '    Next i

                        '    oMatrix = oForm.Items.Item("13").Specific

                        '    For i = 1 To oMatrix.RowCount

                        '        oMatrix.Columns.Item("V_2").Cells.Item(i).Specific.Value = "1800"

                        '    Next i

                        '    'End

                        'oMatrix = oForm.Items.Item("13").Specific

                        'For i() = 1 To oMatrix.RowCount

                        '    oMatrix.Columns.Item("V_5").Cells.Item(i).Specific.Value = "8"

                        'Next i()

                        'oMatrix = oForm.Items.Item("13").Specific

                        'For i() = 1 To oMatrix.RowCount

                        '    oMatrix.Columns.Item("V_1").Cells.Item(i).Specific.Value = "No"

                        'Next i()

                        '***************auto end*******************************************

                End Select

            Else

                Select Case pVal.EventType

                    Case SAPbouiCOM.BoEventTypes.et_COMBO_SELECT And (oForm.Mode = SAPbouiCOM.BoFormMode.fm_ADD_MODE)

                        'Case SAPbouiCOM.BoEventTypes.et_COMBO_SELECT And oForm.Mode = SAPbouiCOM.BoFormMode.fm_ADD_MODE Or oForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE

                        Try

                            If (pVal.ItemUID = "13") And (pVal.ColUID = "V_9") Then

                                matcol2 = oColumns.Item("V_8")

                                matcol1 = oColumns.Item("V_9")

                                oCombo = matcol1.Cells.Item(pVal.Row).Specific

                                oEdit = matcol2.Cells.Item(pVal.Row).Specific

                                oEdit.Value = oCombo.Selected.Description

                            End If

                        Catch ex As Exception

                        End Try

                    Case SAPbouiCOM.BoEventTypes.et_CLICK

                        Try

                            Dim stDate As String = oForm.Items.Item("10").Specific.string()

                            Dim dtDate As Date

                            dtDate = DateTime.Parse(stDate, Globalization.CultureInfo.CreateSpecificCulture("en-CA"))

                            If dtDate > Now() Then

                                objAddOn.SBO_Application.SetStatusBarMessage("Document Date Should be lesser than or equal to Today date.....", SAPbouiCOM.BoMessageTime.bmt_Short, True)

                                Return

                            End If

                        Catch ex As Exception

                        End Try

                        'Select Case pVal.EventType

                        '    Case SAPbouiCOM.BoEventTypes.et_COMBO_SELECT And (oForm.Mode = SAPbouiCOM.BoFormMode.fm_ADD_MODE)

                        '        'Case SAPbouiCOM.BoEventTypes.et_COMBO_SELECT And oForm.Mode = SAPbouiCOM.BoFormMode.fm_ADD_MODE Or oForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE

                        '        Try

                        '            If (pVal.ItemUID = "13") And (pVal.ColUID = "V_9") Then

                        '                matcol2 = oColumns.Item("V_8")

                        '                matcol1 = oColumns.Item("V_9")

                        '                oCombo = matcol1.Cells.Item(pVal.Row).Specific

                        '                oEdit = matcol2.Cells.Item(pVal.Row).Specific

                        '                oEdit.Value = oCombo.Selected.Description

                        '            End If

                        '        Catch ex As Exception

                        '        End Try

                        'Else

                        Try

                            If oMatrix.RowCount = 0 Then

                                objAddOn.SBO_Application.SetStatusBarMessage("No line Items.Please Enter The Values....")

                                Return

                            End If

                        Catch ex As Exception

                        End Try

                        If pVal.ItemUID = "1" And pVal.Action_Success = True And oForm.Mode = SAPbouiCOM.BoFormMode.fm_ADD_MODE Then

                            oForm.Items.Item("12").Specific.value = objAddOn.objGenFunc.GetDocNum("SST_EI_EATR")

                            oForm.Items.Item("10").Specific.string = objAddOn.objGenFunc.GetDateTimeValue(objAddOn.SBO_Application.Company.ServerDate).ToString("dd/MM/yy")

                        End If

                End Select

            End If

        Catch ex As Exception

        End Try

    End Sub

    Private Function Validate() As Boolean

        Try

            'Try

            '    If oForm.Items.Item("1000003").Specific.Value.ToString() = Nothing Then

            '        objAddOn.SBO_Application.SetStatusBarMessage("Department should not be Blank, Please enter the department.")

            '        Return False

            '    End If

            'Catch ex As Exception

            'End Try

            Try

                If oForm.Items.Item("1000002").Specific.Value.ToString() = Nothing Then

                    objAddOn.SBO_Application.SetStatusBarMessage("branch should not be Blank, Please enter the Branch.")

                    Return False

                End If

            Catch ex As Exception

            End Try

            Try

                If oForm.Items.Item("10").Specific.Value.ToString() = Nothing Then

                    objAddOn.SBO_Application.SetStatusBarMessage("Date should not be Blank, Please enter the Date.")

                    Return False

                End If

            Catch ex As Exception

            End Try

            Try

                If oMatrix.RowCount = 0 Then

                    objAddOn.SBO_Application.SetStatusBarMessage("No line Items.Please Enter The Values....")

                    Return False

                End If

            Catch ex As Exception

            End Try

            'Try

            '    If (oForm.Items.Item("13").Specific) And (oMatrix.Columns.Item("V_5").Cells.ToString) = "" Then

            '        objAddOn.SBO_Application.SetStatusBarMessage("Date should not be Blank, Please enter the Date.")

            '        Return False

            '    End If

            'Catch ex As Exception

            'End Try

            Try

                Dim stDate As String = oForm.Items.Item("10").Specific.string()

                Dim dtDate As Date

                dtDate = DateTime.Parse(stDate, Globalization.CultureInfo.CreateSpecificCulture("en-CA"))

                If dtDate > Now() Then

                    objAddOn.SBO_Application.SetStatusBarMessage("Document Date Should be lesser than or equal to Today date.....", SAPbouiCOM.BoMessageTime.bmt_Short, True)

                    Return False

                End If

            Catch ex As Exception

            End Try

            Return True

        Catch ex As Exception

        End Try

    End Function

    'Public Sub RightClickEvent(ByRef eventInfo As SAPbouiCOM.ContextMenuInfo, ByRef BubbleEvent As Boolean)

    '    Dim oMenuItem As SAPbouiCOM.MenuItem

    '    Dim oMenus As SAPbouiCOM.Menus

    '    oMatrix = oForm.Items.Item("13").Specific

    '    If (eventInfo.BeforeAction = True) Then

    '        If eventInfo.ItemUID = "13" Then

    '            oMenuItem = objAddOn.SBO_Application.Menus.Item("1280") 'Data'

    '            oMenus = oMenuItem.SubMenus

    '            If oMenus.Exists("DelRow") Then

    '            Else

    '                Try

    '                    Dim oCreationPackage As SAPbouiCOM.MenuCreationParams

    '                    oCreationPackage = objAddOn.SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams)

    '                    oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

    '                    oCreationPackage.UniqueID = "DelRow"

    '                    oCreationPackage.String = "Delete Row"

    '                    oCreationPackage.Enabled = True

    '                    oMenuItem = objAddOn.SBO_Application.Menus.Item("1280") 'Data'

    '                    oMenus = oMenuItem.SubMenus

    '                    oMenus.AddEx(oCreationPackage)

    '                Catch ex As Exception

    '                End Try

    '            End If

    '            RowNo = eventInfo.Row

    '        End If

    '    End If

    'End Sub

    'Private Sub DeleteRow(ByVal pVal As SAPbouiCOM.MenuEvent, ByVal FormUID As String)

    '    oForm = objAddOn.SBO_Application.Forms.Item(FormUID)

    '    oMatrix = oForm.Items.Item("13").Specific

    '    If oMatrix.RowCount > 0 Then

    '        oMatrix.DeleteRow(RowNo)

    '        If oForm.Mode = SAPbouiCOM.BoFormMode.fm_OK_MODE Then

    '            oForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE

    '        End If

    '    End If

    'End Sub

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

        If pVal.MenuUID = "1292" Then

            'oForm.Items.Item("13").Enabled = True

        End If

        If pVal.MenuUID = "1293" Then

            'oForm.Items.Item("13").Enabled = True

        End If

        'If pVal.MenuUID = "DelRow" Then

        '    DeleteRow(pVal, objAddOn.SBO_Application.Forms.ActiveForm.UniqueID)

        '    oForm.Items.Item("13").Enabled = True

        'End If

    End Sub

    Private Function i() As Object

        Throw New NotImplementedException

    End Function

    Private Function m_SBO_Form() As Object

        Throw New NotImplementedException

    End Function

    Private Function enControlName() As Object

        Throw New NotImplementedException

    End Function

    Private Function SBO_Application() As Object

        Throw New NotImplementedException

    End Function

End Class

Former Member
0 Kudos

Hi Bharath,

     Please refer to this post. http://scn.sap.com/thread/3231623

Regards,