Skip to Content

Export report from SM37 and save to specified drive

Hello All, I would like to check with you how to export the report from SM37 and save it in specified drive. I have tried the script from scriptman but unsuccessful. Sub export()
   
    EXCEL_Path = "\\C:\Users\beeshlim\Desktop\DMA"
    myWorkbook = test88 & ".txt"
    
If Not IsObject(SAPApp) Then
       Set SAPGUIAuto = GetObject("SAPGUI")
       Set SAPApp = SAPGUIAuto.GetScriptingEngine
    End If
    
    If Not IsObject(Connection) Then
        Set Connection = SAPApp.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
session.findById("wnd[0]/tbar[0]/okcd").Text = "/nsm37"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtBTCH2170-FROM_DATE").Text = "03.11.2019"
session.findById("wnd[0]/usr/ctxtBTCH2170-TO_DATE").Text = "04.11.2019"
session.findById("wnd[0]/usr/ctxtBTCH2170-TO_DATE").SetFocus
session.findById("wnd[0]/usr/ctxtBTCH2170-TO_DATE").caretPosition = 10
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/usr/chk[1,12]").Selected = True
'session.findById("wnd[0]/usr/chk[1,13]").SetFocus
session.findById("wnd[0]/tbar[1]/btn[44]").press
session.findById("wnd[0]/usr/lbl[14,3]").SetFocus
session.findById("wnd[0]/usr/lbl[14,3]").caretPosition = 0
session.findById("wnd[0]").sendVKey 2
session.findById("wnd[0]/tbar[1]/btn[46]").press
session.findById("wnd[1]/usr/txtDIS_TO").Text = "50"
session.findById("wnd[1]/usr/txtDIS_TO").SetFocus
session.findById("wnd[1]/usr/txtDIS_TO").caretPosition = 2
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/mbar/menu[5]/menu[5]/menu[2]/menu[2]").Select
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/usr/ctxtDY_PATH").Text = EXCEL_Path
session.findById("wnd[1]/usr/ctxtDY_FILENAME").Text = myWorkbook
session.findById("wnd[1]/usr/ctxtDY_FILENAME").caretPosition = 6
session.findById("wnd[1]/tbar[0]/btn[11]").press
End Sub
    
    
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

0 Answers

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.