Skip to Content
0
Former Member
Aug 31, 2006 at 05:06 AM

how to assign unique keys to UDF(tried sample but getting error -1120)

53 Views

hi all

how to assign unique keys through userkeysMD

i am writing the same way as example in sdk. but i am getting Error : -1120. what does this mean. the sample code i wrote is

Try

' A User Fields object

Dim oUserFieldsMD As SAPbobsCOM.UserFieldsMD

Dim oUserKeysMD As SAPbobsCOM.UserKeysMD

''Dim oUserKeys As SAPbobsCOM.UserKeysMDClass

'' Init the user fields object

oUserFieldsMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)

oUserKeysMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserKeys)

oUserFieldsMD.Name = "emp1_ld"

oUserFieldsMD.Type = SAPbobsCOM.BoFieldTypes.db_Alpha

oUserFieldsMD.Size = 8

oUserKeysMD.Unique = SAPbobsCOM.BoYesNoEnum.tYES

oUserKeysMD.KeyName = "PK_emp_id"

oUserFieldsMD.Description = "Linked Field"

'oUserFieldsMD.LinkedTable = "OHEM"

oUserFieldsMD.TableName = "Employment1"

'oUserFieldsMD.EditSize = 8

''// Adding the Field to the Table

''// Determine whether the key is unique or not

'oUserKeysMD.Unique = SAPbobsCOM.BoYesNoEnum.tYES

oUserKeysMD.Add()

lRetCode = oUserFieldsMD.Add