<?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>topic Re: ABAP CDS View Cast in Case Expression in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-cast-in-case-expression/m-p/400374#M10204</link>
    <description>&lt;P&gt;Whoa, that was an easy workaround! Thank you!&lt;/P&gt;</description>
    <pubDate>Mon, 19 Dec 2016 13:45:17 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2016-12-19T13:45:17Z</dc:date>
    <item>
      <title>ABAP CDS View Cast in Case Expression</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-cast-in-case-expression/m-p/400371#M10201</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I want to make a new field in my CDS-View, with a CASE-condition, like that:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;case 
        when usage_6m  = 0 then '1'
        when usage_6m &amp;lt; '10' or usage_6m &amp;gt; '0' then '2'
        when usage_6m &amp;lt; '250' or usage_6m &amp;gt; '10' then '3'
        else '0'
        end as usage_icon&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The problem is that the type of the field "usage_6m" NUMC10 is, so eclipse throws an error : "data type conflict". So then I wanted to cast the field to abap.int4, but that does not work eighter, because the CAST--expression is not supported in this position like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;case 
        when cast( usage_6m  as abap.int4 )  = 0 then '1'

...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Do any of you have an idea how I cand solve this, or why I can't cast a field inside of a CASE-expression.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;Cristina&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2016 14:01:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-cast-in-case-expression/m-p/400371#M10201</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-12-15T14:01:44Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP CDS View Cast in Case Expression</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-cast-in-case-expression/m-p/400372#M10202</link>
      <description>&lt;P&gt;Could you consider NUMC10 as a string giving a simpler&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CASE
  WHEN usage_6m = '0000000000' then '1'
  WHEN usage_6m &amp;lt; '0000000010' then '2'
  WHEN usage_6m &amp;lt; '0000000250' then '3'
  ELSE '0'
END AS usage_icon&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;BR /&gt;Raymond&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2016 09:00:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-cast-in-case-expression/m-p/400372#M10202</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2016-12-16T09:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP CDS View Cast in Case Expression</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-cast-in-case-expression/m-p/400373#M10203</link>
      <description>&lt;P&gt;Hi Cristina,&lt;/P&gt;&lt;P&gt;Sorry, but the searched CASE does not support expressions as LHS, see &lt;A href="http://help.sap.com/abapdocu_751/en/index.htm?file=abencds_cond_expr_case.htm"&gt;docu.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;You have to find a workaround e.g. as Raymond suggested.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2016 09:23:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-cast-in-case-expression/m-p/400373#M10203</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2016-12-16T09:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP CDS View Cast in Case Expression</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-cast-in-case-expression/m-p/400374#M10204</link>
      <description>&lt;P&gt;Whoa, that was an easy workaround! Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2016 13:45:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-cast-in-case-expression/m-p/400374#M10204</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-12-19T13:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP CDS View Cast in Case Expression</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-cast-in-case-expression/m-p/400375#M10205</link>
      <description>&lt;P&gt;Hello Sir,&lt;/P&gt;&lt;P&gt;i have  also got same requirement, how did you achieve.please let me know, its great thankful to you if you would give early response.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Ravilla&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 15:28:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-cast-in-case-expression/m-p/400375#M10205</guid>
      <dc:creator>ravilla</dc:creator>
      <dc:date>2019-07-30T15:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP CDS View Cast in Case Expression</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-cast-in-case-expression/m-p/400376#M10206</link>
      <description>&lt;P&gt;Hi Cristina,&lt;/P&gt;&lt;P&gt;Take your &lt;STRONG&gt;usage_6m&lt;/STRONG&gt; as string and then try . Hope it works.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Ram&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 09:23:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-cast-in-case-expression/m-p/400376#M10206</guid>
      <dc:creator>former_member39336</dc:creator>
      <dc:date>2019-09-12T09:23:31Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP CDS View Cast in Case Expression</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-cast-in-case-expression/m-p/400377#M10207</link>
      <description>&lt;P&gt;Requirement
