on 12-30-2005 9:08 AM
Hi,
I am trying to add a primary key through UserKeysMD in a user defined table.But It is showing the invalid field name error,
Pls help me
Try the following... that work for me:
UserKeysMD keyMd = (UserKeysMD)SboCompany.GetBusinessObject(BoObjectTypes.oUserKeys);
keyMd.TableName = "TableName";
keyMd.KeyName = "KeyName";
keyMd.Elements.ColumnAlias = "Field";
keyMd.Unique = BoYesNoEnum.tYES;
keyMd.Add();
Message was edited by: Rasmus Jensen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Make sure the field's names you're indexing (then Elements.ColumnAlias) are less o equal than 8 characters (it gives me a lot of headaches...)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I've deleted my UDT an created it again this time in code
after i've added the UDF also in code
the same error ocurres when i try to create the unique constraint
code i used for creating the key.
oUserKeysMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserKeys)
oUserKeysMD.TableName = "MGCF"
oUserKeysMD.KeyName = "Key_CCode"
oUserKeysMD.Elements.ColumnAlias = "CCode"
oUserKeysMD.Unique = SAPbobsCOM.BoYesNoEnum.tYES
If oUserKeysMD.Add <> 0 Then
BO_Application.MessageBox(oCompany.GetLastErrorDescription())
End If
if anyone cam spot the bug please let me know
Thanks Pedro Gomes
Hi yash sharma
Must amke sure the table and the field exists in that database, then do not put in your code the "@" symbol or the "U_" symbol. Also the field should not have dupliacte data.Once you have added the key look in OUKD, this is where sap stores the MDKeys.
Here is sample code if you do it in vb
Dim UserKey As SAPbobsCOM.UserKeysMD
UserKey = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserKeys)
Try
UserKey.TableName = "SM_OPED"
UserKey.KeyName = "test"
UserKey.Elements.ColumnAlias = "Proc"
UserKey.Unique = SAPbobsCOM.BoYesNoEnum.tYES
lRetCode = UserKey.Add
If lRetCode <> 0 Then
oCompany.GetLastError(lRetCode, sErrMsg)
MsgBox(sErrMsg)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
The above works and adds one key.
Hope this helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I have a UDT whith a UDF created throw the SAP BO Application, and need to enforce a unique constraint.
I used the sample code provided by Louis but
the UserKet.Add returns error code
-5002 : Invalid field name
UserKey.TableName = "MGCF" 'The UDT Name
UserKey.KeyName = "KeyCCode" 'The Key Name
UserKey.Elements.ColumnAlias = "CCode" 'The Column Name
UserKey.Unique = SAPbobsCOM.BoYesNoEnum.tYES
What Have i done wroung?
Thanks Pedro Gomes.
User | Count |
---|---|
100 | |
12 | |
11 | |
6 | |
6 | |
4 | |
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.