<?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: CDS View Pivot or Tranpose in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-pivot-or-tranpose/m-p/11903433#M1962495</link>
    <description>&lt;P&gt;Solved on my Own.&lt;/P&gt;&lt;P&gt;Solution used LEFT OUTER JOIN on the same table. I did this per field. So you need to create one query for each of the fields and combine them all together via UNION.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Mar 2019 13:16:59 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2019-03-12T13:16:59Z</dc:date>
    <item>
      <title>CDS View Pivot or Tranpose</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-pivot-or-tranpose/m-p/11903432#M1962494</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
  &lt;P&gt;I am trying to develop a simple Summary Report in ABAP. However, due to the very large data volume, we decided to leverage HANA by using SALV-IDA and moving all processing to the DB Level via CDS Views. &lt;/P&gt;
  &lt;P&gt;Below is a simplified version of what I'm trying to accomplish. The goal is to be able to compare fields one-by-one per Document Item and ultimately display it as Item and Category Summaries. In the example below we see that the Quantity, Amount and Currency Fields are different for Document 1 Item 1. &lt;/P&gt;
  &lt;P&gt;The complication revolves around the table ZITEMS Table. This Contains Versions (at most 2) of the same Document Item as rows. I figured to be able to do comparisons and aggregates, I need to create an intermediate view which basically transpose/pivot the version and the comparison fields(material,qty,etc). &lt;/P&gt;
  &lt;P&gt;I'm quite new to SQL Script and SQL programming in general and have no idea how this is done. I'm used to the traditional approaching of pulling everything via OpenSQL and processing in ABAP. I would like to get some pointers on how this can be done.&lt;/P&gt;
  &lt;P&gt;Thanks!&lt;/P&gt;
  &lt;P&gt;-Emir&lt;/P&gt;
  &lt;P&gt;&lt;A href="https://answers.sap.com/storage/attachments/1640499-cds-view-problem.jpg" target="_blank"&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1640499-cds-view-problem.jpg" /&gt;cds-view-problem.jpg(316.9 kB)&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 15:42:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-pivot-or-tranpose/m-p/11903432#M1962494</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-03-11T15:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: CDS View Pivot or Tranpose</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-pivot-or-tranpose/m-p/11903433#M1962495</link>
      <description>&lt;P&gt;Solved on my Own.&lt;/P&gt;&lt;P&gt;Solution used LEFT OUTER JOIN on the same table. I did this per field. So you need to create one query for each of the fields and combine them all together via UNION.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Mar 2019 13:16:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-pivot-or-tranpose/m-p/11903433#M1962495</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-03-12T13:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: CDS View Pivot or Tranpose</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-pivot-or-tranpose/m-p/11903434#M1962496</link>
      <description>&lt;P&gt;I have the same requirement, can you please me with your way/code how did you achieve this?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2020 08:08:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-pivot-or-tranpose/m-p/11903434#M1962496</guid>
      <dc:creator>viren_sharma</dc:creator>
      <dc:date>2020-10-29T08:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: CDS View Pivot or Tranpose</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-pivot-or-tranpose/m-p/11903435#M1962497</link>
      <description>&lt;P&gt;i used following approach:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;define view ZI_PIVOT( keyField, selectField ) 
as select from xxx{ key abc, fieldAlpha } 
union all select from xxx{ keyField, fieldBeta } 
union all select from xxx{ keyField, fieldGamma }&amp;lt;br&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So you get from |Key|fieldAlpha|fieldBeta|fieldGamma to Key|field&lt;/P&gt;&lt;P&gt;key1|X|E|Z to&lt;/P&gt;&lt;P&gt;key1|X&lt;BR /&gt;key1|E&lt;BR /&gt;key1|Z&lt;/P&gt;&lt;P&gt;if you use UNION instead of UNION ALL - the duplicate entries will be removed automatically&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 09:59:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-pivot-or-tranpose/m-p/11903435#M1962497</guid>
      <dc:creator>theequalizer</dc:creator>
      <dc:date>2021-08-25T09:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: CDS View Pivot or Tranpose</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-pivot-or-tranpose/m-p/11903436#M1962498</link>
      <description>&lt;P&gt;Hi Emir,&lt;/P&gt;&lt;P&gt;Could you please let us know your approach you used to solve this. I have a similar requirement and could use some inputs.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2022 05:45:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-pivot-or-tranpose/m-p/11903436#M1962498</guid>
      <dc:creator>RohitSingh</dc:creator>
      <dc:date>2022-10-21T05:45:34Z</dc:date>
    </item>
  </channel>
</rss>

