cancel
Showing results for 
Search instead for 
Did you mean: 

Empty a field by datasource

Former Member
0 Kudos

Hi there,

I've got a matrix with some columns. I've got userdatasources bound to them. So far, so good.

One of those userdatasources is of the type <i>dt_SHORT_NUMBER</i> and bound to a column. Now do I want to place a empty value in a certain field in the column this datasource is bound to, using the datasource.

<b>Code (C#)</b>


for(int i = 1; i <= oMatrix.RowCount; i++)
{
  oMatrix.GetLineData(i);
  oDataSource.ValueEx = "";
  oMatrix.SetLineData(i);
}

But this gives me an error... (Data Source - Invalid field value)

Does anybody have a solution?

Accepted Solutions (0)

Answers (1)

Answers (1)

AlexGrebennikov
Active Contributor
0 Kudos

hi!

what about oDataSource.ValueEx = "0";?

i don't exactly know - will it be shown Zero in cell or not. just test it. if the Zero will be appeared, then try to use SuppressZeros-property.

Former Member
0 Kudos

Hi Alexey,

If I do that, it will show 0... (I already tried that)

I'll give <i>suppresszero</i> a try...

<b>Edit:</b>

Suppresszero doesn't work...

Isn't there a way to unset a datasource or variable...? (Or see/test if it's empty?)

barend_morkel2
Active Contributor
0 Kudos

I don't know if this will solve your problem...

'1. to clear

oColumnDBS.DataBind.SetBound(False, "OUSR", "U_NAME")

'2. bind agian to fill with values

oColumnDBS.DataBind.SetBound(True, "OUSR", "U_NAME")

'. getting the data sources bound to the form

oDBDataSource = oForm.DataSources.DBDataSources.Item("OUSR")

oMatrix.Clear()

' Querying the DB Data source

oDBDataSource.Query()

' Adding the data to the matrix

oMatrix.LoadFromDataSource()

FOA
Advisor
Advisor
0 Kudos

Hi,

Try to clear the datasource ex:

' *** To clear the Combobox we have to reset the Datasource!

Frm.DataSources.DBDataSources.Item("OCRD").Clear()

or

m_UserDS.ValueEx = oValidVal.Value

' Clear a value of a user data source

m_UserDS.ValueEx = Nothing

I have tested both cases and it works. Select the one that fits better your case.

Best regards,

Felipe

Former Member
0 Kudos

Hi Felipe,

I had already serached for a Clear() method, that looked obvious to me, but couldn't find one...

Visual Studio also:

<i>'SAPbouiCOM.UserDataSource' does not contain a definition for 'Clear'</i>

So the first function does not work, and the second function, I guess <i>Noting</i> is VB? I don't have that value in C#...

By the way, I'm using SBO 2004A (6.70.188) SP00 PL21

Former Member
0 Kudos

I was looking for a solution of this problem, without success.

I create a not in SAP :

the question was :

<i>I want to populate a matrix bounded to user datasource.

One of the user datasource is numeric.

How can I clear this user datsource to see no value ?

the only way seems to be to set theuserdatasource to 0 but 0 is a value, and I need to have it clear.

I have the same problem for EditText bounded to user datasource in user form. I can't put a Null value or a value that would clear the edit text.</i>

and the answer I got is :

<i>In the user form you can set the SuppressZeros on the edittext object.

This does not seems to be working inside the matrix, please send this

message back to me and I will forward this issue to development.

To get around this maybe you can set the edit text to ""

m_matrix.AddRow

Set editText = m_column.Cells(1).Specific

editText.String = ""

This make it look "" but once you select it in in matrix a 0 appears

again.

So maybe when you leave a field you could catch the lost focus event and

set the string ="" if the value is still zero.

Please send this message back to me and I will get development to look

at why SuppressZeros is not working for matrices.</i>

AlexGrebennikov
Active Contributor
0 Kudos

Hi friends!

i don't know will it be acceptable for your projects, but try to set <b>dt_PRICE</b> as a type of Column.

That works fine for me: if USDataSourse = 0 then i see nothing in column.

hope it'll help

Former Member
0 Kudos

Hi Alexey,

For me, I'ts a quantity, so dt_PRICE could, but I also do want to be able to see 0 also as a value...