Skip to Content
May 22 at 12:27 PM

Group and Merge data from multiple rows table in CDS

145 Views Last edit May 24 at 05:08 AM 6 rev

hello Guys,

My requirement is to get partner data and its contracts and then get the corresponding appointment dates of those contracts in SAP CRM tables. So now I have created CDS to retrieve the partner and contract details, and now I have to retrieve the dates from the appointment table. The problem is I need to retrieve multiple dates for each contract how can I achieve this in CDS view.

eg: My current CDS will retrieve something like this (not exactly like below but just for explanation purpose :) )


but now for each contract, I need to retrieve dates that are stored in the SCAPPTSEG table with appointment types as below,


Now I would like to get the dates in different columns for each item, the output should look like this.


Can we do it in the same CDS view?

Note: The date types are not dynamic. For each contract, only 5 types of dates need to retrieve.

After assigning the values using CASE for the new fields, I tried GROUP BY, but it won't work, since I need to show multiple fields it's not grouping into a single line.


image.png (4.3 kB)
image.png (116.9 kB)
image.png (17.3 kB)
image.png (6.2 kB)