I need help identifying the exact cause of the error # Login failed in my workflow. The error is being displayed in OpenRPA, but it seems that the login was successful because the credentials were accepted, and I can see the “SAP Menu”. However, one second later, the error appears.
This is my logs:
[14:24:27.779][Debug] Received reply: 6977 getconnections
[14:24:27.719][Debug] Sending: 6977 getconnections
[14:24:12.319][Debug] Deleted 2 items from workflow history.
[14:24:06.856][Output] RPA007DSI-ResetContaSAP failed at 1.118 in 00:18.106
# Global/RPA002GBL-LoginSAP failed with Login failed
[14:24:06.740][Debug] InitializeStateEnvironment
[14:24:06.738][Error] System.Exception: Global/RPA002GBL-LoginSAP failed with Login failed ---> System.Exception: Login failed
at OpenRPA.SAP.SAPhook.SendMessage(SAPEvent message, TimeSpan timeout)
at OpenRPA.SAP.Login.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
--- End of inner exception stack trace ---
at OpenRPA.Activities.InvokeOpenRPA.OnBookmarkCallback(NativeActivityContext context, Bookmark bookmark, Object obj)
[14:24:06.731][Information] RPA007DSI-ResetContaSAP resumed
[14:24:06.511][Output] RPA002GBL-LoginSAP failed at 1.64 in 00:04.226
# Login failed
[14:24:06.507][Debug] Received reply: 6975 login
[14:24:02.295][Debug] Sending: 6975 login
[14:24:02.292][Debug] Received reply: 6973 getconnections
[14:24:02.287][Debug] Sending: 6973 getconnections
[14:24:02.284][Information] RPA002GBL-LoginSAP started in 00:00.000
[14:23:57.706][Debug] Received reply: 6971 getconnections
[14:23:57.687][Debug] Sending: 6971 getconnections
[14:23:55.336][Debug] Header (add to line numbers): 45
[14:23:54.403][Debug] Deleted 1 items from workflow history.
[14:23:49.230][Information] RPA007DSI-ResetContaSAP resumed
[14:23:48.878][Output] RPA001GBL-GetPlatformData completed in 00:00.150
[14:23:48.727][Information] RPA001GBL-GetPlatformData started in 00:00.000
[14:23:48.633][Information] RPA007DSI-ResetContaSAP started in 00:00.000
Hi @kowts.
I have the same problem, but I end up leaving the project (didn’t find any solution or reason for why it happened) and start another, different project.
I hope someone can help with this, it’s really weird.
In my case, clearly the login was successful, but OpenRPA says that “System.Exception: Login failed.”
I don’t have access to SAP anymore, so is hard to support and troubleshoot.
Test that there is no conflicting server settings that is blocking SAP GUI scripting.
Normally setting sapgui/user_scripting to true is enough, but a few months ago I was helping troubleshoot an installation where it turned out there was another setting that would block the use from using SAP GUI scripting enabled. ( Could not take selector on sap - #10 by Allan_Zimmermann )
Hi @Allan_Zimmermann
I tried your suggestion and the issue persisted, but I found a solution that worked for me. I then created a python script to execute the login and it works fine.
@UnyBots
Hopefully this code can help you out a bit. This code is a Python script that interacts with the SAP GUI application using the pywin32 module: pip install pywin32
import win32com.client
import sys
import subprocess
import time
class SapGui():
def __init__(self):
self.path = r"C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe" # Path to saplogon instalation folder
subprocess.Popen(self.path)
time.sleep (2)
self.SapGuiAuto = win32com.client.GetObject("SAPGUI")
if not isinstance(self.SapGuiAuto, win32com.client.CDispatch):
return
application = self.SapGuiAuto.GetScriptingEngine
self.connection = application.OpenConnection("SAP PROD", True) # Name of your SAP connection
time.sleep(3)
self.session = self.connection.Children(0)
self.session.findById("wnd[0]").maximize
def sapLogin(self):
try:
# Set the text of the SAP GUI element with the ID for login
self.session.findById("wnd[0]/usr/txtRSYST-MANDT").text = "***" # Client
self.session.findById("wnd[0]/usr/txtRSYST-BNAME").text = "***" # User
self.session.findById("wnd[0]/usr/pwdRSYST-BCODE").text = "***" # Password
self.session.findById("wnd[0]/usr/txtRSYST-LANGU").text = "***" # Language
self.session.findById("wnd[0]").sendVKey(0)
# check a element you want to verify login status
elemExist = self.session.findById("wnd[0]/tbar[0]/btn[15]")
if elemExist is not None:
# Resize the working pane of the SAP GUI window
self.session.findById("wnd[0]").resizeWorkingPane(100, 20, False)
# Login was successful
# Perform further actions
else:
# Login failed or window text does not match and Handle the failure case
# Display an error message
print("Login failed or window text does not match")
# Close the SAP GUI connection
self.connection.CloseSession('ses[0]')
# Terminate the SAP GUI application
application = self.SapGuiAuto.GetScriptingEngine()
application.Quit()
# Raise an exception or return an error code if necessary
raise Exception("Login failed!")
except:
print(sys.exc_info())
sap_gui = SapGui()
sap_gui.sapLogin()
This code demonstrates a basic interaction with the SAP GUI using the win32com.client module in Python. It starts the SAP GUI, performs a login operation, and performs some actions if the login is successful.
@Allan_Zimmermann If I want to create this as an agent, is it possible? (after some improvments)
You should beable to do the same using openrpa, but this is ssooooo much cleaner.
You can run this as an agent right now ( using assistent, since it requires a desktop )