on 03-09-2005 3:38 PM
Hi at all,
I had programmed an Add-On. In one case I use a SQL-Statement with a Recordset-Object. The function will work. After finish the function I call her a second time SBO will threw the exception: The server threw an exception. A use VB.NET for programming Add-ons.
I read all posts in this forum before I write this message. All of the other Problems with this error message don't help me for my problem. I also Read the SAP Notes: 814163, 813111,706379,642676,816384,809601. But the notes doesn't help me, because the installed version of SBO and the version of the DI-API are on the same Patchlevel. I use SBO 2004 A. It is possible I compile my AddOn with the patch level 09 and the installed Version of the Customer is PL 03.
I hope someone can help me
Best regards
Jörn
Hi,
Can you put the code's function?
Ribeiro Santos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Private Sub erstellenFormularBusinessPartner()
Try
' Deklarieren und initalisieren der Objekte, die benötigt
' werden um ein Formaular einzurichten
Dim oForms As SAPbouiCOM.Forms
Dim oForm As SAPbouiCOM.Form
Dim oItems As SAPbouiCOM.Items
Dim oItem As SAPbouiCOM.Item
Dim oButton As SAPbouiCOM.Button
Dim oComboBox As SAPbouiCOM.ComboBox
Dim oEditText As SAPbouiCOM.EditText
Dim oStaticText As SAPbouiCOM.StaticText
Dim oOptionButton As SAPbouiCOM.OptionBtn
oForms = SBO_Application.Forms
oForm = oForms.Add("CIBBP", BoFormTypes.ft_Floating)
oForm.Title = "Auswahl der Daten für den Brief"
oForm.Width = 432
oForm.Height = 255
oForm.Top = 350
oForm.Left = 350
' DataSource hinzufügen
oForm.DataSources.UserDataSources.Add( _
"Auswahl", BoDataType.dt_SHORT_TEXT, 1)
' Die Beschriftungsfelder zeichnen
oItem = oForm.Items.Add("GPCode", BoFormItemTypes.it_STATIC)
oItem.Left = 5
oItem.Top = 5
oItem.Width = 120
oItem.Height = 15
oItem.LinkTo = "Code"
oStaticText = oItem.Specific
oStaticText.Caption = "GP-Code:"
oItem = oForm.Items.Add("GPName", BoFormItemTypes.it_STATIC)
oItem.Left = 5
oItem.Top = 25
oItem.Width = 120
oItem.Height = 15
oItem.LinkTo = "Name"
oStaticText = oItem.Specific
oStaticText.Caption = "GP-Name:"
oItem = oForm.Items.Add("AnPa", BoFormItemTypes.it_STATIC)
oItem.Left = 5
oItem.Top = 45
oItem.Width = 120
oItem.Height = 15
oItem.LinkTo = "rbAP"
oStaticText = oItem.Specific
oStaticText.Caption = "Ansprechpartner:"
oItem = oForm.Items.Add("RAdresse", BoFormItemTypes.it_STATIC)
oItem.Left = 5
oItem.Top = 65
oItem.Width = 120
oItem.Height = 15
oItem.LinkTo = "rbRA"
oStaticText = oItem.Specific
oStaticText.Caption = "Rechnungsadresse:"
oItem = oForm.Items.Add("LAdresse", BoFormItemTypes.it_STATIC)
oItem.Left = 5
oItem.Top = 85
oItem.Width = 120
oItem.Height = 15
oItem.LinkTo = "rbLA"
oStaticText = oItem.Specific
oStaticText.Caption = "Lieferadresse:"
oItem = oForm.Items.Add("Betreff", BoFormItemTypes.it_STATIC)
oItem.Left = 5
oItem.Top = 105
oItem.Width = 120
oItem.Height = 15
oItem.LinkTo = "Bet"
oStaticText = oItem.Specific
oStaticText.Caption = "Betreff:"
oItem = oForm.Items.Add("UnZeich", BoFormItemTypes.it_STATIC)
oItem.Left = 5
oItem.Top = 125
oItem.Width = 120
oItem.Height = 15
oItem.LinkTo = "Uz"
oStaticText = oItem.Specific
oStaticText.Caption = "Unterzeichnender:"
oItem = oForm.Items.Add("BrVorl", BoFormItemTypes.it_STATIC)
oItem.Left = 5
oItem.Top = 145
oItem.Width = 120
oItem.Height = 15
oItem.LinkTo = "Vorl"
oStaticText = oItem.Specific
oStaticText.Caption = "Briefvorlage:"
' Die Datenfelder zeichnen
oItem = oForm.Items.Add("Code", BoFormItemTypes.it_EDIT)
oItem.Left = 130
oItem.Top = 5
oItem.Width = 150
oItem.Height = 15
oItem = oForm.Items.Add("Name", BoFormItemTypes.it_EDIT)
oItem.Left = 130
oItem.Top = 25
oItem.Width = 150
oItem.Height = 15
oItem = oForm.Items.Add("Partner", BoFormItemTypes.it_COMBO_BOX)
oItem.Left = 130
oItem.Top = 45
oItem.Width = 150
oItem.Height = 15
oItem = oForm.Items.Add("RAdres", BoFormItemTypes.it_COMBO_BOX)
oItem.Left = 130
oItem.Top = 65
oItem.Width = 150
oItem.Height = 15
oItem = oForm.Items.Add("LAdres", BoFormItemTypes.it_COMBO_BOX)
oItem.Left = 130
oItem.Top = 85
oItem.Width = 150
oItem.Height = 15
oItem = oForm.Items.Add("Bet", BoFormItemTypes.it_EDIT)
oItem.Left = 130
oItem.Top = 105
oItem.Width = 150
oItem.Height = 15
oItem = oForm.Items.Add("Uz", BoFormItemTypes.it_COMBO_BOX)
oItem.Left = 130
oItem.Top = 125
oItem.Width = 150
oItem.Height = 15
oItem = oForm.Items.Add("Vorl", BoFormItemTypes.it_COMBO_BOX)
oItem.Left = 130
oItem.Top = 145
oItem.Width = 150
oItem.Height = 15
oComboBox = oItem.Specific
' Jetzt das Verzeichnis Vorlagen suchen und die einzelnen
' Dateien, die mit *.dot aufhören in die ComboBox als
' ValidValue eintragen.
' Das Company-Objekt neu initialisieren und sich mit der Datenbank
' verbinden, damit das Verzeichnis initialisiert werden kann.
Dim oPath As String
Try
oPath = Configuration.ConfigurationSettings.AppSettings("Vorlagen")
Dim oDirectoryInfo As New System.IO.DirectoryInfo(oPath)
If oDirectoryInfo.Exists = False Then
MsgBox("Der Pfad zu den Vorlagendateien ist" & _
" nicht korrekt. Richten Sie den Pfad " & _
"bitte in der Datei " & _
System.Windows.Forms.Application.StartupPath _
& "Office.exe.config unter " & _
"dem Abschnitt Vorlagenpfad ein.", _
MsgBoxStyle.Critical, _
"Pfad nicht korrekt")
oForm.Close()
oForm = Nothing
GC.Collect()
Exit Sub
End If
Catch ex As System.Exception
SBO_Application.MessageBox(ex.ToString & _
" Fehler im Bereich Formular erstellen")
End Try
' Wenn das Vorlagen verzeichnis existiert dann
' durchlaufe das und für jedes File das die Extension
' dot hat, wird ein ValidValue hinzugefügt.
If System.IO.Directory.Exists(oPath) Then
Dim oDirectoryInfo As New System.IO.DirectoryInfo(oPath)
Dim oFiles As System.IO.FileInfo() = _
oDirectoryInfo.GetFiles()
Dim oFile As System.IO.FileInfo
' Das Verzeichnis durchlaufen
For Each oFile In oFiles
' Wenn die Datei die Endung .dot hat, dann
' einen ValidValue anlegen
If oFile.Extension = ".dot" Then
Try
oComboBox.ValidValues.Add( _
oFile.Name, oFile.Extension)
Catch ex As SystemException
SBO_Application.MessageBox("Die Vorlagendatei " & _
oFile.Name & " konnte der Auswahlbox nicht " & _
"hinzugefügt werden, wahrscheinlich ist der " & _
"Dateiname zu lang.")
End Try
End If
Next
End If
' Die Adressauswahlliste zeigen
oItem = oForm.Items.Add("AdVer", BoFormItemTypes.it_STATIC)
oItem.Left = 285
oItem.Top = 25
oItem.Width = 140
oItem.Height = 15
oStaticText = oItem.Specific
oStaticText.Caption = "Adresse verwenden"
oItem = oForm.Items.Add("rbAP", BoFormItemTypes.it_OPTION_BUTTON)
oItem.Left = 285
oItem.Top = 45
oItem.Width = 140
oOptionButton = oItem.Specific
oOptionButton.Caption = "Ansprechpartneradresse"
oOptionButton.ValOff = "0"
oOptionButton.ValOn = "1"
oOptionButton.DataBind.SetBound(True, "", "Auswahl")
oItem = oForm.Items.Add("rbRA", BoFormItemTypes.it_OPTION_BUTTON)
oItem.Left = 285
oItem.Top = 65
oItem.Width = 140
oOptionButton = oItem.Specific
oOptionButton.Caption = "Rechnungsadresse"
oOptionButton.Selected = True
oOptionButton.ValOff = "0"
oOptionButton.ValOn = "2"
oOptionButton.DataBind.SetBound(True, "", "Auswahl")
oOptionButton.GroupWith("rbAP")
oItem = oForm.Items.Add("rbLA", BoFormItemTypes.it_OPTION_BUTTON)
oItem.Left = 285
oItem.Top = 85
oItem.Width = 140
oOptionButton = oItem.Specific
oOptionButton.Caption = "Lieferadresse"
oOptionButton.Selected = True
oOptionButton.ValOff = "0"
oOptionButton.ValOn = "3"
oOptionButton.DataBind.SetBound(True, "", "Auswahl")
oOptionButton.GroupWith("rbRA")
' Rechteck zeichnen
oItem = oForm.Items.Add("Rect1", BoFormItemTypes.it_RECTANGLE)
oItem.Top = 23
oItem.Height = 79
oItem.Left = 3
oItem.Width = 424
Dim oLabel As SAPbouiCOM.StaticText
' Aktivität hinzufügen
' Ein Label hinzufügen
oItem = oForm.Items.Add("LAktiv", BoFormItemTypes.it_STATIC)
oItem.Left = 5
oItem.Top = 165
oItem.Width = 120
oItem.Height = 15
oLabel = oItem.Specific
oLabel.Caption = "Aktivität:"
' Die ComboBox hinzufügen
oItem = oForm.Items.Add("cbAktiv", BoFormItemTypes.it_COMBO_BOX)
oItem.Left = 130
oItem.Top = 165
oItem.Width = 150
oItem.Height = 15
oComboBox = oItem.Specific
' Die Combobox mit ValidValues füllen
oComboBox.ValidValues.Add("Notiz", "N")
oComboBox.Select(0, BoSearchKey.psk_Index)
oItem.Enabled = False
' Ein Label hinzufügen, dient nur dazu, die Linie zu zeichnen
oItem = oForm.Items.Add("LVor2", BoFormItemTypes.it_EDIT)
oItem.Left = 285
oItem.Top = 165
oItem.Width = 1
oItem.Height = 15
oItem.Visible = False
' Aktivitättyp hinzufügen
' Ein Label hinzufügen
oItem = oForm.Items.Add("LTyp", BoFormItemTypes.it_STATIC)
oItem.Left = 5
oItem.Top = 185
oItem.Width = 120
oItem.Height = 15
oLabel = oItem.Specific
oLabel.Caption = "Typ:"
' Die ComboBox hinzufügen
oItem = oForm.Items.Add("cbTyp", BoFormItemTypes.it_COMBO_BOX)
oItem.Left = 130
oItem.Top = 185
oItem.Width = 150
oItem.Height = 15
oComboBox = oItem.Specific
' Die Combobox mit ValidValues füllen
Dim oRecordset As SAPbobsCOM.Recordset
oRecordset = vcmp.GetBusinessObject(BoObjectTypes.BoRecordset)
oRecordset.DoQuery("SELECT Name, Code FROM OCLT")
If oRecordset.RecordCount > 0 Then
Dim index As Integer
index = 0
While index < oRecordset.RecordCount
oComboBox.ValidValues.Add( _
oRecordset.Fields.Item(0).Value, _
oRecordset.Fields.Item(1).Value)
oRecordset.MoveNext()
index += 1
End While
End If
' Richtiges Feld auswählen, das in der Config vorgegeben ist
Dim oWert As String
Try
oWert = Configuration.ConfigurationSettings.AppSettings("Typ")
If oWert <> "" Then
oComboBox.Select(oWert, BoSearchKey.psk_ByValue)
End If
Catch ex As System.Exception
oForm.Close()
SBO_Application.MessageBox("Der Wert in der " & _
"Datei Office.exe.config für den Abschnitt " & _
"Typ ist nicht korrekt! " & _
"Fehler im Bereich Formular Serienbrief erstellen")
Exit Sub
End Try
' Ein Label hinzufügen, dient nur dazu, die Linie zu zeichnen
oItem = oForm.Items.Add("LVor3", BoFormItemTypes.it_EDIT)
oItem.Left = 285
oItem.Top = 185
oItem.Width = 1
oItem.Height = 15
oItem.Visible = False
' Aktivitättyp hinzufügen
' Ein Label hinzufügen
oItem = oForm.Items.Add("LSubject", BoFormItemTypes.it_STATIC)
oItem.Left = 5
oItem.Top = 205
oItem.Width = 120
oItem.Height = 15
oLabel = oItem.Specific
oLabel.Caption = "Thema:"
' Die ComboBox hinzufügen
oForm.DataSources.UserDataSources.Add("subject", BoDataType.dt_LONG_TEXT)
oItem = oForm.Items.Add("cbSubject", BoFormItemTypes.it_COMBO_BOX)
oItem.Left = 130
oItem.Top = 205
oItem.Width = 150
oItem.Height = 15
oComboBox = oItem.Specific
oComboBox.DataBind.SetBound(True, , "subject")
' Die Combobox mit ValidValues füllen
oRecordset.DoQuery("SELECT Name, Code FROM OCLS WHERE " & _
"Type = '" & oForm.Items.Item("cbTyp").Specific. _
Selected.Description.ToString() & "'")
If oRecordset.RecordCount > 0 Then
Dim index As Integer
index = 0
While index < oRecordset.RecordCount
oComboBox.ValidValues.Add( _
oRecordset.Fields.Item(0).Value, _
oRecordset.Fields.Item(1).Value)
oRecordset.MoveNext()
index += 1
End While
End If
' Richtiges Feld auswählen, das in der Config vorgegeben ist
Try
oWert = Configuration.ConfigurationSettings.AppSettings("Thema")
If oWert <> "" Then
oComboBox.Select(oWert, BoSearchKey.psk_ByValue)
End If
Catch ex As System.Exception
oForm.Close()
SBO_Application.MessageBox("Der Wert in der " & _
"Datei Office.exe.config für den Abschnitt " & _
"Typ ist nicht korrekt! " & _
"Fehler im Bereich Formular Serienbrief erstellen")
Exit Sub
End Try
' Ein Label hinzufügen, dient nur dazu, die Linie zu zeichnen
oItem = oForm.Items.Add("LVor4", BoFormItemTypes.it_EDIT)
oItem.Left = 285
oItem.Top = 205
oItem.Width = 1
oItem.Height = 15
oItem.Visible = False
oRecordset = Nothing
GC.Collect()
' Den Okay Button initalisieren
oItem = oForm.Items.Add("btnOK", BoFormItemTypes.it_BUTTON)
oItem.Left = 5
oItem.Top = 230
oItem.Width = 60
oItem.Height = 19
oButton = oItem.Specific
oButton.Caption = "OK"
' Den Okay Button initalisieren
oItem = oForm.Items.Add("btnCancel", BoFormItemTypes.it_BUTTON)
oItem.Left = 70
oItem.Top = 230
oItem.Width = 60
oItem.Height = 19
oButton = oItem.Specific
oButton.Caption = "Abbrechen"
auswahlDatenBrief(oForm.UniqueID)
' Das Fromular sichtbar machen
oForm.Visible = True
Catch ex As System.Exception
SBO_Application.MessageBox("Fehler beim Erstellen des Briefauswahlformulars: " & _
ex.Message.ToString)
End Try
End Sub
User | Count |
---|---|
98 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
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.