Delete Last Row in Matrix on SBO 2005

Hi,
Im using SAPB1 2005 SP1 with B1DE.
I've seen a post that indicates that the following code should delete a row from a matrix (even the last row) when using SBO 2005
I still find that all rows except last row of matrix are removed from the database.
<b>How do I delete the last row from the Del button event handler????</b>
I'm using
<i>        [B1Listener(BoEventTypes.et_CLICK, false)]
        public virtual void OnAfterClick(ItemEvent pVal)
            bool ActionSuccess = pVal.ActionSuccess;
            Form form = B1Connections.theAppl.Forms.Item(pVal.FormUID);
            Item item = form.Items.Item("del");
            Button button = ((Button)(item.Specific));
            // ADD YOUR ACTION CODE HERE ...
            int row;
            Matrix oMtx = (Matrix)form.Items.Item("mtx_0").Specific;
            DBDataSource oDBDS = (DBDataSource)form.DataSources.DBDataSources.Item("@SD_POOLCONTRCT_LINE");
            row = oMtx.GetNextSelectedRow(0, BoOrderType.ot_SelectionOrder);
            oMtx.DeleteRow(row);
            if (oMtx.RowCount == 0)
                oDBDS.RemoveRecord(0);
            if ((form.Mode != BoFormMode.fm_ADD_MODE) | (form.Mode != BoFormMode.fm_UPDATE_MODE))
                form.Mode = BoFormMode.fm_UPDATE_MODE;
            }</i>

Hi Ben,
[B1Listener(BoEventTypes.et_CLICK, false)]
public virtual void OnAfterClick(ItemEvent pVal)
bool ActionSuccess = pVal.ActionSuccess;
Form form = B1Connections.theAppl.Forms.Item(pVal.FormUID);
Item item = form.Items.Item("del");
Button button = ((Button)(item.Specific));
// ADD YOUR ACTION CODE HERE ...
int row;
Matrix oMtx = (Matrix)form.Items.Item("mtx_0").Specific;
DBDataSource oDBDS = (DBDataSource)form.DataSources.DBDataSources.Item("@SD_POOLCONTRCT_LINE");
Rest of your code will remain same.
I am making the modification here. I am using the RowCount property that gives me the address of the last row of the matrix.
<b>row = oMtx.RowCount;</b>
Every time this will return you the last row and that row will be deleted.
<b>row = oMtx.RowCount;</b>
oMtx.DeleteRow(row);
if (oMtx.RowCount == 0)
oDBDS.RemoveRecord(0);
if ((form.Mode != BoFormMode.fm_ADD_MODE) | (form.Mode != BoFormMode.fm_UPDATE_MODE))
form.Mode = BoFormMode.fm_UPDATE_MODE;
Regards,
Prashant

