public static void CreateUDT(String udtName, String udtDesc, SAPbobsCOM.BoUTBTableType udtType) { if (!CheckTableExists(udtName)) { //SDK -> UserTableMD Object -> Fields Required SAPbobsCOM.IUserTablesMD oUDTMD = null; try { // 1. Get Company Object oUDTMD = AddOnUtilities.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables); // 2. Set Table Properties oUDTMD.TableName = udtName; oUDTMD.TableDescription = udtDesc; oUDTMD.TableType = udtType; // 3. Add AddOnUtilities.IRetCode = oUDTMD.Add(); // 4. Error Handling AddOnUtilities.DIErrorHandler(String.Format("UDT {0} Created.", udtName)); } catch (Exception ex) { AddOnUtilities.MsgBoxWrapper(ex.Message + " " + ex.StackTrace, Enum.MsgBoxType.B1StatusBar, SAPbouiCOM.BoMessageTime.bmt_Short, true); } finally { //Important - release COM Object System.Runtime.InteropServices.Marshal.ReleaseComObject(oUDTMD); GC.Collect(); oUDTMD = null; } } }
public static void AddTable(string tableName, string description, SAPbobsCOM.BoUTBTableType tableType) { var oUserTablesMD = B1Helper.DiCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables) as SAPbobsCOM.UserTablesMD; try { if (!oUserTablesMD.GetByKey(tableName)) { oUserTablesMD.TableName = tableName; oUserTablesMD.TableDescription = description; oUserTablesMD.TableType = tableType; if (oUserTablesMD.Add() != 0) { var error = B1Helper.DiCompany.GetLastErrorDescription(); } } } catch (Exception ex) { Utilities.LogException(ex); } finally { oUserTablesMD.ReleaseObject(); } }
/// <summary> /// Method for creating UDT /// </summary> /// <param name="udtName"></param> /// <param name="udtDesc"></param> /// <param name="udtType"></param> public void Create(string udtName, string udtDesc, SAPbobsCOM.BoUTBTableType udtType) { SAPbobsCOM.UserTablesMD oUDTMD = null; try { oUDTMD = (SAPbobsCOM.UserTablesMD)PublicVariable.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables); oUDTMD.TableName = udtName; oUDTMD.TableDescription = udtDesc; oUDTMD.TableType = udtType; PublicVariable.lRetCode = oUDTMD.Add(); } catch (Exception ex) { PublicVariable.oApplication.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); } finally { if (oUDTMD != null) { Marshal.FinalReleaseComObject(oUDTMD); oUDTMD = null; GC.Collect(); } } }
public void AddTables(string strTab, string strDesc, SAPbobsCOM.BoUTBTableType nType) { GC.Collect(); SAPbobsCOM.UserTablesMD oUserTablesMD = null; try { oUserTablesMD = null; oUserTablesMD = ____bobCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables); // Adding Table if (!oUserTablesMD.GetByKey(strTab)) { oUserTablesMD.TableName = strTab; oUserTablesMD.TableDescription = strDesc; oUserTablesMD.TableType = nType; if (oUserTablesMD.Add() != 0) { throw new Exception(____bobCompany.GetLastErrorDescription()); } } } catch (Exception ex) { throw ex; } finally { System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserTablesMD); oUserTablesMD = null; GC.WaitForPendingFinalizers(); GC.Collect(); } }
public static string CreateUDT(string tableName, string tableDesc, SAPbobsCOM.BoUTBTableType tableType) { oApp = (SAPbouiCOM.Application)Application.SBO_Application; oCompany = (SAPbobsCOM.Company)oApp.Company.GetDICompany(); SAPbobsCOM.UserTablesMD oUdtMD = null; SAPbobsCOM.UserFieldsMD oUdtCA = null; tableName = "Prueba"; try { oUdtMD = (SAPbobsCOM.UserTablesMD)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables); if (oUdtMD.GetByKey(tableName) == false) { oUdtMD.TableName = tableName; oUdtMD.TableDescription = tableName; oUdtMD.TableType = tableType; // oUdtCA.Mandatory = "tYes"; int lRetCode; lRetCode = oUdtMD.Add(); oUdtCA.Add(); System.Runtime.InteropServices.Marshal.ReleaseComObject(oUdtMD); oUdtMD = null; GC.Collect(); if ((lRetCode != 0)) { if ((lRetCode == -2035)) { return("-2035"); } return(oCompany.GetLastErrorDescription()); } return(""); } else { return(""); } } catch (Exception ex) { return(ex.Message); } }
public static string CreateUDT(string tableName, string tableDesc, SAPbobsCOM.BoUTBTableType tableType) { SAPbobsCOM.Company SBO_Company = Conexion.oCompany; //get company service if (!SBO_Company.Connected) { Conexion.Conectar_Aplicacion(); } SAPbobsCOM.UserTablesMD oUdtMD = null /* TODO Change to default(_) if this is not a reference type */; try { oUdtMD = (SAPbobsCOM.UserTablesMD)SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables); if (oUdtMD.GetByKey(tableName) == false) { oUdtMD.TableName = tableName; oUdtMD.TableDescription = tableDesc; oUdtMD.TableType = tableType; int lRetCode; lRetCode = oUdtMD.Add(); System.Runtime.InteropServices.Marshal.ReleaseComObject(oUdtMD); oUdtMD = null /* TODO Change to default(_) if this is not a reference type */; GC.Collect(); if ((lRetCode != 0)) { if ((lRetCode == -2035)) { return("-2035"); } return(SBO_Company.GetLastErrorDescription()); } return(""); } else { return(""); } } catch (Exception ex) { return(ex.Message); } }
private bool CreaTablaMD(string NombTabla, string DescTabla, SAPbobsCOM.BoUTBTableType tipoTabla) { SAPbobsCOM.UserTablesMD oUserTablesMD = null; try { oUserTablesMD = null; oUserTablesMD = (SAPbobsCOM.UserTablesMD)Conexion.company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables); if (!oUserTablesMD.GetByKey(NombTabla)) { oUserTablesMD.TableName = NombTabla; oUserTablesMD.TableDescription = DescTabla; oUserTablesMD.TableType = tipoTabla; m_iErrCode = oUserTablesMD.Add(); if (m_iErrCode != 0) { Conexion.company.GetLastError(out m_iErrCode, out m_sErrMsg); StatusMessageError("Error al crear tabla: " + NombTabla); return(false); } else { StatusMessageSuccess("Se ha creado la tabla: " + NombTabla); } LiberarObjetoGenerico(oUserTablesMD); oUserTablesMD = null; return(true); } return(false); } catch (Exception ex) { StatusMessageError("Error: EstructuraDatos.cs > CreaTablaMD():" + ex.Message); return(false); } finally { LiberarObjetoGenerico(oUserTablesMD); oUserTablesMD = null; } }
public static string CreateUDT(string tableName, string tableDesc, SAPbobsCOM.BoUTBTableType tableType) { oApp = (SAPbouiCOM.Application)Application.SBO_Application; oCompany = (SAPbobsCOM.Company)oApp.Company.GetDICompany(); SAPbobsCOM.UserTablesMD oUdtMD = null; SAPbobsCOM.UserFieldsMD oUdtCA = null; string VERSION = null; SAPbobsCOM.Recordset oRec = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); oRec.DoQuery(" SELECT [U_APLICACION] as 'SAP',[U_Version] As 'Version',[U_fecha] as Fecha FROM [@VERSION]"); oRec.MoveFirst(); while (!oRec.EoF) { //oCBC.ValidValues.Add(oRec.Fields.Item(0).Value.ToString(), oRec.Fields.Item(1).Value.ToString()); VERSION = oRec.Fields.Item("Version").Value.ToString(); // Extraerdequery1 = Convert.ToString(Grid2.Columns.Item("Descripción")); oRec.MoveNext(); } if (VERSION == "1.1") { tableName = "@Prueba"; try { oUdtMD = (SAPbobsCOM.UserTablesMD)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables); if (oUdtMD.GetByKey(tableName) == false) { oUdtMD.TableName = tableName; oUdtMD.TableDescription = tableName; oUdtMD.TableType = tableType; // oUdtCA.Mandatory = "tYes"; int lRetCode; lRetCode = oUdtMD.Add(); oUdtCA.Add(); System.Runtime.InteropServices.Marshal.ReleaseComObject(oUdtMD); oUdtMD = null; GC.Collect(); if ((lRetCode != 0)) { if ((lRetCode == -2035)) { return("-2035"); } return(oCompany.GetLastErrorDescription()); } return("exito"); } else if (VERSION == "1.2") { return(""); } else { return(""); } } catch (Exception ex) { return(ex.Message); } } else { return(""); } }
public void AddUserTable(string Name, string Description, SAPbobsCOM.BoUTBTableType Type) { try { if (!connect()) { return; } //**************************************************************************** // The UserTablesMD represents a meta-data object which allows us // to add\remove tables, change a table name etc. //**************************************************************************** SAPbobsCOM.UserTablesMD oUserTablesMD = null; //**************************************************************************** // In any meta-data operation there should be no other object "alive" // but the meta-data object, otherwise the operation will fail. // This restriction is intended to prevent a collisions //**************************************************************************** // the meta-data object needs to be initialized with a // regular UserTables object oUserTablesMD = ((SAPbobsCOM.UserTablesMD)(oSetupCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables))); //************************************************** // when adding user tables or fields to the SBO DB // use a prefix identifying your partner name space // this will prevent collisions between different // partners add-ons // SAP's name space prefix is "BE_" //************************************************** // set the table parameters oUserTablesMD.TableName = Name; oUserTablesMD.TableDescription = Description; oUserTablesMD.TableType = Type; // Add the table // This action add an empty table with 2 default fields // 'Code' and 'Name' which serve as the key // in order to add your own User Fields // see the AddUserFields.frm in this project // a privat, user defined, key may be added // see AddPrivateKey.frm in this project lRetCode = oUserTablesMD.Add(); // check for errors in the process if (lRetCode != 0) { oSetupCompany.GetLastError(out lRetCode, out sErrMsg); errorLog("Add table error. Table: " + oUserTablesMD.TableName + ", " + sErrMsg); } else { errorLog("Table: " + oUserTablesMD.TableName + " was added successfully"); } oUserTablesMD = null; GC.Collect(); } catch (Exception ex) { string err = string.Format("Add Table: {0}, Exeption: {1}", Name, ex.Message); errorLog(err); if (ex.Message.IndexOf("Ref count") >= 0) { GC.Collect(); } } finally { connect(); GC.Collect(); // Release the handle to the table } }
public UDT_Model(SAPbobsCOM.BoUTBTableType tableType, String table) { TableType = tableType; TableName = table; }