Skip to Content
avatar image
Former Member

Just export xls-files and save automatically at specific path

Hi there,

my problem is that i want to automatically download xls-files out of SAP. To find them, I already created a XML-File, which contains the DIS-numbers.

Now actually the code works pretty good. There are several problems I have to solve. First of all, when I run the script there comes an error message like " a script tries to run SAP" and I have to press OK.

Second there is the problem that my script just uses the first position in the workstation application or in other words it downloads the first file, because when I recorded it, the excel file was the first one. Now I get the wrong documents for some DIS-Numbers,

And the last problem is the storage location. In my script it just opens the file, but instead of this variant, actually I don`t have to open it, it`s enough to save it at a specific path.

Hope you could understand my problems, if not just ask.

Set xmlDoc = CreateObject("MSXML.DomDocument")
xmlDoc.Load "DIS.xml" 

For Each testNode In xmlDoc.selectNodes("/Reports/Report")
    Number_PDP = testNode.SelectSingleNode("DIS_PDP").Text
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 132,31,false
session.findById("wnd[0]/tbar[0]/okcd").text = "/n CV04N"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/tabsMAINSTRIP/tabpTAB1/ssubSUBSCRN:SAPLCV100:0401/ssubSCR_MAIN:SAPLCV100:0402/ctxtSTDOKNR-LOW").text = Number_PDP

session.findById("wnd[0]/usr/tabsMAINSTRIP/tabpTAB1/ssubSUBSCRN:SAPLCV100:0401/ssubSCR_MAIN:SAPLCV100:0402/ctxtSTDOKNR-LOW").caretPosition = 12

session.findById("wnd[0]/usr/tabsTAB_MAIN/tabpTSMAIN/ssubSCR_MAIN:SAPLCV110:0102/cntlCTL_FILES1/shellcont/shell/shellcont[1]/shell").selectNode "          2"


Thanks in advance,


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Dec 08, 2016 at 01:41 PM


    haben sie vielleicht eine Idee?

    Habe in den letzten Tagen erneut ihre Antworten in diesem Forum bezüglich dem Thema gelesen, daher meine Frage direkt an Sie, falls Sie mir weiterhelfen können, vielen Dank.

    Add comment
    10|10000 characters needed characters exceeded