cancel
Showing results for 
Search instead for 
Did you mean: 

Just export xls-files and save automatically at specific path

Former Member
0 Kudos

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]/tbar[1]/btn[8]").press
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").doubleClickCurrentCell
session.findById("wnd[0]/usr/tabsTAB_MAIN/tabpTSMAIN/ssubSCR_MAIN:SAPLCV110:0102/cntlCTL_FILES1/shellcont/shell/shellcont[1]/shell").selectNode "          2"
session.findById("wnd[0]/usr/tabsTAB_MAIN/tabpTSMAIN/ssubSCR_MAIN:SAPLCV110:0102/btnPB_DISPLAY").press

Next

Thanks in advance,

Fabian

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

stefan.schnell

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.