Skip to Content
avatar image
Former Member

Delete last row in 2007

Hi, we are migrating from 2005A PL39 to 2007A PL30 and i find an old problem that was resolved in 2005A, when i delete the last and unique row of a matrix in a UDO form it doesn´t modified database and the row persits.

Does any one have the same problem?

Thanks,

Daniel

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 03, 2008 at 02:16 PM

    Thanks Mohama for your answer, I tried your sample but i doesn´t work for me in version 2007 (in version 2005 runs well).

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Daniel,

      I'm working with B1 2007A, and I remove a row with this function

      Private Sub DeleteLine(ByRef oCompany As SAPbobsCOM.Company, ByRef oApplication As SAPbouiCOM.Application, _
                  ByRef pVal As SAPbouiCOM.MenuEvent)
      
              oForm = oApplication.Forms.ActiveForm
      
              Try
                  oForm.Freeze(True)
      
                  If oForm.Mode <> BoFormMode.fm_FIND_MODE Then
                      Dim oMatrix As SAPbouiCOM.Matrix = oForm.Items.Item("mtx_NP").Specific
                      Dim LineDeleted As Boolean = False
      
                      With oForm.DataSources.DBDataSources.Item("@ADAT_NP1")
      
                          For i As Integer = 1 To .Size - 1
                              If oMatrix.Columns.Item("V_LineId").Cells.Item(i).Specific.Value <> i Then
      
                                  If LineDeleted = True Then 
                                      If oForm.Mode = BoFormMode.fm_ADD_MODE Then .SetValue("LineID", i - 1, CStr(i))
      
                                  Else 
                                      .RemoveRecord(i - 1)
                                      If oForm.Mode = BoFormMode.fm_ADD_MODE Then .SetValue("LineID", i - 1, CStr(i))
                                      LineDeleted = True
                                  End If
                              End If
                          Next
                      End With
      
                      oMatrix.LoadFromDataSource()
                  End If
      
              Catch ex As Exception
                  oApplication.MessageBox("DeleteLine(): " & ex.Message)
              Finally
                  oForm.Freeze(False)
              End Try
      

      Hope it helps,

      Vítor Vieira

  • avatar image
    Former Member
    Sep 03, 2008 at 09:40 AM

    hi..

    try this one

    If (pVal.MenuUID = "OnlyOnRC") And (pVal.BeforeAction = False) Then

    Try

    Dim oMenuItem As SAPbouiCOM.MenuItem

    Dim oMenus As SAPbouiCOM.Menus

    Dim omat As SAPbouiCOM.Matrix

    Dim GCols As SAPbouiCOM.Columns

    Dim i As Integer

    oitem = OForm.Items.Item("38")

    omat = oitem.Specific

    GCols = omat.Columns

    omat = OForm.Items.Item(selItem).Specific

    For i = 1 To omat.RowCount

    If omat.IsRowSelected(i) = True Then

    omat.DeleteRow(i)

    Exit For

    End If

    Next

    Catch ex As Exception

    SBO_Application.MessageBox(ex.Message)

    End Try

    End If

    regards...

    Mohana

    Add comment
    10|10000 characters needed characters exceeded