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
9,858

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!

5 Comments
Former Member
0 Kudos

Hi Tom,

Nice blog, dealing with a topic for which I have already torn my hair out a few times!

I like to use another solution which, in my opinion, is slightly simpler when you only have to deal with days.

Here it is:

%=Day(Date+7)%.%=Month(Date+7)%.%=Year(Date+7)%


The evaluation of the Day, Month and Year is done individually, so it will be correct every time: either on 03/11/3014, or 29/11/2014, or even 30/12/2014.

The limitation is that it works only when dealing with days.


Rémi.



P.S.: Tobias Kratofil added very interesting suggestions about the possibility to choose what to add (among which were days, weekdays, months, etc.), but somehow its comment has been deleted. I don't know who did it? Is there any way to retrieve the information he had provided?

TomCenens
Active Contributor
0 Kudos

Hi Rémi

Thanks, great to see you here as well :smile: .

Thanks for adding value by giving more options as well.

There are multiple ways to achieve the same thing and it's possible to use even shorter VBscript lines, as Tobias pointed out but then you need to have your front-end configuration in a specific way to ensure the date format is correct and that's where things can get complicated.

That's why I have the "." included and I see you have them as well because transaction X need dd.mm.yyyy and another transaction could expect dd/mm/yyyy so I want to avoid having to change settings on the front-end where the test execution is performed on.

Yes, I see, we wanted to have the due date, one month ahead of time. Therefor that's our current solution. In terms of if it's simple, I think it's simple enough (any of our example) if the person who implements the logic understands the VBscript, once you have it, the next is just copy / paste and adjust.

Kr,

Tom

PS: I'll can send you (mail) his comment if you want but he removed it from the blog which is why it isn't visible anymore

former_member729759
Discoverer
How to use Regular expression in CBTA URI

 

I am trying to identify an object in SAP Fiori application using CBTA Object Spy URI. As the Frame Id is always changing, would like to use Regular Expression so that it can be identified all the times.

 

I tried with Frame Id~=^iFrameId_[0-9]+$ but I am unbale to find unique object identification.

 

Default used URI :- ls.type=LN; label=Search Material; windowId=1; frameId=iFrameId_1613557579968; tag=SPAN; innerText=Search Material; parentTag=A

 

Could you please help on this issue.

 

Regards,

Virendra Kumar
0 Kudos
In case of unstable ID's you can use Object Spy and spy those elements with unstable IDs and use URI alternatives within the Object Spy. Within the Operator you can choose different operator like Starts, Contains, Ends for some of the Attributes.
JeannineGardner1
Explorer
0 Kudos

I have a question I hope someone can help me with:

Why is the token/code returning the date format DDMMYYYY without the zero before the single digit month; for example, instead of returning 06/13/2024 it's returning 6/13/2024?

Here are the details of this issue:

  1. The CBTA script extracts data from SAP, creates a file and sends the resulting file to an AL11 directory.
  2. The script navigates to the directory path, sorts the files in descending order such that the current date displays on the top row.
  3. Then the date is captured with checkproperty (a parameter) and compared to today's date, which is picked up as it is displayed on screen (format MMDDYYYY) as expected.
  4. However, when the parameter is compared to today's date using any of the three methods listed in item 5 below; the date does not include the zero before the month, where month is June for instance.  For example, Jun is is returned as 6/13/2024 (format MDDYYYY) instead of 06/13/2024.  Therefore, the script fails with the following error:     

      Target: GridCell_0_MOD_DATE
     - The 'GetCellValue(0, "MOD_DATE")' property is set to: 06/13/2024
      - It has been compared to: 6/13/2024
     - Using the operator: =

JeannineGardner1_1-1718654393628.png
 

    5. Received the same error using any/all of the 3 items below:

  • %today%
  • %=month(now())&"/"&day(now())+1&"/"&year(now())%
  • %=Month($today$)%/%=Day($today$)%/%=Year($today$)%

Thank you,

Jeannine

Labels in this area