cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possilbe to use SNC and SAPGUI scripting together?

Former Member
0 Kudos

Hello,

I have a need to log onto many different systems using SAPGUI scripting. Below is the code segment I use to logon currently (the user is prompted for username and password earlier in the code). What I would like to do though is eliminate the need to prompt the user and just use SNC to log them on. Does anyone know how I can accomplish this with SAPGUI scripting?

Thanks!

Set SapGuiAuto = GetObject("SAPGUI")

Set application = SapGuiAuto.GetScriptingEngine

connectionString = "/H/srnp/S/3299/H/" & System & "-" & Instance & "/S/32" & Instance

Set connection = application.OpenConnectionbyConnectionString(connectionString)

Set session = connection.Children(0)

If IsObject(WScript) Then

WScript.ConnectObject session, "on"

WScript.ConnectObject application, "on"

End If

'*** Login***

session.findById("wnd[0]").resizeWorkingPane 103,24,False

session.findById("wnd[0]/usr/txtRSYST-MANDT").Text = clientNumber

session.findById("wnd[0]/usr/txtRSYST-BNAME").text = userstring

session.findById("wnd[0]/usr/pwdRSYST-BCODE").text = passwordstring

session.findById("wnd[0]/usr/pwdRSYST-BCODE").setFocus

session.findById("wnd[0]/usr/pwdRSYST-BCODE").caretPosition = 7

session.findById("wnd[0]").sendVKey 0

Accepted Solutions (0)

Answers (1)

Answers (1)

RMW
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello,

from the command line this can be done with

sapgui SNC_PARTNERNAME=“<snc-name>“ SNC_QOP=<nr> <connection>

I am not sure if it works to directly add the snc parameters into the connectionString of your script or if you need an additinal API for that.

The alternative is to define a connection in SAP logon including usage of SNC and then using the openConnection call taking the parameter as the description name in SAP logon.

For more information please refer to the <a href="https://service.sap.com/~sapidb/011000358700002236192002E">Programming API</a>.

Best regards

Rolf-Martin