cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting with windows 8 or seven

Former Member
0 Kudos


Hello everybody

I use scripting to update data in SAP. the script open a txt.file and automatise some actions.

The scripting works fine with windows XP but on other computer in windows 8 or seven the script don't find the file. message : file not found.

I have update the sap gui 7.30 to package 10 but we had the same problem even if we execute SAP in administrator side.

Someone have an idea ?

Best reagrds

Bruno

Accepted Solutions (1)

Accepted Solutions (1)

holger_khn
Contributor
0 Kudos

Hello.

May you adopt your coding e.g. to Excel VBA and check from there. We work on Windows 8. But I never have used WSH (vbs) for SAP Scripting. Always MS Office VBA (Excel or ACCESS) without any Problems.

Best regards,

Holger

Former Member
0 Kudos

Thank you for you answer. i 'm not aware in VBA script language. perhaps could you correct my script ?

 

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]").maximize

 

dim ds()

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.OpenTextFile("todo.txt", 1)

Set objFilelog = objFSO.OpenTextFile("log.txt", 8, true)

 

objFilelog.WriteLine("-----------------------------------------------------")

objFilelog.WriteLine("--------Start: " & now & "-------------------")

objFilelog.WriteLine("-----------------------------------------------------")

i = "0"

Do Until objFile.AtEndOfStream

strInputline = objFile.readLine

if len(strInputline) > 0 then

Redim Preserve ds(i)

ds(i) = strInputline

i = i + 1

end if

Loop

 

for each datensatzausdatei in ds

 

'--- begin to putin your recoded source code here 

session.findById("wnd[0]").maximize

session.findById("wnd[0]/usr/ctxtLAGP-LGPLA").text = datensatzausdatei

session.findById("wnd[0]/usr/ctxtLAGP-LGPLA").caretPosition = 6

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/mbar/menu[0]/menu[5]").select

session.findById("wnd[1]/usr/btnSPOP-OPTION1").press

'-- end of putin from your recode source code here

next

objFilelog.WriteLine("-----------------------------------------------------")

objFilelog.WriteLine("--------Ende: " & now & "--------------------")

objFilelog.WriteLine("-----------------------------------------------------")

Msgbox("Fertig /end")

holger_khn
Contributor
0 Kudos

Hello.

Seems like you miss to define fullpath of Textfiles. This cause issue:


Set objFile = objFSO.OpenTextFile("todo.txt", 1)

Set objFilelog = objFSO.OpenTextFile("log.txt", 8, true)

Should defined as fullpath:

e,g,


Set objFile = objFSO.OpenTextFile("C:\YourDirectory\todo.txt", 1)

Set objFilelog = objFSO.OpenTextFile("C:\YourDirectory\log.txt", 8, true)

Then it should work.

Best regards,

Holger

Former Member
0 Kudos

Thank you holger.

it works fine. with XP windows look by default in the same directory like the script but for seven or Windows 8 it is necessary to define the real complete directory directory.

best regards

Bruno

Answers (0)