Have you ever fallen into the situation that you have to repeat same operations plenty of times to find something out or get it down in SAP . For instance:
1. There are 1000 sales orders in production system and you need to find out which of them used a pricing type ZT01 in its variant material item.
2. You're required to create 100 variants for a transaction and the variant values have been in Excel or MS Access.
Of course, you can figure these requests out with some technologies like query, eCATT, LSMW, BDC etc. but here, I'd like to introduce another solution - SAP GUI Scripting.
Steps:
1. Start script recording in SAP
2. Run proper transaction like VA03 and step into target screen
3. Stop the recording
4. Tune the generated Script(VBScript)
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 = "VA03"
session.findById("wnd[0]").sendVKey 0
...
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/usr/lbl[0,2]").setFocus
session.findById("wnd[0]/usr/lbl[0,2]").caretPosition = 37
session.findById("wnd[0]/tbar[0]/btn[3]").press
5. Run the script
Comment:
1. We can use session.findById to find value of screen fields, and check the value with custom logic
2. We even can use ADO to get data from database like MS Access as data source, but need the support of VB/VBA.
3. QTP is a powerful automatic testing tool which can be used to test SAP based on SAP GUI Scription as well.