SAP connection

SAP connection - VB/VBA/VBS - Programmation

Marsh Posté le 27-06-2017 à 17:55:09    

Bonjour
je cherche un script en VBS me permettant de me connecter à SAP
 
j'ai essayé ce code, trouvé là
http://scn.sap.com/thread/3763970
 
mais cela ne fonctionne pas pour moi
 

Code :
  1. REM Directives
  2.     Option Explicit
  3.   REM Variables!  Must declare before using because of Option Explicit
  4.     Dim WSHShell, SAPGUIPath, SID, InstanceNo, WinTitle, SapGuiAuto, application, connection, session
  5.   REM Main
  6.     Set WSHShell = WScript.CreateObject("WScript.Shell" )
  7.     If IsObject(WSHShell) Then
  8.       REM Set the path to the SAP GUI directory
  9.         SAPGUIPath = "C:Program Files (x86)SAPFrontEndSAPgui"
  10.       REM Set the SAP system ID
  11.         SID = "PAC"
  12.         'SID = "PAC"
  13.       REM Set the instance number of the SAP system
  14.         InstanceNo = "00"
  15.       REM Starts the SAP GUI
  16.         WSHShell.Exec SAPGUIPath & "SAPgui.exe " & SID & " " & _
  17.           InstanceNo
  18.       REM Set the title of the SAP GUI window here
  19.         WinTitle = "PAC"
  20.       While Not WSHShell.AppActivate(WinTitle)
  21.         WScript.Sleep 250
  22.       Wend
  23.       Set WSHShell = Nothing
  24.     End If
  25.     REM Remove this if you need to test the above script and want a message box at the end launching the login screen.
  26.     REM MsgBox "Here now your script..."
  27. If Not IsObject(application) Then
  28.    Set SapGuiAuto  = GetObject("SAPGUI" )
  29.    Set application = SapGuiAuto.GetScriptingEngine
  30. End If
  31. If Not IsObject(connection) Then
  32.    Set connection = application.Children(0)
  33. End If
  34. If Not IsObject(session) Then
  35.    Set session    = connection.Children(0)
  36. End If
  37. If IsObject(WScript) Then
  38.    WScript.ConnectObject session,     "on"
  39.    WScript.ConnectObject application, "on"
  40. End If
  41. session.findById("wnd[0]" ).maximize
  42. session.findById("wnd[0]/usr/txtRSYST-BNAME" ).text = "user"
  43. session.findById("wnd[0]/usr/pwdRSYST-BCODE" ).text = "pwd"
  44. session.findById("wnd[0]/usr/pwdRSYST-BCODE" ).setFocus
  45. session.findById("wnd[0]/usr/pwdRSYST-BCODE" ).caretPosition = 10
  46. session.findById("wnd[0]" ).sendVKey 0


vous auriez une idée d'ou viens le problème ?
j'ai cette erreur :  hostname PAC unknow  :??:   alors que j'ai bien un SID avec PAC

Reply

Marsh Posté le 27-06-2017 à 17:55:09   

Reply

Marsh Posté le 28-06-2017 à 20:59:10    

tout script VBS ou VBA permettant de me connecter a SAP, je prends aussi  :)

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed