I'm using a SAP GUI Script to make an extraction of a SAP transaction, but the scripts stops because of the save form
I have to write the filename and saving path manually, How can i do to let SAP do this automatically?
Code:
Public Sub RunGUIScript_PROJ_WP_INFO_INV()
Dim W_Ret As Boolean
Dim answer As Integer
' Connect to SAP
W_Ret = Attach_Session
If Not W_Ret Then
Exit Sub
End If
On Error GoTo myerr
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/txtGD-MAX_LINES").SetFocus
session.findById("wnd[0]/usr/txtGD-MAX_LINES").caretPosition = 7
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/tblSAPLSE16NSELFIELDS_TC/btnPUSH[4,1]").SetFocus
session.findById("wnd[0]/usr/tblSAPLSE16NSELFIELDS_TC/btnPUSH[4,1]").press
session.findById("wnd[1]/tbar[0]/btn[24]").press
session.findById("wnd[1]/tbar[0]/btn[8]").press
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/usr/cntlRESULT_LIST/shellcont/shell").pressToolbarContextButton "&MB_EXPORT"
session.findById("wnd[0]/usr/cntlRESULT_LIST/shellcont/shell").selectContextMenuItem "&XXL"
WaitingForm.Show
MsgBox "Extracción Exitosa", vbInformation, "SAP"
Exit Sub
myerr:
MsgBox "Error while retrieving data", vbOKOnly + vbCritical
End Sub
Our SAP recently updated and broke many of my scripts, disabling the "show native MS Windows dialogs" allowed my previous code to run again. A basic SAP script cannot directly inteface with the MS windows dialog box shown in your screen shot.
below is the code to set the path and file name
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").contextMenu
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").selectContextMenuItem "&XXL"
session.findById("wnd[1]/tbar[0]/btn[0]").press
'set path and file name
session.findById("wnd[1]/usr/ctxtDY_PATH").text = "\\network\path\to\folder\"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").text = "Filename.xlsx"
session.findById("wnd[1]/tbar[0]/btn[0]").press