MS_SAP
This commit is contained in:
@@ -39,8 +39,8 @@ Public Class frmSAP_FuBa
|
||||
Dim con As New R3Connection
|
||||
Try
|
||||
Me.Cursor = Cursors.WaitCursor
|
||||
ClassLogger.Add("", False)
|
||||
ClassLogger.Add(">> SAP Connect started:", False)
|
||||
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
|
||||
@@ -48,16 +48,17 @@ Public Class frmSAP_FuBa
|
||||
con.Password = PasswordTextBox.Text
|
||||
con.Client = ClientTextBox.Text
|
||||
con.Language = LanguageTextBox.Text
|
||||
ClassLogger.Add(">> HOST: " & HostTextBox.Text & " |SystemNumber: " & SystemNumberTextBox.Text & " |UserName: " & UserNameTextBox.Text & " |Password: " & PasswordTextBox.Text & " |Client: " & ClientTextBox.Text & " |Language: " & LanguageTextBox.Text, False)
|
||||
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)
|
||||
ClassLogger.Add(">> SAP-Connection erfolgreich aufgebaut!", False)
|
||||
ClassLogger.Add("", False)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(">> SAP-Connection erfolgreich aufgebaut!", False)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add("", False)
|
||||
lblConnectionopen.Visible = True
|
||||
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
|
||||
Exit Sub
|
||||
End Try
|
||||
Try
|
||||
@@ -77,7 +78,10 @@ Public Class frmSAP_FuBa
|
||||
' table.AddCriteria("SPRAS = 'DE'")
|
||||
|
||||
table.TableName = TableNameTextBox.Text
|
||||
table.RowCount = 1000
|
||||
If txtLimitRows.Text <> "" Then
|
||||
table.RowCount = CInt(txtLimitRows.Text)
|
||||
End If
|
||||
|
||||
|
||||
table.Run()
|
||||
|
||||
@@ -94,11 +98,18 @@ Public Class frmSAP_FuBa
|
||||
' ClassLogger.Add(">> " & row.Item(0).ToString & "|" & row.Item(1).ToString & "|" & row.Item(2).ToString)
|
||||
'Next
|
||||
con.Close()
|
||||
If txtLimitRows.Text <> "" Then
|
||||
lblResult.Text = "Result of FuBa (limited to " & txtLimitRows.Text & " rows)"
|
||||
Else
|
||||
lblResult.Text = "Result of FuBa (unlimited) >> " & resulttable.Rows.Count & " rows retreived"
|
||||
End If
|
||||
lblResult.Visible = True
|
||||
Me.Cursor = Cursors.Default
|
||||
Catch ex As Exception
|
||||
MsgBox("Unexpected Error in SAP Table Result: " & ex.Message, MsgBoxStyle.Critical)
|
||||
lblResult.Visible = False
|
||||
Me.Cursor = Cursors.Default
|
||||
GridControl2.DataSource = Nothing
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -117,8 +128,8 @@ Public Class frmSAP_FuBa
|
||||
Dim con As New R3Connection
|
||||
Try
|
||||
Me.Cursor = Cursors.WaitCursor
|
||||
ClassLogger.Add("", False)
|
||||
ClassLogger.Add(">> SAP Connect started:", False)
|
||||
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
|
||||
@@ -126,10 +137,10 @@ Public Class frmSAP_FuBa
|
||||
con.Password = PasswordTextBox.Text
|
||||
con.Client = ClientTextBox.Text
|
||||
con.Language = LanguageTextBox.Text
|
||||
ClassLogger.Add(">> HOST: " & HostTextBox.Text & " |SystemNumber: " & SystemNumberTextBox.Text & " |UserName: " & UserNameTextBox.Text & " |Password: " & PasswordTextBox.Text & " |Client: " & ClientTextBox.Text & " |Language: " & LanguageTextBox.Text, False)
|
||||
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)
|
||||
ClassLogger.Add(">> SAP-Connection erfolgreich aufgebaut!", False)
|
||||
ClassLogger.Add("", 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)
|
||||
Me.Cursor = Cursors.Default
|
||||
@@ -153,11 +164,14 @@ Public Class frmSAP_FuBa
|
||||
' table.AddCriteria("SPRAS = 'DE'")
|
||||
|
||||
table.TableName = TableNameTextBox.Text
|
||||
If txtLimitRows.Text <> "" Then
|
||||
table.RowCount = CInt(txtLimitRows.Text)
|
||||
End If
|
||||
table.Run()
|
||||
|
||||
resulttable = table.Result
|
||||
ClassLogger.Add(">> resulttable created!", False)
|
||||
ClassLogger.Add("", False)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(">> resulttable created!", False)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add("", False)
|
||||
|
||||
Catch ex As Exception
|
||||
Me.Cursor = Cursors.Default
|
||||
@@ -185,9 +199,10 @@ Public Class frmSAP_FuBa
|
||||
End If
|
||||
|
||||
'Die Tabelle anlegen
|
||||
ClassLogger.Add(">> Create Table: " & createtablesql, False)
|
||||
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
|
||||
End If
|
||||
Try
|
||||
@@ -200,18 +215,19 @@ Public Class frmSAP_FuBa
|
||||
Using bulkCopy As SqlBulkCopy = _
|
||||
New SqlBulkCopy(SQLconnect)
|
||||
bulkCopy.DestinationTableName = tablename
|
||||
|
||||
Try
|
||||
' Write from the source to the destination.
|
||||
bulkCopy.WriteToServer(resulttable)
|
||||
|
||||
Catch ex As Exception
|
||||
Console.WriteLine(ex.Message)
|
||||
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)
|
||||
Catch ex As Exception
|
||||
MsgBox("Unexpected Error in Get SAP Table Result: " & ex.Message, MsgBoxStyle.Critical)
|
||||
MsgBox("Unexpected Error in SQL bulkCopy: " & ex.Message, MsgBoxStyle.Critical)
|
||||
Me.Cursor = Cursors.Default
|
||||
End Try
|
||||
End If
|
||||
|
||||
Reference in New Issue
Block a user