Skip to Content
0
Former Member
Jun 21, 2007 at 12:46 PM

-5002 Error when using SAPbobsCOM.BoObjectTypes.oUserFields

44 Views

Good Morning

Experts:

I am having some difficulty with using the SAPbobsCOM.BoObjectTypes.oUserFields object. I have several tables that are getting built in code that use this object. However, my latest attempt to add 1 tables is causing some trouble. I am getting a -5002 Invalid Type error returned and cannot figure out why. One might think...there is an Invalid Type.

<b>In my code I add a this field and it gets added to the table structure:</b>

'***********************

'Define Field Properties

'***********************

lRetCode = 0

oUserFieldsMD.TableName = sTableNameColl(lloop)

oUserFieldsMD.Name = "DocNum" oUserFieldsMD.Description = "Purch Req#" oUserFieldsMD.Type = SAPbobsCOM.BoFieldTypes.db_Numeric

oUserFieldsMD.SubType = SAPbobsCOM.BoFldSubTypes.st_None

oUserFieldsMD.EditSize = 10

'*****************************

'Adding the Field to the Table

'*****************************

lRetCode += oUserFieldsMD.Add

'****************

'Check for errors

'****************

If lRetCode <> 0 Then

g_B1Connection.Company.GetLastError(lErrCode, sErrMsg)

Throw New ApplicationException("AddUserField - Add Field: " & oUserFieldsMD.Name & " to Table: " & sTableNameColl(lloop) & " Failed ")

Else

UpdateStatus("Field: " & oUserFieldsMD.Name & " was Added Successfully to " & oUserFieldsMD.TableName, SAPbouiCOM.BoStatusBarMessageType.smt_Success)

End If

<b>Later on in the code after adding more tables, I try to add this field:</b>

'***********************

'Define Field Properties

'***********************

lRetCode = 0

oUserFieldsMD.TableName = sTableNameColl(lloop)

oUserFieldsMD.Name = "WONum" oUserFieldsMD.Description = "WorkOrder"

oUserFieldsMD.Type = SAPbobsCOM.BoFieldTypes.db_Numeric

oUserFieldsMD.SubType = SAPbobsCOM.BoFldSubTypes.st_None

oUserFieldsMD.EditSize = 10

'*****************************

'Adding the Field to the Table

'*****************************

lRetCode += oUserFieldsMD.Add

'****************

'Check for errors

'****************

If lRetCode <> 0 Then

g_B1Connection.Company.GetLastError(lErrCode, sErrMsg)

Throw New ApplicationException("AddUserField - Add Field: " & oUserFieldsMD.Name & " to Table: " & sTableNameColl(lloop) & " Failed ")

Else

UpdateStatus("Field: " & oUserFieldsMD.Name & " was Added Successfully to " & oUserFieldsMD.TableName, SAPbouiCOM.BoStatusBarMessageType.smt_Success)

End If

I get the -5002 error. Fields are added between these 2 but none of them are of Numeric type. So, not being able to see what was wrong, I copied the last working field add for the Numeric type which is the first one listed above and changed the field name/description. Still no good.

Perhaps someone has received this same error and can shed some insight.

I appreciate the help,

Ed