Delete row matrix in UDO Form

Hi All,
I've created a simple form based on an registered UDO (2 tables: Document and Document Lines).
This form contains a matrix bounded to the lines of my UDO document.
Everything works fine except the Delete button that should delete a document line in the matrix: it never
deletes the lines from database, although it deletes them from the form. But if I select again the same
record, the deleted line is show again!
My code is very simple:
void btRemove_ClickEvent()
     // Remove selected row from Matrix
     SAPbouiCOM.Matrix oMatrix = (SAPbouiCOM.Matrix) oForm.Items.Item("mxMatrix").Specific;
     int iPos = oMatrix.GetNextSelectedRow( 0, SAPbouiCOM.BoOrderType.ot_RowOrder );
     if( iPos > -1 )
          oMatrix.DeleteRow( iPos );
          oMatrix.FlushToDataSource();
          oForm.Update();
What is the problem with my code? Is it missing something?
Regards,
Manuel Dias

Thanks Gianluigi,
By the way, I want to delete the Matrix line with DI API has you suggest, so I was thinking in using this code:
     SAPbobsCOM.UserTables pUT = Main.oSBOCompany.UserTables;
     SAPbobsCOM.UserTable dt = pUT.Item("@PDWC_LINE");
     bool xx = dt.GetByKey( sKey );
     int res = dt.Remove();
The problem is that UserTable object, has a GetByKey() method that works only for user tables whose PK
contains only one column (GetByKey requires only a single value).
Since my table is created in SBO with the UDO Document Lines template, the PK is composed automatically
by Code and LineId columns, so the GetByKey() method does not allow me to select a specific record in
order to delete it next.
Do you know any workaround for this? Of course I could user the Recordsed object and write SQL to
delete my table line, but I think it must be an esay way to do this....
Regards,
Manuel Dias

