cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Connect avoiding sso with a script

0 Kudos
827

Hi,

I'm currently searching how I could use a script to launch SAP and display the logon screen using a script.

I've written the code below for VBA, but after the last line, it connect directly because SSO is activated.

What I would like is to display the logon screen dispite SSO, to be able to change the connexion language or to log with another account than my main one as display in the capture below when you right click on the system you want to connect to and select Logon without Single Sign-On.

Thanks for your help.

Sub SAP_Connect()
    Dim SapGuiAuto, SapApp, oShell
    
    SAP_SYSTEM_NAME = "blahblahblah"


    'Close all running SAP instance
    oShell.Run "taskkill /f /im Saplogon.exe", , True
    
    'Launch SAP Logon
    CreateObject("wscript.shell").Run ("saplogon.exe")
    Application.Wait Now + TimeValue("0:00:02")
    Set SapGuiAuto = Nothing
    Set SapApp = Nothing
    Do While SapApp Is Nothing
    On Error Resume Next
    Set SapGuiAuto = GetObject("SAPGUI")
    Set SapApp = SapGuiAuto.GetScriptingEngine
    On Error GoTo 0
    Loop
    Application.Wait Now + TimeValue("0:00:02")
    
    'Display logon screen
    Set connection = SapApp.OpenConnection(SAP_SYSTEM_NAME, True)
End Sub

Accepted Solutions (0)

Answers (0)