cancel
Showing results for 
Search instead for 
Did you mean: 

VBA Scripting - How to script SAPGUI logon WITHOUT SSO?

former_member926184
Discoverer

Hello-

  • Root Cause: Our unit has transitioned to mandatory Single Sign-On (SSO) and deactivated/deleted the non-SSO connection.
  • What I know: I can manually right click (or Shift+Enter) to get to the Context Menu of the SSO connection in order to "SNC Logon without Single Sign-On".
  • What I need: I have a script that uses a protected ID/pw to run a transaction that I don't want all 200 people to have full access to so I need to be able to have the code open the non-SSO connection on any user's computer.

My question: How can I script the right-click action on the SAPGUI logon pad?

My code is here:

  • "PAG - North American AG Production (006)" = non-SSO connection (this was deactivated)
  • "PAG - North American AG Production (SSO)" = SSO connection Dim SapGui
    Dim Applic
    Dim Connection
    Dim Session
    Dim WSHShell

    Shell "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe", vbNormalFocus

    Set WSHShell = CreateObject("WScript.Shell")

    Do Until WSHShell.AppActivate("SAP Logon ")
        DoEvents
        Application.Wait Now + TimeValue("0:00:01")
    Loop
    
    Set WSHShell = Nothing
    Set SapGui = GetObject("SAPGUI")
    Set Applic = SapGui.GetScriptingEngine
    Set Connection = Applic.OpenConnection("PAG - North American AG Production (006)", True)
    Set Session = Connection.Children(0)
former_member34
Product and Topic Expert
Product and Topic Expert
0 Kudos

Thank you for visiting SAP Community to get answers to your questions. Since this is your first question, I recommend that you familiarize yourself with our Q&A Tutorial: https://developers.sap.com/tutorials/community-qa.html, as it provides tips for preparing questions that draw responses from our members. Should you wish, you can revise your question by selecting Actions, then Edit.

By adding a picture to your profile you encourage readers to respond: https://www.youtube.com/watch?v=46bt1juWUUM

Many thanks!

Accepted Solutions (0)

Answers (1)

Answers (1)

script_man
Active Contributor

Hi Grace,

many years ago I solved a similar requirement with a workaround, which I will present here now:

    Dim Applic
    Dim Connection
    Dim Session
    Dim WSHShell

    Shell "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe", vbNormalFocus

    Set WSHShell = CreateObject("WScript.Shell")

    Do Until WSHShell.AppActivate("SAP Logon ")
        DoEvents
        Application.Wait Now + TimeValue("0:00:01")
    Loop
   
    WSHShell.sendkeys "^{HOME}"  
    Application.Wait Now + TimeValue("0:00:01")
    WSHShell.sendkeys "+{ENTER}"
    Application.Wait Now + TimeValue("0:00:04")
    
    Set WSHShell = Nothing
    Set SapGui = GetObject("SAPGUI")
    Set Applic = SapGui.GetScriptingEngine
    'Set Connection = Applic.OpenConnection("PAG - North American AG Production (006)", True)
    Set connection = Applic.Children(0)
    Set Session = Connection.Children(0)

Regards, ScriptMan