Skip to Content
author's profile photo Former Member
Former Member

Dynamically add data to Matrix

Hi,

I have one table which contains 3 columns and several rows. I need to read from these table and dynamically attached to a Matrix which will be bounded to another table. I've made several attempts to display the record before adding which I am successful. I want this automatically add instead of adding it row by row or pressing the Add button. I can only create this record once I have emulated to a click button but was not able to attach the display to the matrix before it is being added.

Can you please provide me some sample snippets on how to go about this?

Thanks

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 07:50 AM

    Hi Milben,

    if is the binding of second table your binding and not done by SAP in system form, you may add to the recordset your next table (join new table or make subselect) and bind it from that one recordset. If is it bounded internall on system forms, i think there is no way how to bind it - you`l have to fill it cell by cell.

    Petr

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 02:49 PM

    Hi,

    This is a sample code snippets which I'm going to attach.

    As a result, there are 3 rows in TB_DSET and it is reflected in matrix. The problem is that it doesn't show in the matrix. Even if I attempt to retrieve and reflected it back cell by cell. Still doesn't display. Form.Update/Form.Refresh, any kind of testing is done.

    Can anyone help me to troubleshoot this for me?

    rs = ((SAPbobsCOM.Recordset)(oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)));

    oCurrentForm.Freeze(true);

    oMatrix = (SAPbouiCOM.Matrix)oForm.Items.Item("mat_OSET").Specific;

    oDBDataSource = oForm.DataSources.DBDataSources.Item("@TB_OSET"); // destination table(currently blank)

    //oDBDataSource.Query(null);

    rs.DoQuery("SELECT U_QSETID,U_QSETNM from [dbo].[@tb_DSET]"); //source table

    if (oMatrix.RowCount == 0)

    oDBDataSource.Clear();

    //oMatrix.FlushToDataSource();

    int i = 1;

    int rwcnt = rs.RecordCount; //contains 3 rows

    while (!rs.EoF)

    {

    if (oCurrentForm.Mode == SAPbouiCOM.BoFormMode.fm_ADD_MODE)

    {

    long j = (long)DBFunction.GenerateGUID(oCompany, "Code", "TB_OSET");

    oDBDataSource.InsertRecord(0);

    oDBDataSource.Offset = oDBDataSource.Size - 1;

    oDBDataSource.SetValue("Code", oDBDataSource.Size - 1, i.ToString());

    oDBDataSource.SetValue("U_GRPSETID", oDBDataSource.Size - 1, rs.Fields.Item("U_QSETID").Value.ToString());

    oDBDataSource.SetValue("U_GRPSETNM", oDBDataSource.Size - 1, rs.Fields.Item("U_QSETNM").Value.ToString());

    oDBDataSource.SetValue("U_OPTIONAL", oDBDataSource.Size - 1, "N");

    oDBDataSource.SetValue("U_PERCENT", oDBDataSource.Size - 1, "0.00");

    oMatrix.AddRow(1, -1);

    //oMatrix.GetLineData(i);

    //oColumn = (SAPbouiCOM.Column)oMatrix.Columns.Item("COLSETID");

    //oEditText = (SAPbouiCOM.EditText)oColumn.Cells.Item(i).Specific;

    //oEditText.Value = rs.Fields.Item("U_QSETID").Value.ToString();

    //oColumn = (SAPbouiCOM.Column)oMatrix.Columns.Item("COLGRPSET");

    //oEditText = (SAPbouiCOM.EditText)oMatrix.Columns.Item("COLGRPSET").Cells.Item(i).Specific;

    ////oEditText = (SAPbouiCOM.EditText)oColumn.Cells.Item(i).Specific;

    //oEditText.Value = rs.Fields.Item("U_QSETNM").Value.ToString();

    oMatrix.SetLineData(i);

    i++;

    }

    //oMatrix.LoadFromDataSource();

    oMatrix.FlushToDataSource();

    rs.MoveNext();

    }

    // oMatrix.FlushToDataSource();

    int k = oMatrix.RowCount; // used to debug and reflected exact # of rows against source table

    //oMatrix.LoadFromDataSource();

    rs = null;

    oForm.Refresh();

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 03:31 PM

    Hi Pter,

    Based on the snippets, I have already preset the DBDatasource to TB_OSET. So it doesn't have anything to with DBDatasources.Add. The matrix count should give you enough idea that it is populating the matrix together with the datasource.

    If I press add button, it is saving the data but again the issue is it doesn't display in matrix.

    Thanks

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 05:15 PM

    Do you want the user to make changes to the matrix? or is it view only?

    Will the user have the ability to add and delete rows?

    Where I'm going with this, is that based on my experiences with UDO's and matrices, I only use them as a last resort.

    I much prefer my own tables and my own update mechanisms, coupled with a Grid object.

    If you don't have a lot of user interaction this may be an easier option for you.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.