public static bool CheckTableExists(string TableName) { SAPbobsCOM.Company SBO_Company = Conexion.oCompany; SAPbobsCOM.UserTablesMD oUdtMD = null /* TODO Change to default(_) if this is not a reference type */; bool ret = false; try { TableName = TableName.Replace("@", ""); oUdtMD = (SAPbobsCOM.UserTablesMD)SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables); if (oUdtMD.GetByKey(TableName)) { ret = true; } else { ret = false; } } catch (Exception ex) { ret = false; } finally { System.Runtime.InteropServices.Marshal.ReleaseComObject(oUdtMD); oUdtMD = null /* TODO Change to default(_) if this is not a reference type */; GC.Collect(); } return(ret); }
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(""); } }
private static void LoadUserTablesMDToXmlFile(string prefix) { SAPbobsCOM.UserTablesMD userTablesMD = null; XmlDocument documentoFinal = null; SAPbobsCOM.Recordset RS = (SAPbobsCOM.Recordset)sbo_company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); if (sbo_company.DbServerType == SAPbobsCOM.BoDataServerTypes.dst_HANADB) { RS.DoQuery(string.Format(@"SELECT ""TableName"" FROM OUTB WHERE ""TableName"" LIKE '{0}%'", prefix)); } if (RS.RecordCount > 0) { while (!RS.EoF) { string table = RS.Fields.Item("TableName").Value.ToString(); userTablesMD = (SAPbobsCOM.UserTablesMD)sbo_company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables); if (userTablesMD.GetByKey(table)) { XmlDocument documento = new XmlDocument(); sbo_company.XmlExportType = SAPbobsCOM.BoXmlExportTypes.xet_ExportImportMode; documento.LoadXml(userTablesMD.GetAsXML()); if (documentoFinal == null) { documentoFinal = new XmlDocument(); documentoFinal.LoadXml(userTablesMD.GetAsXML()); } else { XmlNode nodeBO = documento.DocumentElement.FirstChild; string stringContenidoNodeBO = nodeBO.InnerXml; try { XmlNode nuevoNodeBO = documentoFinal.CreateElement("BO"); nuevoNodeBO.InnerXml = stringContenidoNodeBO; documentoFinal.DocumentElement.AppendChild(nuevoNodeBO); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } System.Runtime.InteropServices.Marshal.ReleaseComObject(userTablesMD); userTablesMD = null; GC.Collect(); RS.MoveNext(); } } if (documentoFinal != null) { documentoFinal.Save(UserTablesFile); } sbo_application.StatusBar.SetText("UDT export completed", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success); }