SAP B1 : Read from Matrix

Miguel Ribeiro picture Miguel Ribeiro · May 10, 2010 · Viewed 17.8k times · Source

I'm trying to read from a Matrix. The code that I have until now is:

SAPbouiCOM.Matrix matrix = (SAPbouiCOM.Matrix SBO_Application.Forms.ActiveForm.Items.Item("38").Specific;              
SAPbouiCOM.Column col = matrix.Columns.Item("1") ;
SAPbouiCOM.Cells cells = col.Cells;
String cell = cells.Item(2).Specific.ToString();
String f = cell.ToString();

None of the Strings (cell and f) give me the value of the cell...

Any Idea?

Answer

RRUZ picture RRUZ · May 11, 2010

@Miguel try this code

  string ColId   = "1"; //Set The Column Name to read
  Int32  Row     = 2; //Set the Row to Read
  Matrix oMatrix =(Matrix)SBO_Application.Forms.ActiveForm.Items.Item("38").Specific; //Get Access to the Matrix
  EditText oEdit =(EditText)oMatrix.Columns.Item(ColId).Cells.Item(Row).Specific; //Cast the Cell of the matrix to the respective type , in this case EditText
  string sValue  = oEdit.Value; //Get the value form the EditText

Miguel additionally check the SAP Business One SDK Forum for any question about SAP B1.