This commit is contained in:
SchreiberM
2016-05-12 16:55:36 +02:00
parent 7ca78e8d65
commit 0f227039a0
4 changed files with 298 additions and 289 deletions

View File

@@ -108,8 +108,8 @@ Public Class ClassDatabase
End If
Catch ex As Exception
ClassLogger.Add(" - Unexpected Error in MSSQL_ReturnDTWithConnection: " & vbNewLine & ex.Message)
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected Error in MSSQL_ReturnDTWithConnection:")
ClassLogger.Add("Unexpected Error in MSSQL_ReturnDTWithConnection: " & vbNewLine & ex.Message & vbNewLine & vbNewLine & sql)
MsgBox("Unexpected Error in MSSQL_ReturnDTWithConnection:" & vbNewLine & ex.Message & vbNewLine & vbNewLine & sql, MsgBoxStyle.Critical)
Return Nothing
End Try
End Function

View File

@@ -256,6 +256,7 @@
<Compile Include="ClassJumpRecord.vb" />
<Compile Include="ClassLicence.vb" />
<Compile Include="ClassRecordState.vb" />
<Compile Include="ClassSAP.vb" />
<Compile Include="frmRight_Management.Designer.vb">
<DependentUpon>frmRight_Management.vb</DependentUpon>
</Compile>

View File

@@ -33,7 +33,7 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("2.4.5.3")>
<Assembly: AssemblyVersion("2.4.5.4")>
<Assembly: AssemblyFileVersion("1.0.0.0")>
<Assembly: NeutralResourcesLanguageAttribute("")>

View File

