Skip to Content
0
Nov 04, 2019 at 08:26 AM

Import text file in script

2176 Views Last edit Jan 03, 2020 at 11:24 AM 3 rev

I am trying to run the script to import a list of values in the table field using script. Here is the subset of the code. The script opens a file select dialog and just sits there. Is there a way I can pass a static filename in the script for importing data.

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,25,false
session.findById("wnd[0]/tbar[0]/okcd").text = "ZSE16N"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtGD-TAB").text = "VBAK"
session.findById("wnd[0]").sendVKey 0 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[21]").press
'this where the file select dialog opens and I have to select the file manually.
session.findById("wnd[1]/tbar[0]/btn[8]").press