<?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: CAPM: undefined is not iterable in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/capm-undefined-is-not-iterable/qaa-p/12490291#M4680022</link>
    <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;johannesvogel&lt;/SPAN&gt; can you check this one?&lt;/P&gt;</description>
    <pubDate>Tue, 23 Nov 2021 13:35:58 GMT</pubDate>
    <dc:creator>chgeo</dc:creator>
    <dc:date>2021-11-23T13:35:58Z</dc:date>
    <item>
      <title>CAPM: undefined is not iterable</title>
      <link>https://community.sap.com/t5/technology-q-a/capm-undefined-is-not-iterable/qaq-p/12490286</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
  &lt;P&gt;I am following the learning journey 'Developing with SAP Extension Suite' from SAP BTP Learning Group. I am consuming Business Partner service from S4HANA Cloud via API Gateway sandbox. According to the learning journey, I am implementing my own service handler to handle $expand case when it calls data from business partners. However, I am getting error in cds watch logs that 'TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))'.&lt;/P&gt;
  &lt;P&gt;Here is my code&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;const cds = require("@sap/cds");

// service implementation with handlers
module.exports = cds.service.impl(async function () {
  const { Risks, BusinessPartners } = this.entities;

  // connect to remote service
  const BPSrv = await cds.connect.to("API_BUSINESS_PARTNER");

  // to handle $expand=bp call
  this.on("READ", Risks, async (req, next) =&amp;gt; {
    try {
      const res = await next();
      if (Array.isArray(res)) {
        const aColumns = req.query.SELECT.columns || [];
        const aBpColumn = aColumns.find((column) =&amp;gt; column.ref.includes("bp"));
        if (aBpColumn.expand &amp;amp;&amp;amp; aBpColumn.expand.length &amp;gt; 0) {
          // $expand=bp was used
          const aRiskBps = res.map((risk) =&amp;gt; risk.bp_BusinessPartner);
          const aBps = await BPSrv.run({
            query: SELECT.from(BusinessPartners)
              .where({ BusinessPartner: { in: aRiskBps } })
              .columns(["BusinessPartner", "FirstName", "LastName"]),
            headers: {
              apiKey: process.env.apiKey,
            },
          });
          console.log(aBps);
        }
      }
    } catch (error) {
      console.error(error);
    }
  });
});

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 04 Feb 2024 02:26:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/capm-undefined-is-not-iterable/qaq-p/12490286</guid>
      <dc:creator>EkanshCapgemini</dc:creator>
      <dc:date>2024-02-04T02:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: CAPM: undefined is not iterable</title>
      <link>https://community.sap.com/t5/technology-q-a/capm-undefined-is-not-iterable/qaa-p/12490287#M4680018</link>
      <description>&lt;P&gt;Please add the full error, incl. stack trace.  If that is not visible, set DEBUG=true and start again.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 12:25:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/capm-undefined-is-not-iterable/qaa-p/12490287#M4680018</guid>
      <dc:creator>chgeo</dc:creator>
      <dc:date>2021-11-23T12:25:34Z</dc:date>
    </item>
    <item>
      <title>Re: CAPM: undefined is not iterable</title>
      <link>https://community.sap.com/t5/technology-q-a/capm-undefined-is-not-iterable/qaa-p/12490288#M4680019</link>
      <description>&lt;P&gt;Hi  &lt;SPAN class="mention-scrubbed"&gt;christian.georgi&lt;/SPAN&gt;, I updated the error with stack trace in the question.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 12:35:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/capm-undefined-is-not-iterable/qaa-p/12490288#M4680019</guid>
      <dc:creator>EkanshCapgemini</dc:creator>
      <dc:date>2021-11-23T12:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: CAPM: undefined is not iterable</title>
      <link>https://community.sap.com/t5/technology-q-a/capm-undefined-is-not-iterable/qaa-p/12490289#M4680020</link>
      <description>&lt;P&gt;Don't see it.. it's an empty box&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 12:57:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/capm-undefined-is-not-iterable/qaa-p/12490289#M4680020</guid>
      <dc:creator>chgeo</dc:creator>
      <dc:date>2021-11-23T12:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: CAPM: undefined is not iterable</title>
      <link>https://community.sap.com/t5/technology-q-a/capm-undefined-is-not-iterable/qaa-p/12490290#M4680021</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;[cds] - &amp;gt; READ Risks {
  '$count': 'true',
  '$select': 'HasActiveEntity,ID,IsActiveEntity,bp_BusinessPartner,criticality,descr,impact,miti_ID,owner,prio,title',
  '$filter': '(IsActiveEntity eq false or SiblingEntity/IsActiveEntity eq null)',
  '$expand': 'bp($select=BusinessPartner,LastName),miti($select=ID,IsActiveEntity,description)',
  '$skip': '0',
  '$top': '30'
}
TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
    at _newQuery (/home/user/projects/risk-management/node_modules/@sap/cds/libx/_runtime/common/utils/resolveView.js:591:26)
    at resolveView (/home/user/projects/risk-management/node_modules/@sap/cds/libx/_runtime/common/utils/resolveView.js:616:20)
    at RemoteService.handle (/home/user/projects/risk-management/node_modules/@sap/cds/libx/_runtime/remote/Service.js:207:17)
    at RemoteService.dispatch (/home/user/projects/risk-management/node_modules/@sap/cds/lib/serve/Service-dispatch.js:47:15)
    at RemoteService.dispatch (/home/user/projects/risk-management/node_modules/@sap/cds/lib/serve/Service-dispatch.js:17:48)
    at RemoteService.run (/home/user/projects/risk-management/node_modules/@sap/cds/lib/serve/Service-api.js:51:17)
    at ApplicationService.&amp;lt;anonymous&amp;gt; (/home/user/projects/risk-management/srv/risk-service.js:29:36)
    at async next (/home/user/projects/risk-management/node_modules/@sap/cds/lib/serve/Service-dispatch.js:81:17)
    at async ApplicationService.handle (/home/user/projects/risk-management/node_modules/@sap/cds/lib/serve/Service-dispatch.js:79:10)
    at async _readCollection (/home/user/projects/risk-management/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/handlers/read.js:259:19)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I don't know why but the trace is getting replaced with &amp;lt;br/&amp;gt; tag in code block in question. So I am trying to paste it in comments now.  &lt;SPAN class="mention-scrubbed"&gt;christian.georgi&lt;/SPAN&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 13:04:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/capm-undefined-is-not-iterable/qaa-p/12490290#M4680021</guid>
      <dc:creator>EkanshCapgemini</dc:creator>
      <dc:date>2021-11-23T13:04:32Z</dc:date>
    </item>
    <item>
      <title>Re: CAPM: undefined is not iterable</title>
      <link>https://community.sap.com/t5/technology-q-a/capm-undefined-is-not-iterable/qaa-p/12490291#M4680022</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;johannesvogel&lt;/SPAN&gt; can you check this one?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 13:35:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/capm-undefined-is-not-iterable/qaa-p/12490291#M4680022</guid>
      <dc:creator>chgeo</dc:creator>
      <dc:date>2021-11-23T13:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: CAPM: undefined is not iterable</title>
      <link>https://community.sap.com/t5/technology-q-a/capm-undefined-is-not-iterable/qaa-p/12490292#M4680023</link>
      <description>&lt;P&gt;Hi  &lt;SPAN class="mention-scrubbed"&gt;ekansh005&lt;/SPAN&gt; ,&lt;/P&gt;&lt;P&gt;"BPSrv.run" is not designed to provide custom headers for a request to a remote service.&lt;/P&gt;&lt;P&gt;Did you see that snippet in the learning journey or in one of our samples?&lt;/P&gt;&lt;P&gt;Please either use &lt;A href="https://cap.cloud.sap/docs/node.js/services#srv-send"&gt;.send in order to send custom headers&lt;/A&gt; with the request or consider adding the apiKey as a &lt;A href="https://cap.cloud.sap/docs/guides/consuming-services#configure-application-defined-destinations-in-nodejs" target="_blank"&gt;declarative header to the app defined destination&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Hope that helps,&lt;/P&gt;&lt;P&gt;Johannes&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 14:09:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/capm-undefined-is-not-iterable/qaa-p/12490292#M4680023</guid>
      <dc:creator>johannesvogel</dc:creator>
      <dc:date>2021-11-23T14:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: CAPM: undefined is not iterable</title>
      <link>https://community.sap.com/t5/technology-q-a/capm-undefined-is-not-iterable/qaa-p/12490293#M4680024</link>
      <description>&lt;P&gt;Ahh... I misread .send as .run and was banging my head &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;&lt;P&gt;Thanks for your explanation and it works as expected on changing it to .send().&lt;/P&gt;&lt;P&gt;BR, Ekansh&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 14:33:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/capm-undefined-is-not-iterable/qaa-p/12490293#M4680024</guid>
      <dc:creator>EkanshCapgemini</dc:creator>
      <dc:date>2021-11-23T14:33:53Z</dc:date>
    </item>
  </channel>
</rss>

