Former Member

### SAP HANA scripted Calc View syntax

Hi HANA experts,

My scenario is as follows:

Currently, I have a calculated column with the following logic:

IF ( now() > daydate(string(component(now(),1))+'1010'), daydate(string(component(now(),1))+'1010'),

IF ( now() > daydate(string(component(now(),1))+'0710'), daydate(string(component(now(),1))+'0710'),

IF ( now() > daydate(string(component(now(),1))+'0410'), daydate(string(component(now(),1))+'0410'),

IF ( now() > daydate(string(component(now(),1))+'0110'), daydate(string(component(now(),1))+'0110'),

daydate(string(component(now(),1)-1)+'1010') ) ) ) )

I want to create a scripted calc view with the same such logic in a column.

What is the proper syntax to do so?

I have already tried using case statements and if statements using common sql syntax but can't seem to get it to work ðŸ˜”

John

10|10000 characters needed characters exceeded

• Former Member
Dec 23, 2014 at 12:34 PM

Hi,

BR

Sumeet

10|10000 characters needed characters exceeded
• Dec 26, 2014 at 02:37 PM

Hi John,

Can you try the syntax like this inside the scripted calculation view:

Note: We have to use CASE..THEN.. END instead of IF

Example below:

SELECT CASE WHEN month(now()) = '12'

Â Â Â Â Â Â  THEN 'DEC'

Â Â Â Â Â Â  WHEN month(now()) =Â  '11'

Â Â Â Â Â Â  Then 'NOV'

Â Â Â Â Â Â  ELSE

Â Â Â Â Â Â Â Â Â Â Â  'Other'

Â Â Â Â Â Â  ENDÂ  as V_monthnameÂ  -- result variable

Â Â Â Â Â Â  from DUMMY;

Let me know if you have see any concerns.

best regards,

Varma