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

filling data in user matrix

Hi, I have created a user matrix and would like to know how I can fill string type data within the code. i have tried something like this but returns an error about object refernce not set to an instance of an object.. My code is below:

oItem = oForm.Items.Add("Matrix1", SAPbouiCOM.BoFormItemTypes.it_MATRIX)


...add columns

oUserMatrix = oform.Items.Item("Matrix1").Specific

oUserMatrix.Columns.Item("itemcode").Cells.Item(1).Specific.string() = "ABC"

When I try to assign a value to a cell, the error message is thrown. Any advice from you would be appreciated.

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 27, 2005 at 08:11 AM

    The code of Alexy should work, there is a little different with your one (see the .string() part at your last line)

    But I must agree with Sébastien, I also stringly recommend to use user- or dbdatasources to fill your matrix... That way you are doning with EditText fields is very slow... you can win a lot on performance if you use userdatasources...

    Sample (C#)

    // Add datasource
    UserDataSource dsTXT = MySAPForm.DataSources.UserDataSources.Add("MyDS",BoDataType.dt_SHORT_TEXT, 20);
    
    // Get a object to the matrix and bind the datasource
    Matrix MyMatrix = (Matrix)MySAPForm.Items.Item("MyMatrix").Specific;
    MyMatrix.Columns.Item("MyColumn").DataBind.SetBound(true, "", "MyDS");
    
    // Add 10 rows
    MyMatrix.Rows.Add(10,0);
    
    // Loop through the matrix
    for(int i = 1; i <= 10; i++)
    {
      // Assign a value to the datasource
      MyDS.ValueEx = "Nice Value";
    
      // Load the line into the matrix
      MyMatrix.SetLineData(i);
    }
    

    Hope it helps... 😊

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 22, 2005 at 04:59 AM

    Hi Alan! That should work:

    oItem = oForm.Items.Add("Matrix1", SAPbouiCOM.BoFormItemTypes.it_MATRIX)
    \...add columns
    oUserMatrix = oform.Items.Item("Matrix1").Specific
    oEdit = oUserMatrix.Columns.Item("itemcode").Cells.Item(1).Specific
    oEdit.string = "ABC"

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 24, 2005 at 12:27 PM

    Alan,

    you must be sure that the matrix has rows.

    oUserMatrix.AddRow

    I think it would be better to fill the matrix thru the datasource.

    Sebastien

    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.