Similar Messages

  • Unable to delete row(s) from tabular form

    Hi!
    I created report with row selector, when I select one row I get tabular form regarding to the selected row from report. I can insert and update data from tabular form, but I have problem with deleting them. Error I get is ORA-01403: no data found (Row 207589)My tabular form is created by wizard and primary key is managed by database rowid, I use apex 4.1 an 10g database.
    Do you know for any solution for my problem?
    Regards,
    drama9346
    Add:
    For creating report and tabular form I use code and suggestion from this thread: {thread:id=2490862}
    Edited by: drama9346 on 28.1.2013 1:51

    Hi,
    I tried everything I know and I didn't solve my problem.
    Can anyone give me some clue?
    Regards,
    drama9346
    Add:
    I solve my problem.
    Edited by: drama9346 on 29.1.2013 1:52

  • Delete row

    Hi
    Is it possible to delete a row using DI ??? I think no...
    But if no, <b>then how system form manage it</b>. If we delete any row from system matrix, it is also deleted from DBase also.....

    Hi,
    there are many possibilities, for deleting row ... in system form, easiest and perhaps safiest way is to simulate "Ctrl-K"
    in custom form, with DBDatasource, you have to delete it on your own I've tried the Ctrl-K, but it isn't doing anything, from DBDatasource for visualisation and from Database ...
    Or perhaps, only delete it from Database, and requery and reload DBDatasource ?
    conclusion: I also think, that it is impossible to delete row from your own form ...
    Jaro

  • Can't delete matrix row in UDO form

    Hi all,
    i have a problem. I've already searched the forum and found a couple of solutions, but they didn't work.
    I can't delete a matrix row. I'm on patch level 39, i've read that patches from 32 to 38 gave some problems with matrix row delete.
    Any one has notice regarding same problems with patch 39?
    I post the code i'm using for the delete.
    matrix.FlushToDataSource()
    dbDataSource.RemoveRecord(row - 1)
    matrix.LoadFromDataSource()
    UIForm.Update()
    'Removes the change trace row
    changeTrace.RemoveAt(row - 1)
    UIForm.Mode = BoFormMode.fm_UPDATE_MODE
    Thanks in advance

    Hi,
    I'm using PL39 and I can delete rows in matrix (you are right in previous patch there was an error, and it´s imposible to delete rows). I saw the code you put and I doesn´t undestand what you are trying to do. I explain what I do:
    - I enable the menu 1293 to delete row in a matrix, in the menu event i put the following code
                         Dim oMtx As SAPbouiCOM.Matrix =
    oMtx.FlushToDataSource()
    This works for me.

  • Delete Row In Matrix

    Hello All,
    I have a UDO and a form for it. The UDO has a child table, which is binded to a matrix in the form. Everything works well except Delete Row in the matrix.
    If I don't do anything when Delete Row menu is clicked, the row is deleted. But as soon as Update button is clicked, a new empty row gets added to the matrix and the underlying table.
    The same happens even if I catch the delete row event, do the delete myself and then set the bubbleevent to false.
    Is this the default behaviour. What is the workaround to avoid this addition of new empty row.
    Following is the code I am using for deleting the row. I've used various combinations of this code to the same affect.
            Dim oMatrix As SAPbouiCOM.Matrix
            Dim RowIndex As Integer
            Try
                If oForm.Mode <> SAPbouiCOM.BoFormMode.fm_FIND_MODE Then
                    oMatrix = oForm.Items.Item("AC_MX01").Specific
                    RowIndex = oMatrix.GetNextSelectedRow
                    If RowIndex <= 0 Then
                        Exit Sub
                    End If
                    oForm.DataSources.DBDataSources.Item("@AC_SMP1").RemoveRecord(RowIndex - 1)
                    oMatrix.DeleteRow(RowIndex)
                    'oMatrix.FlushToDataSource()
                    'oMatrix.LoadFromDataSource()
                Else
                    Exit Sub
                End If

    Hi Rahul
    Try this code
            Dim oMatrix As SAPbouiCOM.Matrix
            Dim RowIndex As Integer
            oMatrix = oForm.Items.Item("AC_MX01").Specific
            For RowIndex = 1 To oMatrix.RowCount
                 If oMatrix.IsRowSelected(RowIndex) = True Then
                     oMatrix.DeleteRow(RowIndex)
                     oMatrix.FlushToDataSource()
                     If form.Mode = 1 Then form.Mode = BoFormMode.fm_UPDATE_MODE
                     Exit For
                 End If
           Next
    Hope this helps....
    Kind Regards
    Arun TB

  • Delete row of matrix

    i have created amatrix. but when i delete a particular line by clicking on delline error reflects as
    matrix-invalid row no
    form generated via udo form generator

    thanks for the reply. it really helped me and i got my problem solved.

  • Udo form matrix binding

    Hi,
    I created one UDO form.
    in that i am trying to fill the matrix with recordset.
    becoz i am selecting the value from combobox and i run the query with this value.
    so this resultant record set i want to fill in matrix rows.
    oForm = SBO_Application.Forms.Item("JBWISSUES_")
                oItem = oForm.Items.Item("mtx_0")
                oMatrix = oItem.Specific
                oColumns = oMatrix.Columns
                'frm = app.Forms.ActiveForm
                'oMat = frm.Items.Item("gd_act").Specific
                'oMatrix.Clear()
                oComboBox = oForm.Items.Item("27").Specific
                ds = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
                ds.DoQuery("select a.code as Code,b.Itemname as Desc1,a.quantity as Quantity from itt1 a,oitm b where a.code=b.Itemcode and a.code='" & oComboBox.Selected.Value & "'")
                ds.MoveFirst()
                'oColumn = oColumns.Item("col_0")
                For i = 0 To ds.RecordCount - 1
                 oColumn.ValidValues.Add(ds.Fields.Item("Code").Value, ds.Fields.Item("Desc1").Value)
                    ds.MoveNext()
                Next
                oMatrix.AddRow()
    here i am getting error like Object reference not set to instance error at oColumn.validvalues....... plz hel p me in that.
    Regards,
    Ravi

    That's because you have commented out the line where you set the oColumn object:
    'oColumn = oColumns.Item("col_0")
    Regards,
    Frank

  • Add row / delete row in PDF Form

    Alright so I am really struggling here and no one has been able to provide me a solid answer to date.
    1. I am creating a PDF form I want users to be able to fill and remit via email
    2. I have created the form in Acrobat 9 Pro via the form Wizard and in some combination with MS Word 2007 for text and table fields to get the forms wizard to auto-populate Adobe form fields.
    3. Some of the tables, i.e. In the first table for "Full Time" and "Part Time" should have check boxes - works fine to date. While others should have drop downs, i.e. platform build, etc - works fine to date.
    4. This is the pressing issue. As they exist today there is a large table as you can clearly see. I want users to be able to simply click an "Add Row" or "Delete Row" button to add another row to the table (or delete) without having to have a massive table.
    I've watched demos on Lynda.com (all of which are irrelevant and provided 0 value), tried to work with what people have responded with previously but all are mainly sample documents and I don't know where to start. In short, I open my form and other forms in LifeCycle Designer ES, take a look at the buttons people have created, the scripts, the XML source, etc. but no idea where to go. If the button needs to be in the table. How it should be scripted. etc. I cannot find a video tutorial anywhere on the web and all the responses simply provide a sample but no idea how to make it a reality in terms of translating their sample into a working dynamic form in PDF. Any help is greatly appreciated. Thanks.

    For a dynamic table you have to design a new XFA-form in Designer.
    Here's a little tutorial how to create dynamic tables.
    http://forms.stefcameron.com/2009/02/25/expandable-table-with-totals/
    Just a little correction.
    You can inport Docx-Files with tables and add / remove rows in a dynamic PDF.
    But, this is not handy, if the table contains more than one row when it is imported because Designer gives every detected row the same name (Row).
    Delete all row excepting the first one and set it to repeatable in the binding tab.
    Then you can use the addInstance() and removeInstance() methods to add/remove row to the table.
    Here an example file I made from a docx file.
    https://acrobat.com/#d=k8XbQWmqu6bhfrrwui93pw

  • Deleting row in matrix.

    Hello.
    I have weird problem.
    If I add some rows to matrix, and then delete rows the method with:
    m_pMatrix->GetRowCount();
    return the number of rows without delete.
    For example:
    If i have matrix with 5 rows, and I delete 2 rows, method with GetRowCount show me 5
    What is wrong ?
    I solved this problem with adding new variable, but why does it work wrong ?
    Sorry for my english.
    Regards
    Kamil Wydra

    Hello.
    Thank You for Your response.
    I try that and it works.
    Thanks again.
    Regards
    Kamil Wydra

  • Can't catch the matrix row for Deleting Rows

    Hi,
    I've already read related topics but couldn't solve the problem.
    I catch the Delete Row menu event 1293, but then I can't save the deleted row in an array since it's no longer listed as a selected row.
    All the matrix rows return
    oMatrix.IsRowSelected(i) = False after catching that 1293 event.  
    Trying BeforeAction True or false didn't solve that problem.
    What am I missing ?

    it sounds like a bug.
    here is workaround: in oMatrix-itempress event try to store selected rowIndex in your variable - so, when you catch 1293-menuEvent you'll know which row you should save - it'll be value of your variable.

  • Delete Row (1293) always disabled with matrix

    I have a maxtrix whose menu-item 'Delete Row' (menu uid 1293) is always
    disabled, even though its 'AllowRowDelete'-property is set to 'true'.
    What could be the problem here ?
    (I have several other matrixes on which it just works fine,
    only on this one matrix, I cannot get it to work. Very strange).

    ok,
    than enable the menuUID with
    oForm.EnableMenu "1293", True
    but you have to program the remove line function by yourself
    regards
    David

  • Matrix Delete Row

    Good Afternoon
    Experts:
    After some review of handling the updating of a Matrix with the help of Neftali, I had another thought on the topic.  The actual update of a row is no problem.  However, the delete of a row presents a bit of a quandry.  While it can be done,  this way be seems ok:
    <b>Scenario1:</b>
    1)Add a delete button to the screen
    2)Click on the grey column on the left of the Matrix. 
    3)The Matrix row gets highlighted and the Delete button is enabled
    4)Hit the button to delete the row and then in code behind the button
      go delete the record from the table
    **Problem is I cannot figure out how to get the whole row to highlight when I click
      in the leftmost grey column in the Matrix
    <b>Scenario2:</b>
    1)I enabled the delete row right for the Matrix with  MatReqForm.EnableMenu("1293", True)
    2)Using the MenuEvent, I can trap the event and ask the user if the DELETE is for sure using a message box.  However, the data is already gone from the Matrix at this point.
    So, I think highlighting the whole row and hitting a delete button may work better...unless I am missing something in Scenario2.
    Thoughts...questions?
    Thanks,
    EJD

    Hi Ed,
    You could trap the right-click event and add your own Delete Row option to the menu (there's an example of how to use the right-click event in the SDK samples). If it's your own menu option then you have full control on when the row is deleted so you can prompt the user to confirm the deletion and only delete after they say yes. My own preference would be a right-click menu option but a button is another good option.
    Highlighting a row is easy as SBO does it all for you. It's just a case of setting the correct value to the SelectionMode property of the matrix (setting it to 1 will allow the user to select multiple rows, 2 and they can select only a single row).
    Kind Regards,
    Owen

  • Delete rows from Tabular form

    Hi,
    Anyone knows how dynamicly delete rows from Tabular Form (on button click, button is as item)?
    Thanks.

    I am in a great fix. We had a test instance.. and we had a version apex 3.2.. But when the same application has been uploaded to prod.. we used apex 4.0.Why on Earth would you do this? The whole point of the testing is to verify that the application will work in the production environment: the first requirement for this is that the test and production environments are equivalent.
    has any body is facing the same issue as mine..Yes, as is easily discovered by searching the forum...see Delete button doesn't work in tabular form after upgrade from APEX3.2 to 4.

  • Delete row menu on sales line item matrix

    Can anyone tell me how I can tell which row is being deleting by the menu event for this delete row ( MENU ID 1293)
    I want to access the record on the menu event and check some fields but the user does not always have to have a row selected to use this menu. If I put the cursor in the item code field on the first line item even though the row is not selected and hit delete row it will delete the 1st row.
    Any ideas?

    Thanks for the posting John. I guess I can also use the right click event to get the row?
    Would this work the same?
    currently i am using
    int selRow = myMat.GetNextSelectedRow(0,SAPbouiCOM.BoOrderType.ot_RowOrder);
    but of course there isn't always a row selected when the user selects delete

  • Matrix With UDO Datasource

    Hi,
    I have been through all the Matrix Samples and read many threads here but I just dont get a few things with the Matrix.
    I have created an add on that adds a new folder to the Business Partners Form,
    I can have built a matrix in this form and created bound columns bound to my UDO Table @xxxx
    I have an event that fires when a business partner is chosen and the folder is only shown when a Customer is selected.
    I can even get the matrix to fill with data related to the specific customer only when the customer is selected - using conditions on the DBDataSource.
    This is all great but the 2 problems I have are :
    I have created a button called Add Row that Adds a Row to Matrix - this button turns into an Update button when the row is added in the Matrix.
    Problem 1 : When the row is added in the Matrix it takes the data from the last row of the data and duplicates it in the new row - you can change this data of course however I would like a blank row inserted instead.
    Problem 2 : When I update I do a Matrix.FlushToDataSource - then I requery but it has not saved the new entry ?
    How do I get the new entry to save into the database.
    Any Help would be appreciated.
    Thanks

    Thanks - I sent the Screen shot - here is the event code
                If ((pVal.FormType = 134 And pVal.EventType <> SAPbouiCOM.BoEventTypes.et_FORM_UNLOAD) And (pVal.Before_Action = True)) Then
                     oForm = SBO_Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount)
                    If ((pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_LOAD) And (pVal.Before_Action = True)) Then
                            oNewItem = oForm.Items.Add("BOMFolder", SAPbouiCOM.BoFormItemTypes.it_FOLDER)
                        oItem = oForm.Items.Item("9")
                        oNewItem.Top = oItem.Top
                        oNewItem.Height = oItem.Height
                        oNewItem.Width = oItem.Width
                        oNewItem.Left = oItem.Left + oItem.Width
                        oFolderItem = oNewItem.Specific
                        oFolderItem.Caption = "Lynxs BOM"
                        oFolderItem.GroupWith("9")
                        SetupBOMMatrix()
                        oForm.PaneLevel = 1
                    End If
                    If pVal.EventType = SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST Then
                        If pVal.ItemUID = "mat" Or pVal.ItemUID = "colitem" Then
                            Try
                                Dim oCFLEvento As SAPbouiCOM.IChooseFromListEvent
                                oCFLEvento = pVal
                                Dim sCFL_ID As String
                                sCFL_ID = oCFLEvento.ChooseFromListUID
                                Dim oForm1 As SAPbouiCOM.Form
                                oForm1 = SBO_Application.Forms.Item(FormUID)
                                Dim oCFL As SAPbouiCOM.ChooseFromList
                                oCFL = oForm1.ChooseFromLists.Item(sCFL_ID)
                                If oCFLEvento.BeforeAction = False Then
                                    Dim oDataTable As SAPbouiCOM.DataTable
                                    oDataTable = oCFLEvento.SelectedObjects
                                    Dim val As String
                                    Dim nam As String
                                    Try
                                        val = oDataTable.GetValue(0, 0)
                                        nam = oDataTable.GetValue(1, 0)
                                     Catch ex As Exception
                                        val = "none"
                                        nam = "none"
                                    End Try
                                     Try
                                        Call UpdateCells(oForm1, pVal.Row, val, nam)
                                    Catch
                                        MsgBox("Couldnt Set Data Tables")
                                    End Try
                                End If
                            Catch
                                MsgBox("Error in Item Event - CFL : " & Err.Description)
                            End Try
                        End If
                    End If
                     If pVal.ItemUID = "btnAddRow" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED And pVal.Before_Action = True Then
                        ' SOMETHING IS AMISS HERE
                        Dim ob As SAPbouiCOM.Button = oForm.Items.Item("btnAddRow").Specific
                        Dim oe As SAPbouiCOM.EditText = oForm.Items.Item("5").Specific
                        oMatrix = oForm.Items.Item("mat").Specific
                        If MatrixMode = "Nothing" Then
                            oMatrix.AddRow()
                            Dim i As Integer
                            i = oMatrix.RowCount
                            Dim oc As SAPbouiCOM.Column
                            Dim ocell As SAPbouiCOM.Cell
                            Dim oed As SAPbouiCOM.EditText
                            oc = oMatrix.Columns.Item("colArea")
                            oed = oc.Cells.Item(i).Specific
                            oed.String = ""
                            oc = oMatrix.Columns.Item("colItem")
                            oed = oc.Cells.Item(i).Specific
                            oed.String = ""
                            oc = oMatrix.Columns.Item("colItemtxt")
                            oed = oc.Cells.Item(i).Specific
                            oed.String = ""
                            oc = oMatrix.Columns.Item("colFitted")
                            oed = oc.Cells.Item(i).Specific
                            oed.Value = 0
                            oc = oMatrix.Columns.Item("colCritica")
                            oed = oc.Cells.Item(i).Specific
                            oed.Value = 0
                            oc = oMatrix.Columns.Item("colSpares")
                            oed = oc.Cells.Item(i).Specific
                            oed.Value = 0
                            MatrixMode = "Add"
                            ob.Caption = "Update Row"
                        Else
                            oMatrix.FlushToDataSource()
                            Dim oConditions As SAPbouiCOM.Conditions
                            Dim ocondition As SAPbouiCOM.Condition
                            oConditions = New SAPbouiCOM.Conditions
                            ocondition = oConditions.Add
                            ocondition.BracketOpenNum = 1
                            ocondition.Alias = "U_CARDCODE"
                            ocondition.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL
                            ocondition.CondVal = oe.Value.ToString
                            ocondition.BracketCloseNum = 1
                            oDBDatasource.Query(oConditions)
                            oMatrix.LoadFromDataSource()
                            MatrixMode = "Nothing"
                            ob.Caption = "Add Row"
                        End If
                    End If
                    If pVal.ItemUID = "BOMFolder" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED And pVal.Before_Action = True Then
                        '// when the new folder is clicked change the form's pane level
                        '// by doing so your items will apear on the new folder
                        '// assuming they were placed correctly and their pane level
                        '// was also set accordingly
                        oForm.PaneLevel = 11
                    End If
                End If

