I have a CDS View with multiple associations:
define view ZORDER as select from ZORDERHDR as orderHdr
association [0..1] to ZORDER_LOCATION as _location on _location.orderID = orderHdr.orderID
association [0..*] to ZORDER_ITEM as _items on _items.orderID = orderHdr.orderID
association [0..*] to ZORDER_PARTNER as _partners on _partners.orderID = orderHdr.orderID
Now, I would like to select from the view a single order and get a result something like this:
TYPES: BEGIN OF t_order,
header TYPE zorderhdr,
location TYPE zorder_location,
items TYPE zorder_items, "This is a table type
END OF t_order.
Is there a SELECT statement that can read all the order into a nested structure like the one above?
Edit: I added a second 0..* association to ensure that the proposed solution doesn't suggest to select everything and then reduce the header and location to their structures. The problem I see is that with complex CDS views I seem to need to handle all the associations with custom code like I would do if it was normal OpenSQL, then I lose the benefit of the CDS views model design (when not consuming from Gateway) and I select too much data.