Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
TomCenens
Active Contributor

A common need in a test script recording / playback tool is the need to insert dates throughout business processes. While I was working together with end-users at customer side, we noticed the date was captured in a raw format as let’s say today 22.10.2014 which is fine for today but can be problematic tomorrow since the input field of this date was a “required end date”.

Thus we need to be able to pass a dynamic parameter to the script that takes today’s date and adds days or months or years to that date in order for the process to run through fine when we play back the test script.

Otherwise you see this nice error in your task bar of SAPgui:

ECATT parameter &DATE?

So what are the options then? CBTA script can leverage ECATT parameters so the &DATE would translate into the date of today. Well, if your configuration is correct and you’ve implemented a couple of recent (at moment of writing) notes to make this work:

2025280 - CBTA - Support of &DATE eCATT variable

2013565 - eCATT - Integration of external test tools - &DATE not resolved


So I tried to use &DATE but it still failed by giving me a date in format DD/MM/YYYY while the system expected DD.MM.YYYY. Darn, that’s too bad, right. So I contacted SAP and the CBTA team actually told me I need to look at my end-user environment date settings because this parameter takes the settings from the local system (Windows XP in my case, so my laptop at customer side which runs the script to do this automated test).

Where to find this configuration, depends on the Windows version but in essence you want to look at regional options / date-time / calendar options in your respective Windows version or at your registry (check out windows support website to locate the registry key for it).

Just changing the short date format for my own language / environment (Belgium – Dutch) didn’t cut it. I had to go and change English (United States) into this format to make the script execution take the right format but that worked in the end.

To use it in CBTA, you can use &date (comes from ECATT capaibilities)

So putting today’s date in the parameters tab in your CBTA script, can work.

But that doesn’t meet the requirements of getting a date in the future …

VBscript as input?

So I continued to explore the next option which is to use VBscript as input for the CBTA input parameter.

The date() function returns the date of today but in a wrong format, darn again, as it returns the date in MM.DD.YYYY and I need DD.MM.YYYY instead. So using just date() won’t cut it either.

Looking at more date / time functions of VBScript, I noticed day(), month(), year() and now(). Furthermore, using day() +1 is possible in VBScript.

Aha!

To use VBscript in that input parameter value field, you need to use %=% so for example %=date()% will then translate in 10.22.2014.

Next month?

So if I want to have next month as input I can use the following line of VBscript:

%=day(now())&"."&month(now())+1&"."&year(now())%


Update 01.12.2014: The above function works fine, except in December!


To overcome this, you can include the DateAdd() VBScript function. Thanks to mark.goovaerts to figure out the code update for me :wink: .

%=day(DateAdd("m",1,now()))&"."&month(DateAdd("m",1,now()))&"."&year(DateAdd("m",1,now()))%


Note that you can use a shorter expression if you don't have specific format requirements. In this case, I have a prerequisite to have a "." in between the mm dd yyyy.


Instead of using +1, we use the DateAdd function to get the current date, one month from now without "next year" issues.

Et voila, there it is, now run the script and let’s see if that works.

Works like a charm!

4 Comments
Labels in this area