cancel
Showing results for 
Search instead for 
Did you mean: 

Design Studio - Input Parameter/variable passing value from DATEFIELD component

ssurampally
Active Contributor
0 Kudos
Hi, I have got a HANA view having an input parameter on date column, input value should be taken based on a DATEFIELD component in Design Studio. I have got below function from SAP help document, APPLICATION.setVariableValue("IP1", DATEFIELD_1.getDate()); I am not able to conclude where should I place it, I mean which event of application?

I have tried using in Variable initialization event, but how would I get the value for DATEFIELD_1 component when an IP is called initially? I do not want to load entire data into Datasource from HANA but apply filter on reading itself. Please let me know, the appropriate way to do this..

Thanks

Sreekanth

Accepted Solutions (1)

Accepted Solutions (1)

MustafaBensan
Active Contributor

Hi Sreekanth,

Ideally, for a cleaner solution, I think you should code your HANA view such that the date input parameter defaults to the current date because I think that on startup it makes sense to show the data related to the current date, instead of forcing the user to pick a date. They can then change the date afterwards if needed.

However, if you really want to implement the scenario exactly as you have described, then you should follow these steps:

1. Set the Load in Script property of the data source to true;

2. Apply the following code in the "On Select" event script of the Date Field component:

if (!DS_1.isInitialized()) {

	DS_1.loadDataSource();	
}

DS_1.setVariableValue("IP1", me.getDate());

Regards,

Mustafa.

ssurampally
Active Contributor
0 Kudos

Thanks Mustafa, Can you tell me when does this script gets executed? I think, it is On Select event, so when a value is selected in DATEFIELD component.

However, my data source is loaded with all the data from HANA view even before On Select event taken place, correct? for example user wanted to see only records greater than 2017.01.01 by selecting it DATEFIELD component, but this filter does not pushed to HANA view, brings all the data first, then DS_1 is filtered accordingly.

I am trying to understand, how the filter is pushed down to HANA view from Design Studio?

MustafaBensan
Active Contributor
0 Kudos

Sreekanth,

Please see my comments below:

1. "Can you tell me when does this script gets executed?"

As stated in Step 2 of my answer, the script is executed in the "On Select" event of the date field.

2. "However, my data source is loaded with all the data from HANA view even before On Select event taken place, correct?"

No this is not correct. In Step 1 of my suggested solution, the Load in Script property of your HANA data source should be set to true. Therefore it will not load automatically at startup. This is why the data source is loaded via script for the first time in the "On Select" event of the date field, as per the code I have provided.

3. "I am trying to understand, how the filter is pushed down to HANA view from Design Studio?"

The best way to understand this is by implementing the solution I have suggested, observing the behaviour and then asking further questions if needed for clarification.

Regards,

Mustafa.

Answers (1)

Answers (1)

ssurampally
Active Contributor
0 Kudos

Thanks Mustafa, it works. Your answers are very helpful and making point always.

MustafaBensan
Active Contributor
0 Kudos

Thanks Sreekanth. Happy to help.