cancel
Showing results for 
Search instead for 
Did you mean: 

Error -5002 when adding field to userdefined table

Former Member
0 Kudos

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");

}

}

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

it's a while i know kim but this st_Price where'd u get that from

thanks