<?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: External API select data from expand Odata V2 in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/external-api-select-data-from-expand-odata-v2/qaa-p/12613998#M4731091</link>
    <description>&lt;P&gt;You can set the logger "com.sap.cds.remote.odata" to "DEBUG", as described here: &lt;A href="https://cap.cloud.sap/docs/java/observability#logging-configuration" target="test_blank"&gt;https://cap.cloud.sap/docs/java/observability#logging-configuration&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This will show the OData URL that is built based on the CQN query. Maybe this gives a hint what is going wrong.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Nov 2022 15:46:11 GMT</pubDate>
    <dc:creator>marcbecker</dc:creator>
    <dc:date>2022-11-17T15:46:11Z</dc:date>
    <item>
      <title>External API select data from expand Odata V2</title>
      <link>https://community.sap.com/t5/technology-q-a/external-api-select-data-from-expand-odata-v2/qaq-p/12613997</link>
      <description>&lt;P&gt;Hi colleagues,&lt;/P&gt;
  &lt;P&gt;we have a JAVA application, which bases on Cloud Application Programming Model (CAP). In addition we have integrated SAP Cloud SKD to CAP. We have done this in order to replicated data from Sales Cloud system to our JAVA application.&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;Requirement:&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;We want to replicate Accounts with its Addresses from Sales Cloud System to our JAVA application. Meaning we do a Get operation in order to get accounts and use an expand to get assigned addresses. For the expand of addresses we want to use a select as we need only some of the address attributes.&lt;/P&gt;
  &lt;P&gt;The OData V2 request looks like this:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;Get {{url}}/sap/c4c/odata/v1/c4codataapi/CorporateAccountCollection?$expand=CorporateAccountAddress&amp;amp;$top=100&amp;amp;$select=Name,IndustrialSectorCode,LifeCycleStatusCode,RoleCode,CorporateAccountAddress/MainIndicator,CorporateAccountAddress/CountryCode,CorporateAccountAddress/City,CorporateAccountAddress/HouseNumber,CorporateAccountAddress/Street&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;And this request works also as expected. Meaning the expand entity CorporateAccountAddress gets back only the mentioned attributes of the select, for instance CorporateAccountAddress/CountryCode.&lt;/P&gt;
  &lt;P&gt;When I try to do the same Get operation with a CQN query with a select in the expand part then I get back all attributes of CorporateAccountAddress.&lt;/P&gt;
  &lt;P&gt;The query look like this in JAVA&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;private CqnSelect queryAccountCollectionWithAddressesSinceChangedOnOrderedByChangedOn(Instant changedOn, long skipValue, long limit) {&lt;BR /&gt;        return Select.from(C4codataapi_.CORPORATE_ACCOUNT_COLLECTION)&lt;BR /&gt;                .columns(&lt;BR /&gt;                        b -&amp;gt; b.get(CorporateAccountCollection.NAME),&lt;BR /&gt;                        b -&amp;gt; b.get(CorporateAccountCollection.ACCOUNT_ID),&lt;BR /&gt;                        b -&amp;gt; b.get(CorporateAccountCollection.ROLE_CODE),&lt;BR /&gt;                        b -&amp;gt; b.get(CorporateAccountCollection.CREATION_ON),&lt;BR /&gt;                        b -&amp;gt; b.get(CorporateAccountCollection.CHANGED_ON),&lt;BR /&gt;                        b -&amp;gt; b.get(CorporateAccountCollection.CORPORATE_ACCOUNT_ADDRESS),&lt;BR /&gt;                        b -&amp;gt; b.get(CorporateAccountAddressCollection.CITY),&lt;BR /&gt;                        b -&amp;gt; b.CorporateAccountAddress().expand(&lt;BR /&gt;                                a -&amp;gt; a.get(CorporateAccountAddressCollection.CITY),&lt;BR /&gt;                                a -&amp;gt; a.get(CorporateAccountAddressCollection.COUNTRY_CODE)&lt;BR /&gt;                        )&lt;BR /&gt;                )&lt;BR /&gt;                .where(o -&amp;gt; o.ChangedOn().ge(changedOn))&lt;BR /&gt;                .orderBy(ContactCollection.CHANGED_ON)&lt;BR /&gt;                .limit(limit, skipValue);&lt;BR /&gt; }&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;The expectation is that I get back from the entitiy CorporateAccountAddress only the attributes City and Country Code. But in fact I get back all attributes.&lt;/P&gt;
  &lt;P&gt;Please can you give advice how to declare the CQN query in a correct way that only some attributes of CorporateAccountAddressCollection are returned.&lt;/P&gt;
  &lt;P&gt;Thanks in advance.&lt;/P&gt;
  &lt;P&gt;Best Regards, Axel&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;&amp;lt;cds.services.version&amp;gt;1.29.0&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Nov 2022 13:30:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/external-api-select-data-from-expand-odata-v2/qaq-p/12613997</guid>
      <dc:creator>axel_semling</dc:creator>
      <dc:date>2022-11-17T13:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: External API select data from expand Odata V2</title>
      <link>https://community.sap.com/t5/technology-q-a/external-api-select-data-from-expand-odata-v2/qaa-p/12613998#M4731091</link>
      <description>&lt;P&gt;You can set the logger "com.sap.cds.remote.odata" to "DEBUG", as described here: &lt;A href="https://cap.cloud.sap/docs/java/observability#logging-configuration" target="test_blank"&gt;https://cap.cloud.sap/docs/java/observability#logging-configuration&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This will show the OData URL that is built based on the CQN query. Maybe this gives a hint what is going wrong.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 15:46:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/external-api-select-data-from-expand-odata-v2/qaa-p/12613998#M4731091</guid>
      <dc:creator>marcbecker</dc:creator>
      <dc:date>2022-11-17T15:46:11Z</dc:date>
    </item>
  </channel>
</rss>

