<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Syntax error in case statement used in script-based Calculation view in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/syntax-error-in-case-statement-used-in-script-based-calculation-view/qaa-p/9170198#M3254313</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Veera,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) you don't have procedural CASEs in Standard (ANSI) SQL like you mentioned.&lt;/P&gt;&lt;P&gt;What you could do (as Anooj mentioned) is, within a SELECT (or any other) statement, something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;SELECT&amp;nbsp; (CASE WHEN "NAME" = 'ZRRAPC003_FI_COPA_SD' AND "TYPE" = 'S' AND "SIGN"='I' AND "OPTION"= 'EQ' AND "LOW" = '111199995' THEN 'SALES_SD' ELSE ' ' END) AS &lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: helvetica, arial; font-size: 12px;"&gt;"CA_FM_SRC"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: helvetica, arial; font-size: 12px;"&gt;FROM myTable ...&lt;/SPAN&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) Within SQLScript procedures, there is a transactional IF clause.&lt;/P&gt;&lt;P&gt;Check page 35 of the &lt;A href="http://help.sap.com/hana/hana_dev_sqlscript_en.pdf"&gt;HANA SQLScript guide&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;IF &amp;lt;bool-expr1&amp;gt;&lt;/P&gt;&lt;P&gt;THEN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; {then-stmts1}&lt;/P&gt;&lt;P&gt;{ELSEIF &amp;lt;bool-expr2&amp;gt;&lt;/P&gt;&lt;P&gt;THEN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; {then-stmts2}}&lt;/P&gt;&lt;P&gt;{ELSE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; {else-stmts3}}&lt;/P&gt;&lt;P&gt;END IF&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) As for CE functions, I have not tested this in particular, but I suppose you could evaluate a CASE expression (as mentioned in point 1 above) within the CE_CALC() function. Please try this and let us know the results.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Best regards,&lt;/P&gt;&lt;P&gt;Henrique.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 13 Nov 2012 14:04:46 GMT</pubDate>
    <dc:creator>henrique_pinto</dc:creator>
    <dc:date>2012-11-13T14:04:46Z</dc:date>
    <item>
      <title>Syntax error in case statement used in script-based Calculation view</title>
      <link>https://community.sap.com/t5/technology-q-a/syntax-error-in-case-statement-used-in-script-based-calculation-view/qaq-p/9170195</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I had joined a custom table and a Graphical calculation view using CE_JOIN function in a Script-based Calc View.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) A IF statement metioned below was written to populate a calculated Attribute based on multiple conditions but was getting a syntax error at &lt;SPAN style="color: #ff0000;"&gt;'&lt;/SPAN&gt;&lt;STRONG style="color: #ff0000;"&gt;='.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;IF "NAME" = 'ZRRAPC003_FI_COPA_SD' AND "TYPE" = 'S' AND "SIGN" = 'I' AND "OPTION" = 'EQ' AND "LOW" = '11119995' &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;THEN&amp;nbsp; &lt;A&gt;&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"CA_FM_SRC" &lt;STRONG style="color: #ff0000;"&gt;=&lt;/STRONG&gt; 'SALES_SD' ELSE "CA_FM_SRC" = ' '&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;END;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #7f0055; font-size: 10pt;"&gt;&amp;nbsp; &lt;/STRONG&gt;&lt;STRONG style=": ; color: #7f0055; font-size: 10pt;"&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;2) I then tried a CASE statement on the same scenario and again got a syntax error at &lt;SPAN style="color: #ff0000;"&gt;CASE&lt;/SPAN&gt; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG style="color: #ff0000;"&gt;CASE&lt;/STRONG&gt; WHEN("NAME" = 'ZRRAPC003_FI_COPA_SD' AND "TYPE" = 'S' AND "SIGN"='I' AND "OPTION"= 'EQ' AND "LOW" = '111199995') &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;THEN&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"CA_FM_SRC" = 'SALES_SD' ELSE "CA_FM_SRC"= ' '&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;END;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Please let me know where I have go wrong in Syntax of the above two statements.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Thanks&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #7f0055; font-size: 10pt;"&gt;&amp;nbsp; &lt;/STRONG&gt;&lt;SPAN style="color: #3f5fbf; font-size: 10pt;"&gt;&amp;nbsp; &lt;/SPAN&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Nov 2012 07:49:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/syntax-error-in-case-statement-used-in-script-based-calculation-view/qaq-p/9170195</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-11-13T07:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in case statement used in script-based Calculation view</title>
      <link>https://community.sap.com/t5/technology-q-a/syntax-error-in-case-statement-used-in-script-based-calculation-view/qaa-p/9170196#M3254311</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Veera,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you using SQL script (SELECT statement) or using CE functions in the script based view which has the given calculated attribute.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the CASE is part of the SELECT statement, then it should be something like below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; background-color: #ffffff; color: #333333;"&gt;&lt;EM style="font-family: inherit;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit; color: #ff0000;"&gt;( CASE&lt;/STRONG&gt; WHEN("NAME" = 'ZRRAPC003_FI_COPA_SD' AND "TYPE" = 'S' AND "SIGN"='I' AND "OPTION"= 'EQ' AND "LOW" = '111199995')&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 12px; background-color: #ffffff; color: #333333;"&gt;&lt;EM style="font-family: inherit;"&gt;THEN &lt;/EM&gt;&lt;EM style="font-family: inherit;"&gt;'SALES_SD' ELSE ' ' &lt;/EM&gt;&lt;EM style="font-family: inherit;"&gt;END ) as &lt;/EM&gt;&lt;EM style="font-family: inherit;"&gt;&lt;EM style="font-family: inherit;"&gt;"CA_FM_SRC"&lt;/EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Nov 2012 07:59:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/syntax-error-in-case-statement-used-in-script-based-calculation-view/qaa-p/9170196#M3254311</guid>
      <dc:creator>Ravi_Channe</dc:creator>
      <dc:date>2012-11-13T07:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in case statement used in script-based Calculation view</title>
      <link>https://community.sap.com/t5/technology-q-a/syntax-error-in-case-statement-used-in-script-based-calculation-view/qaa-p/9170197#M3254312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ravi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using CE functions in script-based calc view. Can you let me know if we can use CASE with CE functions. If yes, i need to know the syntax of the CASE statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Veera&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Nov 2012 10:31:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/syntax-error-in-case-statement-used-in-script-based-calculation-view/qaa-p/9170197#M3254312</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-11-13T10:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in case statement used in script-based Calculation view</title>
      <link>https://community.sap.com/t5/technology-q-a/syntax-error-in-case-statement-used-in-script-based-calculation-view/qaa-p/9170198#M3254313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Veera,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) you don't have procedural CASEs in Standard (ANSI) SQL like you mentioned.&lt;/P&gt;&lt;P&gt;What you could do (as Anooj mentioned) is, within a SELECT (or any other) statement, something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;SELECT&amp;nbsp; (CASE WHEN "NAME" = 'ZRRAPC003_FI_COPA_SD' AND "TYPE" = 'S' AND "SIGN"='I' AND "OPTION"= 'EQ' AND "LOW" = '111199995' THEN 'SALES_SD' ELSE ' ' END) AS &lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: helvetica, arial; font-size: 12px;"&gt;"CA_FM_SRC"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: helvetica, arial; font-size: 12px;"&gt;FROM myTable ...&lt;/SPAN&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) Within SQLScript procedures, there is a transactional IF clause.&lt;/P&gt;&lt;P&gt;Check page 35 of the &lt;A href="http://help.sap.com/hana/hana_dev_sqlscript_en.pdf"&gt;HANA SQLScript guide&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;IF &amp;lt;bool-expr1&amp;gt;&lt;/P&gt;&lt;P&gt;THEN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; {then-stmts1}&lt;/P&gt;&lt;P&gt;{ELSEIF &amp;lt;bool-expr2&amp;gt;&lt;/P&gt;&lt;P&gt;THEN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; {then-stmts2}}&lt;/P&gt;&lt;P&gt;{ELSE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; {else-stmts3}}&lt;/P&gt;&lt;P&gt;END IF&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) As for CE functions, I have not tested this in particular, but I suppose you could evaluate a CASE expression (as mentioned in point 1 above) within the CE_CALC() function. Please try this and let us know the results.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Best regards,&lt;/P&gt;&lt;P&gt;Henrique.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Nov 2012 14:04:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/syntax-error-in-case-statement-used-in-script-based-calculation-view/qaa-p/9170198#M3254313</guid>
      <dc:creator>henrique_pinto</dc:creator>
      <dc:date>2012-11-13T14:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in case statement used in script-based Calculation view</title>
      <link>https://community.sap.com/t5/technology-q-a/syntax-error-in-case-statement-used-in-script-based-calculation-view/qaa-p/9170199#M3254314</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Veera,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The CASE statement can be used in Calc views using CE_CALC function as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CE_CALC('CASE ("B1", ''x1'', "B2", 0 )', integer) AS "CC"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check if value of B1 column = x1 (please not that x1 is not in double quotes but has two single quotes before and after), then&amp;nbsp; use B2 column value else use value 0. This column is named as CC with type INTEGER.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your case, since you have multiple conditions to check, either it can go over nested CASE statements or can be implemented with the IF() function in CE_CALC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will try to post IF() function in Calc view shortly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Nov 2012 14:54:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/syntax-error-in-case-statement-used-in-script-based-calculation-view/qaa-p/9170199#M3254314</guid>
      <dc:creator>Ravi_Channe</dc:creator>
      <dc:date>2012-11-15T14:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in case statement used in script-based Calculation view</title>
      <link>https://community.sap.com/t5/technology-q-a/syntax-error-in-case-statement-used-in-script-based-calculation-view/qaa-p/9170200#M3254315</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The syntax for IF statement is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;CE_CALC('IF (("NAME" = ''ZRRAPC003_FI_COPA_SD'' AND "TYPE" = ''S'' AND "SIGN" = ''I'' AND "OPTION" = ''EQ'' AND "LOW" = ''11119995''), "SALES_SD", '''' )', varchar(20)) AS "CA_FM_SRC"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Nov 2012 15:09:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/syntax-error-in-case-statement-used-in-script-based-calculation-view/qaa-p/9170200#M3254315</guid>
      <dc:creator>Ravi_Channe</dc:creator>
      <dc:date>2012-11-15T15:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in case statement used in script-based Calculation view</title>
      <link>https://community.sap.com/t5/technology-q-a/syntax-error-in-case-statement-used-in-script-based-calculation-view/qaa-p/9170201#M3254316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ravi,&lt;/P&gt;&lt;P&gt;I was using the CE script for my conditional calculation in CE_PROJECTION using CASE statement something like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var_out = CE_PROJECTION(:JOIN2, ["ProductId","PriceDate","Price","PriceNew", CE_CALC('CASE ("PriceDate", ''1/1/2010 0:00'', "PriceNew", 0 )', DECIMAL(10,2)) AS "FinalPrice"]);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Except "FinalPrice" that should be based on "PriceDate" value,&amp;nbsp; remaining all fields are available in my schema.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This throws me an error &lt;/P&gt;&lt;P&gt;"&lt;/P&gt;&lt;P&gt;Variable depends on an unassigned variable: 00: line 12 col 78 (at pos 889)nSet Schema DDL statement: set schema "SYSTEM"nType DDL: create type "_SYS_BIC"."cPricing/CA_CMDTY_PRC1/proc/tabletype/VAR_OUT" as table "&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Further I want to calculate the "Revenue" too using the "FinalPrice".. &lt;/P&gt;&lt;P&gt;Would you please pass on any thoughts?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Anil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Sep 2013 04:50:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/syntax-error-in-case-statement-used-in-script-based-calculation-view/qaa-p/9170201#M3254316</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-09-06T04:50:36Z</dc:date>
    </item>
  </channel>
</rss>