@@ -37,6 +37,13 @@ Public Class frmSAP_FuBa
rBFuba.Checked = True
End If
End If
If rbTable.Checked Then
MethodTextBox.Text = "TABLE"
lblMethodname.Text = "Table Name"
Else
lblMethodname.Text = "FuBa Name"
MethodTextBox.Text = "FUBA"
End If
Catch ex As Exception
MsgBox("Error in Load Fubas:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
@@ -44,33 +51,40 @@ Public Class frmSAP_FuBa
Private Sub btnERPConnect_Click(sender As Object, e As EventArgs) Handles btnERPConnect.Click
Dim con As New R3Connection
Try
Me.Cursor = Cursors.WaitCursor
If LogErrorsOnly = False Then ClassLogger.Add("", False)
If LogErrorsOnly = False Then ClassLogger.Add(">> SAP Connect started:", False)
ERPConnect.LIC.SetLic("W86DWC992C")
con.Host = HostTextBox.Text
con.SystemNumber = SystemNumberTextBox.Text
con.UserName = UserNameTextBox.Text
con.Password = PasswordTextBox.Text
con.Client = ClientTextBox.Text
con.Language = LanguageTextBox.Text
If LogErrorsOnly = False Then ClassLogger.Add(">> HOST: " & HostTextBox.Text & " |SystemNumber: " & SystemNumberTextBox.Text & " |UserName: " & UserNameTextBox.Text & " |Password: " & PasswordTextBox.Text & " |Client: " & ClientTextBox.Text & " |Language: " & LanguageTextBox.Text, False)
con.Open(False)
If LogErrorsOnly = False Then ClassLogger.Add(">> SAP-Connection erfolgreich aufgebaut!", False)
If LogErrorsOnly = False Then ClassLogger.Add("", False)
Me.Cursor = Cursors.WaitCursor
If ClassSAP.ConnectionInit(HostTextBox.Text, SystemNumberTextBox.Text, UserNameTextBox.Text, PasswordTextBox.Text, ClientTextBox.Text, LanguageTextBox.Text) = True Then
lblConnectionopen.Visible = True
Me.Cursor = Cursors.Default
Catch ex As Exception
MsgBox("Unexpected Error in SAP Connect: " & ex.Message, MsgBoxStyle.Critical)
Else
lblConnectionopen.Visible = False
Me.Cursor = Cursors.Default
lblResult.Visible = False
GridControl2.DataSource = Nothing
lblSave.Visible = False
Me.Cursor = Cursors.Default
Exit Sub
End Try
End If
Me.Cursor = Cursors.Default
'Try
' Me.Cursor = Cursors.WaitCursor
' If LogErrorsOnly = False Then ClassLogger.Add("", False)
' If LogErrorsOnly = False Then ClassLogger.Add(">> SAP Connect started:", False)
' ERPConnect.LIC.SetLic("W86DWC992C")
' con.Host = HostTextBox.Text
' con.SystemNumber = SystemNumberTextBox.Text
' con.UserName = UserNameTextBox.Text
' con.Password = PasswordTextBox.Text
' con.Client = ClientTextBox.Text
' con.Language = LanguageTextBox.Text
' If LogErrorsOnly = False Then ClassLogger.Add(">> HOST: " & HostTextBox.Text & " |SystemNumber: " & SystemNumberTextBox.Text & " |UserName: " & UserNameTextBox.Text & " |Password: " & PasswordTextBox.Text & " |Client: " & ClientTextBox.Text & " |Language: " & LanguageTextBox.Text, False)
' con.Open(False)
' If LogErrorsOnly = False Then ClassLogger.Add(">> SAP-Connection erfolgreich aufgebaut!", False)
' If LogErrorsOnly = False Then ClassLogger.Add("", False)
' lblConnectionopen.Visible = True
' Me.Cursor = Cursors.Default
'Catch ex As Exception
' MsgBox("Unexpected Error in SAP Connect: " & ex.Message, MsgBoxStyle.Critical)
' lblConnectionopen.Visible = False
' Me.Cursor = Cursors.Default
' lblResult.Visible = False
' GridControl2.DataSource = Nothing
' lblSave.Visible = False
' Me.Cursor = Cursors.Default
' Exit Sub
'End Try
End Sub
Private Sub TBPMO_SAP_FUBABindingSource_AddingNew(sender As Object, e As System.ComponentModel.AddingNewEventArgs) Handles TBPMO_SAP_FUBABindingSource.AddingNew
@@ -92,66 +106,46 @@ Public Class frmSAP_FuBa
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnInsertData.Click
If TempTableNameTextBox.Text <> "" Then
Dim SAPCon As New R3Connection
Me.Cursor = Cursors.WaitCursor
Dim con As New R3Connection
Try
If LogErrorsOnly = False Then ClassLogger.Add("", False)
If LogErrorsOnly = False Then ClassLogger.Add(">> SAP Connect started:", False)
ERPConnect.LIC.SetLic("W86DWC992C")
con.Host = HostTextBox.Text
con.SystemNumber = SystemNumberTextBox.Text
con.UserName = UserNameTextBox.Text
con.Password = PasswordTextBox.Text
con.Client = ClientTextBox.Text
con.Language = LanguageTextBox.Text
If LogErrorsOnly = False Then ClassLogger.Add(">> HOST: " & HostTextBox.Text & " |SystemNumber: " & SystemNumberTextBox.Text & " |UserName: " & UserNameTextBox.Text & " |Password: " & PasswordTextBox.Text & " |Client: " & ClientTextBox.Text & " |Language: " & LanguageTextBox.Text, False)
con.Open(False)
If LogErrorsOnly = False Then ClassLogger.Add(">> SAP-Connection erfolgreich aufgebaut!", False)
If LogErrorsOnly = False Then ClassLogger.Add("", False)
Catch ex As Exception
MsgBox("Unexpected Error in SAP Connect: " & ex.Message, MsgBoxStyle.Critical)
If ClassSAP.ConnectionInit(HostTextBox.Text, SystemNumberTextBox.Text, UserNameTextBox.Text, PasswordTextBox.Text, ClientTextBox.Text, LanguageTextBox.Text) = True Then
lblConnectionopen.Visible = True
Else
lblConnectionopen.Visible = False
Me.Cursor = Cursors.Default
lblResult.Visible = False
GridControl2.DataSource = Nothing
lblSave.Visible = False
Exit Sub
End Try
Dim resulttable As DataTable
Try
Dim table As New ERPConnect.Utils.ReadTable(con)
'Dim cWhereClause = "SAP_OBJECT EQ '<ObjectType>' AND AR_DATE GE '<AR_DATE>'"
'Dim sSearchDate1 = "20160101"
'cWhereClause = Replace(cWhereClause, "<ObjectType>", Objekttyp.Text)
'cWhereClause = Replace(cWhereClause, "<AR_DATE>", sSearchDate1)
If WHERE_CLAUSETextBox.Text <> "" Then
table.AddCriteria(WHERE_CLAUSETextBox.Text)
End If
Dim SAPResulttable As DataTable = New DataTable
If rbTable.Checked = True Then
End If
If rBFuba.Checked = True Then
Dim result = ClassSAP.FuBa_Returndatatable_Seperated(TableNameTextBox.Text, FuBa_SplitCharacterTextBox.Text, txtLimitRows.Text)
If Not IsNothing(result) Then
SAPResulttable = result
End If
'ClassLogger.Add(">> cWhereClause: " & cWhereClause, False)
'table.AddField("MATNR")
'table.AddField("MAKTX")
' table.AddCriteria("SPRAS = 'DE'")
table.TableName = TableNameTextBox.Text
If txtLimitRows.Text <> "" Then
table.RowCount = CInt(txtLimitRows.Text)
End If
table.Run()
resulttable = table.Result
If LogErrorsOnly = False Then ClassLogger.Add(">> resulttable created!", False)
If LogErrorsOnly = False Then ClassLogger.Add("", False)
Catch ex As Exception
End If
If SAPResulttable Is Nothing Then
SAPCon.Close()
lblResult.Visible = False
Me.Cursor = Cursors.Default
MsgBox("Unexpected Error in Get SAP Table Result: " & ex.Message, MsgBoxStyle.Critical)
lblSave.Visible = False
GridControl2.DataSource = Nothing
ClassLogger.Add(">> SAPResulttable is nothing", False)
Exit Sub
End Try
End If
'######
Dim i = 0
Dim tablename = "TPPMO_SAPFUBA_ " & TempTableNameTextBox.Text
Dim createtablesql = "CREATE TABLE TPPMO_SAPFUBA_ " & TempTableNameTextBox.Text & " ("
Dim tablename = "[DD_ECM].[dbo].[TPPMO_SAPFUBA_ " & TempTableNameTextBox.Text & "]"
Dim createtablesql = "CREATE TABLE TPPMO_SAPFUBA_" & TempTableNameTextBox.Text & " ("
For Each col As System.Data.DataColumn In resulttable.Columns
For Each col As System.Data.DataColumn In SAPResulttable.Columns
If i = 0 Then
createtablesql += "[" & col.ColumnName & "] [varchar](100)"
Else
@@ -163,19 +157,32 @@ Public Class frmSAP_FuBa
Dim check = String.Format("SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE' AND TABLE_NAME='{0}'", tablename)
If ClassDatabase.Execute_Scalar(check) = 1 Then
ClassDatabase.Execute_non_Query("DROP TABLE " & tablename)
' ClassDatabase.Execute_non_Query_withConn("DROP TABLE " & tablename, 1)
End If
'Die Tabelle anlegen
''Die Tabelle anlegen
If LogErrorsOnly = False Then ClassLogger.Add(">> Create Table: " & createtablesql, False)
If ClassDatabase.Execute_non_Query(createtablesql) = False Then
Me.Cursor = Cursors.Default
MsgBox("Error while creating the temporary table. Please check the logfile!", MsgBoxStyle.Critical)
Exit Sub
'If ClassDatabase.Execute_non_Query_withConn(createtablesql, 1) = False Then
' Me.Cursor = Cursors.Default
' MsgBox("Error while creating the temporary table. Please check the logfile!", MsgBoxStyle.Critical)
' Exit Sub
'End If
Dim ins = "Insert into " & tablename & "("
Dim DT As DataTable = ClassDatabase.Return_Datatable("SELECT * FROM " & tablename)
If Not IsNothing(DT) Then
Dim i As Integer = 0
For Each DataColumn In DT.Columns
ins = ins &
Next
End If
Try
For Each row As DataRow In SAPResulttable.Rows
Next
Dim OwnerCS As String
OwnerCS = ClassDatabase.GetConnectionString(1)
Dim SQLconnect As New SqlClient.SqlConnection
SQLconnect.ConnectionString = MyConnectionString
SQLconnect.ConnectionString = OwnerCS
SQLconnect.Open()
' Note that the column positions in the source DataTable
' match the column positions in the destination table,
@@ -185,19 +192,20 @@ Public Class frmSAP_FuBa
bulkCopy.DestinationTableName = tablename
Try
' Write from the source to the destination.
bulkCopy.WriteToServer(resulttable)
bulkCopy.WriteToServer(SAPResulttable)
Catch ex As Exception
MsgBox("Unexpected Error in BulkCopy SQL: " & ex.Message, MsgBoxStyle.Critical)
End Try
End Using
SQLconnect.Close()
Me.Cursor = Cursors.Default
If LogErrorsOnly = False Then ClassLogger.Add(">> Create table from SAP FuBa was successfull " & resulttable.Rows.Count & " Rows were inserted to table '" & tablename & "'!", False)
MsgBox("Create table was successfull! " & vbNewLine & resulttable.Rows.Count & " Rows were inserted to table '" & tablename & "'!", MsgBoxStyle.Information)
If LogErrorsOnly = False Then ClassLogger.Add(">> Create table from SAP FuBa was successfull " & SAPResulttable.Rows.Count & " Rows were inserted to table '" & tablename & "'!", False)
MsgBox("Create table was successfull! " & vbNewLine & SAPResulttable.Rows.Count & " Rows were inserted to table '" & tablename & "'!", MsgBoxStyle.Information)
Catch ex As Exception
MsgBox("Unexpected Error in SQL bulkCopy: " & ex.Message, MsgBoxStyle.Critical)
Me.Cursor = Cursors.Default
End Try
'######
End If
End Sub
@@ -219,32 +227,19 @@ Public Class frmSAP_FuBa
Private Sub btnGetResult_Click(sender As Object, e As EventArgs) Handles btnGetResult.Click
Dim SAPCon As New R3Connection
Try
Me.Cursor = Cursors.WaitCursor
If LogErrorsOnly = False Then ClassLogger.Add("", False)
If LogErrorsOnly = False Then ClassLogger.Add(">> SAP Connect started:", False)
ERPConnect.LIC.SetLic("W86DWC992C")
SAPCon.Host = HostTextBox.Text
SAPCon.SystemNumber = SystemNumberTextBox.Text
SAPCon.UserName = UserNameTextBox.Text
SAPCon.Password = PasswordTextBox.Text
SAPCon.Client = ClientTextBox.Text
SAPCon.Language = LanguageTextBox.Text
If LogErrorsOnly = False Then ClassLogger.Add(">> HOST: " & HostTextBox.Text & " |SystemNumber: " & SystemNumberTextBox.Text & " |UserName: " & UserNameTextBox.Text & " |Password: " & PasswordTextBox.Text & " |Client: " & ClientTextBox.Text & " |Language: " & LanguageTextBox.Text, False)
SAPCon.Open(False)
If LogErrorsOnly = False Then ClassLogger.Add(">> SAP-Connection created and connected!", False)
If LogErrorsOnly = False Then ClassLogger.Add("", False)
Me.Cursor = Cursors.WaitCursor
If ClassSAP.ConnectionInit(HostTextBox.Text, SystemNumberTextBox.Text, UserNameTextBox.Text, PasswordTextBox.Text, ClientTextBox.Text, LanguageTextBox.Text) = True Then
lblConnectionopen.Visible = True
Catch ex As Exception
ClassLogger.Add(">> Unexpected Error in SAP Connect: " & ex.Message, False)
MsgBox("Unexpected Error in SAP Connect: " & ex.Message, MsgBoxStyle.Critical)
Else
lblConnectionopen.Visible = False
Me.Cursor = Cursors.Default
lblResult.Visible = False
GridControl2.DataSource = Nothing
lblSave.Visible = False
Exit Sub
End Try
End If
Dim SAPResulttable As DataTable = New DataTable
If rbTable.Checked = True Then
Try
@@ -307,192 +302,205 @@ Public Class frmSAP_FuBa
End Try
End If
If rBFuba.Checked = True Then
If LogErrorsOnly = False Then ClassLogger.Add(" >> Get data from FuBa-Function", False)
Dim func As RFCFunction
Try
func = SAPCon.CreateFunction(TableNameTextBox.Text)
If LogErrorsOnly = False Then ClassLogger.Add(" >> func.Execute", False)
func.Execute()
If LogErrorsOnly = False Then ClassLogger.Add(" >> function was executed", False)
Catch ex As Exception
ClassLogger.Add(">> Unexpected Error in Create SAP Function: " & ex.Message, False)
MsgBox("Error in Create SAP Function: " & ex.Message, MsgBoxStyle.Critical)
lblResult.Visible = False
Me.Cursor = Cursors.Default
lblSave.Visible = False
GridControl2.DataSource = Nothing
Exit Sub
End Try
Dim FUNCT_ROW_COUNT As Integer = 1
Dim RowMaskresult As String
Try
If LogErrorsOnly = False Then ClassLogger.Add(" >> Checking FunctionExecute", False)
'Den ersten Wert ausgeben lassen um die Spalten zu splitten
Dim result = ClassSAP.FuBa_Returndatatable_Seperated(TableNameTextBox.Text, FuBa_SplitCharacterTextBox.Text, txtLimitRows.Text)
If Not IsNothing(result) Then
SAPResulttable = result
For Each row As RFCStructure In func.Tables("T_INDEX").Rows
Try
If row.Item(1).ToString.Contains(FuBa_SplitCharacterTextBox.Text) Then
RowMaskresult = row.Item(1).ToString
If LogErrorsOnly = False Then ClassLogger.Add(" >> RowMask result: " & RowMaskresult, False)
FUNCT_ROW_COUNT = 2
End If
Catch ex As Exception
RowMaskresult = "ErrorInGetSeperatedResult: " & ex.Message
End Try
If FUNCT_ROW_COUNT = 2 Then Exit For
Next
Catch ex As Exception
ClassLogger.Add(">> Unexpected Error in Checking FunctionExecute: " & ex.Message, False)
MsgBox("Error in Checking FunctionExecute: " & ex.Message, MsgBoxStyle.Critical)
SAPCon.Close()
lblResult.Visible = False
Me.Cursor = Cursors.Default
lblSave.Visible = False
GridControl2.DataSource = Nothing
Exit Sub
End Try
FUNCT_ROW_COUNT = 1
Dim ColCount As Integer
If FuBa_SplitCharacterTextBox.Text <> "" And RowMaskresult.Contains(FuBa_SplitCharacterTextBox.Text) Then
Try
If LogErrorsOnly = False Then ClassLogger.Add(" >> Define Datatable with SplitCharacter method", False)
Dim split() = RowMaskresult.Split(FuBa_SplitCharacterTextBox.Text)
If split.Length > 0 Then
ColCount = split.Length - 1
If LogErrorsOnly = False Then
ClassLogger.Add(" >> ColCount: " & ColCount.ToString, False)
ClassLogger.Add(" >> Split-Results: ", False)
For Each s As String In split
ClassLogger.Add(" # " & s, False)
Next
End If
For x = 0 To ColCount
' Declare DataColumn and DataRow variables.
Dim column As DataColumn
column = New DataColumn()
column = New DataColumn()
column.DataType = Type.GetType("System.String")
column.ColumnName = "Column " & x.ToString
SAPResulttable.Columns.Add(column)
Next
If LogErrorsOnly = False Then ClassLogger.Add(" >> Datatable Columns after Split created", False)
' Create new DataRow objects and add to DataTable.
'Jetzt die Zeilen der Function durchlaufen
For Each row As RFCStructure In func.Tables("T_INDEX").Rows
Dim new_row As DataRow
If txtLimitRows.Text <> "" Then
If CInt(txtLimitRows.Text) = FUNCT_ROW_COUNT Then
Exit For
End If
End If
new_row = SAPResulttable.NewRow()
Dim Rowresult As String = row.Item(1).ToString
If Rowresult.Contains(FuBa_SplitCharacterTextBox.Text) Then
Dim RowSplit() = RowMaskresult.Split(FuBa_SplitCharacterTextBox.Text)
Dim col_index = 0
'Jetzt die Spaltenwerte in die NewRow eintragen
For x = 0 To ColCount
new_row(x) = RowSplit(x)
Next
SAPResulttable.Rows.Add(new_row)
End If
Next
End If
Catch ex As Exception
ClassLogger.Add(">> Unexpected Error in Create Datatable with split-method: " & ex.Message, False)
MsgBox("Unexpected Error in Create Datatable with split-method: " & ex.Message, MsgBoxStyle.Critical)
SAPCon.Close()
lblResult.Visible = False
Me.Cursor = Cursors.Default
lblSave.Visible = False
GridControl2.DataSource = Nothing
Exit Sub
End Try
Else
If LogErrorsOnly = False Then ClassLogger.Add(" >> Define Datatable WITHOUT SplitCharacter method", False)
' Declare DataColumn and DataRow variables.
Dim column As DataColumn
' Create new DataColumn, set DataType, ColumnName and add to DataTable.
column = New DataColumn()
column.DataType = System.Type.GetType("System.Int32")
column.ColumnName = "id"
SAPResulttable.Columns.Add(column)
' Create second column.
column = New DataColumn()
column.DataType = Type.GetType("System.String")
column.ColumnName = "FuBa-Result"
SAPResulttable.Columns.Add(column)
If LogErrorsOnly = False Then ClassLogger.Add(" >> Datatable Columns created", False)
' Create new DataRow objects and add to DataTable.
Try
For Each row As RFCStructure In func.Tables("T_INDEX").Rows
Dim new_row As DataRow
If LogErrorsOnly = False And FUNCT_ROW_COUNT = 1 Then
ClassLogger.Add(" >> The first 30 rows will be logged", False)
End If
If txtLimitRows.Text <> "" Then
If CInt(txtLimitRows.Text) = FUNCT_ROW_COUNT Then
Exit For
End If
End If
new_row = SAPResulttable.NewRow()
Dim Result As String
Try
Result = row.Item(1).ToString
Catch ex As Exception
Result = "2 Empty"
End Try
new_row("id") = FUNCT_ROW_COUNT
new_row("FuBa-Result") = Result
If LogErrorsOnly = False And FUNCT_ROW_COUNT <= 30 Then
ClassLogger.Add(" >> Result Row: " & Result, False)
End If
FUNCT_ROW_COUNT += 1
SAPResulttable.Rows.Add(new_row)
Next
Catch ex As Exception
ClassLogger.Add(">> Unexpected Error in Create SAP Function-Create Datatable: " & ex.Message, False)
MsgBox("Error in Create Datatable: " & ex.Message, MsgBoxStyle.Critical)
SAPCon.Close()
lblResult.Visible = False
Me.Cursor = Cursors.Default
lblSave.Visible = False
GridControl2.DataSource = Nothing
Exit Sub
End Try
End If
'Jetzt dem Grid die Datasource zuordnen
Try
If SAPResulttable.Rows.Count > 0 Then
GridControl2.DataSource = SAPResulttable
End If
SAPCon.Close()
If txtLimitRows.Text <> "" Then
lblResult.Text = "Result of FuBa (limited to " & txtLimitRows.Text & " rows)"
Else
lblResult.Text = "Result of FuBa (unlimited) >> " & SAPResulttable.Rows.Count & " rows retreived"
End If
lblResult.Visible = True
Me.Cursor = Cursors.Default
lblSave.Visible = False
Catch ex As Exception
SAPCon.Close()
lblResult.Visible = False
Me.Cursor = Cursors.Default
lblSave.Visible = False
GridControl2.DataSource = Nothing
ClassLogger.Add(">> Unexpected Error in GridControl2 >> DataTable 2: " & ex.Message, False)
MsgBox("Error in GridControl2 >> DataTable: " & ex.Message, MsgBoxStyle.Critical)
End Try
'If LogErrorsOnly = False Then ClassLogger.Add(" >> Get data from FuBa-Function", False)
'Dim func As RFCFunction
'Try
' func = SAPCon.CreateFunction(TableNameTextBox.Text)
' If LogErrorsOnly = False Then ClassLogger.Add(" >> func.Execute", False)
' func.Execute()
' If LogErrorsOnly = False Then ClassLogger.Add(" >> function was executed", False)
'Catch ex As Exception
' ClassLogger.Add(">> Unexpected Error in Create SAP Function: " & ex.Message, False)
' MsgBox("Error in Create SAP Function: " & ex.Message, MsgBoxStyle.Critical)
' lblResult.Visible = False
' Me.Cursor = Cursors.Default
' lblSave.Visible = False
' GridControl2.DataSource = Nothing
' Exit Sub
'End Try
'Dim FUNCT_ROW_COUNT As Integer = 1
'Dim RowMaskresult As String
'Try
' If LogErrorsOnly = False Then ClassLogger.Add(" >> Checking FunctionExecute", False)
' 'Den ersten Wert ausgeben lassen um die Spalten zu splitten
' For Each row As RFCStructure In func.Tables("T_INDEX").Rows
' Try
' If row.Item(1).ToString.Contains(FuBa_SplitCharacterTextBox.Text) Then
' RowMaskresult = row.Item(1).ToString
' If LogErrorsOnly = False Then ClassLogger.Add(" >> RowMask result: " & RowMaskresult, False)
' FUNCT_ROW_COUNT = 2
' End If
' Catch ex As Exception
' RowMaskresult = "ErrorInGetSeperatedResult: " & ex.Message
' End Try
' If FUNCT_ROW_COUNT = 2 Then Exit For
' Next
'Catch ex As Exception
' ClassLogger.Add(">> Unexpected Error in Checking FunctionExecute: " & ex.Message, False)
' MsgBox("Error in Checking FunctionExecute: " & ex.Message, MsgBoxStyle.Critical)
' SAPCon.Close()
' lblResult.Visible = False
' Me.Cursor = Cursors.Default
' lblSave.Visible = False
' GridControl2.DataSource = Nothing
' Exit Sub
'End Try
'FUNCT_ROW_COUNT = 1
'Dim ColCount As Integer
'If FuBa_SplitCharacterTextBox.Text <> "" And RowMaskresult.Contains(FuBa_SplitCharacterTextBox.Text) Then
' Try
' If LogErrorsOnly = False Then ClassLogger.Add(" >> Define Datatable with SplitCharacter method", False)
' Dim split() = RowMaskresult.Split(FuBa_SplitCharacterTextBox.Text)
' If split.Length > 0 Then
' ColCount = split.Length - 1
' If LogErrorsOnly = False Then
' ClassLogger.Add(" >> ColCount: " & ColCount.ToString, False)
' ClassLogger.Add(" >> Split-Results: ", False)
' For Each s As String In split
' ClassLogger.Add(" # " & s, False)
' Next
' End If
' For x = 0 To ColCount
' ' Declare DataColumn and DataRow variables.
' Dim column As DataColumn
' column = New DataColumn()
' column = New DataColumn()
' column.DataType = Type.GetType("System.String")
' column.ColumnName = "Column " & x.ToString
' SAPResulttable.Columns.Add(column)
' Next
' If LogErrorsOnly = False Then ClassLogger.Add(" >> Datatable Columns after Split created", False)
' ' Create new DataRow objects and add to DataTable.
' 'Jetzt die Zeilen der Function durchlaufen
' For Each row As RFCStructure In func.Tables("T_INDEX").Rows
' Dim new_row As DataRow
' If txtLimitRows.Text <> "" Then
' If CInt(txtLimitRows.Text) = FUNCT_ROW_COUNT Then
' If LogErrorsOnly = False Then ClassLogger.Add(" >> RowCount limited to" & txtLimitRows.Text & " rows. Exit SAP Function", False)
' Exit For
' End If
' End If
' new_row = SAPResulttable.NewRow()
' Dim Rowresult As String = row.Item(1).ToString
' If Rowresult.Contains(FuBa_SplitCharacterTextBox.Text) Then
' Dim RowSplit() = Rowresult.Split(FuBa_SplitCharacterTextBox.Text)
' Dim col_index = 0
' 'Jetzt die Spaltenwerte in die NewRow eintragen
' For x = 0 To ColCount
' new_row(x) = RowSplit(x)
' Next
' FUNCT_ROW_COUNT += 1
' SAPResulttable.Rows.Add(new_row)
' End If
' Next
' End If
' Catch ex As Exception
' ClassLogger.Add(">> Unexpected Error in Create Datatable with split-method: " & ex.Message, False)
' MsgBox("Unexpected Error in Create Datatable with split-method: " & ex.Message, MsgBoxStyle.Critical)
' SAPCon.Close()
' lblResult.Visible = False
' Me.Cursor = Cursors.Default
' lblSave.Visible = False
' GridControl2.DataSource = Nothing
' Exit Sub
' End Try
'Else
' If LogErrorsOnly = False Then ClassLogger.Add(" >> Define Datatable WITHOUT SplitCharacter method", False)
' ' Declare DataColumn and DataRow variables.
' Dim column As DataColumn
' ' Create new DataColumn, set DataType, ColumnName and add to DataTable.
' column = New DataColumn()
' column.DataType = System.Type.GetType("System.Int32")
' column.ColumnName = "id"
' SAPResulttable.Columns.Add(column)
' ' Create second column.
' column = New DataColumn()
' column.DataType = Type.GetType("System.String")
' column.ColumnName = "FuBa-Result"
' SAPResulttable.Columns.Add(column)
' If LogErrorsOnly = False Then ClassLogger.Add(" >> Datatable Columns created", False)
' ' Create new DataRow objects and add to DataTable.
' Try
' For Each row As RFCStructure In func.Tables("T_INDEX").Rows
' Dim new_row As DataRow
' If LogErrorsOnly = False And FUNCT_ROW_COUNT = 1 Then
' ClassLogger.Add(" >> The first 30 rows will be logged", False)
' End If
' If txtLimitRows.Text <> "" Then
' If CInt(txtLimitRows.Text) = FUNCT_ROW_COUNT Then
' Exit For
' End If
' End If
' new_row = SAPResulttable.NewRow()
' Dim Result As String
' Try
' Result = row.Item(1).ToString
' Catch ex As Exception
' Result = "2 Empty"
' End Try
' new_row("id") = FUNCT_ROW_COUNT
' new_row("FuBa-Result") = Result
' If LogErrorsOnly = False And FUNCT_ROW_COUNT <= 30 Then
' ClassLogger.Add(" >> Result Row: " & Result, False)
' End If
' FUNCT_ROW_COUNT += 1
' SAPResulttable.Rows.Add(new_row)
' Next
' Catch ex As Exception
' ClassLogger.Add(">> Unexpected Error in Create SAP Function-Create Datatable: " & ex.Message, False)
' MsgBox("Error in Create Datatable: " & ex.Message, MsgBoxStyle.Critical)
' SAPCon.Close()
' lblResult.Visible = False
' Me.Cursor = Cursors.Default
' lblSave.Visible = False
' GridControl2.DataSource = Nothing
' Exit Sub
' End Try
End If
If SAPResulttable Is Nothing Then
SAPCon.Close()
lblResult.Visible = False
Me.Cursor = Cursors.Default
lblSave.Visible = False
GridControl2.DataSource = Nothing
ClassLogger.Add(">> SAPResulttable is nothing", False)
End If
'Jetzt dem Grid die Datasource zuordnen
Try
If SAPResulttable.Rows.Count > 0 Then
GridControl2.DataSource = SAPResulttable
End If
SAPCon.Close()
If txtLimitRows.Text <> "" Then
lblResult.Text = "Result of FuBa (limited to " & txtLimitRows.Text & " rows)"
Else
lblResult.Text = "Result of FuBa (unlimited) >> " & SAPResulttable.Rows.Count & " rows retreived"
End If
lblResult.Visible = True
Me.Cursor = Cursors.Default
lblSave.Visible = False
Catch ex As Exception
SAPCon.Close()
lblResult.Visible = False
Me.Cursor = Cursors.Default
lblSave.Visible = False
GridControl2.DataSource = Nothing
ClassLogger.Add(">> Unexpected Error in GridControl2 >> DataTable 2: " & ex.Message, False)
MsgBox("Error in GridControl2 >> DataTable: " & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
Private Sub rBFuba_CheckedChanged(sender As Object, e As EventArgs) Handles rBFuba.CheckedChanged