Updating a row in a matrix

Hi All,
I am facing a problem while updating a new in row in a matrix. The problem is i have a row in matrix which contains some data. i want to add another row in the same matrix and i want to update it but when click the add row button the row is getting added but it is displaying the same data that is its displaying the same data in the previous row but the newly added row should be empty. pls suggest some solution.
Regards,
Vijay Kumar.

Hi Edy,
Thanks for the reply. Still its not working this is the code m using,
If pVal.MenuUID = "1288" Or pVal.MenuUID = "1289" Or pVal.MenuUID = "1290" Or pVal.MenuUID = "1291" Then
                Try
                    oForm = SBO_Application.Forms.ActiveForm
                    If oForm.Type = "320" Then
                        oEdit = oForm.Items.Item("74").Specific
                        oForm.DataSources.DataTables.Item("SALES").ExecuteQuery("SELECT T0.[U_code], T0.[U_desc], T0.[U_purchase] FROM [dbo].[@SALES]  T0 WHERE T0.[U_salescode] ='" & oEdit.Value & "'")
                        omatrix = oForm.Items.Item("productmat").Specific
                        omatrix.Columns.Item("item").DataBind.Bind("SALES", "U_code")
                        omatrix.Columns.Item("itemdes").DataBind.Bind("SALES", "U_desc")
                        omatrix.Columns.Item("check").DataBind.Bind("SALES", "U_purchase")
                        omatrix.Clear()
                        omatrix.LoadFromDataSource()
                        omatrix.AutoResizeColumns()
                    End If
                Catch ex As Exception
                    SBO_Application.MessageBox(ex.Message)
                End Try
Two rows are getting added with the same data.

