public int AddUserTable(ref SAPbobsCOM.Company oCompany, string name, string description,
SAPbobsCOM.BoUTBTableType tableType)
{
int returnCode = 0;
string errorMessage = string.Empty;
// The UserTablesMD represents a meta-data object which allows us
// to add\remove tables, change a table name etc.
SAPbobsCOM.UserTablesMD oUserTableMD =
(SAPbobsCOM.UserTablesMD)oCompany.
GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);
// set the table parameters
oUserTableMD.TableName = name;
oUserTableMD.TableDescription = description;
oUserTableMD.TableType = tableType;
returnCode = oUserTableMD.Add();
//Note: a return code of -1 is successful
if(returnCode != 0)
{
if(returnCode != - 1)
{
oCompany.GetLastError(out returnCode, out errorMessage);
throw new ApplicationException(returnCode.ToString() + " - " + errorMessage);
}
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserTableMD);
oUserTableMD = null;
return returnCode;
}