Skip to Content
avatar image
Former Member

MUltiple CFL in Matrix

Dear All,

How To use "Multiple CFL" in Matrix . I tried below code .but it does not work.

The Following Columns are in the Matrix

BP Code,BP Name,Contact Person,Resource Group, Resource Code, Resource Name,Remarks

The Following CFL Columns are

BP Code,BP Name,Contact Person,Resource Group, Resource Code, Resource Name

Fill CFL Selected Record into Matrix - Code for BP Code ,BP Name

 Friend Sub DisplayBPDetails(ByVal oForm As SAPbouiCOM.Form, ByVal oMatrixUId As Object, ByVal oDataSource As Object, ByRef pVal As SAPbouiCOM.ItemEvent, ByVal oempId As Object, ByVal oempName As Object, ByVal oempContact As Object, ByVal oColUid As Integer)
        Dim oCFLEvento As SAPbouiCOM.IChooseFromListEvent = Nothing
        Dim oCFL As SAPbouiCOM.ChooseFromList = Nothing
        Dim sCHFL_ID As String = String.Empty
        Dim oDataTable As SAPbouiCOM.DataTable = Nothing
        Dim oMatrix As SAPbouiCOM.Matrix = Nothing
        Dim oDBDataSource As SAPbouiCOM.DBDataSource = Nothing
        Dim strCardCode As String = String.Empty
        Dim strCardName As String = String.Empty
        Dim strContact As String = String.Empty
        Try
            oCFLEvento = pVal
            sCHFL_ID = oCFLEvento.ChooseFromListUID
            oCFL = oForm.ChooseFromLists.Item(sCHFL_ID)
            '// Get the DBdatasource we base the matrix on
            oDBDataSource = oForm.DataSources.DBDataSources.Item(oDataSource)
            If pVal.ActionSuccess Then
                oDataTable = oCFLEvento.SelectedObjects
                If oDataTable Is Nothing Then Exit Sub
                If Not oDataTable Is Nothing And pVal.BeforeAction = False Then
                    oMatrix = oForm.Items.Item(oMatrixUId).Specific
                    For i As Integer = 0 To oDataTable.Rows.Count - 1
                        If oDataTable.Rows.Count > 1 Then
                            strCardCode = Convert.ToString(oDataTable.GetValue("CardCode", i))
                            strCardName = Convert.ToString(oDataTable.GetValue("CardName", i))
                            strContact = Convert.ToString(oDataTable.GetValue("CntctPrsn", i))
                            With oDBDataSource
                                .InsertRecord(oDBDataSource.Size - 1)
                                .SetValue(oempId, i, strCardCode)
                                .SetValue(oempName, i, strCardName)
                                .SetValue(oempContact, i, strContact)
                                oMatrix.SetLineData(pVal.Row)
                                oMatrix.LoadFromDataSource()
                                'If Not i = oDataTable.Rows.Count - 1 Then
                                '    oMatrix.AddRow()
                                'End If
                            End With
                        ElseIf oDataTable.Rows.Count = 1 Then
                            strCardCode = oDataTable.GetValue("CardCode", i)
                            strCardName = Convert.ToString(oDataTable.GetValue("CardName", i))
                            strContact = Convert.ToString(oDataTable.GetValue("CntctPrsn", i))
                            With oDBDataSource


                                .InsertRecord(i)
                                .SetValue(oempId, oDBDataSource.Offset, strCardCode)
                                .SetValue(oempName, oDBDataSource.Offset, strCardName)
                                .SetValue(oempContact, oDBDataSource.Offset, strContact)
                                oMatrix.SetLineData(pVal.Row)
                                oMatrix.FlushToDataSource()
                                Call AddMatrixRow(oForm, oMatrixUId)
                            End With
                        End If
                        oMatrix.Columns.Item(oColUid).Cells.Item(pVal.Row).Click(SAPbouiCOM.BoCellClickType.ct_Regular, 0)
                    Next
                End If
            End If


        Catch ex As Exception
        Finally


            oDataTable = Nothing
            oDBDataSource = Nothing
        End Try
    End Sub

Fill CFL Selected Record into Matrix - Code for Resource Group Name

 Friend Sub DisplayResGroup(ByVal oForm As SAPbouiCOM.Form, ByVal oMatrixUId As Object, ByVal oDataSource As Object, ByRef pVal As SAPbouiCOM.ItemEvent, ByVal oResType As Object, ByVal oColUid As Integer)
        Dim oCFLEvento As SAPbouiCOM.IChooseFromListEvent = Nothing
        Dim oCFL As SAPbouiCOM.ChooseFromList = Nothing
        Dim sCHFL_ID As String = String.Empty
        Dim oDataTable As SAPbouiCOM.DataTable = Nothing
        Dim oMatrix As SAPbouiCOM.Matrix = Nothing
        Dim oDBDataSource As SAPbouiCOM.DBDataSource = Nothing
        Dim strResGroup As String = String.Empty
        Try
            oCFLEvento = pVal
            sCHFL_ID = oCFLEvento.ChooseFromListUID
            oCFL = oForm.ChooseFromLists.Item(sCHFL_ID)
            '// Get the DBdatasource we base the matrix on
            oDBDataSource = oForm.DataSources.DBDataSources.Item(oDataSource)
            If pVal.ActionSuccess Then
                oDataTable = oCFLEvento.SelectedObjects
                If oDataTable Is Nothing Then Exit Sub
                If Not oDataTable Is Nothing And pVal.BeforeAction = False Then
                    oMatrix = oForm.Items.Item(oMatrixUId).Specific
                    For i As Integer = 0 To oDataTable.Rows.Count - 1
                        If oDataTable.Rows.Count > 1 Then
                            With oDBDataSource
                                strResGroup = Convert.ToString(oDataTable.GetValue("ResGrpNam", i))
                                .InsertRecord(oDBDataSource.Size - 1)
                                .SetValue(oResType, i, strResGroup)
                                oMatrix.SetLineData(pVal.Row)
                                oMatrix.LoadFromDataSource()
                            End With
                        ElseIf oDataTable.Rows.Count = 1 Then
                            strResGroup = oDataTable.GetValue("ResGrpNam", i)
                            With oDBDataSource
                                .InsertRecord(i)
                                .SetValue(oResType, .Offset, strResGroup)
                                'oMatrix.LoadFromDataSource()
                                oMatrix.SetLineData(pVal.Row)
                                oMatrix.FlushToDataSource()
                                'Call AddMatrixRow(oForm, oMatrixUId)
                            End With
                        End If
                        oMatrix.Columns.Item(oColUid).Cells.Item(pVal.Row).Click(SAPbouiCOM.BoCellClickType.ct_Regular, 0)
                    Next
                End If
            End If


        Catch ex As Exception
        Finally


        End Try
    End Sub

Scenarios are given below

Scenario 1 -- Select Multiple BP Code CFL

  1. User selects multiple BP Code .
  2. Displayed in the Matrix .
  3. User selects single Row from Resource Group Name.
  4. It does not show in the Matrix.

Scenario 2 -- Select Single BP Code CFL

  1. User selects Single BP Code .
  2. Displayed in the Matrix .
  3. User selects single Row from Resource Group Name.
  4. It's shows in the Matrix
  5. Second time, user selects BP Code
  6. Automatically , Previous Row Record added into next Row.

So please let me know ,How to handle this issue and any common solution ,Please share it.


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Dec 05, 2016 at 01:46 AM

    SetLineData is not required.
    Use oMatrix.FlushToDataSource after referencing your matrix in your code.

    Add comment
    10|10000 characters needed characters exceeded