Does anyone know how to automate SAP Login in Automation Anywhere 11 - sap

enter image description hereI am using Vb script to launch SAP logon application and successfully able to launch and login into SAP, but the issue, the next line of code is not getting executes until the application is closed.
Any approach how to achieve please suggest.
VB Script Code
[set WshShell = CreateObject("WScript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")
Set proc = WshShell.Exec("C:\Program Files (x86)\SAP GUI_7.40_P10_LITE (VMware ThinApp)\saplogon.exe")
Do While proc.Status = 0
WScript.Sleep 100
Loop
Set SapGui = GetObject("SAPGUI")
Set Appl = SapGui.GetScriptingEngine
Set Connection = Appl.Openconnection("connectioname", True)
Set session = Connection.Children(0)
session.findById("wnd\[0\]/usr/txtRSYST-BNAME").Text = "username"
session.findById("wnd\[0\]/usr/pwdRSYST-BCODE").Text = "password"
session.findById("wnd\[0\]/usr/txtRSYST-LANGU").Text = "EN"
session.findById("wnd\[0\]").sendVKey 0][1]

Please refer https://botstore.automationanywhere.com/bot/sap-utilities/ , it is free. Just install it and you will be able to use the metabot.
I'd suggest not to use VBScript so extensively for SAP Automation. Metabots are highly compatible and reliable when it comes to SAP Automation. I can provide you SAP DLL (if you need), you can just import it and start using it. In this case, steps to Login to SAP would be as below.
Launch SAP (Program/File Command)
Wait for Window
The rest could be easily done with Metabot DLLs
Also, "the next line of code is not getting executes until the application is closed.", which line of code are you referring to exactly? Is it session.findById("wnd[0]").sendVKey 0][1]
Please try session.findById("wnd[0]").sendVKey [1] or session.findById("wnd[0]").sendVKey [0][1]

you will need the SAP DLL metbot if you are using v11 of AA
doc: https://docs.automationanywhere.com/bundle/enterprise-v11.3/page/enterprise/topics/aae-client/bot-creator/commands/using-bapi-to-automate-task.html

Related

wnd[1] not found with .findById()

I'm new to SAP scripting. Someone told me it is possible to automatize my work with VBA, so I looked into it. I looked on the internet how to connect, it works fine. I use the recorder to know what code to write. Everything works very well until the last line of this code:
session.findById("wnd[0]/usr/ctxtCAUFVD-AUFNR").Text = "000000000" 'write service order number
session.findById("wnd[0]").sendVKey 0 'Confirm (enter)
session.findById("wnd[0]/mbar/menu[0]/menu[9]/menu[2]/menu[4]").Select 'execute a function to close the order
session.findById("wnd[1]/usr/btnSPOP-OPTION1").press 'A popup appears (always) with "No" in autoselect. I want to click on "Yes"
.findById("wnd[1]") should allow me to use the confirmation popup window, but it always returns Error 619, Control not found. I have no idea why, since this line was written by the recorder. I explored for many hours the Internet and I can't find the answer.
Thank you in advance for your help.
Of course, I needed to ask to have the resolution idea...
The was I set up my connection was that session was actually the SAP session .ActiveWindow(), therefore only wnd[0]. It couldn't find wnd[1]. I execute the findById() from the SAP session and it works.
If Not IsObject(SAPGuiApp) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set SAPGuiApp = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = SAPGuiApp.Children(0)
End If
If Not IsObject(SAP_session) Then
Set SAP_session = Connection.Children(0)
End If
Set session = SAP_session.ActiveWindow()
session.findById("wnd[1]") 'Bad. session is only wnd[0]
SAP_session.findById("wnd[1]") 'Good it can find wnd[0] and wnd[1]

SAP Logon 760 via VBA

since the SAP update my vba application fails to connect to the sap system.
My previous code does not work anymore. I guess it is because of the new subfolder. The subfolder "All Urt SAP Systems" and "01 Test System" did not exist in the past.
However this code worked in the past without the new subfolders:
Set rotentry = GetObject("SAPGUI")
Set App = rotentry.GetScriptingEngine
App.Application.DisplayAlerts = False
Set Connection = App.OpenConnection("TE1 (Test - Development System)") '<-- Here comes the error
Set Session = Connection.Children(0)
Does anybody know what I am missing here? I tried a few SAP forums without success.
I am getting the following error message:
SAP Logon connection entry not found