Similar Messages

  • 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.

  • How can i add a new row in System Matrix passing itemcode and quantaty

    Hi All,
    I have to add new lines in the matrix system only through the itemcode and item quantity. I tried several ways without success. Maybe the following code help to explain what I'm trying to do.
    Someone already inserted rows in the matrix system? Can someone show me how I can do. This example is in C# but if someone has in VB I will apreciate.
    FormUID = SBO_Application.Forms.ActiveForm.UniqueID;
                f = SBO_Application.Forms.Item(FormUID);
                try
                    SAPbobsCOM.Recordset oRS;
                    oRS = ((SAPbobsCOM.Recordset)oCompany.GetBusinessObje
    SAPbobsCOM.BoObjectTypes.BoRecordset));
                    oItem = f.Items.Item("38");
                    oMatrix = ((SAPbouiCOM.Matrix)(oItem.Specific));
                    oEditText = ((SAPbouiCOM.EditText)oMatrix.Columns.Item(3).Cells.Item(oMatrix.RowCount - 1).Specific);
                    string Codigo = oEditText.Value; //Select the item number to use in strQuery
                    strQuery = "SELECT U_ART_COM FROM [@SB1EVOL_COMPOSTOS] where
    U_ART_PRI='" + Codigo.ToString();
                     oRS.DoQuery(strQuery);
                    if (oRS.RecordCount > 0)
                        oRS.MoveFirst();
                        numart = oRS.RecordCount;
                        f.Freeze(true);
                        for (j = 1; j <= numart; j++)
                            try
                                ItemCodeTXT = oRS.Fields.Item(0).Value.ToString();
                                oEditText = ((SAPbouiCOM.EditText)(oMatrix.Columns.Item(3).Cells.Item(oMatrix.RowCount).Specific));
                                oEditText.Value = ItemCodeTXT.ToString();
                                f.Update();
                                oRS.MoveNext();
                            catch (Exception oEx)
                                f.Freeze(false);
                                f.Update();
                                MessageBox.Show(oEx.Message + " j = " + System.Convert.ToString(j));
                        j = 0;
                        f.Freeze(false);
                        f.Update();
    In this example i try to add rows in Invoice matrix.
    Thanks in advance.
    Edited by: Luís Filipe Duarte on Jun 26, 2009 4:14 PM
    Edited by: Luís Filipe Duarte on Jun 26, 2009 4:17 PM

    Viva Vitor,
    Antes de mais obrigado pela resposta.
    È esse mesmo o meu objectivo. Passo a explicar qual é o objectivo deste desenvolvimento. O que se pretende é que quando um utilizador escreva o código de um artigo numa linha da matrix de um documento de venda o add-on vai ler esse artigo e de seguida consultar uma tabela de utilizador que ja esta criada para validar se esse artigo tem outros artigos associados, e se tiver, entao o addon tem que os escrever nas linhas imediatamente a seguir. Eu queria mesmo, era escrever qual era o artigo e qual a respectiva quantidade. Eu consigo encontrar qual o artigo que o utlizador escreve e qual os artigos associados. O meu problema acontece quando tendo adicionar as novas linhas.
    Com o codigo que se segue podes ver que estou a atribuir a uma EditText o codigo do artigo a escrever. O problema é se correr em modo debug consigo ver que a aplicação chega a essa linha 
    oEditText.Value = ItemCodeTXT.ToString();
    e volta para trás, ou seja entra num loop e nao sai daqui.
    if (oRS.RecordCount > 0)
                        oRS.MoveFirst();
                        numart = oRS.RecordCount;
                        f.Freeze(true);
                        for (j = 1; j <= numart; j++)
                            try
                                ItemCodeTXT = oRS.Fields.Item(0).Value.ToString();
                                oEditText = ((SAPbouiCOM.EditText)(oMatrix.Columns.Item(3).Cells.Item(oMatrix.RowCount).Specific));
                                oEditText.Value = ItemCodeTXT.ToString();
                                f.Update();
                                oRS.MoveNext();
                            catch (Exception oEx)
                                f.Freeze(false);
                                f.Update();
                                MessageBox.Show(oEx.Message + " j = " + System.Convert.ToString(j));
    Eu para adicionar uma nova linha o que tenho de fazer? não vasta passar a informação do item code?
    Este desenvolvimento é para implementar ecoreee no sap. Nao sei já tiveste alguma coisa dessas entre mãos.
    Obrigado mais uma vez pela atenção. Espero também um dia poder ajudar.
    Com os melhores cumprimentos.
    Luis duarte

  • Update multiple rows in a dynamic table Dreamweaver CS5.5

    hello there
    i want to update multiple rows which comes from a dynamic table in Dreamweaver CS5 (a loop in php) here is my Mysql table :
    sql code
    CREATE TABLE `register`.`s_lessons` (
    `lid` int( 5 ) NOT NULL ,
    `sid` int( 9 ) NOT NULL ,
    `term` int( 5 ) NOT NULL ,
    `tid` int( 5 ) NOT NULL ,
    `point` double NOT NULL DEFAULT '0',
    PRIMARY KEY ( `lid` , `sid` , `term` ) ,
    KEY `tid` ( `tid` ) ,
    KEY `point` ( `point` )
    ) ENGINE = MYISAM DEFAULT CHARSET = utf8 COLLATE = utf8_persian_ci;
    and this is my page source code:
    php file
    <?php require_once('../Connections/register.php'); ?>
    <?php
    session_start();
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $colname1_rs1 = "-1";
    if (isset($_GET['term'])) {
      $colname1_rs1 = $_GET['term'];
    $colname_rs1 = "-1";
    if (isset($_GET['lid'])) {
      $colname_rs1 = $_GET['lid'];
    $colname2_rs1 = "-1";
    if (isset($_SESSION['tid'])) {
      $colname2_rs1 = $_SESSION['tid'];
    mysql_select_db($database_register, $register);
    $query_rs1 = sprintf("SELECT s_lessons.sid, s_lessons.lid, s_lessons.term, s_lessons.tid, s_lessons.point FROM s_lessons WHERE s_lessons.lid = %s AND s_lessons.term = %s AND s_lessons.tid  = %s", GetSQLValueString($colname_rs1, "int"),GetSQLValueString($colname1_rs1, "int"),GetSQLValueString($colname2_rs1, "int"));
    $rs1 = mysql_query($query_rs1, $register) or die(mysql_error());
    $row_rs1 = mysql_fetch_assoc($rs1);
    $totalRows_rs1 = mysql_num_rows($rs1);
    $count=mysql_num_rows($rs1);
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    for ($j = 0, $len = count($_POST['lid']); $j < $len; $j++) {
    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
      $updateSQL = sprintf("UPDATE s_lessons SET point=%s WHERE tid=%s, lid=%s, sid=%s, term=%s",
                           GetSQLValueString($_POST['point'] [$j], "double"),
                                GetSQLValueString($_SESSION['tid'], "int"),
                           GetSQLValueString($_POST['lid'] [$j], "int"),
                                GetSQLValueString($_POST['sid'] [$j], "int"),
                                GetSQLValueString($_POST['term'] [$j], "int"));
      mysql_select_db($database_register, $register);
      $Result1 = mysql_query($updateSQL, $register) or die(mysql_error());
      $updateGoTo = "student_lists.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $updateGoTo));
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>r</title>
    <link href="styles/style.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="styles/in_styles.css" rel="stylesheet" type="text/css" media="screen" />
    </head>
    <body>
    <div id="wrapper">
         <div id="header-wrapper">
         </div>
         <!-- end #header -->
         <div id="page">
              <div id="page-bgtop">
                   <div id="page-bgbtm">
                        <div id="content">
                             <div class="post">
                               <div style="clear: both;">
                            <form name="form1" id="form1" method="post" action="<?php echo $editFormAction; ?>">
                            <table border="1" align="center">
                              <tr>
                                <th>Student ID</th>
                                <th>Lesson ID</th>
                                <th>Semester</th>
                                <th>Point</th>
                              </tr>
                              <?php do { ?>
                                <tr>
                                  <td class="data"><label for="sid[]"></label>
                                  <input name="sid[]" type="text" id="sid[]" value="<?php echo $row_rs1['sid']; ?>" size="9" readonly="readonly" /></td>
                                  <td class="data"><label for="lid[]"></label>
                                  <input name="lid[]" type="text" id="lid[]" value="<?php echo $row_rs1['lid']; ?>" size="5" readonly="readonly" /></td>
                                  <td class="data"><label for="term[]"></label>
                                  <input name="term[]" type="text" id="term[]" value="<?php echo $row_rs1['term']; ?>" size="4" readonly="readonly" /></td>
                                  <td><label for="point[]"></label>
                                    <input name="point[]" type="text" id="point[]" value="<?php echo $row_rs1['point']; ?>" size="4" />                             
                              </tr>
                                <?php } while ($row_rs1 = mysql_fetch_assoc($rs1)); ?>
                            </table>
                            <p>
                              <input type="submit" name="Submit" id="Submit" value="Submit" />
                              <input type="hidden" name="MM_update" value="form1" />
                            </p>
                            </form>
                               </div>
                             </div>
                        <div style="clear: both;">
                    </div>
                        </div>
                        <!-- end #content -->
                        <!-- end #sidebar -->
                        <div style="clear: both;"> </div>
                   </div>
              </div>
         </div>
         <!-- end #page -->
    </div>
    <!-- end #footer -->
    </body>
    </html>
    <?php
    mysql_free_result($rs1);
    ?>
    All i want is that when users click on SUBMIT button values of point column in s_lessons(database table) be updated by new entries from user.
    i did my best and result with that code is :
    You  have an error in your SQL syntax; check the manual that corresponds to  your MySQL server version for the right syntax to use near ' lid=888,  sid=860935422, term=902' at line 1
    I would appreciate any idea.
    with prior thanks

    Go to the Row Properties, and in the Visibility tab, you have "Show or hide based on an expression". You can use this to write an expression that resolves to true if the row should be hidden, false otherwise.
    Additionally, in the Matrix properties you should take a look at the filters section, perhaps you can achieve what you wish to achieve through there by removing the unnecessary rows instead of just hiding them.
    It's only so much I can help you with the limited information. If you require further help, please provide us with more information such as what data are you displaying, what's the criteria to hiding rows, etc...
    Regards
    Andrew Borg Cardona

  • UDO: Add and Remove rows to/from Matrix.

    Hi all,
    Yes, I know there are lots of topics about adding and removing rows but I was having trouble with these and I need some expert's opinion.
    I'm working with a Document type UDO, with 1 header table (ADAT_ONR) and 1 child table (ADAT_NR1 -  MatrixUID = "mtx_NR").
    I add the first row when the user chooses the business partner.
    If oMatrix.RowCount = 0 Then
         oMatrix.AddRow()
          oMatrix.AutoResizeColumns()
         oMatrix.Columns.Item("V_LineId").Cells.Item(1).Specific.Value = 1
    End If
    Then, the user has to press the AddRow button to add new rows, and the user can only add 1 new blank row. Later I'll change the row adding behavior to mimic B1s.
                If pVal.BeforeAction = False Then
                    Select Case pVal.ItemUID
                        Case "AddRow"
                            'ItemHandler_Click = AddRow(oCompany, oApplication, oForm, oForm.Items.Item("mtx_NR").Specific.RowCount())
                            oMatrix = oForm.Items.Item("mtx_NR").Specific
                            If oMatrix.RowCount > 0 Then
                                If Trim(oMatrix.Columns.Item("V_PltCode").Cells.Item(oMatrix.RowCount).Specific.Value) = "" Then
                                    oApplication.StatusBar.SetText(TranslateStr(oApplication, MustChoosePallet), BoMessageTime.bmt_Short)
                                    Exit Function
                                End If
                            End If
                            ItemHandler_Click = NewLine(oCompany, oApplication, oForm)
                            Exit Function
        Private Function NewLine(ByRef oCompany As SAPbobsCOM.Company, ByRef oApplication As SAPbouiCOM.Application, _
            ByRef oForm As SAPbouiCOM.Form) As Boolean
            NewLine = False
            Try
                oMatrix = oForm.Items.Item("mtx_NR").Specific
                Dim Index As Integer = oMatrix.RowCount
                With oForm.DataSources.DBDataSources.Item("@ADAT_NR1")
                    .Clear()
                End With
                oMatrix.AddRow()
                oMatrix.Columns.Item("V_LineId").Cells.Item(Index + 1).Specific.Value = (Index + 1).ToString
                oMatrix.FlushToDataSource()
                oMatrix.LoadFromDataSource()
                oForm.Refresh()
                NewLine = True
            Catch ex As Exception
                oApplication.MessageBox("NewLine(): " & oCompany.GetLastErrorCode.ToString & ", " & ex.Message)
            End Try
        End Function
    When I Add or Update the data, I clear the last blank row, if it exists.
               '// In the Click Event
               If pVal.BeforeAction = True Then
                    Select Case pVal.ItemUID
                        Case "1"
                            If oForm.Mode <> BoFormMode.fm_FIND_MODE Then
                                oMatrix = oForm.Items.Item("mtx_NR").Specific
                                oMatrix.FlushToDataSource()
                                oMatrix.LoadFromDataSource()
                                If Trim(oMatrix.Columns.Item("V_PltCode").Cells.Item(oMatrix.RowCount).Specific.Value) = "" Then
                                    oForm.DataSources.DBDataSources.Item("@ADAT_NR1").RemoveRecord(oMatrix.RowCount - 1)
                                    oMatrix.DeleteRow(oMatrix.RowCount)
                                    'oMatrix.FlushToDataSource()
                                End If
                            End If
                    End Select
    My question is, Is there an easier way to Add and Delete Rows??
    BTW, I still have a problem so solve. With this code, when the user deletes a row the row numbering is incorrect. Example: if I have to rows in a matrix and I delete row nº1, row nº2 will hold the same number...
    Any Ideas?
    Thanks in advanced,
    Vítor Vieira

    Hi Victor,
    there is a Form Data event which you ca use in that try to write the code for adding a row after updating and delete a row while inserting and add a row while traversing.
    sample code.
    Sub FormDataEvent(ByRef BusinessObjectInfo As SAPbouiCOM.BusinessObjectInfo, ByRef BubbleEvent As Boolean)
            Try
                Select Case BusinessObjectInfo.EventType
                    Case SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD, SAPbouiCOM.BoEventTypes.et_FORM_DATA_UPDATE
                        If BusinessObjectInfo.BeforeAction = True Then
                            objForm = objMain.objApplication.Forms.Item(BusinessObjectInfo.FormUID)
                            oDBs_Head = objForm.DataSources.DBDataSources.Item("@Header")
                            oDBs_Detail= objForm.DataSources.DBDataSources.Item("@Line")
                            objMatrix = objForm.Items.Item("83").Specific
                            If objMatrix.VisualRowCount <> 0 Then
                                objMatrix.DeleteRow(objMatrix.VisualRowCount)
                                objMatrix.FlushToDataSource()
                            End If
                            If BusinessObjectInfo.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD Then
                                End If
                        ElseIf BusinessObjectInfo.ActionSuccess = True Then
                            objForm = objMain.objApplication.Forms.Item(BusinessObjectInfo.FormUID)
                            If BusinessObjectInfo.EventType =                    SAPbouiCOM.BoEventTypes.et_FORM_DATA_UPDATE Then
                                objMatrix = objForm.Items.Item("83").Specific
                                objMatrix.AddRow()
                                SetNewLineCharge(objForm.UniqueID, objMatrix.VisualRowCount)
                                objMatrix.FlushToDataSource()
                              End If
                        End If
                    Case SAPbouiCOM.BoEventTypes.et_FORM_DATA_LOAD
                        If BusinessObjectInfo.ActionSuccess = True Then
                            oDBs_Head = objForm.DataSources.DBDataSources.Item("@Header")
                           oDBs_Detail = objForm.DataSources.DBDataSources.Item("@Line")
                            objMatrix = objForm.Items.Item("83").Specific
                            objMatrix.AddRow()
                            SetNewLineCharge(objForm.UniqueID, objMatrix.VisualRowCount)
                            objMatrix.FlushToDataSource()
                           End If
                End Select
                End Sub
    Hope this helps,
    OM Prakash

  • Ordering and Reordering rows in a Matrix

    Hi,
    I am using a DBDataSource (User Defined) to populate a Matrix.
    I use Conditions to filter this matrix.
    I have a field called Seq in the Matrix and want to be able to order the matrix by Seq.
    Can this be done without using a SQL Query in the datasource.
    Also I have up and down buttons next to the Matrix - is there a way to move rows up and down (or reorder the rows) in the matrix without changing a code and requerying the Datasource ?
    Thanks
    Nick
    Pages: 1

    Hi Dragos,
    Hope this can help.
    In my form I have 2 matrix's that need reordering, and I have 2 buttons next to each up1/dn1 and up2/dn2
    Here is the event code :
    Private Sub FLBOM_ItemPress(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByVal oform As SAPbouiCOM.Form)
            Dim s As Integer = 0
            'Dim oform2 As SAPbouiCOM.Form
            'oform2 = SBO_Application.Forms.Item("FLBOM")
            Try
                If pVal.Before_Action = True Then
                    Select Case pVal.ItemUID
                        Case "up1"
                            FLBOM_MoveRow(pVal, oform, "matBOM", Direction.Up)
                        Case "dn1"
                            FLBOM_MoveRow(pVal, oform, "matBOM", Direction.Down)
                        Case "up2"
                            FLBOM_MoveRow(pVal, oform, "matSubBOM", Direction.Up)
                        Case "dn2"
                            FLBOM_MoveRow(pVal, oform, "matSubBOM", Direction.Down)
              End Select
                End If
            Catch ex As Exception
                MessageBox.Show("s=" & s.ToString & ":" & ex.Message)
            End Try
        End Sub
    I also pin this to the itempress event on the matrix itself - if the user selects the top row of the matrix
    it disables the up button, bottom of the matrix disables down button
          If pVal.FormMode = 1 Then
                                    Dim m As SAPbouiCOM.Matrix = oform.Items.Item("matBOM").Specific
                                    Dim r As Integer = pVal.Row
                                    Dim rc As Integer = m.RowCount
                                    Select Case r
                                        Case 1
                                            FLBOM_ItemEnable(oform, "up1", True)
                                            FLBOM_ItemEnable(oform, "dn1", False)
                                            FLBOM_ItemEnable(oform, "btnBOMDel", False)
                                        Case rc
                                            FLBOM_ItemEnable(oform, "up1", False)
                                            FLBOM_ItemEnable(oform, "dn1", True)
                                            FLBOM_ItemEnable(oform, "btnBOMDel", False)
                                        Case Else
                                            FLBOM_ItemEnable(oform, "up1", False)
                                            FLBOM_ItemEnable(oform, "dn1", False)
                                            FLBOM_ItemEnable(oform, "btnBOMDel", False)
                                    End Select
    ItemEnable looks like this
    Private Sub FLBOM_ItemEnable(ByVal oform As SAPbouiCOM.Form, ByVal Itm As String, ByVal Off As Boolean)
            Dim e As SAPbouiCOM.Item
            e = oform.Items.Item(Itm)
            If Off Then
                e.Enabled = False
            Else
                e.Enabled = True
            End If
        End Sub
    Then I have code to handle the moving of the rows - it is fairly generic - you feed it the form, matrix name and the direction and the code does the rest.
    You need to change the SQL to update the right UDT
    The matrix name(s) - remember I have 2 on the same form that I reorder so this code could easily be simplified.
    Private Sub FLBOM_MoveRow(ByVal pval As SAPbouiCOM.ItemEvent, ByVal oform As SAPbouiCOM.Form, ByVal Mat As String, ByVal dir As Direction)
            If pval.FormMode = 1 Then
                Dim oMatrix As SAPbouiCOM.Matrix = oform.Items.Item(Mat).Specific
                Dim irow As Integer
                Try
                    irow = oMatrix.GetNextSelectedRow(0, SAPbouiCOM.BoOrderType.ot_SelectionOrder)
                    If irow = 1 And dir = Direction.Up Then
                        SBO_Application.StatusBar.SetText("Cannot Go Up ", SAPbouiCOM.BoMessageTime.bmt_Medium, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
                        Exit Sub
                    End If
                Catch
                    SBO_Application.StatusBar.SetText("Must Select a Line in First", SAPbouiCOM.BoMessageTime.bmt_Medium, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
                    Exit Sub
                End Try
                If irow < 0 Then
                    SBO_Application.StatusBar.SetText("Must Select a Line First", SAPbouiCOM.BoMessageTime.bmt_Medium, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
                    Exit Sub
                End If
                ' CODE HERE
                Dim oTbl As SAPbouiCOM.DataTable
                Dim sSql As String
                Dim Seq1 As Integer
                Dim Seq2 As Integer
                Dim code1 As String
                Dim code2 As String
                Dim oe As SAPbouiCOM.EditText
                oe = oMatrix.Columns.Item("colSeq").Cells.Item(irow).Specific
                Seq1 = oe.Value
                oe = oMatrix.Columns.Item("#").Cells.Item(irow).Specific
                code1 = oe.Value
                Select Case dir
                    Case Direction.Up
                        code2 = oMatrix.Columns.Item("#").Cells.Item(irow - 1).Specific.value
                        Seq2 = oMatrix.Columns.Item("colSeq").Cells.Item(irow - 1).Specific.value
                    Case Direction.Down
                        code2 = oMatrix.Columns.Item("#").Cells.Item(irow + 1).Specific.value
                        Seq2 = oMatrix.Columns.Item("colSeq").Cells.Item(irow + 1).Specific.value
                End Select
                oTbl = oform.DataSources.DataTables.Item("TEMPTable1")
                sSql = "UPDATE [@LYNXS_SP] SET U_Seq=" & Seq2 & " WHERE Code = '" & code1 & "'"
                oTbl.ExecuteQuery(sSql)
                sSql = "UPDATE [@LYNXS_SP] SET U_Seq=" & Seq1 & " WHERE Code = '" & code2 & "'"
                oTbl.ExecuteQuery(sSql)
                If Mat = "matBOM" Then
                    FLBOM_After_CFLBP(oform)
                Else
                    Dim om1 As SAPbouiCOM.Matrix = oform.Items.Item("matBOM").Specific
                    Dim e As SAPbouiCOM.EditText = om1.Columns.Item("#").Cells.Item(irow).Specific
                    LoadSubBom(e.Value, oform)
                End If
                Select Case dir
                    Case Direction.Up
                        irow = irow - 1
                    Case Direction.Down
                        irow = irow + 1
                End Select
                oMatrix.SelectRow(irow, True, False)
                Dim rc As Integer = oMatrix.RowCount
                Select Case irow
                    Case 1
                        FLBOM_ItemEnable(oform, "up1", True)
                        FLBOM_ItemEnable(oform, "dn1", False)
                    Case rc
                        FLBOM_ItemEnable(oform, "up1", False)
                        FLBOM_ItemEnable(oform, "dn1", True)
                    Case Else
                        FLBOM_ItemEnable(oform, "up1", False)
                        FLBOM_ItemEnable(oform, "dn1", False)
                End Select
                Try
                    If Mat = "matBOM" Then
                        Dim e As SAPbouiCOM.EditText = oMatrix.Columns.Item("#").Cells.Item(irow).Specific
                        LoadSubBom(e.Value, oform)
                    End If
                Catch ex As Exception
                    MsgBox(ex.Message)
                End Try
            Else
                SBO_Application.StatusBar.SetText("Must Update Form First", SAPbouiCOM.BoMessageTime.bmt_Medium, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
            End If
        End Sub
    So Finally - here are the 2 routines that load the matrix - notice I use the same routines to initially load the matrix as I do after the above updates when the row is moved.
    Private Sub FLBOM_After_CFLBP(ByVal oform As SAPbouiCOM.Form)
            Dim oMatrix As SAPbouiCOM.Matrix
            Dim oMatrix2 As SAPbouiCOM.Matrix
            oMatrix = oform.Items.Item("matBOM").Specific
            Dim oe As SAPbouiCOM.EditText = oform.Items.Item("3").Specific
            Dim oc As SAPbouiCOM.ComboBox = oform.Items.Item("cbArea").Specific
            Dim SQLSTR As String = "SELECT * FROM [@LYNXS_SP] WHERE U_PARENTCODE IS NULL AND U_CARDCODE = '" & oe.Value & "' AND U_AREAID = '" & oc.Selected.Value & "'  ORDER BY U_AREAID, U_SEQ"
            oform.DataSources.DataTables.Item("TEMP").ExecuteQuery(SQLSTR)
            oMatrix.LoadFromDataSource()
            oMatrix2 = oform.Items.Item("matSubBOM").Specific
            oMatrix2.Clear()
        End Sub
    and
    Private Sub LoadSubBom(ByVal ParentID As Integer, ByVal oform As SAPbouiCOM.Form)
            Dim m As SAPbouiCOM.Matrix = oform.Items.Item("matSubBOM").Specific
            m.Clear()
            Dim SQLSTR As String = "SELECT * FROM [@LYNXS_SP] WHERE U_PARENTCODE = '" & ParentID & "' ORDER BY U_SEQ"
            oform.DataSources.DataTables.Item("TEMP").ExecuteQuery(SQLSTR)
            m.LoadFromDataSource()
        End Sub
    one last bit of code that is missing from the above
        Public Enum Direction
            Up
            Down
        End Enum
    Let me know how this goes for you.
    Regards,
    Nick

  • Update 100 Row Data In One Time against a Code

    Dear Expert,
    How can I update a Master Data Row Table record using a particular code. Like I write a query Update Table Set U_UDF = 'Value' Where Code = 2
    U_UDF is the field of Master Data Row Table's field. There are 100 Row against code 2 & I want to update all row with same value but in one time only.
    How can I do that ?
    Plz help me.
    Regards

    Hi,
    Try this:
    SAPbobsCOM.GeneralService oGeneralService = null;
                                                    SAPbobsCOM.GeneralData oGeneralData = null;
                                                    SAPbobsCOM.GeneralDataParams oGeneralParams = null;
                                                    SAPbobsCOM.CompanyService sCmp = null;
                                                    SAPbobsCOM.GeneralData oChild = null;
                                                    SAPbobsCOM.GeneralDataCollection oChildren = null;
                                                    sCmp = SBO_Company.GetCompanyService();
                                                    oGeneralService = sCmp.GetGeneralService("UDO");
                                                    // Get UDO record 
                                                    oGeneralParams = ((SAPbobsCOM.GeneralDataParams)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams)));
                                                    oGeneralParams.SetProperty("Code", ContractCode);
                                                    oGeneralData = oGeneralService.GetByParams(oGeneralParams);
                                                   // Add lines on UDO Child Table 
                                                    oChildren = oGeneralData.Child("CONTRACTDETAIL");
                                                    // Update an existing line 
                                                    oChild = oChildren.Item(LineId - 1);
                                                    DateTime dt = DateTime.Now;
                                                    oChild.SetProperty("U_STATS", "Terminated");
                                                    oChild.SetProperty("U_Updated", dt);
                                                    oChild.SetProperty("U_Remarks", "Service Terminated");
    //Update the UDO Record
                                                    oGeneralService.Update(oGeneralData);
    I have given you the sample. Just change it accordingly.
    Hope it helps.
    Thanks & Regards
    Ankit Chauhan

  • Updating single row by multiple users at the same time

    Hi,
    I have been asked to develop an application where a single row from a table will be accessed by multiple users. Even multiple users can try to update the same row at the same time. So, to provide a solution of this problem should it be the best way to lock that particular row when user requesting to update it and after completion of commit the lock will be released. In the same time if some other user request to update the same row then it will be in the wait condition.
    Please provide suggestion that is it the best way to handle the situation or not. If it is then can you also please provide an example (with sample code) of it.
    Regards,
    Koushik

    It depends entirely on how the system was built.
    You could relatively easily build an application that does something like
    - Select a row with as last_updated_date column
    - Update the row specifying the last_updated_date you had selected in your WHERE clause
    - If the update updates 1 row, it was successful, otherwise inform the user that the row was already updated.
    In this case, the second user would get an error indicating that the seat had already been purchased.
    You could also relatively easily do a SELECT FOR UPDATE to prevent users from ever getting an error between the time they select a seat and the time they finish their transaction. Of course, if the user wanders away from the computer, or inadvertently ends up locking dozens of rows, this tends to rather problematic in practice. You may find that when the train pulls out of the station, someone that never ended up buying a ticket has locked a dozen rows so you lost a dozen sales. If you have a call center where operators are reserving seats for people on the phone, you may decide that explicit locking is more appropriate because you're confident that the operators aren't going to leave tickets locked for long periods of time and the cost of having the customer walked through the seat selection process multiple times would be higher than the cost of having rows locked longer than they need to be.
    Justin

  • How to update multiple rows in one query using php

    i am new to this can any one help me how to update multiple rows at a time i am doing an school attendance page

    Often the situation is such that you have multiple courses across a range of dates.So students may take more than one course, and you need to track attendance for each course date. The following graphic demonstrates this:
    In such a situation, you need four database tables as follows:
    students (student_id, student_name, etc.)
    courses (course_id, course_name, etc.)
    students_courses (student_id, course_id)
    attendance (student_id, course_id, dater)
    A fifth table may also be needed to define the dates of courses, but you may also be able to build this array programmatically by using PHP's robust date functions, which can give you, for instance, all the Tuesdays and Thursdays between a start date and end date.
    The students_courses table simply keeps track of which students are taking which courses, so it has just two columns for the primary keys of both of the main tables. The attendance table is similar, but it also includes a date field. The following view of the attendance table demonstrates this:
    So if David's solution does cover your needs, consider yourself lucky, because this could quickly grow from a beginner-appropriate project to a moderately advanced one.

  • Update one row at a time, Data Grid

    Is it possible to update one row of a mx:DataGrid at a time.  I want to be able to have a user push a button and info populates one row of the data grid, user changes some properties and pushes the button again and another row of values populate the DataGrid.  Everything I see does a mass population from an XML or what have you.
    Thanks

    I did this this to work, so for those of you who may find this info helpfull here is how I solved the issue.
    I instantiated an ArrayCollection object like so:
    private var _rowValues:ArrayCollection = new ArrayCollection();
    I simply referenced the .addItem() property of my ArrayCollection.
    I then added values to the ArrayCollection as follows
    _rowValues.addItem({Ingredient:ingredient, Amount:amount, Category:category}); //dataField:value
    and referenced the dataField proerpty of the DataGrid... so in my case my 3 dataField properties (in my mxml compontent) were as fillows:
    dataField="Ingredient"
    dataField="Amount"
    dataField="Category"
    all done, and it works.

  • How to disable a Entire row in a Matrix in Find Mode (User Form)

    Hi,
    How to disable a Entire row in a Matrix in Find Mode (User Form)
    Regards
    Jambu

    Hi,
       Iam using Bubble event = false in click event but the matrix row
    is allow to edit but we cant save the document in Find Mode That is fine.
    What is my actual requirement is In find mode matrix Row not allow to enter the data .
    For examble In ADD mode i enter the data in Three rows (Item Section - Matrix) and
    save the document. Whwn i open the document in find mode the three row is not allow
    to editable like the same functionality of PO, sales Order, etc ..
    Regards
    Jambu

  • Update all rows in a View Column via one Apex Form field

    Appreciate any helpful answers to this query.
    I have an Apex App (4.x) where I have a view: PRICE_MODEL_CRA_V
    In the view, I have the following applicable columns:
    COUNTRY
    GRADE
    SALARY
    In the form I have the following fields
    :P16_COUNTRY (DROPDOWN)
    :P16_GRADE (DROPDOWN)
    :P16_SALARY (Number)
    In my app, I have a form with an Update button. I am simply trying to get Apex to update all rows in the salaray column in the view, where the country and grade match.
    I've the following code for the Update button:
    UPDATE PRICE_MODEL_CRA_V
    SET SALARY = :P16_SALARY
    WHERE COUNTRY = :P16_COUNTRY
    AND GRADE = :P16_GRADE
    The option I have chosen in condition type is:
    Value of Item / Column expression is NOT Null (as there are values in the column)
    Also tried SQL Expression and it does not like..says that there is No Expression.
    Thanks again if anyone can help :)

    Hi,
    Sorry I realize now that piece of information was not well supported.
    If I choose SQL Expression for Condition Type in my Form Page and I try to Apply Changes
    Apex says this..
    •Failed to parse SQL query!
    ORA-00936: missing expression
    I was assuming that I need to have the colon for the items in the form where I am wanting Apex to grab the values entered by the user. I tried them without the colons with the SQL Expression condition and same result.
    UPDATE PRICE_MODEL_CRA_V
    SET SALARY = P16_SALARY
    WHERE COUNTRY = P16_COUNTRY
    AND GRADE = P16_GRADE
    I did put 1-1/0 in my expression field and applied changes and then tried ot submit the form and it does not produce an error, so perhaps it is not being called? Where would I start with troubleshooting that?
    Thanks,

  • How to change the forecolor of a single row of a matrix

    In a matrix which is displaying list of items like the Sales Order Form, I am trying to change the forecolor to red for only those items where the item's required quantity is lesser than the item's avialable quantity.
    The Code Snippet is as follows:
    ReqQty = oMatrix.Columns.Item("ReqQty").Cells.Item(pval.row).Specific.value
    AvaQty = oMatrix.Columns.Item("AvaQty").Cells.Item(pval.row).Specific.value
    If ReqQty > AvaQty Then
    Dim txtField As SAPbouiCOM.EditText
    oMatrix = oform.Items.Item("cMatrix").Specific
    txtField = oMatrix.Columns.Item("ItemNo").Cells.Item (pval.row).Specific
    txtField.ForeColor = 200
    txtField = oMatrix.Columns.Item("ItemDesc").Cells.Item(pval.row).Specific
    txtField.ForeColor = 200
    oMatrix.Columns.Item("ReqQty").Cells.Item(pval.row).Specific
    txtField.ForeColor = 200
    oMatrix.Columns.Item("AvaQty").Cells.Item(pval.row).Specific
    txtField.ForeColor = 200
    End If
    But the problem is , if this condition applies to any one of the items in the matrix, then all the rows in the matrix change the forecolor to red.
    Has anyone faced this problem and has a solution to it?

    I haven't tested the problems you have for a matrix.
    But I have seen the properties are not exposed for the Cell object...
    Regarding the ForeColor and BackColor on the EditText they are deprecated starting from 2004 BUT you have the same properties now exposed at the <b>Item</b> level.
    For the Column object the ForeColor and BackColor are not market as deprecated.
    Regards
    Trinidad.

  • How to Update Particular row in a table from OAF page

    Hi Can anyone please help me on the following requirement:
    In my oaf page i am displaying table values(supplier site details from base tables) with update and delete icons . When i click on update button a new page opens in which we used to update the values and click on apply button which again comes back to the original page.
    So when i click on apply button on update page i have to first search for the site in the site table whether it exists or not, if not exists i have to create a new row and save the data, if site exists in the table i have to update the row of a table for that particular site. I have written code for this but unable to achive the requirement, it is not updating the existing row of the table. And i am doing all this on the Temp tables.
    So now when i save, previous transaction is also updating along with the current transaction. That means when i m trying to save 2nd transaction values , 1st transactions values are getting updated with the 2nd transaction values(2 rows are getting updated)
    Can anyone help me with the code used for updating the current row of the table. Please correct me if i m doing anyting wrong in code.
    following is the current code i m using and which is failing :
    Controller Code
    if(pcontactaction.equals("createECdetailsEvent")) {
    String currentSiteName=pageContext.getParameter("SiteName");
    System.out.println("Selected Site Name is : " + currentSiteName);
    Serializable x[]={reqNum,suppId,currentSiteName,pnotifMethod,pfaxNum};
    System.out.println("Invoking AM Method.........");
    am.invokeMethod("initCreateECDetails",x);
    System.out.println("initCreateECDetails Method Executed. ");
    //am.invokeMethod("save");
    localOAApplicationModule.getTransaction().commit();
    pageContext.setForwardURL(
    "OA.jsp?page=/oracle/apps/floaf/flpos/supregister/webui/ECDetailsPG"
    , null //not needed as we are retaining menu context
    ,OAWebBeanConstants.KEEP_MENU_CONTEXT
    , null //not needed as we are retaining menu context
    ,null // no parameters are needed
    ,true //retain AM
    ,OAWebBeanConstants.ADD_BREAD_CRUMB_NO
    ,OAWebBeanConstants.IGNORE_MESSAGES);
    AM Code
    public void initUpdateECDetails(String request_number,String supplier_id,String site_name,String site_id,String notification_method,String fax_number)
    OADBTransaction localOADBTransaction = getOADBTransaction();
    String siteToUpdate;
    siteToUpdate=site_name;
    String siteidToUpdate;
    siteidToUpdate=site_id;
    System.out.println("Site Name to Update or Create is : " + siteToUpdate);
    System.out.println("Site Id to Update or Create is : " + siteidToUpdate);
    System.out.println("Inside Update EC Details MEthod.");
    OAViewObject suppSiteDetVO = getFLPOSSuppSiteDetailsVO1();
    FLPOSSuppSiteDetailsVORowImpl sro=null;
    String existingWhereClause = suppSiteDetVO.getWhereClause();
    suppSiteDetVO.setWhereClause(null);
    suppSiteDetVO.setWhereClauseParams(null);
    suppSiteDetVO.setWhereClause("SUPPLIER_ID = :1 AND REQUEST_NUMBER = :2 AND SITE_ID = :3 ");
    suppSiteDetVO.setWhereClauseParam(0, supplier_id);
    suppSiteDetVO.setWhereClauseParam(1, request_number);
    suppSiteDetVO.setWhereClauseParam(2, site_id);
    suppSiteDetVO.executeQuery();
    suppSiteDetVO.setWhereClauseParams(null);
    suppSiteDetVO.setWhereClause(existingWhereClause);
    int rowcount = suppSiteDetVO.getRowCount();
    System.out.println("Fetched Rows : " + rowcount);
    if (rowcount == 0) {
    Row row = suppSiteDetVO.createRow();
    System.out.println("Row is : " +row);
    suppSiteDetVO.insertRow(row);
    String siteId = getOADBTransaction().getSequenceValue("FLPOS_SITE_ID_SEQ").toString();
    System.out.println("New Site ID : " + siteId);
    row.setNewRowState(Row.STATUS_INITIALIZED);
    row.setAttribute("RequestNumber", request_number);
    row.setAttribute("SupplierId", supplier_id);
    row.setAttribute("SiteName", site_name);
    row.setAttribute("SiteId", siteId);
    row.setAttribute("FaxNo",fax_number);
    row.setAttribute("NotificationMethod",notification_method);
    System.out.println("New Row Created for Supplier Site.");
    System.out.println("Data Saved to table.");
    else{
    System.out.println("Inside Else Block ");
    try {
    System.out.println("Inside Try Block ");
    Row[] row = suppSiteDetVO.getAllRowsInRange();
    for (int i = 0; i < rowcount; i++) {
    sro = (FLPOSSuppSiteDetailsVORowImpl)row;
    String psiteName=sro.getSiteName();
    Number psiteid=sro.getSiteId();
    System.out.println(" p Site Name is : " +psiteName);
    System.out.println(" p site id is " +psiteid);
    if(psiteid.equals(siteidToUpdate) ) {
    sro.setAttribute("FaxNo",fax_number);
    sro.setAttribute("NotificationMethod",notification_method);
    //getOADBTransaction().commit();
    break;
    catch (Exception e) {
    System.out.println("Exception in update : " + e);
    }

    Please answer following:
    1. Are you using EO based VOs or ReadOnly VO?
    2. What is your VO Query for the search and update?
    3. Why have you based your logic on site_name; you should have used site_id?
    4.Are you getting correct site name in handling createECdetailsEvent event in CO?
    5. In case of update are you getting correct values on the Update Site Details?
    6. On coming back from Update page to Supplier Site Search page, do you see old values of the site or the new values in the results table?
    Please share the screenshot if possible.
    -Prince
    [email protected]
    http://princekapoor82.blogspot.com

  • SSRS Get value of previous row in a matrix (cannot use previous function because it's a matrix)

    I have a SSRS report which uses a matrix for a crosstab effect.
    Each row contains about 10 score values in 10 columns respectively. I need each row to check against the previous row, and i need each score value in each column to be compared to the corresponding column score value in the previous row. 
    If the current score is greater than the corresponding previous score (in the previous row), then i want to change the background of the cell.
    if the current score is smaller than the previous, then it's a different color.
    if they are equal, or it's the first row in the matrix table, then leave white.
    I have found custom code functions to use in the SSRS expression fields, but every single one of them compares against the previous COLUMN value and not the previous ROW value which is what i need. the "Previous" function would be perfect if i
    could use it in a matrix but i can't. (i keep getting error "The use of a Previous aggregate function in a tablix cell is not supported"). looking around it turns out that matrices are arrange in groups and not in rows which is why Previous can't
    be used and the only way is with custom code.
    Please help. if you have any custom code samples that achieve what i need, please share, or give me advice on how to achieve this. 
    Thank you

    I figured it out. Maybe it can help someone else in the future:
    Public Shared count as Integer = 0
    Public Shared currentRow As Integer = 1
    Public Shared MatrixStructures As New System.Collections.Generic.List(Of MatrixStructure)()
    Public Shared Function GetCellColor(row as Integer, score as Integer)
    If (row > currentRow) Then
    count = 0
    currentRow = row
    End If
    count = count + 1
    Dim matrixStructure As New MatrixStructure()
    matrixStructure.RowIndex = row
    matrixStructure.ColumnIndex = count
    matrixStructure.ScoreValue = score
    MatrixStructures.Add(matrixStructure)
    If score = 0 Then
    Return "White"
    End If
    Dim val As MatrixStructure = MatrixStructures.Find(Function(s As MatrixStructure)
    Return s.GetRowIndex() = row - 1 AndAlso s.GetColumnIndex() = count
    End Function)
    If (Not (val Is Nothing)) Then
    If val.scoreValue = 0 Then
    Return "White"
    End If
    If score >= val.scoreValue + 2 Then
    Return "Green"
    ElseIf score <= val.scoreValue - 2 Then
    Return "Red"
    End If
    End If
    Return "White"
    End Function
    Public Class MatrixStructure
    Public rowIndex As Integer
    Property GetRowIndex() As Integer
    Get
    Return rowIndex
    End Get
    Set(ByVal Value As Integer)
    rowIndex = Value
    End Set
    End Property
    Public columnIndex As Integer
    Property GetColumnIndex() As Integer
    Get
    Return columnIndex
    End Get
    Set(ByVal Value As Integer)
    columnIndex = Value
    End Set
    End Property
    Public scoreValue As Integer
    Property GetScoreValue () As Integer
    Get
    Return scoreValue
    End Get
    Set(ByVal Value As Integer)
    scoreValue = Value
    End Set
    End Property
    End Class
    and to pass the current row number from the expression i use this
    Ceiling(RowNumber(NOTHING) / 10)
    i divide the row number by 10 because there are ten columns. if you don't know the number of columns, or it's a variable number, then return it from the stored procedure query in the first place. that's what I had to do

Maybe you are looking for