on 06-08-2006 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,
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.
Hi Guillermo,
Is there a similar scripting for attaching a file in mm03 or mm43
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Guillermo Riojas ,
We also have the same requirement. Did you get any solution for this. Please can you share some more inputs on this.
Regards,
Naveen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gregor,
Well, i have been using ECATT tool, which i found useful, but it is a little bit difficult for people who is not involved in the sap world to understand or use it. That is way i would like to learn how to use the sap api with VB or VBscript in order to create automated scripts, easy to understand and use for people who is not involved with sap but know vb or vbscript.
Is there any way to use sap api, with these tools? (VBscript, VB)
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi guys,
Basically, the purpose of trying to create scripts using the sap api scripting guide, is because, im involved in the functional testing field. So im trying to create a new way to script against sap using descriptive programming style, without using the gui
i would like to browse across sap tcodes, fields, etc, and automate any process i.e. creating a sales order, usign functions of the api.
It might sound a little bit strange, but that is my job, lol,
so, did i explain what im trying to get?
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Guillermo,
can you tell us more about your Business Case?
I think a possible solution can also be Batch Input which can be recorded in Transaction SHDB. From this recording you can create a Program or Function Module.
Regards
Gregor
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.