vbscript starting a specific profile connection in ibm personal communications

I have been given the task of converting the slower Macro Express Pro coding for IBM Personal Communications over to a VBScript/VBA version. The Macro Express Pro coding opens a predetermined profile from a specific location.
This process can take up to 30 seconds. VBScript does this in about a third of the time for a default profile (TN3270.WS). However, when we try opening the specific link highlighted in the UNET.txt file, we get this as an error:
Run-time error '440': Automation error
Here is the VBScript code we are trying to use:
Sub Main()
Dim EName
Dim autECLConnList, objConnMgr
Set objConnMgr = CreateObject("Pcomm.autECLConnMgr")
objConnMgr.autECLConnList.Refresh
objConnMgr.StartConnection ("profile='C:\ProgramData\IBM\Personal Communications\UNET REWORK.ws' connname=a")
Application.Wait (Now + TimeValue("00:00:12"))
objConnMgr.autECLConnList.Refresh
EName = objConnMgr.autECLConnList(1).Name
End Sub
The error occurs on the objConnMgr.StartConnection ("profile='C:\ProgramData\IBM\Personal Communications\UNET REWORK.ws' connname=a") line. We know we have the correct path to the profile because it's we found its location:
IBM says that if the profile name contains blanks, it "must to be surrounded by single quotes":
Can anyone provide some advice on what we're doing wrong or what we're missing?
Thanks.
I found a way of doing what I need to do. I was looking too specific into starting a PCOMM session that I didn't even think of just running the .exe file and send it parameters. Here's how I did it:
Sub Main()
Dim WShell
Set WShell = CreateObject("WSCript.shell")
WShell.Run """C:\Program Files (x86)\IBM\Personal Communications\pcsws.exe"" ""C:\ProgramData\IBM\Personal Communications\UNET REWORK.WS"""
End Sub
I'm sure this is a duplicate answer to another question out there, but most of the answers are more than a few years old and outdated. This solution is current and recently tested, so it is a more reliable source.

SAP GUI Scripting "Invalid use of property" Error in VBA

Hello I am using SAP GUI Scripting tool which uses Excel VBA functionality to complete the task. I am getting Invalid use of property at Set Application = SapGuiAuto.GetScriptingEngine line of code:
If Not IsObject(Application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set Application = SapGuiAuto.GetScriptingEngine
Why do I get this error?
I suggest you to rename the variable Application to another name.
Application is here used like a variable, but it is also a pre-defined read-only object in Excel.

The x command does not correctly when invoked under SASWorkspaceManager.WorkspaceManager?

I have written some SAS code that calls R via the x command (I am using SAS 9.1.3 so there is no native SAS interface to R).
OPTIONS XWAIT XSYNC;
X """&r_path."" --no-save --quiet < ""&out_code_folder.\code.r"" > ""&out_code_folder.\abba.log""";
This code works correctly when I run it in the SAS IDE but when I try to run the same code in VBA using (here strSAScode contains the above mentioned SAS code).
Dim obWM As SASWorkspaceManager.WorkspaceManager
Dim temp_dispaly_alert As Boolean
Dim sm As SAS_Management
Debug.Print strSASCode
Set sm = New SAS_Management
'Set obServerDef = New SASWorkspaceManagerServerDef
Set obWM = New SASWorkspaceManager.WorkspaceManager
Set obSAS = obWM.Workspaces.CreateWorkspaceByServer("MyServerName", VisibilityProcess, Nothing, "", "", "")
Set sm.obLS = obSAS.LanguageService
temp_dispaly_alert = Application.DisplayAlerts
Application.DisplayAlerts = False
sm.obLS.Submit strSASCode
Now every other code works, except the x command. Please Help.
By default, use of SYSTEM and X commands is disabled when accessed via techniques that use integration technologies due to potential security risks.
Have you followed the steps for 9.1.3 on Windows described in this usage note?
It describes how to enable this functionality on your SAS server; you may need to adapt what's described for the workspace, instead of the stored process, server.