Sap script for previous day

Neo Gotcha

New Member
Joined
Jun 3, 2019
Messages
4
Dear all,

i'm facing a problem running an SAP SCRIPT, actually i'm running VL06F transaction automatically to generate a sales report from the beginning of the month up to date ashown in the code below, can you help me to find what to change in order to set the ending date to the previous date than the actual date:

Code:
session.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").focusDate = "20190603"

below the entire code:

Code:
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]/tbar[0]/okcd").text = "/nvl06f"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[1]/btn[17]").press
session.findById("wnd[1]/tbar[0]/btn[8]").press
session.findById("wnd[0]/usr/ctxtIT_WTIST-HIGH").setFocus
session.findById("wnd[0]/usr/ctxtIT_WTIST-HIGH").caretPosition = 0
session.findById("wnd[0]").sendVKey 4
session.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").focusDate = "20190603"
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[1]/btn[8]").press

thank you for your support.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Replace the date string literal "20190603" with:
Code:
Format(Date-1,"yyyymmdd")
This will always return yesterdays date in a string of the proper format.
 
Upvote 0
dear jkpieterse,

i used these code but it gives me an error, seems that the function "format" is not taken in consideration, the error code is 800A000D.
Is there a solution to these problem?

Regards.
 
Upvote 0
OK, I thought the code you gave is VBA code.

i'll explain i'm using SAP ERP which have a recording option which saved as a script, the code i shared is the one that was generated, so i'm trying to modify it when i used (Date-1) it run normal but it gaves a date format as yyyy/mm/dd, unfortunately SAP read format as yyyy.mm.dd

do you think it can be modified.

thanks a lot for your support.

regards.
 
Upvote 0
dear Jan,

i think i foud the solution, since the code generated from SAP is a VBS code the solution is to replace as below:

Code:
replace(Date-1, "/", ".")

thank you for your patience.

regards.
 
Upvote 0

Forum statistics

Threads
1,223,276
Messages
6,171,140
Members
452,381
Latest member
Nova88

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