on 06-15-2004 11:05 AM
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");
}
}
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
7 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.