Similar Messages

  • Delete last row in database?

    How do I delete last row in mysql database? I tried like this without luck:
         public void minus()
         int tal=0;
         try{
         ResultSet row = db.select("select * from midlertidigregning order by id asc");
         row.last();
         tal = row.getInt("nr");
         }catch( SQLException t ){}
              db.insert("delete from midlertidigregning where nr = '"+tal+"' limit 1");
         }

    What didn't work? Did something fail, or did the row not get deleted as expected? Did you issue a commit after the delete?

  • Deleting a row from matrix by context menu

    Hi all
    does anyone know how can i cause right click on mouse button. on a certain row within a matrix to show a context menu with the option to delete the row. and when pressing the menu item handling the event of deleting the row from the matrix?
    appreciate the help
    Yoav

    Hi Yoav,
    Simply, 'context menu' have to be handled with 'menu event' object.
    It can be done by 'flushToDataSource' method and some tricks.
    Basically, method delete the row without any clause of addon code.
    But it's only can be done in display side.
    If you're using DBDataSource, you have to flush to the datasource.
    I mean, you have to update datasource with the data displayed in the matrix.
    and then, delete the last row of the datasource.
    FlushToDataSource doesn't affect to the number of rows in the datasource.
    You have to delete a row with a method of DBDatasource.. I can't remember the name.
    If, the matrix uses userdatasource, you don't need to delete a row in datasource.
    Because userdatasource doesn't have a concept of 'row', actually.
    Hope this helpful for you.
    Regards,
    Hyunil Choi

  • Delete last row in a table - why won't it delete?

    I cannot delete the last row in any of my tables. (InDesign CS2). The option is greyed out - is this by design or a bug and how can I delete it?
    Thanks.

    No,
    The table has two header rows and no footers. The row I cannot delete is the third row which must therefore be a body row.

  • Problems deleting last row of table

    I have tried a number of examples to make a button delete the LAST row of a table, but I cannot make it.
    This is the script I am currently using, but it only delets the second row. I'm desperate, I don't know where's the mistake. Please help!
    var sSubformSOM = "xfa.form.Summary.INTrack.INRecordTable.INRecord.Row1";
    var bCalc = true;
    var message = "You have reached the maximum number of items allowed.";
    var oSubform = xfa.resolveNode(sSubformSOM);
    var sParentSOM = oSubform.parent.somExpression;
    var sManagerSOM = sParentSOM + "._" + oSubform.name;
    var oManager = xfa.resolveNode(sManagerSOM);
    var nMinCount = oManager.occur.min;
    var nSubCount = oManager.count;
    if (nSubCount > nMinCount) {
              oManager.removeInstance(1);
              if (bCalc == true) {
                        xfa.form.recalculate(1);
    } else {
              xfa.host.messageBox(message,"Remove Item", 3);

    Hi
    In fact what you want is somehow strange. But this may be used.
    For the first row:
    <b>SELECT * FROM <table_name> UP TO 1 ROWS
    INTO gs_record</b>
    <i>*-- If you want you can use <b>"ORDER"</b> statement here to order *the contents</i><b>.</b>
    For the last row:
    As far as I know, You should select all the records till the last row and then get the last row.
    But, I think without ordering it will be somehow weird. We do not deal how the database layer handles order of the table. It has different policies regarding indexes etc... If you have an ordering condition, I think it will often be more convenient using an internal table to handle data. That is, retrieve your data with SELECT statement into an internal table, sort it and read it.
    *--Serdar

  • DELETE MULTIPLE ROWS FROM MATRIX

    Hi all,
    I´M DESPERATED.
    I am able to delete row by row in my matrix, but ¿Could anyone post a sample to delete multiple rows?
    I´ve been trying several ways but it doesn´t work.
    My code is:
    ========================
      Dim i As Long = oMatrix.GetNextSelectedRow
                    If i > -1 Then
                        If oMatrix.IsRowSelected(i) = True Then
                            oMatrix.DeleteRow(i)
                        End If
    ========================
    Thank you in advanced,
    lorenzo

    Don´t worry, It was a problem with my loop.
    Thanks anyway
    lorenzo

  • Add new row in Matrix in SBO 2004

    Hi All,
    I created a form by using screen painter and loaded data into matrix by using datasource.That is working fine. But when i add new row in that matrix, it copies  all data from the  last row in that matrix. How will i clear the row to add new values in the row?
    Please help me.
    Thanks in advance
    Denis

    Hello Denis,
    OK, I see the problem.
    This is because your datasource are on the last row, so whenever you add a new row to the matrix, the last record in your datasource will be added. My suggestion is to modify datasource instead of matix itself, and then use oMatrix.LoadfromDatasource to load all the data back to matrix.
    Hope this helps,
    Nick

  • How can I delete the last row of a Matrix

    Hi All,
    Does anyone know whether deleting the last row of a matrix controlled by a UDO child table gives problems? I have the strange effect that I cannot delete the very last existing row in the matrix, i.e. after updating the delete the last to-be deleted row comes back into my matrix !!
    I give you a snippet of my code (function getSelectedRow gives the selected row in the matrix):
    ==
    if (evnt.ItemUID.Equals(ViewConstants.Items.DELETEBUTTON))
      if (evnt.EventType == BoEventTypes.et_ITEM_PRESSED)
        if (evnt.BeforeAction)
          form = BusinessOne.Application.Forms.Item(formUID);
          mtx = (Matrix)form.Items.Item(ViewConstants.Items.MATRIX).Specific;
         int numRow = getSelectedRow(mtx);
         if (numRow != -1)
                                            mtx.DeleteRow(numRow);
                                            form.Mode = BoFormMode.fm_UPDATE_MODE;
                                       Item btn = (Item)form.Items.Item(ViewConstants.Items.ADDBUTTON);
                                       btn.Enabled = true;
    ==
    Cheers,
    Marcel Peek
    Alpha One
    Message was edited by: Marcel Peek
    Message was edited by: Marcel Peek

    Yes, there is a problem to delete the last row.
    It is fixed in version 2005.

  • Re:Adding a row in a matrix using Lost_Focus event & deleting a row

    Dear All,
    Iam facing a problem in adding a row in a matrix using last focus event.its like if i keep the cusor in the last coloumn in a matrix n if i press tab it should add a row .the row is getting added the problem here is the cursor is gng to first row but it should come to the second row.
    the second problem is while deleting a row the row is getting deleted but the row count is showing the deleted row no.
    pls suggest a solution for these problems.
    Thanks & Regards
    Anand

    Hi,
    If pVal.BeforeAction = False Then
                Select Case pVal.EventType
                    Case SAPbouiCOM.BoEventTypes.et_KEY_DOWN
                        If pVal.ItemUID = "matlab" And pVal.ColUID = "mtimeout" And pVal.CharPressed = 9 Then
                            oMatrix = oForm.Items.Item("matlab").Specific
                            Dim rc As Integer = oMatrix.VisualRowCount
                            If rc = pVal.Row Then
                                addrow()    'funtion for adding row
                                oMatrix.Columns.Item("labc").Cells.Item(oMatrix.RowCount).Click()
                                'SBO_Application.MessageBox(oMatrix.RowCount)
                            End If
                        End If
    This is the function i hav used
    Private Sub addrow()
            Try
                If (oForm.UniqueID = "updt") Then
                    oForm = SBO_Application.Forms.ActiveForm
                    oForm = SBO_Application.Forms.Item("updt")
                    omatrix = oForm.Items.Item("matlab").Specific
                    omatrix.AddRow(1, omatrix.VisualRowCount)
                    Dim rc As Integer = omatrix.VisualRowCount
                    'SBO_Application.MessageBox(rc)
                    otext1 = omatrix.Columns.Item("mdatein").Cells.Item(rc).Specific
                    otext1.String = "s" 'RecSet.Fields.Item("date1").Value
                    otext1 = omatrix.Columns.Item("mdateout").Cells.Item(rc).Specific
                    otext1.String = "s" 'RecSet.Fields.Item("date1").Value
                    End If
            Catch ex As Exception
                SBO_Application.MessageBox(ex.Message)
            End Try
        End Sub
    this is the code which m using
    Regards,
    Anand

  • How to delete zero rows from a matrix?

    Hi,
    I have a 2D datamatrix and there are some zero rows. My original program should recognize all zero rows and delete them. How to do that?
    I have tried with the Delete From Array function but no success. I also tried with the OpenG array functions but...no.
    I attached a vi which simulates my problem. There is one zero row and I want to delete it and have a matrix without zero rows.
    Kudos for any good help!
    Solved!
    Go to Solution.
    Attachments:
    DeleteZeroRows.vi ‏19 KB

    Christian_M wrote:
    The idea was to give a hint that people try using their brain....
    Stilll, I think your code is fundamentally flawed and will thus lead the student into a deep swamp.
    Have you actually tried it with multiple rows of zeroes?
    Since "delete from array" rearranges the array indices with each deletion, the code will break if there is more than one row to be deleted. For example if a row is already deleted and it needs to also delete the last row, it would try to delete a row that no longer exists. If a later row still exists, it will delete the wrong row.
    Also, since NaN gets coerced to a valid index (2147483647), it's probably not such a good idea. "-1" would be a better choice. (Well, it's an unlikely implossible possibility in LabVIEW 32 bit, but still....)
    I also don't understand your logic with "search array". You need to test all elements for zero.
    LabVIEW Champion . Do more with less code and in less time .

  • How to delete duplicate rows in oracle and retaining last duplicate rows

    Hi,
    I'm having millions of records in the table .Some duplicate values/rows are inserted in it.
    I just want to delete duplicate rows but also want to retain the last duplicate row.
    For eg if one record is found three times ,i want to delete first and second record and retain
    the third one i.e the last inserted one.
    Regards
    Paramdeep Singh

    user13310594 wrote:
    Hi,
    I'm having millions of records in the table .Some duplicate values/rows are inserted in it.
    I just want to delete duplicate rows but also want to retain the last duplicate row.
    For eg if one record is found three times ,i want to delete first and second record and retain
    the third one i.e the last inserted one.Hi Paramdeep,
    To start with, since you do not wish to keep multiple rows with same values, why allow them to get inserted in the first place?
    Wouldn't it be easier to block duplicate rows from inserting by creating a Unique constraint on Column(s) that define a row as duplicate, then rather deleting duplicate rows periodically?
    For deleting duplicate rows, there are N number of techniques available. Always remember, you need to have a rigid criteria that marks row as duplicate.
    [url http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:15258974323143]this is one recomended by tom for large tables.
    Vivek L

  • 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

  • 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

  • Deleting rows in a table T1, when last row in table T2 is deleted

    I have two tables, T1 and T2. The relation of T1 to T2 is one to many.
    If the last row of T2 is deleted, the correspondig record in T1 should also be deleted.
    How can I implement this in the delete-trigger of T2.
    Thanks
    null

    I have two tables, T1 and T2. The relation of T1 to T2 is one to many.
    If the last row of T2 is deleted, the correspondig record in T1 should also be deleted.
    How can I implement this in the delete-trigger of T2.
    Thanks
    null

  • Deleting last, next 'create' creates non-empty row

    I have been struggling with this for some hours now.
    I have a table component binded to a VO, based on a EO.
    I have two buttons added to the page. A "CreateInsert" button and a "Delete" button. The delete-button has immediate = true, bc some of the values are required.
    The inputfield on each row are editable and have autosubmit = true
    If I:
    1. Create a row
    2. Edit the row's attributes
    3. Delete the row
    4. Create a row
    then the row that I deleted in step 3 shows up in step 4.
    I have also tried to commiting the data (between 2 and 3, and between 3 and 4).
    This only happens if the deleted row is the last row left in the set (iter.getEstimatedRowCount() = 1 before the delete action)
    BUT! If I set immediate = false on the delete-button, the create / delete works as expected.
    I'm running JDeveloper 11.1.1.5
    The iterator has the ChangeEventPolicy attribute set to 'ppr'
    The delete action has the RequiresUpdateModel set to 'false' - Action is set to 'removeCurrentRow'
    The create action has the RequiresUpdateModel set to 'true' - Action is set to 'createInsert'

    it never happens as you said in jdev11.1.1.5.0.
    by default, both of the buttons having immdieate is should be false. so no need to disturb that.
    if you are going to disturb the oracle standard means what it would be reason?
    hen the row that I deleted in step 3 shows up in step 4.from here i understood what i understood means you get deleted row when you click create insert button if am getting you right?
    this will be my answer:
    you make that createinsert immidieate is true. if so means you could get this behavoiur as you said.

Maybe you are looking for

  • How can I return to where I left off on a menu?

    I have a menu with 6 items in it. When you select each item you are taken to that page and then you click on the return to menu button and are taken to the number 1 item on the list each time you return to the list. I want to come back to where I lef

  • GR quantity for movement type 101 not updated in PCA

    Hi, Does anyone have an idea why quantity is not updated in GLPCA-MSL for 101 movement type?. It has updated in FI (BSEG-MENGE) but not in PCA (GLPCA-MSL). Appreciate prompt response. Thanks, Rashmi

  • FBL5N with WBS element

    Hi All I would like to display line with WBS element number in FBL5N but wbs is not populating. Eventhough the selection wbs option is available in layout but not populating since WBS asscociated with revenue account not customer. WBS element is assi

  • Look for smartform

    hi i have standard layout invet_vkbw  - PHYSICAL INVENTORY ( LEIM) i look for sdandard smartform that will do the same layout thanks have a nice day

  • How to save Image from Oracle form!!?

    Hello Every Oracle forms developer i have a from contains block with Blob column ...i store image in it i have used read_image_file to view image in form and insert it into DB 11gR2 now ..* I want to create procedure in form_button to download image