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

Error -5002 when adding field to userdefined table

I am trying to create a user defined table, but when I add a field of type BoFieldTypes.db_Float the systems replies with an error -5002.

The function “GetLastError” translate this error code into a text that I suspect is wrong – please see in sample below.

I use SBO 6.5 / C#

Sincerely,

Kim Kjærsulf

SAPbobsCOM.UserTablesMD tblMd = (SAPbobsCOM.UserTablesMD)ConnectionSAP.getInstance().SBO_company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);

tblMd.TableName = "DK8";

tblMd.TableDescription = "Ydelser";

int ret = tblMd.Add();

String txt = "";

if (ret != 0) {

ConnectionSAP.getInstance().SBO_company.GetLastError(out ret, out txt);

MessageBox.Show ("Fail: " + txt, "create ydelser",

MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);

}

else {

tblMd = null;

System.GC.Collect();

SAPbobsCOM.UserFieldsMD fldMd = (SAPbobsCOM.UserFieldsMD)ConnectionSAP.getInstance().SBO_company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields);

fldMd.TableName = "DK8";

fldMd.Name = "Nr";

fldMd.Description = "Number";

fldMd.Type = SAPbobsCOM.BoFieldTypes.db_Numeric;

fldMd.EditSize = 6;

ret = fldMd.Add();

fldMd = null;

System.GC.Collect();

if (ret == 0) {

SAPbobsCOM.UserFieldsMD fldMd1 = (SAPbobsCOM.UserFieldsMD)ConnectionSAP.getInstance().SBO_company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields);

fldMd1.TableName = "DK8";

fldMd1.Name = "Pris";

fldMd1.Description = "Ydelsespris";

fldMd1.Type = SAPbobsCOM.BoFieldTypes.db_Float;

fldMd1.EditSize = 0;

ret = fldMd1.Add(); // -5002 "Underordnet type er ikke tilladt for denne type "

// translation : "Subtype is not allowed for this type "

fldMd1 = null;

System.GC.Collect();

}

if (ret == 0) {

SAPbobsCOM.UserKeysMD keyMd = (SAPbobsCOM.UserKeysMD)ConnectionSAP.getInstance().SBO_company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserKeys);

keyMd.TableName = "DK8";

keyMd.KeyName = "primary";

keyMd.Unique = SAPbobsCOM.BoYesNoEnum.tYES;

keyMd.Elements.ColumnAlias = "Nr";

ret = keyMd.Add();

}

if (ret != 0) {

ConnectionSAP.getInstance().SBO_company.GetLastError(out ret, out txt);

MessageBox.Show ("Fail: " + txt, "Create table",

MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);

}

else {

MessageBox.Show ("Succes ", "Create table");

}

}

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2004 at 07:38 AM

    I have found the solution to the problem:

    A field of type db_Float MUST have a subtype. In this case I set it to "st_Price" - and it worked.

    Notice that the error message was that subtype is NOT allowed for this type ?!

    Regards,

    Kim Kjærsulf

    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.