Maybe you are looking for

  • IPhone deletes 400 songs from playlist and syncs that to iTunes

    Hi there, I'm new on these forums, although I've been using iTunes (on a Windows PC) for many years. I got an iPhone 4s, set it up to use iCloud and iTunes Match. Now I chose to play a playlist (via Bluetooth) of about 500 songs randomly in the iphon

  • Links to embedded pdf files not working in iOS reader

    I have created a pdf document that links to a variety of embedded pdf files. When I open this file in the iOS reader on my iPad 3, the links are not active. All of the embedded files are listed in the attachments list, but the links themselves do not

  • Connecting iMac to PC internet connection

    I am about to purchase the new iMac G5, and I was wondering before I buy it if it is possible to connect my iMac wirelessly, to the DSL connection that is pre-existing on my PC. If so, what hardware would I need? Thanks

  • No cd in drive error...

    Anytime recently, when trying to add files from "My Music" folder, I get an error message saying "No disc in the drive...". The files have already been ripped onto computer. It gives me the option to Cancel, Retry, or Continue. Any button I press res

  • Performance problem in data replication program written in java

    Dear all, I need your valuable ideas on improving below logic on replicating data fromDB2 to Oracle 9i.We have a huge tables in DB2 to replicate to Oracle side.For one table this taking lot of time.The whole app' is written in java.The current logic