<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>association &#8211; SAP EWM Help</title>
	<atom:link href="https://www.sapewmhelp.com/question-tag/association/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.sapewmhelp.com</link>
	<description>SAP EWM questions answered by experts — ABAP, S/4HANA, warehouse management</description>
	<lastBuildDate>Tue, 05 Aug 2025 18:50:56 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.2</generator>
	<item>
		<title>Types of Association in CDS ?</title>
		<link>https://www.sapewmhelp.com/question/types-of-association-in-cds/</link>
					<comments>https://www.sapewmhelp.com/question/types-of-association-in-cds/#respond</comments>
		
		<dc:creator><![CDATA[DPM125]]></dc:creator>
		<pubDate>Tue, 05 Aug 2025 18:50:30 +0000</pubDate>
				<guid isPermaLink="false">https://www.sapewmhelp.com/?question=types-of-association-in-cds</guid>

					<description><![CDATA[Exposed Associations An exposed association is one that is defined in a CDS view and is made available (exposed) to consumers of the view — such as other CDS views, analytical queries, or OData services. You define the association using the association [&#8230;] to clause and then expose it using an alias (typically starting with [&#8230;]]]></description>
										<content:encoded><![CDATA[<h5><strong>Exposed Associations</strong></h5>
<p>An <strong>exposed association</strong> is one that is <strong>defined</strong> in a CDS view and is <strong>made available (exposed)</strong> to consumers of the view — such as other CDS views, analytical queries, or OData services. You define the association using the association [&#8230;] to clause and then expose it using an alias (typically starting with an underscore _) in the SELECT list.</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-js" data-lang="JavaScript"><code><!--StartFragment --><span><span>define </span>view ZI_SalesOrder <span>as </span><span>select </span><span>from </span>ZSalesOrderHeader
{
    <span>key </span>SalesOrderID<span>,</span>
    CustomerID<span>,</span>

    association [0<span>.</span><span>.</span>1] <span>to </span>ZI_Customer <span>as </span>_Customer 
        <span>on </span>_Customer<span>.</span>CustomerID <span>= </span>ZSalesOrderHeader<span>.</span>CustomerID

    // Exposing the association
    _Customer
}</span> </code></pre>
<p><strong>Key Points:</strong></p>
<ul>
<li>You can reuse exposed associations in other views.</li>
<li>Useful in modular CDS design.</li>
<li>Can be traversed via path expressions (e.g., _Customer.Name).</li>
</ul>
<h5><strong>Ad-hoc Associations</strong></h5>
<p>Ad-hoc associations are associations that are used inline (on-the-fly) via path expressions, without needing to expose the association explicitly in the SELECT list. If an association (like _Customer) is already defined in a view (exposed or implicit), you can use it ad-hoc in the SELECT or WHERE clause without re-exposing it.</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python"><code><!--StartFragment --><span><span>define </span>view ZI_SalesOrder <span>as </span><span>select </span><span>from </span>ZSalesOrderHeader
{
    <span>key </span>SalesOrderID<span>,</span>
    _Customer<span>.</span>Name    // Ad<span>-</span>hoc usage <span>of </span>the association
}
</span> </code></pre>
<p>Key Points:</p>
<ul>
<li>No need to expose <code>_Customer</code> again in the select list.</li>
<li>You&#8217;re just traversing the association to access fields of the target entity.</li>
<li>Makes CDS views more compact and readable.</li>
</ul>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sapewmhelp.com/question/types-of-association-in-cds/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is the difference between association vs Joins in CDS ?</title>
		<link>https://www.sapewmhelp.com/question/what-is-the-difference-between-association-vs-joins-in-cds/</link>
					<comments>https://www.sapewmhelp.com/question/what-is-the-difference-between-association-vs-joins-in-cds/#respond</comments>
		
		<dc:creator><![CDATA[DPM125]]></dc:creator>
		<pubDate>Tue, 05 Aug 2025 18:30:22 +0000</pubDate>
				<guid isPermaLink="false">https://www.sapewmhelp.com/?question=what-is-the-difference-between-association-vs-join-in-cds</guid>

					<description><![CDATA[Association An association is a declarative relationship between CDS entities (like foreign keys), defined using the association keyword. Key Characteristics: Lazy/Evaluated-on-demand: Data from the association is not fetched unless it is explicitly accessed using a path expression (like to_customer.name). Navigation-style access: You can access associated data using dot (.) notation. Defined once, reused many times: [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Association</strong> An association is a declarative relationship between CDS entities (like foreign keys), defined using the association keyword. <strong>Key Characteristics:</strong> Lazy/Evaluated-on-demand: Data from the association is not fetched unless it is explicitly accessed using a path expression (like to_customer.name). Navigation-style access: You can access associated data using dot (.) notation. Defined once, reused many times: Associations can be defined once and used in multiple views or queries. Cardinality can be defined: e.g. [0..1], [1..*].</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python"><code>define view ZSalesOrder as select from sales_order
association [0..1] to customer as _Customer on $projection.customer_id = _Customer.id
{
key sales_order_id,
customer_id,
_Customer.name
}
</code></pre>
<p>Here, _Customer is an association. It won&#8217;t trigger a join unless _Customer.name is accessed.</p></div>
<div class="hcb_wrap"><strong>Join</strong></div>
<div class="hcb_wrap">A join is an explicit operation in CDS to combine two data sources based on a condition, much like in SQL. <strong>Key Characteristics:</strong> Eager execution: The join happens immediately during view evaluation. More control: You control the type of join (INNER, LEFT OUTER, etc.). Typically used when data from both tables is always needed.</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python"><code>define view ZSalesOrderJoin as select from sales_order
inner join customer on sales_order.customer_id = customer.id
{
sales_order.id,
customer.name
}</code></pre>
<p>Here, a real-time INNER JOIN is performed.</p></div>
<h5><strong>When to Use What?</strong></h5>
<p><strong>Use Association:</strong></p>
<ul>
<li>When modeling data relationships.</li>
<li>When you want flexibility and better performance for optional fields.</li>
<li>When the associated data isn’t always needed.</li>
</ul>
<p><strong>Use Join:</strong></p>
<ul>
<li>When you always need data from both sources.</li>
<li>When performing aggregations or filters based on joined fields.</li>
<li>When doing complex multi-joins with specific types (e.g. inner join).</li>
</ul>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sapewmhelp.com/question/what-is-the-difference-between-association-vs-joins-in-cds/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
