SAP GUI Scripting

Card Puncher Data Processing

SAP has several connectors to automate all its transactions. http://service.sap.com/connectors

One of the most interest things, is its capability to record all what you do with SAP and to save it in a script. You can then use it to automate all your tasks and embedded it in a Browser or for instance in a Web Based Software like Oracle OBIEE.

The following chapter come from SAP SDN where you can find all the useful informations that you require.

SAP GUI Scripting

Automate User Interaction with SAP GUI - and more

SAP GUI Scripting is an automation interface that enhances the capabilities of SAP GUI for Windows and Java. Using this interface, end users may automate repetitive tasks by recording and running macro-like scripts. Administrators and developers on the other hand may build tools for server-side application testing or client-side application integration.

Literature

Overview (PDF 18 KB)

This whitepaper offers an overview of SAP GUI Scripting. A user can utilize SAP GUI Scripting to automate SAP GUI by executing scripts that emulate user interaction. These scripts can be created manually from scratch or by recording user interaction.

SAP GUI Scripting API (Zip archive 2,3 MB) SAP GUI Scripting provides a set of scriptable objects wrapping SAP GUI. The document describes the interface that was designed to resemble user interaction, which can then be emulated using a script.

Security Considerations (PDF 185 KB)

This guide deals with security aspects when using the SAP GUI Scripting API.

Presentation and Exercises

SAP GUI Scripting API Presentation (PDF 1,3 MB)

This presentation explains the benefits you have when using scripts in your daily work. Also, it describes the security settings and recommendations for SAP GUI Scripting. In addition, you will learn to access the Scripting Object Model to collect and modify data in SAP GUI and how to use the SAP sample applications that help you to get started with your own development. Also, you will get to know some prominent appplications built using the SAP GUI Scripting API.

SAP GUI Scripting API TechEd Workshop Exercise (PDF 278 KB)

In this exercise, you learn how to record and play back scripts using SAP GUI for Windows and SAP GUI for Java. Availability

SAP GUI Scripting is available as of SAP GUI 6.20 for Windows and SAP GUI 6.20 for Java Revision 6. You find download information on the SAP GUI Family page. SAP System versions beginning with 3.1I are supported. A complete list of all requirements is available in the security documentation above.

How to record a script?

To record a script you can use the recorder embedded in SAP GUI (Alt + F12 to open the menu) or download the recorder from SAP SDN. The recorder produce VBScript or JScript.

sap_gui_scripting_record_and_play_back.jpg

Script

Here below is a script to launch the material transaction (mm02) for a special material code. I changed it a little bit :

  • I added a parameter Vs_MaterialCode. In this way, we can launch the material transaction according to the material code.
  • I formatted it with the <SCRIPT> tag to be able to use it in the Internet Explorer Browser.
  • I added this instruction
 
Set Wrp = CreateObject ("SapROTWr.SapROTWrapper") 
Set SapGui = Wrp.GetROTEntry ("SAPGUI")

because unfortunately GetObject will not access the Running Object Table when you call it from inside IE. This only works in the Windows Script Host. ROT is the Running Object Table where active COM objects are registered.

<SCRIPT LANGUAGE="vbscript" type="text/vbscript">
Function LaunchMaterialSAP(Vs_MaterialCode)
If Not IsObject(application) Then
   Set Wrp = CreateObject ("SapROTWr.SapROTWrapper")
   Set SapGui = Wrp.GetROTEntry ("SAPGUI")
   Set application = sapgui.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 = "/Nmm02"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtRMMG1-MATNR").text = Vs_MaterialCode
session.findById("wnd[0]/usr/ctxtRMMG1-MATNR").caretPosition = 7
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]/usr/tblSAPLMGMMTC_VIEW").getAbsoluteRow(0).selected = true
session.findById("wnd[1]/tbar[0]/btn[0]").press
End Function
</SCRIPT>

How to integrate the SAP script in OBIEE Dashboard

If you want to be able to integrate this script in Oracle OBIEE, you must use the narrative view and :

  • add in the narrative part the call of the vbsscript :
<A HREF=vbscript:LaunchMaterialSAP("@1")  language="VBScript" > @1</A> - <B>@2</B>
  • add in the prefix form the above script. In a other way, you can embedded in the OBIEE skin all your vbs library.

Obiee Narrative Sapscript

Security

Internet Explorer (Client)

The script launch an active X. Thus, if you want to be able to run the above script. You must enable the use of Active X.

To enable the ActiveX .. use the below procedure:

  • Go to Tools → Internet Options → Security → Custom Level
  • Select Prompt in Download and others questions concerned the signed ActiveX controls.
  • When prompted select Yes and you will be able to create the ActiveX object.

Ie Security Activex

SAP Server

You have more information in the Security Considerations guide but to allow the scripting. Use the transaction RZ11 to set the parameter sapgui/user_scripting to true to enable scripting at the server.

sap_rz11.jpg

Micrsoft Script Windows Debugging

To be able to debug a Windows script, you must install the Script Debugger for Windows NT 4.0 and Later and turn on the debugging in IE

Go to tools→internet options→advanced. Make sure that “Disable Script Debugging (other)” and “Disable Script Debugging (Internet Explorer) are NOT checked.

You can find more information about debugging in this good article HOW-TO: Debug JavaScript in Internet Explorer

Script Editor

Support

ActiveX Can't Create Object on Internet Explorer
Verify that you have this instruction and not the orginal instruction from the recorder.

   Set Wrp = CreateObject ("SapROTWr.SapROTWrapper")
   Set SapGui = Wrp.GetROTEntry ("SAPGUI")





Discover More
Saw Object
OBIEE - BI Presentation Service (SAW/OBIPS)

AnswersInteractive DashboardsDelivers The Oracle BI Presentation Service Server: is a pure Web Environment visualize data from the Oracle BI Server through the creation of Interactive Dashboards...
Card Puncher Data Processing
SAP ERP

The Section For the SAP HANA Database section, see Download Center



Share this page:
Follow us:
Task Runner