MS22062016_2

This commit is contained in:
SchreiberM
2016-06-22 16:06:34 +02:00
parent b85ed334e4
commit 3df7d269e9
9 changed files with 122 additions and 320 deletions

View File

@@ -265,231 +265,15 @@ Public Class frmSAP_FuBa
Dim SAPResulttable As DataTable = New DataTable
If rbTable.Checked = True Then
Try
If LogErrorsOnly = False Then ClassLogger.Add(">> Get data from SAP Table", False)
Dim table As New ERPConnect.Utils.ReadTable(ClassSAP.SAP_CONNECTION)
'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
'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
If LogErrorsOnly = False Then ClassLogger.Add(">>Table.Run executed", False)
table.Run()
SAPResulttable = table.Result
Try
GridControl2.DataSource = SAPResulttable
Catch ex As Exception
ClassLogger.Add(">> Unexpected Error in GridControl2 >> DataTable 1: " & ex.Message, False)
MsgBox("Unexpected Error in GridControl2 >> DataTable: " & ex.Message, MsgBoxStyle.Critical)
lblResult.Visible = False
Me.Cursor = Cursors.Default
lblSave.Visible = False
GridControl2.DataSource = Nothing
End Try
Dim i As Integer
'For Each row As DataRow In resulttable.Rows
' ClassLogger.Add(">> " & row.Item(0).ToString & "|" & row.Item(1).ToString & "|" & row.Item(2).ToString)
'Next
ClassSAP.SAP_CONNECTION.Close()
If txtLimitRows.Text <> "" Then
lblResult.Text = "Result of SAP Table (limited to " & txtLimitRows.Text & " rows)"
Else
lblResult.Text = "Result of SAP Table (unlimited) >> " & SAPResulttable.Rows.Count & " rows retreived"
End If
lblResult.Visible = True
Me.Cursor = Cursors.Default
lblSave.Visible = False
Catch ex As Exception
sw.Stop()
ClassLogger.Add(">> Unexpected Error in SAP Table Result: " & ex.Message, False)
MsgBox("Unexpected Error in SAP Table Result: " & ex.Message, MsgBoxStyle.Critical)
lblResult.Visible = False
Me.Cursor = Cursors.Default
lblSave.Visible = False
GridControl2.DataSource = Nothing
End Try
End If
If rBFuba.Checked = True Then
Dim result = ClassSAP.Return_Datatable_for_Table(TableNameTextBox.Text, WHERE_CLAUSETextBox.Text, txtLimitRows.Text)
If Not IsNothing(result) Then
SAPResulttable = result
End If
ElseIf rBFuba.Checked = True Then 'FUBA Abruf
Dim result = ClassSAP.FuBa_Returndatatable_Seperated(TableNameTextBox.Text, FuBa_SplitCharacterTextBox.Text, txtLimitRows.Text)
If Not IsNothing(result) Then
SAPResulttable = result
End If
'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
ClassSAP.SAP_CONNECTION.Close()
@@ -499,6 +283,7 @@ Public Class frmSAP_FuBa
GridControl2.DataSource = Nothing
sw.Stop()
ClassLogger.Add(">> SAPResulttable is nothing", False)
Exit Sub
End If
@@ -513,9 +298,9 @@ Public Class frmSAP_FuBa
elapsed = sw.Elapsed.TotalSeconds
sw.Stop()
If txtLimitRows.Text <> "" And SAPResulttable.Rows.Count >= CInt(txtLimitRows.Text) Then
lblResult.Text = "Result of FuBa (limited to " & txtLimitRows.Text & " rows) - Duration: " & Format(elapsed, "0.00") & " seconds"
lblResult.Text = "Result (limited to " & txtLimitRows.Text & " rows) - Duration: " & Format(elapsed, "0.00") & " seconds"
Else
lblResult.Text = "Result of FuBa (unlimited) >> " & SAPResulttable.Rows.Count & " rows retrieved - Duration: " & Format(elapsed, "0.00") & " seconds"
lblResult.Text = "Result (unlimited) >> " & SAPResulttable.Rows.Count & " rows retrieved - Duration: " & Format(elapsed, "0.00") & " seconds"
End If
lblResult.Visible = True
Me.Cursor = Cursors.Default