cancel
Showing results for 
Search instead for 
Did you mean: 

Update a field to have its value null

Former Member
0 Kudos
579

Hello,

I'd like to know how I can update a User Table to have a field value set to null.

I tried

oTable.UserFields.Fields.Item("U_MyField").Value = nothing

oTable.UserFields.Fields.Item("U_MyFied").Value = System.DBNull.Value

oTable.UserFields.Fields.Item("U_MyFied").Value = Null

but none of them works

my field can be numeric, string, date, I need to update it to be sure it's null (not 0 or "" or 1900-01-01)

Thanks for your help

Sébastien

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Sebastien,

Try

oTable.UserFields.Fields.Item("U_MyField").Value = ""

It sets Date values to NULL.

Miki

Former Member
0 Kudos

Thanks Miklos,

it works great for date field

do you have a same kind of trick for integer and string ?

Former Member
0 Kudos

I found it for string, it's String.Empty

Former Member
0 Kudos

any idea for integer and float ?

Former Member
0 Kudos

I found it for string, it's String.Empty

Hi Sébastien,

Right now I am facing the same problem.

String.Empty doesn't set a null value in the database, it makes it empty, it is not the same. System.DBNull.value doesn't work at all.

Is there a possibility to set a null value in a field through DI ???

Eddy

Former Member
0 Kudos

Eddy,

when I set String.Empty to the field, I do have a null value in the database afetr the update, but you are right, when you get the value, it's "".

But if you use Query analyser, you can see that the value save is Null.

Former Member
0 Kudos

Hi,

I am working with a system table with a userfield. I update the userfield through the DI as following:

object.UserFields.Field.Item("<field>").Value = string.Empty

When I look at my table with the query analyser the field value is not null, it is just empty.

And when I do a selection query with "where <field> is not null, I get the record as result.

I believe you but I don't understand the difference of my case and yours. Should it be a difference between a systemtable with a userfield instead of a usertable?? Or version, I working in SAP 2004A PL18...

greets,

Eddy

Former Member
0 Kudos

I tried set it to ""

but it return me 01/01/1970