How To Export and Import Documents via Generic Object Services (GOS) and SAP GUI Scripting
The GOS supports SAP GUI Script recording, all we have to do is to disable in the SAP Logon the using of native Windows dialogs. More information here.
To try it you can use the TAC SGOSTEST (Test tool for GOS).
Export
After that it is possible to record this activities also.
Here an example with the transaction code FB03 with an export of a PDF file from the GOS.
And now your the scripting code looks like this:
session.findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX"
session.findById("wnd[0]/titl/shellcont/shell").selectContextMenuItem "%GOS_VIEW_ATTA"
session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").currentCellColumn = "BITM_DESCR"
session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").selectedRows = "0"
session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").pressToolbarButton "%ATTA_EXPORT"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").text = "This is a test.pdf"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").caretPosition = 19
session.findById("wnd[1]/tbar[0]/btn[0]").press
Import
Here an example code for an import:
session.findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX"
session.findById("wnd[0]/titl/shellcont/shell").selectContextMenuItem "%GOS_PCATTA_CREA"
session.findById("wnd[1]/usr/ctxtDY_PATH").text = "C:\Dummy\"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").text = "This is a test.pdf"
session.findById("wnd[1]/tbar[0]/btn[0]").press
What script is needed for this window?
Hello Anatoliy,
if you record your activities via SAP GUI Scripting, you see on the right side in the status bar a litte rotating barberpole. This means that a script is running.
In this case the GOS dialog in the Folders Management looks like this:
If you don’t record your activities via SAP GUI Scripting, the same GOS dialog in the Folders Management looks like this:
Do you activate the script recording if you see this dialog?
If yes, which path resp. which activities do you use to open this dialog in Folders Management?
TAC ORGANIZER > …
Cheers
Stefan
Good afternoon, Stefan!
The script is needed to load the pdf file from the disk, the actions of the file and the file are not displayed when the script is run.
Record:
The form of loading does not change.
When formatting and running the script stops Folders Management.
Can I write a script for Folders Management?
Hello Anatoliy,
this is a modal dialog box, this means it blocks other applications, e.g. a running script, on the same process. It is necessary to start another independent process parallel to control this dialog box. You can find a solution here.
Cheers
Stefan
how do I automate findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX"
As I see, GuiShell doesnt contain pressContextButton method
Hello Emin,
GuiShell is an abstract object whose interface is supported by all the controls. Look at the sub type of GuiShell. In your case it is GuiToolbarControl which extends GuiShell. GuiToolbarControl offers the method PressContextButton(Id As BStr) As Void. Here a tiny example script:
Best regards
Stefan
Hi Stefan,
I am trying to automate Archiving in FB03. I am stuck after below code in GOS_TOOLBOX.
session.findById("wnd[0]/shellcont/shell").SelectContextMenuItem "ARL_LINK"
For this to work I require multithreading in VBA and I don't know much about it. So if you could help me with this that would be great.
Thank you in advance
Ajit Mokashi
Hello Ajit,
sorry, but the service to store a business document is not available on my system.
Best regards
Stefan
You mean, your question is about how to drag a file from Windows Explorer and drop it in the SAP field reserved for dropping the files.
(I don't know)
Hi Stefan ,
Good day.
I'm trying to record and get the script from two different System ID A & B.
System ID - A , there's no issue when I record from beginning to end (List-Export-Spreadsheet
Allow me to run smoothly without encountering any issue.
However , when I proceed the same steps in System ID - B , issue encountered where the save option is different and it doesn't allow me to record the script.
VBS script as below:-
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]").resizeWorkingPane 103,29,false
session.findById("wnd[0]/tbar[0]/okcd").text = "/nfbl3n"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/radX_AISEL").select
session.findById("wnd[0]/usr/ctxtSO_BUDAT-LOW").text = "2021.02.01"
session.findById("wnd[0]/usr/ctxtSO_BUDAT-HIGH").text = "2021.02.25"
session.findById("wnd[0]/usr/ctxtSO_BUDAT-HIGH").setFocus
session.findById("wnd[0]/usr/ctxtSO_BUDAT-HIGH").caretPosition = 10
session.findById("wnd[0]").sendVKey 8
session.findById("wnd[0]/mbar/menu[0]/menu[3]/menu[1]").select
session.findById("wnd[1]/usr/radRB_OTHERS").setFocus
session.findById("wnd[1]/usr/radRB_OTHERS").select
session.findById("wnd[1]/usr/cmbG_LISTBOX").setFocus
session.findById("wnd[1]/usr/cmbG_LISTBOX").key = "10"
session.findById("wnd[1]/tbar[0]/btn[0]").press
Your help is highly appreciated !
Hi. someone know how change between those two Windows? I have been tring use this soluction to upload archives but without goals.