on ‎2006 Jun 08 6:29 PM
Hello everyone,
Im new in this field, the thing is that i want to create scripts with vbscript in order to automate some business processes.
I have been reading the SAP GUI Scripting API guide, and some other documents, but i dont know how to use the classes, methods, functions, etc. of the sapfewselib.
Somebody, know how to make reference to this library in order to use it on Vbscript??
If you can put some code examples, that will be great.
Thanx,
Help others by sharing your knowledge.
AnswerRequest clarification before answering.
Please find sapfewse.ocx
(C:\Program Files\SAP\FrontEnd\SAPgui\sapfewse.ocx)
and try this code:
Dim sap As New GuiApplication
Set conexion = sap.OpenConnection("name_of_the_server_in_SAP Logon")
Set sesion = conexion.Children(0)
sesion.findById("wnd[0]").maximize
sesion.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "Client"
sesion.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "User" '
sesion.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "password"
sesion.findById("wnd[0]/usr/pwdRSYST-BCODE").SetFocus
sesion.findById("wnd[0]/usr/pwdRSYST-BCODE").caretPosition = 8
sesion.findById("wnd[0]").sendVKey 0
or try this:
Set gi = CreateObject("SAPGUI.ScriptingCtrl.1")
the better way to work with SAP GUI Scripting is with a record. Please go to RZ11 transaction and change the following parameter to TRUE:
sapgui/user_scripting
then Logoff an Logon again
then Alt+F12 (Customizing for Local Layout), click in Script Recording and Playback and record some transaction
the generated code is itself executable and you can modify o attach this code to another software that supports VBScripting like MSExcel
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
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.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").text = "/nMM01"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/cmbRMMG1-MBRSH").key = "1"
session.findById("wnd[0]/usr/cmbRMMG1-MTART").key = "ROH"
session.findById("wnd[0]/usr/cmbRMMG1-MTART").setFocus
session.findById("wnd[0]/tbar[1]/btn[5]").press
session.findById("wnd[1]/usr/tblSAPLMGMMTC_VIEW").getAbsoluteRow(0).selected = true
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP01/ssubTABFRA1:SAPLMGMM:2004/subSUB1:SAPLMGD1:1002/txtMAKT-MAKTX").text = "TEST"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP01/ssubTABFRA1:SAPLMGMM:2004/subSUB2:SAPLMGD1:2001/ctxtMARA-MEINS").text = "UN"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP01/ssubTABFRA1:SAPLMGMM:2004/subSUB2:SAPLMGD1:2001/ctxtMARA-MEINS").setFocus
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP01/ssubTABFRA1:SAPLMGMM:2004/subSUB2:SAPLMGD1:2001/ctxtMARA-MEINS").caretPosition = 2
session.findById("wnd[0]/tbar[0]/btn[11]").press
If you have any doubts please feel free to send me an email, I have worked some years with SAP GUI Scripting.
Regards,
Arturo Bernal
abmemail@yahoo.com
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.