Hi all,
i hope i can get some help with this as i have looked far and wide! i am trying to get a report to run on SAP that simply runs data and extracts to a spreadsheet, this has been fine, however i cannot find a way for the script to change the date to the previous day for example. i am a complete newb with VBA although it will help with my role running these reports in my job automatically!
please see below VBA 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
session.findById("wnd[0]/usr/txtRSYST-BNAME").text = "********"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").text = "********."
session.findById("wnd[0]/usr/pwdRSYST-BCODE").setFocus
session.findById("wnd[0]/usr/pwdRSYST-BCODE").caretPosition = 9
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[0]/okcd").text = "vl06o"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/btnBUTTON6").press
session.findById("wnd[0]/tbar[1]/btn[17]").press
session.findById("wnd[1]/usr/txtENAME-LOW").text = "e0337478"
session.findById("wnd[1]/usr/txtENAME-LOW").setFocus
session.findById("wnd[1]/usr/txtENAME-LOW").caretPosition = 8
session.findById("wnd[1]").sendVKey 8
session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").currentCellRow = 2
session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").selectedRows = "2"
session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").doubleClickCurrentCell
session.findById("wnd[0]/usr/ctxtIT_KODAT-LOW").text = "14.12.2020"
session.findById("wnd[0]/usr/ctxtIT_WTIST-LOW").text = ""
session.findById("wnd[0]/usr/ctxtIT_LVSTK-LOW").text = "c"
session.findById("wnd[0]/usr/ctxtIT_LVSTK-LOW").setFocus
session.findById("wnd[0]/usr/ctxtIT_LVSTK-LOW").caretPosition = 1
session.findById("wnd[0]").sendVKey 8
session.findById("wnd[0]/tbar[1]/btn[18]").press
session.findById("wnd[0]/mbar/menu[3]/menu[2]/menu[1]").select
session.findById("wnd[1]").sendVKey 81
session.findById("wnd[1]").sendVKey 81
session.findById("wnd[1]").sendVKey 81
session.findById("wnd[1]").sendVKey 81
session.findById("wnd[1]").sendVKey 81
session.findById("wnd[1]/usr/lbl[1,18]").setFocus
session.findById("wnd[1]/usr/lbl[1,18]").caretPosition = 7
session.findById("wnd[1]").sendVKey 2
session.findById("wnd[0]/mbar/menu[0]/menu[5]/menu[1]").select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[0,0]").select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[0,0]").setFocus
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[1]").sendVKey 0
it is the line "session.findById("wnd[0]/usr/ctxtIT_KODAT-LOW").text = "14.12.2020" that inputs the date.
Thanks in advance for any support given to me
i hope i can get some help with this as i have looked far and wide! i am trying to get a report to run on SAP that simply runs data and extracts to a spreadsheet, this has been fine, however i cannot find a way for the script to change the date to the previous day for example. i am a complete newb with VBA although it will help with my role running these reports in my job automatically!
please see below VBA 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
session.findById("wnd[0]/usr/txtRSYST-BNAME").text = "********"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").text = "********."
session.findById("wnd[0]/usr/pwdRSYST-BCODE").setFocus
session.findById("wnd[0]/usr/pwdRSYST-BCODE").caretPosition = 9
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[0]/okcd").text = "vl06o"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/btnBUTTON6").press
session.findById("wnd[0]/tbar[1]/btn[17]").press
session.findById("wnd[1]/usr/txtENAME-LOW").text = "e0337478"
session.findById("wnd[1]/usr/txtENAME-LOW").setFocus
session.findById("wnd[1]/usr/txtENAME-LOW").caretPosition = 8
session.findById("wnd[1]").sendVKey 8
session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").currentCellRow = 2
session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").selectedRows = "2"
session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").doubleClickCurrentCell
session.findById("wnd[0]/usr/ctxtIT_KODAT-LOW").text = "14.12.2020"
session.findById("wnd[0]/usr/ctxtIT_WTIST-LOW").text = ""
session.findById("wnd[0]/usr/ctxtIT_LVSTK-LOW").text = "c"
session.findById("wnd[0]/usr/ctxtIT_LVSTK-LOW").setFocus
session.findById("wnd[0]/usr/ctxtIT_LVSTK-LOW").caretPosition = 1
session.findById("wnd[0]").sendVKey 8
session.findById("wnd[0]/tbar[1]/btn[18]").press
session.findById("wnd[0]/mbar/menu[3]/menu[2]/menu[1]").select
session.findById("wnd[1]").sendVKey 81
session.findById("wnd[1]").sendVKey 81
session.findById("wnd[1]").sendVKey 81
session.findById("wnd[1]").sendVKey 81
session.findById("wnd[1]").sendVKey 81
session.findById("wnd[1]/usr/lbl[1,18]").setFocus
session.findById("wnd[1]/usr/lbl[1,18]").caretPosition = 7
session.findById("wnd[1]").sendVKey 2
session.findById("wnd[0]/mbar/menu[0]/menu[5]/menu[1]").select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[0,0]").select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[0,0]").setFocus
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[1]").sendVKey 0
it is the line "session.findById("wnd[0]/usr/ctxtIT_KODAT-LOW").text = "14.12.2020" that inputs the date.
Thanks in advance for any support given to me