cancel
Showing results for 
Search instead for 
Did you mean: 

generate_userfields

Former Member
0 Kudos

i will generate a userfield with values

but the program does not running,

because i get a error - 5002 when i use

ValidValuesMD.

what is wrong on my source code?

best regards

ingo

Public Function generate_userfields()

Dim UFld As SAPbobsCOM.UserFieldsMD

Dim VVFld As SAPbobsCOM.ValidValuesMD

Dim RetVal As Long

Dim ErrCode As Long

Dim ErrMsg As String

Set UFld = vCompany.GetBusinessObject(oUserFields)

UFld.TableName = “OITM”

UFld.Name = "test"

UFld.Description = "test”

UFld.Type = db_Alpha

UFld.Size = 10

RetVal = UFld.Add

The result was 0 in the error routine

Set VVFld = UFld.ValidValues

VVFld.Description = "test"

VVFld.Value = 1

VVFld.Add

The result was –5002 in the error routine

End Function

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

The description for error -5002 is "Default value is not valid for this field."

If you are setting a list of valid values, you must specify a default value. Add the following to your code:-

UFld.DefaultValue = 1

Regards,

John.

Answers (0)