Alexlyblue

How to work with SAP GUI?

8 posts in this topic

Dear All:

I've already read many posts about SAP and AutoIT v3, even this SAP UDF, Automating SAP using SAP's GUI Scripting COM object .

But my question is I have no right to use SAP GUI Script, so I can't use sean's Library.

Might I ask how to get enough Information of SAP-GUI controls without SAP GUI Script?

Many thanks

Aber

Share this post


Link to post
Share on other sites



I had to automate the SAP GUI myself - until the problem was solved by exporting the data to a text file yb the SAP Guys.

After doing some research I came to the conclusion that the SAP UDF you mentioned above is the only proper way to automate SAP.

If your company wants you to do the job by automating SAP they have to provide the tools you need (enable SAP scripting etc.)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hello Aber and Water,

there are a few ways to communicate with an SAP system. SAP GUI Scripting is only one to automate your user input.

My suggestion is the same as Waters: Talk with your admin to enable SAP GUI Scripting on the application server you need. With the TAC RZ11 he must set the value from the parameter sapgui/user_scripting to TRUE. And activate the option Scripting in your local SAP GUI Logon. If it is also not possible, talk with your admin too. There is no way around this security options.

You can use SAP GUI without enabled SAP GUI Scripting, you find a few (older) examples in my knowledge collection - Tips for AutoIt. But it is not comfortable and if there are some changes in the UI, it could be problematically.

With AutoIt you can also use the SAP GUI ActiveX components or the SAP NetWeaver RFC SDK, if you know the RFC function modules or BAPI interfaces.

Cheers

Stefan

Share this post


Link to post
Share on other sites

Hello, Stefan

I wonder if it is possible to manipulate the field values ​​of a transaction through the AutoIt, it would be asking too much if you post an example? Or some site that teaches how to do.

Note: Through GuiXT could see that the field names and their values ​​appear on the screen, this is what I ask above.

Thankful.

Márcio.

I am Brazilian, I live and work in Brazil.

Excuse me if there are errors, I'm using Google Translator.

Share this post


Link to post
Share on other sites

Use AutoIt's Window Info Tool to check if SAP uses Controls that can be accessed by AutoIt.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hello Márcio,

sorry for my late answer.

With SAP GUI Scripting you can automatically manipulate nearly all objects of SAP GUI for Windows, also field values.

Here an example how to use the ok-field:

;-Begin-----------------------------------------------------------------

  ;-Variables-----------------------------------------------------------
    Dim $SAPROT, $SapGuiAuto, $application, $connection, $session

  $SAPROT = ObjCreate("SapROTWr.SAPROTWrapper")
  If Not IsObj($SAPROT) Then
    Exit
  EndIf

  $SapGuiAuto = $SAPROT.GetROTEntry("SAPGUI")
  If Not IsObj($SapGuiAuto) Then
    Exit
  EndIf

  $application = $SapGuiAuto.GetScriptingEngine()
  If Not IsObj($application) Then
    Exit
  EndIf

  $connection = $application.Children(0)
  If Not IsObj($connection) Then
    Exit
  EndIf

  $session = $connection.Children(0)
  If Not IsObj($session) Then
    Exit
  EndIf

  $session.findById("wnd[0]/tbar[0]/okcd").text = "/nse16"
  $session.findById("wnd[0]").sendVKey(0)

;-End-------------------------------------------------------------------

To analyze SAP GUI and to find out the IDs and names of the objects look here http://scn.sap.com/docs/DOC-32728 and here http://scn.sap.com/docs/DOC-40265 > cool AutoIt analyzer.

Hope it helps a little bit.

Cheers

Stefan

Share this post


Link to post
Share on other sites

Hi all,

When I use the following script

 

;-Begin-----------------------------------------------------------------

 
  ;-Variables-----------------------------------------------------------
    Dim $SAPROT, $SapGuiAuto, $application, $connection, $session
 
 
  If Not IsObj($SAPROT) Then
 
  $SAPROT = ObjCreate("SapROTWr.SAPROTWrapper")
  EndIf
 
 
  If Not IsObj($SapGuiAuto) Then
  $SapGuiAuto = $SAPROT.GetROTEntry("SAPGUI")
  EndIf
 
 
  If Not IsObj($application) Then
  $application = $SapGuiAuto.GetScriptingEngine()
  EndIf
 
 
  If Not IsObj($connection) Then
  $connection = $application.OpenConnection("XXXXXXXXX")
  EndIf
 
;  $session = $connection.Children(0)
;  If Not IsObj($session) Then
;    Exit
;  EndIf
 
  $session.findById("wnd[0]/tbar[0]/okcd").text = "/nse16"
  $session.findById("wnd[0]").sendVKey(0)
 
;-End-------------------------------------------------------------------
 
 
------ Error Msg ----------
 
"C:\Program Files (x86)\AutoIt3\Include\SAP_GenFunc.au3" (56) : ==> Variable must be of type "Object".:
$connection = $application.OpenConnection("xxxxxxxx")
$connection = $application^ ERROR

 

 

Can somebody help me, please.

Thanks

Share this post


Link to post
Share on other sites

Hello everyone

I got the resolution.  All I did is launch the SAP Logon pad as "Run as Administrator".  I tried on Windows 8 (Laptop).

Here is the code

Local $sapapp, $sap_connection, $sap_session

Local $sap_connection_url = "XX_XXX_XXXX"
 
If Not IsObj($sapapp) Then
$sapgui = ObjGet("SAPGUI")
$sapapp = $sapgui.GetScriptingEngine
EndIf
 
 
If Not IsObj($sap_connection) Then
$sap_connection = $sapapp.Openconnection($sap_connection_url, True)
EndIf
 
 
If Not IsObj($sap_session) Then
$sap_session = $sap_connection.Children(0)
EndIf
 
 
 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now