SAP Script variable dates help

wayne2020

New Member
Joined
Dec 15, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
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 :)
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top