cancel
Showing results for 
Search instead for 
Did you mean: 

Calculation Logic

Former Member
0 Kudos

Hi All,

My Requirement is like - Master data table (Example below) having employee ID, From_Date.and To_date.  Based on the current date, I would return data that is valid for today.

Example, My desired output would be from below table is only EMp_ids. since emp_id's are ignored since to_date is expired based on current date.

Table:

Emp_id  From_date To_date
can you some one please give me suggestion to achieve this logic.
Thank you

Accepted Solutions (1)

Accepted Solutions (1)

kilian_kilger
Active Participant
0 Kudos

Hi Vasu,

just use the HANA date / time "function" CURRENT_DATE for that (ok, it is more like a global variable). You could try to use that in the filter condition directly (e.g. "FROM_DATE" >= CURRENT_DATE etc. ) or to add a new calculated column whose expression evaluates to CURRENT_DATE and use that column in the filter conditon.

I would rather prefer to use an input parameter of the view, because it is better unit testable. You can't unit test the current date very good.

Best regards,

Kilian.

You can find this function here: https://help.sap.com/saphelp_hanaone/helpdata/en/20/ddfe5d75191014af50837e2818462d/content.htm

Former Member
0 Kudos

Hi Killian,

Thank you very very much .

Answers (2)

Answers (2)

kilian_kilger
Active Participant
0 Kudos

Hi Vasa,

Is the current date an input Parameter to the view? Then you could just apply a filter condition in a projection node stating

"BEGIN_DATE" <= "$$CURRENT_DATE$$" AND "END_DATE" >= "$$CURRENT_DATE$$"

If I remember the filter editor correctly, you can enter arbitrary expressions in there, just like in an ordinary SQL statement. Just like so:

Best regards,

Kilian.

Former Member
0 Kudos

Hi Kilian,

Thank you for your input.

I want to use the system date as default current date. how would I pass the system date into below expression ? Please advise

"BEGIN_DATE" <= "$$CURRENT_DATE$$" AND "END_DATE" >= "$$CURRENT_DATE$$"

"$$CURRENT_DATE$$" = System date.

kilian_kilger
Active Participant
0 Kudos

Hi Vasu,

do you mean that you want to SELECT data from a table which is according to your description? Then something like:

SELECT DISTINCT emp_id FROM table WHERE from_date <= current_date AND
                                                                                to_date >= current_date.

should do the job.

According to the data you may or may not need the DISTINCT in the SELECT statement.

Best regards,
Kilian.

Former Member
0 Kudos

Thank you kilian !

I am trying to restrict this condition in Variable or filter in the calculation view. Not sure how to perform this logic.

can you please explain me step by step procedure to achieve it.

Thank you

Former Member
0 Kudos

Is there any ways to achieve this logic using variable, filter or input parameters in graphical cal view ? please suggest !