Show Company Code  from Table 1(o) if exist
else if  show Company code  from table2(P) if exist elseif show it from
Table 3(Q).&lt;/P&gt;&lt;P&gt;Data
Type of Company code is different from table 1(o) or Table2 (p) Let us say CHAR
04 and table3 (Q) company code CHAR 20&lt;/P&gt;&lt;P&gt;For
Table 1 and 2 we can write the below code &lt;/P&gt;&lt;P&gt; Case &lt;/P&gt;&lt;P&gt;  when Q.lsa_bukrs is null then
p.company_code&lt;/P&gt;&lt;P&gt;  else  Q.lsa_bukrs 
end  as Company_code2,&lt;/P&gt;&lt;P&gt;For 3 table I
wrote below code but it does not work because the Datatype of Company code is
different in Table 3(Q) &lt;/P&gt;&lt;P&gt;Case&lt;/P&gt;&lt;P&gt;  when t.org_unit_key is not null
and  Q.lsa_bukrs is null and
p.company_code is null &lt;/P&gt;&lt;P&gt;  then  t.org_unit_key&lt;/P&gt;&lt;P&gt; when  Q.lsa_bukrs is not null  then Q.lsa_bukrs&lt;/P&gt;&lt;P&gt; when 
Q.lsa_bukrs is null and p.company_code is not null  then 
p.company_code&lt;/P&gt;&lt;P&gt;end  as
Company_code2,&lt;/P&gt;&lt;P&gt;Then I went and Opted for another Approach Making one more
CDS view Comparing two table and In Main cds View comparing the 3&lt;SUP&gt;rd&lt;/SUP&gt; table
and result of first View&lt;/P&gt;&lt;P&gt;Additional view&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;{ key&lt;/STRONG&gt;  a&lt;STRONG&gt;.&lt;/STRONG&gt;lsa_id  &lt;STRONG&gt;as&lt;/STRONG&gt; lsa_id&lt;STRONG&gt;,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;cast(&lt;/STRONG&gt; Q&lt;STRONG&gt;.&lt;/STRONG&gt;lsa_bukrs &lt;STRONG&gt;as&lt;/STRONG&gt; &lt;EM&gt;abap&lt;/EM&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;EM&gt;&lt;U&gt;char&lt;/U&gt;&lt;/EM&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;20&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;STRONG&gt;as&lt;/STRONG&gt; Q_lsa_bukrs&lt;STRONG&gt;,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;cast(&lt;/STRONG&gt; p&lt;STRONG&gt;.&lt;/STRONG&gt;company_code
&lt;STRONG&gt;as&lt;/STRONG&gt; &lt;EM&gt;abap&lt;/EM&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;EM&gt;&lt;U&gt;char&lt;/U&gt;&lt;/EM&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;20&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;STRONG&gt;as&lt;/STRONG&gt;  p_company_code&lt;STRONG&gt;,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;cast(&lt;/STRONG&gt;&lt;STRONG&gt;case&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;STRONG&gt;when&lt;/STRONG&gt; Q&lt;STRONG&gt;.&lt;/STRONG&gt;lsa_bukrs &lt;STRONG&gt;is&lt;/STRONG&gt;&lt;STRONG&gt;null&lt;/STRONG&gt;// Purchase
Order  &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;then&lt;/STRONG&gt;  p&lt;STRONG&gt;.&lt;/STRONG&gt;company_code&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;else&lt;/STRONG&gt;  Q&lt;STRONG&gt;.&lt;/STRONG&gt;lsa_bukrs  &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;end&lt;/STRONG&gt;&lt;STRONG&gt;as&lt;/STRONG&gt; &lt;EM&gt;abap&lt;/EM&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;EM&gt;&lt;U&gt;char&lt;/U&gt;&lt;/EM&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;20&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;STRONG&gt;as&lt;/STRONG&gt;  QP_Company_code&lt;STRONG&gt;,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;cast(&lt;/STRONG&gt; t&lt;STRONG&gt;.&lt;/STRONG&gt;org_unit_key &lt;STRONG&gt;as&lt;/STRONG&gt; &lt;EM&gt;abap&lt;/EM&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;EM&gt;&lt;U&gt;char&lt;/U&gt;&lt;/EM&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;20&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;STRONG&gt;as&lt;/STRONG&gt; t_Company_code&lt;STRONG&gt;,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;  Q&lt;STRONG&gt;.&lt;/STRONG&gt;gsber_sc  &lt;STRONG&gt;as&lt;/STRONG&gt;
Lsa_Business_area&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;View Main: In this View Compare the company code which u received
from first View and Table 3 (Q) Company Code&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;STRONG&gt;key&lt;/STRONG&gt; U.QP_Company_code,&lt;/P&gt;&lt;P&gt;  U.t_Company_code,&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;case&lt;/STRONG&gt;&lt;STRONG&gt;when&lt;/STRONG&gt; U&lt;STRONG&gt;.&lt;/STRONG&gt;QP_Company_code
&lt;STRONG&gt;is&lt;/STRONG&gt;&lt;STRONG&gt;null&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;then&lt;/STRONG&gt;  U&lt;STRONG&gt;.&lt;/STRONG&gt;t_Company_code&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;else&lt;/STRONG&gt;  U&lt;STRONG&gt;.&lt;/STRONG&gt;QP_Company_code  &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;end&lt;/STRONG&gt;&lt;STRONG&gt;as&lt;/STRONG&gt; Company_code&lt;STRONG&gt;,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 May 2020 11:52:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-cast-in-case-expression/m-p/400377#M10207</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-05-25T11:52:59Z</dc:date>
    </item>
  </channel>
</rss>

