Skip to Content

invalid field name when Insert user defined field on No object Table

Good morning experts,

I have a no object table named D_OGDR with several fields, one of them is called CAINumber

I tried on demo databases and gives no error, I tried on many scenarios on my client's database and sometimes gives the error Invalid Field Type, and sometimes it doesn't.

My SAP version is 9.20.190 PL:09

Here is my code

SAPbobsCOM.UserTable GdrTable = RefCompany.UserTables.Item("D_OGDR");

GdrTable.Code = LastNum.ToString();
GdrTable.Name = LastNum.ToString();
GdrTable.UserFields.Fields.Item("U_CAIDate").Value = MyDate;
GdrTable.UserFields.Fields.Item("U_CAINumber").Value = MyNumber;

Res = GdrTable.Add();
if (Res == 0)
{
//Success
}

I have checked

SELECT * FROM CUFD WHERE TableID = '@D_OGDR' and the fields seem to be good, also

select * from [@D_OGDR]

shows me the records the my code insert when it doesn't give the invalid field message

My SQL version is 2014

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Oct 19, 2018 at 11:44 AM

    Hi Alfredo,

    Usually with this error it will be thrown on the line that causes the error, before you even get to the add method. You may use debug step-through or a Try block to determine which field specifically is causing the error.

    What is the data type of the MyDate variable, and what is the data type of the U_CAIDate field?

    What is the data type of the MyNumber variable, and what is the data type of the U_CAINumber field?

    Do the data types of the variables and their respective fields match?

    If you have used alphanumeric for either field, the error may be thrown because of existing values of a different data type in either field. This is less likely in a demo database, so that might explain why it works there.

    Regards,

    Johan

    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.