Skip to Content

Adding Rows to Sales Quotation results in Invalid Row Status

Mar 09 at 04:06 PM


avatar image

I am using SAP 9.2 with UI and DI API and C#. I need to add rows to Sales Quotations in my addon, but not using the DI API, but the UI (the SalesQ. not always saved when I need to add rows to it).

What I did was, freeze the form and add the rows manually, like this.:

public void AddRows(Form oForm, WtestResults wr)

        NumberFormatInfo nfi = new NumberFormatInfo();
        nfi.NumberDecimalSeparator = ".";
        nfi.NumberDecimalDigits = 4;

        Matrix oMatrix = (Matrix)oForm.Items.Item(SalesQuotationItemIdentifierDefinition.Grid.ItemID).Specific;

        int rowCounter = 1;
        int rowIndex = oMatrix.RowCount - 1;
        foreach (var wrr in wr.Rows)
            oMatrix.AddRow(1, rowIndex++);
            //oMatrix.ClearRowData(rowIndex); <-- MUST NOT DELETE THE CONTENT

            SBOApp.StatusBar.SetText($"Adding rows {rowCounter++}/{wr.Rows.Count}",BoMessageTime.bmt_Medium,BoStatusBarMessageType.smt_Success);
            SBOTools.SetValueComboBoxForMatrixCell(oMatrix, "257", rowIndex, 0);// Regular

           // SBOTools.SetValueComboBoxForMatrixCell(oMatrix, "40", rowIndex, "Open"); <--- FORM NOT EDITABLE!

            SBOTools.SetValueEditTextForMatrixCell(oMatrix, "1", rowIndex, wrr.ItemNumber);
            SBOTools.SetValueEditTextForMatrixCell(oMatrix, "11", rowIndex, wrr.Quantity.ToString(nfi));
            SBOTools.SetValueEditTextForMatrixCell(oMatrix, "14", rowIndex, "" + Math.Round(wrr.UnitPrice, 0));
            SBOTools.SetValueEditTextForMatrixCell(oMatrix, "15", rowIndex, "" + wrr.Disc);

            SBOTools.SetValueEditTextForMatrixCell(oMatrix, "212", rowIndex, "" + wrr.MENeve);

    SBOApp.StatusBar.SetText($"Rorws added successfully.", BoMessageTime.bmt_Medium, BoStatusBarMessageType.smt_Success);

// -----

public static void SetValueEditTextForMatrixCell(Matrix oMatrix, string ColUID, int rowIndex, string newVal)
    Column oColumn = oMatrix.Columns.Item(ColUID);
    Cell oCell = oColumn.Cells.Item(rowIndex);
    EditText oEdit = (EditText)oCell.Specific;
    oEdit.Value = newVal;

I tried to clean the row beforehand, but quickly realized it will delete important values, like the Row Status, which I also cannot change manually.

If I do not clear the row, most of the time it will work, but sometimes it still inserts a new row with NULL status (SAP also allows it to save to the database, I checked the QUT1 table). I could not figure out the reason why it will sometimes just adds a row with an invalid status, but I really would like to solve this.

How can I change the Row Status to always be correct?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Danilo Kasparian Mar 09 at 04:22 PM

You might want to try not to add rows manually, but just fill the ItemCode cell first, then the other columns, SAP will trigger automatically and add a new row, then you keep adding the items in the last row always.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thank you. Time will tell if the problem persists or not, but it seems to work without explicit AddRow calling too.