Created
December 1, 2023 23:13
-
-
Save SidVal/d2814ba643284d421a7cc47894ca0fb3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If Session.ActiveWindow.Text = "Error" Then Err.Raise 99 ' error detected? | |
' | |
' find the collection object that contains the Message from the bottom of the SAP screen and write the message to Excel | |
Info (17) ' puts the Message in the 17th column on the Excel Spreadsheet - column "Q" | |
' | |
If Session.ActiveWindow.Name = "wnd[1]" And Session.ActiveWindow.Text = "Log Off" Then | |
Session.findById("wnd[1]/usr/btnSPOP-OPTION2").press | |
Sheets("SAP_DATA").Cells(lDataRow, 16) = "error" | |
End If | |
'------------------------------------------------------- | |
Exit Sub | |
ErrorHandler: | |
Sleep (1000) | |
'return the error message 3/4/06 - *** | |
sMessage = "Error # " & Str(Err.Number) & " was generated by " _ | |
& Err.Source & Chr(13) & Err.Description '& Err.HelpFile & Err.HelpContext | |
Sheets("SAP_DATA").Cells(lDataRow, 21) = sMessage | |
'--------------------------------- | |
If StopOnErrors = vbYes Then | |
Application.WindowState = xlMaximized | |
If lDataRow > 10 Then ActiveWindow.ScrollRow = lDataRow - 5 | |
StopOnErrors = MsgBox("Do you want to Stop On the next Error ?", vbYesNo, "Error Found") | |
Application.WindowState = xlMinimized | |
Else | |
If Session.ActiveWindow.Name = "wnd[1]" And Session.ActiveWindow.Type = "GuiModalWindow" Then ' Information Pop Up Box exists | |
Sheets("SAP_DATA").Cells(lDataRow, 22) = Session.ActiveWindow.PopupDialogText ' capture message | |
Session.findById("wnd[0]/tbar[0]/btn[0]").press '- enter key | |
End If | |
Info iColumn 'capture any SAP message and write to excel | |
'test the message | |
If Session.ActiveWindow.children.Count > 1 Then ' see if the collection item exists | |
If Session.ActiveWindow.children.Item((Session.ActiveWindow.children.Count - 1)).Text <> "" Then 'message exists | |
If Session.ActiveWindow.children.Item((Session.ActiveWindow.children.Count - 1)).MessageType <> "E" Then Session.findById("wnd[0]/tbar[0]/btn[0]").press 'enter through warnings and Informational messages | |
End If |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'Para ocultar el proceso | |
Application.ScreenUpdating = False | |
'Declaration | |
Dim objBAPIControl As Object 'Function Control (Collective object) | |
Dim sapConnection As Object 'Connection object | |
Dim Total | |
Dim MyFunc As Object | |
' Assign. | |
Set objBAPIControl = CreateObject("SAP.Functions") | |
Set sapConnection = objBAPIControl.Connection | |
'Logon with initial values Credenciales de conexcion | |
sapConnection.Client = "mandante" | |
sapConnection.User = "usuario" | |
sapConnection.Password = "contraseña" | |
sapConnection.SystemNumber = 1 | |
sapConnection.System = "system" | |
sapConnection.HostName = "hostname" | |
sapConnection.Language = "ES" | |
If sapConnection.logon(1, True) <> True Then | |
MsgBox "No connection to R/3!" | |
Exit Sub | |
End If | |
Dim SEL_TAB, NAMETAB, TABENTRY, ROW As Object | |
Dim Result As Boolean | |
Dim iRow, iColumn, iStart, iStartRow As Integer | |
iStartRow = 4 | |
Sheets("Obj_ORD").Select | |
Cells.Clear | |
'***************************************************** | |
'Call RFC function TABLE_ENTRIES_GET_VIA_RFC | |
'***************************************************** | |
Set MyFunc = objBAPIControl.Add("TABLE_ENTRIES_GET_VIA_RFC") | |
Dim oParam1 As Object | |
Dim oParam2 As Object | |
Dim oParam3 As Object | |
Dim oParam4 As Object | |
Dim lv_text As String | |
Dim lv_contador As Integer | |
'Descripción de la orden | |
oParam1.Value = "E" | |
oParam2.Value = "" | |
oParam3.Value = "E07T" | |
Dim lv_orden | |
lv_orden = "TRKORR = '" + orden + "'" | |
If lv_orden <> "" Then | |
oParam4.Rows.Add | |
oParam4.Value(1, "ZEILE") = lv_orden | |
End If | |
Result = MyFunc.Call | |
If Result = True Then | |
Set NAMETAB = MyFunc.Tables("NAMETAB") | |
Set SEL_TAB = MyFunc.Tables("SEL_TAB") | |
Set TABENTRY = MyFunc.Tables("TABENTRY") | |
Else | |
MsgBox MyFunc.EXCEPTION | |
objBAPIControl.Connection.LOGOFF | |
Exit Sub | |
End If | |
If Result <> True Then | |
MsgBox (EXCEPTION) | |
Exit Sub | |
End If | |
'Display Contents of the table | |
lv_rango = "D" + CStr(fila) | |
Range(lv_rango).Select | |
'Extraemos desde la pos 21, 60 caracteres de la entrada 1 | |
Range(lv_rango).Value = Mid(TABENTRY(1, "ENTRY"), 22, 60) | |
Range(lv_rango).EntireRow.AutoFit | |
'******************************************* | |
'Quit the SAP Application | |
'******************************************* | |
objBAPIControl.Connection.LOGOFF | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dim Logoncontrol As Object | |
Dim objBAPIControl As Object | |
Dim sapConnection As Object | |
Dim Total | |
Dim MyFunc As Object | |
' Assign. | |
Set Logoncontrol = CreateObject("SAP.LogonControl.1") | |
Set objBAPIControl = CreateObject("SAP.Functions") | |
Set sapConnection = Logoncontrol.NewConnection | |
'Logon with initial values Credenciales de conexcion | |
sapConnection.Client = "200" | |
sapConnection.ApplicationServer = "10.10.0.111" | |
sapConnection.User = "USUARIO" | |
sapConnection.Password = "PASSWORD" | |
sapConnection.SystemNumber = "00" | |
sapConnection.System = "EMD" | |
sapConnection.UseSAPLogonIni = False | |
sapConnection.Language = "ES" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment