<?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: How to use ROUND( ) function to a nested case statement in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/how-to-use-round-function-to-a-nested-case-statement/qaa-p/13626946#M4820602</link>
    <description>1) Is it ABAP, ABAP CDS or HANA CDS? 2) There are two questions in one, frst one: why it's multiplied by 10 (NO REASON, CHECK YOUR DATA AGAIN), second one: why it's not rounded. You should use CAST to type correctly your result.</description>
    <pubDate>Mon, 04 Mar 2024 12:32:21 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2024-03-04T12:32:21Z</dc:date>
    <item>
      <title>How to use ROUND( ) function to a nested case statement</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-use-round-function-to-a-nested-case-statement/qaq-p/13626798</link>
      <description>&lt;P&gt;Hi There!&lt;BR /&gt;I wrote the below case statement. But it is not giving the required results. I WANT 93,855 BUT I'M GETTING 938.5566666666666666666 like this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;(SELECT CASE (MAIN.RECEIPT+MAIN.ISSUE) WHEN 0 THEN 0.0 ELSE MAIN.AMOUNT/(MAIN.RECEIPT+MAIN.ISSUE) END)  AS UNITP&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I tried writing the nested case statement for the above line and it worked but in the output, I'm getting so many numbers after decimal. I want the number to round off and I have tried ROUND( ) as well it is throwing an error maybe I misplaced the function. Can anyone let me know how to use ROUND( ) in nested case statements? Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;CASE
	WHEN 
		case MSEG.SHKZG when 'S' then MSEG.MENGE else 0.0 end
		+
		case MSEG.SHKZG when 'H' then MSEG.MENGE else 0.0 end = 0
	THEN 0.00
ELSE
	CASE
		WHEN 
			CASE WHEN MSEG.DMBTR = 0 THEN 0 ELSE 0.00 END = 0
			AND 
			CASE WHEN MSEG.MENGE = 0 THEN 0 ELSE 0.00 END = 0
			AND
			case MSEG.SHKZG when 'S' then MSEG.MENGE else 0.0 end = 0
			AND
			case MSEG.SHKZG when 'H' then MSEG.MENGE else 0.0 end = 0
		THEN 0
	ELSE
			MSEG.DMBTR/
			(case MSEG.SHKZG when 'S' then MSEG.MENGE else 0.0 end
			+
			case MSEG.SHKZG when 'H' then MSEG.MENGE else 0.0 end)
	END
END
AS UNITP,&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 10:39:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-use-round-function-to-a-nested-case-statement/qaq-p/13626798</guid>
      <dc:creator>Albatross</dc:creator>
      <dc:date>2024-03-04T10:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to use ROUND( ) function to a nested case statement</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-use-round-function-to-a-nested-case-statement/qaa-p/13626946#M4820602</link>
      <description>1) Is it ABAP, ABAP CDS or HANA CDS? 2) There are two questions in one, frst one: why it's multiplied by 10 (NO REASON, CHECK YOUR DATA AGAIN), second one: why it's not rounded. You should use CAST to type correctly your result.</description>
      <pubDate>Mon, 04 Mar 2024 12:32:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-use-round-function-to-a-nested-case-statement/qaa-p/13626946#M4820602</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2024-03-04T12:32:21Z</dc:date>
    </item>
  </channel>
</rss>

