DAtabase integriert
This commit is contained in:
@@ -8,16 +8,16 @@ Public Class ClassSAP
|
||||
Private Shared NewDatatable As DataTable
|
||||
Public Shared Function ConnectionInit(Host As String, SysNumber As String, Username As String, PW As String, Client As String, Lang As String)
|
||||
Try
|
||||
LOGGER.Debug("", False)
|
||||
LOGGER.Debug("SAP Connect started:", False)
|
||||
LOGGER.Debug("")
|
||||
LOGGER.Debug("SAP Connect started:")
|
||||
SAPConnectionString = String.Format("USER={0} LANG={1} CLIENT={2} SYSNR={3} ASHOST={4} PASSWD={5}", Username, Lang, Client, SysNumber, Host, PW)
|
||||
Dim con As New R3Connection()
|
||||
ERPConnect.LIC.SetLic("W86DWC992C")
|
||||
LOGGER.Debug("SAP Connectionstring: " & SAPConnectionString, False)
|
||||
LOGGER.Debug("SAP Connectionstring: " & SAPConnectionString)
|
||||
con.Open(SAPConnectionString)
|
||||
SAP_CONNECTION.Open(SAPConnectionString)
|
||||
LOGGER.Debug("SAP-Connection created!", False)
|
||||
LOGGER.Debug("", False)
|
||||
LOGGER.Debug("SAP-Connection created!")
|
||||
LOGGER.Debug("")
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
MsgBox("Error in SAP ConnectionInit: " & ex.Message, MsgBoxStyle.Critical)
|
||||
@@ -29,29 +29,29 @@ Public Class ClassSAP
|
||||
Try
|
||||
Dim RESULT_TABLE As DataTable = New DataTable
|
||||
|
||||
LOGGER.Debug("Get data from FuBa-Function", False)
|
||||
LOGGER.Debug("Get data from FuBa-Function")
|
||||
Dim func As RFCFunction
|
||||
Try
|
||||
func = SAP_CONNECTION.CreateFunction(FuBaName)
|
||||
LOGGER.Debug("func.Execute", False)
|
||||
LOGGER.Debug("func.Execute")
|
||||
func.Execute()
|
||||
LOGGER.Debug("function was executed", False)
|
||||
LOGGER.Debug("function was executed")
|
||||
Catch ex As Exception
|
||||
LOGGER.Warn("Unexpected Error in Create SAP Function: " & ex.Message, False)
|
||||
LOGGER.Warn("Unexpected Error in Create SAP Function: " & ex.Message)
|
||||
MsgBox("Error in Create SAP Function: " & ex.Message, MsgBoxStyle.Critical)
|
||||
Return Nothing
|
||||
End Try
|
||||
Dim FUNCT_ROW_COUNT As Integer = 1
|
||||
Dim RowMaskresult As String = ""
|
||||
Try
|
||||
LOGGER.Debug("Checking FunctionExecute", False)
|
||||
LOGGER.Debug("Checking FunctionExecute")
|
||||
'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(SplitCharacter) Then
|
||||
RowMaskresult = row.Item(1).ToString
|
||||
LOGGER.Debug("RowMask result: " & RowMaskresult, False)
|
||||
LOGGER.Debug("RowMask result: " & RowMaskresult)
|
||||
FUNCT_ROW_COUNT = 2
|
||||
End If
|
||||
Catch ex As Exception
|
||||
@@ -60,7 +60,7 @@ Public Class ClassSAP
|
||||
If FUNCT_ROW_COUNT = 2 Then Exit For
|
||||
Next
|
||||
Catch ex As Exception
|
||||
LOGGER.Warn("Unexpected Error in Checking FunctionExecute: " & ex.Message, False)
|
||||
LOGGER.Warn("Unexpected Error in Checking FunctionExecute: " & ex.Message)
|
||||
MsgBox("Error in Checking FunctionExecute: " & ex.Message, MsgBoxStyle.Critical)
|
||||
SAP_CONNECTION.Close()
|
||||
Return Nothing
|
||||
@@ -69,16 +69,16 @@ Public Class ClassSAP
|
||||
Dim ColCount As Integer
|
||||
If SplitCharacter <> "" And RowMaskresult.Contains(SplitCharacter) Then
|
||||
Try
|
||||
LOGGER.Debug("Define Datatable with SplitCharacter method", False)
|
||||
LOGGER.Debug("Define Datatable with SplitCharacter method")
|
||||
Dim split() = RowMaskresult.Split(SplitCharacter)
|
||||
If split.Length > 0 Then
|
||||
ColCount = split.Length - 1
|
||||
CURRENT_COL_COUNT = ColCount
|
||||
|
||||
LOGGER.Debug("ColCount: " & ColCount.ToString, False)
|
||||
LOGGER.Debug("Split-Results: ", False)
|
||||
LOGGER.Debug("ColCount: " & ColCount.ToString)
|
||||
LOGGER.Debug("Split-Results: ")
|
||||
For Each s As String In split
|
||||
LOGGER.Debug(" # " & s, False)
|
||||
LOGGER.Debug(" # " & s)
|
||||
Next
|
||||
|
||||
For x = 0 To ColCount
|
||||
@@ -90,14 +90,14 @@ Public Class ClassSAP
|
||||
column.ColumnName = "Column " & x.ToString
|
||||
RESULT_TABLE.Columns.Add(column)
|
||||
Next
|
||||
LOGGER.Debug("Datatable Columns after Split created", False)
|
||||
LOGGER.Debug("Datatable Columns after Split created")
|
||||
' 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 RowLimit <> 0 Then
|
||||
If RowLimit = FUNCT_ROW_COUNT Then
|
||||
LOGGER.Debug("RowCount limited to" & RowLimit.ToString & " rows. Exit SAP Function", False)
|
||||
LOGGER.Debug("RowCount limited to" & RowLimit.ToString & " rows. Exit SAP Function")
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
@@ -114,13 +114,13 @@ Public Class ClassSAP
|
||||
RESULT_TABLE.Rows.Add(new_row)
|
||||
End If
|
||||
Next
|
||||
LOGGER.Debug("RowCount FuBa: " & RESULT_TABLE.Rows.Count.ToString, False)
|
||||
LOGGER.Debug("RowCount FuBa: " & RESULT_TABLE.Rows.Count.ToString)
|
||||
Return RESULT_TABLE
|
||||
Else
|
||||
Return Nothing
|
||||
End If
|
||||
Catch ex As Exception
|
||||
LOGGER.Warn("Unexpected Error in Create Datatable with split-method: " & ex.Message, False)
|
||||
LOGGER.Warn("Unexpected Error in Create Datatable with split-method: " & ex.Message)
|
||||
MsgBox("Unexpected Error in Create Datatable with split-method: " & ex.Message, MsgBoxStyle.Critical)
|
||||
SAP_CONNECTION.Close()
|
||||
Return Nothing
|
||||
@@ -129,7 +129,7 @@ Public Class ClassSAP
|
||||
Return Nothing
|
||||
End If
|
||||
Catch ex As Exception
|
||||
LOGGER.Warn("Unexpected Error in Function FuBa_ReturnDatatable Seperated: " & ex.Message, False)
|
||||
LOGGER.Warn("Unexpected Error in Function FuBa_ReturnDatatable Seperated: " & ex.Message)
|
||||
MsgBox("Unexpected Error in Function FuBa_ReturnDatatable Seperated: " & ex.Message, MsgBoxStyle.Critical)
|
||||
Return Nothing
|
||||
End Try
|
||||
@@ -165,14 +165,14 @@ Public Class ClassSAP
|
||||
If RowLimit <> 0 Then
|
||||
oReadTable.RowCount = RowLimit
|
||||
End If
|
||||
LOGGER.Debug("Table.Run executing.....", False)
|
||||
LOGGER.Debug("Table.Run executing.....")
|
||||
read = oReadTable
|
||||
read.Run()
|
||||
|
||||
LOGGER.Debug("Table.Run executed", False)
|
||||
LOGGER.Debug("Table.Run executed")
|
||||
RESULT_TABLE = read.Result
|
||||
If Not IsNothing(NewDatatable) Then
|
||||
LOGGER.Debug($"Got [{NewDatatable.Rows.Count}] rows", False)
|
||||
LOGGER.Debug($"Got [{NewDatatable.Rows.Count}] rows")
|
||||
End If
|
||||
|
||||
SAP_CONNECTION.Close()
|
||||
@@ -188,7 +188,7 @@ Public Class ClassSAP
|
||||
|
||||
Public Shared Function LINK_ARC_OBJECT(table As String, barcode As String, contrep As String, docid As String, ardate As String, doctype As String)
|
||||
Try
|
||||
LOGGER.Debug("CREATE_ARC_OBJECT", False)
|
||||
LOGGER.Debug("CREATE_ARC_OBJECT")
|
||||
Dim sapfunc As RFCFunction = SAP_CONNECTION.CreateFunction("BAPI_BARCODE_SENDLIST")
|
||||
|
||||
'Create and fill the frist row
|
||||
@@ -213,14 +213,14 @@ Public Class ClassSAP
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
LOGGER.Warn("Unexpected Error in SAP Table Result: " & ex.Message, False)
|
||||
LOGGER.Warn("Unexpected Error in SAP Table Result: " & ex.Message)
|
||||
MsgBox("Unexpected Error in CREATE_ARC_OBJECT: " & ex.Message, MsgBoxStyle.Critical)
|
||||
Return ex.Message
|
||||
End Try
|
||||
End Function
|
||||
Public Shared Function INSERT_ARCHIVE_OBJECT(ARCHIV_ID As String, ARC_DOC_ID As String, AR_OBJECT As String, OBJECT_ID As String, SAP_OBJECT As String, DOC_TYPE As String, table As String)
|
||||
Try
|
||||
LOGGER.Debug("INSERT_ARCHIVE_OBJECT", False)
|
||||
LOGGER.Debug("INSERT_ARCHIVE_OBJECT")
|
||||
Dim sapfunc As RFCFunction = SAP_CONNECTION.CreateFunction("ARCHIV_CONNECTION_INSERT")
|
||||
|
||||
'Create and fill the frist row
|
||||
@@ -250,7 +250,7 @@ Public Class ClassSAP
|
||||
Return ""
|
||||
|
||||
Catch ex As Exception
|
||||
LOGGER.Warn("Unexpected Error in INSERT_ARCHIVE_OBJECT: " & ex.Message, False)
|
||||
LOGGER.Warn("Unexpected Error in INSERT_ARCHIVE_OBJECT: " & ex.Message)
|
||||
MsgBox("Unexpected Error in INSERT_ARCHIVE_OBJECT: " & ex.Message, MsgBoxStyle.Critical)
|
||||
Return ex.Message
|
||||
End Try
|
||||
|
||||
Reference in New Issue
Block a user