cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Hi folks,

I've been searching these forums with not much luck - most scripts seem to be using a form of connection with SAP that involves hard coding one's username and password, either into the excel spreadsheet or into the VBA itself. I'm trying to find some sort of way to utilize the "SAP Logon 740" launcher that is prompting me to input an environment (think "PRD" or "QRA"), which will then either automatically roll out the SAP session if only one client exists for that environment, or prompt another selection for the client within an SAP session. As this second step is inside an active SAP session, I've been able to record and run a script to select the proper client. I just need to be able to utilize single sign on from the launcher to kick off a session for a given environment - it's really just highlighting one text search field and inputing a passed string variable.

Launching the application isn't a problem, but since I cannot figure out a way to record a macro with the launcher itself I can't get from point A (launching the application) to point C (being able to execute my macros). Point B, navigating to the proper environment/client, is not something I'm able to find good logic for.

Appreciate your help experts - this is important as our sessions seem to get bogged down after running macros for 40-50 iterations. Whether that's due to behind the scenes transaction tracking or something else, we find that refreshing the session manually every 10-15 minutes significantly speeds up our net processing. We're hoping to automate this refreshing process so this will be a large upgrade to our overall macro performance. Appreciate urgent guidance on this and I will do my best to be timely in my response to assistance.

Thanks,

Jon

0 Likes
View Entire Topic
Former Member
0 Likes

Hi Jonathan -

I have a SSO solution I created that has worked for me.  It opens your SAP connection via the Logon Pad (thus allowing SSO to do it's work). 

First it checks through Shell to see if the Logon Pad has been launched, and launches if it is hasn't.

It then strikes ENTER to open the top SAP connection.

Finally, this sample will start transaction VA03 (for me, that is Read-Only Orders) and Echo a confirmation that it has started.

The key caveat here is that I have my SAP connections saved to my Favorites folder, which by default is loaded on the Logon Pad.  Then, I only need to use the top connection.  If you are able to move your two to favorites, and know that they will always be in the same position, you can sendkeys to select them depending on which instance you need to run. (DOWN DOWN DOWN ENTER, for example).

Probably not the most efficient way, but it works 100% of the time for me!

Good luck

Joe

On Error Resume Next

If Not IsObject(application) Then

  Set SapGuiAuto = GetObject("SAPGUI")

       If Err.Number <> 0 Then

            On Error Goto 0

            Set WshShell = CreateObject("WScript.Shell")

            Set oExec = WshShell.Exec(_

            "c:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe")

            Do While Not wshShell.AppActivate("SAP Logon 740")

                 WScript.Sleep 500

            Loop

            WshShell.sendkeys "~"

            Set SapGuiAuto = GetObject("SAPGUI")

            Set application = SapGuiAuto.GetScriptingEngine

            Do While Not wshShell.AppActivate("SAP Easy Access")

                 WScript.Sleep 500

            Loop

       Else

            On Error Goto 0

       End If

  Set application = SapGuiAuto.GetScriptingEngine

End If

On Error Resume Next

If Not IsObject(connection) Then

        Set connection = application.Children(0)

         If Err.Number <> 0 Then

            On Error Goto 0

            Set WshShell = CreateObject("WScript.Shell")

            Set oExec = WshShell.Exec(_

            "c:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe")

            Do While Not wshShell.AppActivate("SAP Logon 740")

                 WScript.Sleep 500

            Loop

            WshShell.sendkeys "~"

            Set SapGuiAuto = GetObject("SAPGUI")

            Set application = SapGuiAuto.GetScriptingEngine

            Do While Not wshShell.AppActivate("SAP Easy Access")

                 WScript.Sleep 500

            Loop

       Else

            On Error Goto 0

  End If

   Set connection = application.Children(0)

End If

If Not IsObject(session) Then

   Set session = connection.Children(0)

End If

If IsObject(WScript) Then

   WScript.ConnectObject session,     "on"

   WScript.ConnectObject application, "on"

End If

session.startTransaction "VA03"

WScript.Echo "VA03 Started"