Skip to Content
avatar image
Former Member

Eeload Matrix after adding value in the user table

Hello friends,

I am creating a matrix object with some columns.

The process of creating the matrix and the columns is successful.

I created a button to perform the action to add the values ​​entered in the matrix of fields in a user table. This process is successful.

After add the values ​​entered in the columns in the database column is empty.

Would appear that the values ​​in the column after added.

I used the parameter below however is not working.

oMatrix.LoadFromDataSource ()

Below my code.

----------------------------------------------------

oMktForm = SBO_Application.Forms.GetForm(FormTypeEx, FormTypeCount)

            sboRecordSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

          

            oEditText = oMktForm.Items.Item("10").Specific

            ContractID = oEditText.Value

          

            oItem = oMktForm.Items.Item("Matrix01")

            oMatrix = oItem.Specific

            Dim FTMCodigo As String = ""

            Dim FTMDesc As String = ""

            'Percorre as linhas do Matrix

            Dim i As Integer

            For i = 1 To oMatrix.VisualRowCount

             

                oEditText = oMatrix.Columns.Item("FTMCodigo").Cells.Item(i).Specific

                FTMCodigo = oEditText.Value

                FTMDesc = oEditText.Value

                oEditText = oMatrix.Columns.Item("FTMDesc").Cells.Item(i).Specific

                'Se itemCode está preenchido

                If FTMCodigo <> "" Then

                    'Confere se já tem esse item na tabela de Servicos do LocOne

                    sboRecordSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

                    strQuery = "SELECT"

                    strQuery &= " U_FTM_ContractID"

                    strQuery &= " FROM [@FTM_CBRA]  (NOLOCK) "

                    strQuery &= " WHERE U_FTM_ContractID = '" & ContractID & "'"

                    strQuery &= " AND U_FTM_CodeCobertura = '" & FTMCodigo & "'"

                    sboRecordSet.DoQuery(strQuery)

               If sboRecordSet.RecordCount = 0 Then

                        Dim ProxID As String

                        'busca prox ID

                        strQuery = "SELECT ISNULL(MAX(Cast(Code as Int))+1,1) as Code FROM [@FTM_CBRA] (NOLOCK) "

                        sboRecordSet.DoQuery(strQuery)

                        ProxID = CStr(sboRecordSet.Fields.Item(0).Value)

                        'Insere o item

                        strQuery = "INSERT INTO [@FTM_CBRA] "

                        strQuery &= " (Code, Name,"

                        strQuery &= " U_FTM_ContractID,"

                        strQuery &= " U_FTM_Codecobertura,"

                        strQuery &= " U_FTM_Descricao"

                        strQuery &= " )"

                        strQuery &= " VALUES"

                        strQuery &= " ('" & ProxID & "', '" & ProxID & "',"

                        strQuery &= " '" & ContractID & "',"

                        strQuery &= " '" & FTMCodigo & "',"

                        strQuery &= " '" & FTMDesc & "'"

                        strQuery &= " )"

                        sboRecordSet.DoQuery(strQuery)

                    End If

                End If 'Se itemCode está preenchido

                'Limpa matriz para inserir os dados

                'oMatrix.Clear()

                oMktForm.DataSources.DataTables.Item("DTM01").Rows.Add()

                oMatrix.AutoResizeColumns()

                oMatrix.LoadFromDataSource()

----------------------------------------------------

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 19, 2015 at 10:51 AM

    Hello,

    I managed to solve the problem through the code below.

    Thank you all.

    Dim oItem As SAPbouiCOM.Item = oMktForm.Items.Item("FTMMTX1")

                    oMatrix = oItem.Specific

                    Dim SQL As String = "SELECT" +

                    " U_FTM_ContractID AS ContractID," +

                    " U_FTM_Codecobertura as CodeCobertura," +

                    " U_FTM_Descricao as Descricao" +

                    " FROM [@FTM_CBRA]  (NOLOCK) " +

                    " WHERE U_FTM_ContractID = '" & ContractID & "'"

                    oMktForm.DataSources.DataTables.Item("FTM_DTM01").Clear()

                    oMktForm.DataSources.DataTables.Item("FTM_DTM01").ExecuteQuery(SQL)

                    'oMatrix.LoadFromDataSource()

                    'Dim oDBDataSource As SAPbouiCOM.DBDataSource =

                    oMktForm.DataSources.UserDataSources.Add("U_FTM_cc", SAPbouiCOM.BoDataType.dt_LONG_TEXT, 20)

                    oMktForm.DataSources.UserDataSources.Add("U_FTM_DE", SAPbouiCOM.BoDataType.dt_SHORT_TEXT, 10)

                    'Dim oDBDataSource As SAPbouiCOM.UserDataSource = oMktForm.DataSources.UserDataSources

                    Dim oDataTable As SAPbouiCOM.DataTable = oMktForm.DataSources.DataTables.Item("FTM_DTM01")

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 16, 2015 at 11:47 PM

    Hi,

    For quick response, please repost above discussion at SDK forum.

    Close this thread here with helpful answer.

    Thank you.

    Add comment
    10|10000 characters needed characters exceeded