Title: Run SAP GUI script in the background (not visible)
Tags: sap-gui
Question: I am writing a code using SAP GUI Scripting API to automate some tasks in the SAP GUI for Windows, but I need to hide the screens.

Is there such thing as a ```visible = false``` option?

If there is not, how can I do it?

Context: the SAP GUI Scripting API is called from VBA in Microsoft Outlook but is valid for any language automating SAP GUI via SAP GUI Scripting API.

Comment: not clear, what are you want from SAP, just read the data from it thro RFC, or trying to insert/update some SAP data?

Comment: did you try to use WScript.Shell?

Comment: Insert data, fill fields

Comment: I did not, would it be possible?


Here is another answer: You can connect to your server through ```OpenConnection``` or ```OpenConnectionByConnectionString``` using ```/INPLACE``` at the end of the connection string.

Resuming... Instead of use something like ```conn = scripting_engine.Children( 0 )```, try to use something like:

```conn = scripting_engine.OpenConnection( 'MYSAPCONNECTION /INPLACE' )
session = conn.Children( 0 )
```

By the away... See more at this link.


Here is another answer: Thank you all.

I figured it out, just needed to add

```.findById("wnd[0]").iconify
```

Thanks again

Comment for this answer: Does anyone know how can I apply this command "findById("wnd[0]").iconify"   to the pop-ups windows?
I tried changing wnd[0]  for  wnd[1]  but it did not work
Comment for this answer: Apologies for the late comment, if you didn't figure it out I think you may have to use `Application.SendKeys("{ENTER}")` from VBA. This will click the "Enter" key. However, this will only work when the popup window is activated.

Here is another answer: from my expirience, I know two options of running SAP script, the first one is using WScript.Shell, I know that there is too much information against this method, try to search about it 

```Sub test()
    Dim Wsh
    Set Wsh = CreateObject("WScript.Shell").Run("C:\Users\USERNAME\Desktop\Script1.vbs")
End Sub
```

this method is allow to launch applications in your PC, e.g.:

```Sub test2()
    Dim Wsh As Object
    Set Wsh = CreateObject("WScript.Shell").Exec("calc.exe")
End Sub
```

the second one of running script, is the launch the code from script in MS office without *.vbs file, as in example bellow

```Option Explicit

Public SapGuiAuto As Object
Public ApplicationSAP As Object
Public Connection As Object
Public Session As Object

Sub start()
Set SapGuiAuto = GetObject("SAPGUI")
Set ApplicationSAP = SapGuiAuto.GetScriptingEngine
Set Connection = ApplicationSAP.Children(0)
Set Session = Connection.Children(0)

Session.findById("wnd[0]").maximize             ' max main SAP window
Session.findById("wnd[0]/tbar[0]/okcd").Text = "/n" &amp; "IW33"    'Transaction code
Session.findById("wnd[0]").sendVKey 0               'start transaction

End Sub
```

I hope it will help you in further searching of the required information

Comment for this answer: @levys Maybe I'm wrong, but when you use scripts, you will hardly be able to turn off screen updating for the SAP window. But you can use other methods of updating the SAP data. without using the SAP window, e.g. connection to SAP using RFC BAPI Call, but in this case you need to know functional module which is behind transaction-code. the second method which is might help you, is the using of GuiXT.
Comment for this answer: I think I was not clear enough.
I have a code in Outlook VBA and it is working just fine.
It automates a SAP process.
The thing is: I want SAP Screen to be updated in the end of the process, and NOT while the process is running.
It would be something similar to Application.ScreenUpdate = False  in VBA

Here is another answer: You can automate Outlook from any application without displaying Outlook UI. See How to automate Outlook from another program for more information.

Also you may find the Using Automation to Send a Microsoft Outlook Message article helpful. 

Comment for this answer: @levys That isn't particularly clear in your question, made more apparent by the fact that this answer exists. Perhaps you could edit your question to be more clear?
Comment for this answer: Not quite what I expected... It is SAP that I don't want to display. Outlook is fine
Comment for this answer: I think I was not clear enough. I have a code in Outlook VBA and it is working just fine. It automates a SAP process. The thing is: I want SAP Screen to be updated in the end of the process, and NOT while the process is running. It would be something similar to Application.ScreenUpdate = False in VBA

Here is another answer: You could try the following: session.TestToolMode = 1

Regards,
ScriptMan


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 5, 'CommentCount': 4, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2015:00:01/27/15', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<sap-gui>', 'Title': 'Run SAP GUI script in the background (not visible)', 'ViewCount': 15382, 'id': 28169872, 'user_AboutMe': '', 'user_AccountId': 3174540.0, 'user_DisplayName': 'AndroidDev', 'user_Reputation': 791.0, 'user_Views': 222.0, 'user_id': 2682736.0}}