Skip to Content
0

Date range in design Studio

Jul 06, 2017 at 08:37 PM

491

avatar image
Former Member

Hi All,

I am having a requirement to have date range in design studio and my data Source is BW query.

Below is the code I am using but I am getting following error.

Value '04/02/2017-05/30/2017' is not valid for variable Invoice Clearing Date or does not exist

Code I am using:

var varange =DATEFIELD_1.getDate();

var varange1 =DATEFIELD_2.getDate();

var external_date1 = Convert.subString(varange, 4,6) +"/" + Convert.subString(varange, 6,8) + "/" + Convert.subString(varange, 0,4);

var external_date2 = Convert.subString(varange1, 4,6) +"/" + Convert.subString(varange1, 6,8) + "/" + Convert.subString(varange1, 0,4);

var range= external_date1 + "-"+external_date2; DS_2.setVariableValueExt("ZVAR_INCD", range);

Please help me if I am missing anything.

Thanks,

Guna

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Mustafa Bensan Jul 07, 2017 at 05:06 AM
0

Hi Guna,

There are three points you should check:

1) Ensure that the BEx Variable is defined as a range variable;

2) Since you are using setVariableValueExt(), the date format must be in the user's locale. Make sure that you are using the correct date format. Check that the user locale format is in fact MM/DD/YYYY rather than another format;

3) Try placing a space between the dash separating the dates in the range by changing your code to:

var range= external_date1 + " - " + external_date2; 
DS_2.setVariableValueExt("ZVAR_INCD", range);

Regards,

Mustafa.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jul 07, 2017 at 06:34 PM
0

Hi Mustafa,

Thank you very much for your response.

I am trying to use the code you have send, I am now seeing any change in Data. I have users from different geographies.

Ex: I am running this from US and my user setting is MM/DD/YYYY.

1. My BW variable is range.

Now Kindly help how this can be achieved. I tried to Capture the data input to a Test input box and it shows as 20170101 - 20170101.

Kindly advise.

Thanks,

Guna

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Guna,

This is the problem with using setVariableValueExt() because it requires the date to be formatted in the user's locale. Is there a reason why you simply don't use the Variable Prompt Dialogue to allow the user to enter the desired date range?

Alternatively, you could just use the setFilter() method with the internal date format.

Regards,

Mustafa.

0
Zahid Yener Aug 03, 2017 at 10:45 AM
0

You can also use it like this

DS_1.setFilter("0CALDAY",{"low":external_date1 ,"high":external_date2 });

Share
10 |10000 characters needed characters left characters exceeded
Martin Pankraz Aug 04, 2017 at 08:22 AM
0

Hi Guna,

Mustafa pointed you in the right direction. You can reuse your provided coding using the substring method to create the US date format from the given internal format that the datefield provides. You might want to consider creating a script to deal with other countries. Here are some hints from me:

As long as you are sure your users have the same setting only, you are fine. The european format you could indentify by checking for dots instead of slashes. Unfortunately our british friends can have slashes and also swap month and date. So consider this MM/DD/YYYY vs. DD/MM/YYYY. Now you cannot know what it actually is. To check for sure you would need to put more effort like reading the browser's language setting or creating a web service on ABAP backend to provide the user's assigned language.

You can stay away from such issues by avoiding BEx variables or sticking to the SAP standard prompt like Mustafa suggested.

Kind regards

Martin

Share
10 |10000 characters needed characters left characters exceeded