<?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: CAP: Select inside Action in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/cap-select-inside-action/qaa-p/12259996#M4591815</link>
    <description>&lt;P&gt;It was my namespace that was causing the issue: &lt;STRONG&gt;demo.callcenter&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;ensureUnlocalized method compares the localized table name with below localized prefixes.&lt;/P&gt;&lt;P&gt;localized.de, localize.fr ....&lt;/P&gt;&lt;P&gt;In my case, localized table name is &lt;STRONG&gt;localized.demo.callcenter.Inquiries&lt;/STRONG&gt; and it matches with &lt;STRONG&gt;localized.de&lt;/STRONG&gt;, so the method truncates the table name, resulting the error.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1851867-sb9lk.png" /&gt;&lt;/P&gt;&lt;P&gt;I changed the namespace to &lt;STRONG&gt;zdemo.callcenter&lt;/STRONG&gt; and now it is working fine.&lt;/P&gt;&lt;P&gt;It seems we cannot use namespaces starting with 'de', 'fr', or any other language keys.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Oct 2020 21:27:43 GMT</pubDate>
    <dc:creator>MioYasutake</dc:creator>
    <dc:date>2020-10-15T21:27:43Z</dc:date>
    <item>
      <title>CAP: Select inside Action</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-select-inside-action/qaq-p/12259992</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;
  &lt;P&gt;I'm struggling to implement an Action inside CAP.&lt;/P&gt;
  &lt;P&gt;What I want to do is simple SELECT, but it throws me an error...&lt;/P&gt;
  &lt;P&gt;Service definition&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;using { demo.callcenter as call } from '../db/schema';

service CallCenterService {
    entity Inquiries as select from call.Inquiries
    actions {
        @sap.applicable.path: 'startEnabled'
        action start();
    }; 
}&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Service implementation&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;const cds = require('@sap/cds')

module.exports = async function () {
    const { Inquiries } = cds.entities

    this.on ('start', async (req)=&amp;gt; {
        console.log('data: ' + req.data)
        const id = req.params[0]

        //Get createdAt
        const createdAt = await SELECT.from(Inquiries).columns(['createdAt']).where({ID:id})

        //Calculate hoursBeforeStart
        const startedAt = Date.now()
        const difference = startedAt - new Date(createdAt).getTime()
        const hoursBefoerStart =  Math.floor(difference/1000/60/60)        

        const n = await UPDATE(Inquiries).set({ 
            status_code:'2',
            startedAt: Date.now(),
            hoursBefoerStart: hoursBefoerStart
        }).where ({ID:id}).and({status_code:'1'})
        n &amp;gt; 0 || req.error (404) 
    })
}&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;The error is occurring at below statement. &lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;const createdAt = await SELECT.from(Inquiries).columns(['createdAt']).where({ID:id})&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1851765-error3.png" /&gt;&lt;/P&gt;
  &lt;P&gt;Can anybody point out what's wrong with this statement?&lt;/P&gt;
  &lt;P&gt;Thanks,&lt;/P&gt;
  &lt;P&gt;Mio&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 20:56:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-select-inside-action/qaq-p/12259992</guid>
      <dc:creator>MioYasutake</dc:creator>
      <dc:date>2020-10-13T20:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: CAP: Select inside Action</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-select-inside-action/qaa-p/12259993#M4591812</link>
      <description>&lt;P&gt;Hi Mio,&lt;/P&gt;&lt;P&gt;There is not enough information provided to find the reason behind your issue. Could you please provide us a link to your project or a minimal working example which will help us to reproduce the problem?&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Olena&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 10:36:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-select-inside-action/qaa-p/12259993#M4591812</guid>
      <dc:creator>OlenaT</dc:creator>
      <dc:date>2020-10-14T10:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: CAP: Select inside Action</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-select-inside-action/qaa-p/12259994#M4591813</link>
      <description>&lt;P&gt;Hi Olena,&lt;/P&gt;&lt;P&gt;Thank you for your attention.&lt;/P&gt;&lt;P&gt;I have uploaded my project to below git repository.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/miyasuta/cap-callcenter" target="test_blank"&gt;https://github.com/miyasuta/cap-callcenter&lt;/A&gt;&lt;/P&gt;&lt;P&gt;You can reproduce the issue by executing the POST request in srv/test.http file.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Mio&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 11:23:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-select-inside-action/qaa-p/12259994#M4591813</guid>
      <dc:creator>MioYasutake</dc:creator>
      <dc:date>2020-10-14T11:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: CAP: Select inside Action</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-select-inside-action/qaa-p/12259995#M4591814</link>
      <description>&lt;P&gt;I tried debugging below module.&lt;/P&gt;&lt;P&gt;@sap\cds-runtime\lib\db\data-conversion\post-processing.js:128&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1851814-zromg.png" /&gt;&lt;/P&gt;&lt;P&gt;When below statement was called, nothing was returned to the variable &lt;STRONG&gt;entity&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;This is the reason of the error '&lt;EM&gt;TypeError: Cannot read property 'elements' of undefined&lt;/EM&gt;'.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;const entity = csn.definitions[ensureUnlocalized(entityName)]&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;entityName&lt;/STRONG&gt; was 'localized.demo.callcenter.Inquiries', and &lt;STRONG&gt;ensureUnlocalized(entityName) &lt;/STRONG&gt;returned 'o.callcenter.Inquiries', which was not in csn.definitions.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1851815-hrg7e.png" /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 21:25:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-select-inside-action/qaa-p/12259995#M4591814</guid>
      <dc:creator>MioYasutake</dc:creator>
      <dc:date>2020-10-14T21:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: CAP: Select inside Action</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-select-inside-action/qaa-p/12259996#M4591815</link>
      <description>&lt;P&gt;It was my namespace that was causing the issue: &lt;STRONG&gt;demo.callcenter&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;ensureUnlocalized method compares the localized table name with below localized prefixes.&lt;/P&gt;&lt;P&gt;localized.de, localize.fr ....&lt;/P&gt;&lt;P&gt;In my case, localized table name is &lt;STRONG&gt;localized.demo.callcenter.Inquiries&lt;/STRONG&gt; and it matches with &lt;STRONG&gt;localized.de&lt;/STRONG&gt;, so the method truncates the table name, resulting the error.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1851867-sb9lk.png" /&gt;&lt;/P&gt;&lt;P&gt;I changed the namespace to &lt;STRONG&gt;zdemo.callcenter&lt;/STRONG&gt; and now it is working fine.&lt;/P&gt;&lt;P&gt;It seems we cannot use namespaces starting with 'de', 'fr', or any other language keys.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2020 21:27:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-select-inside-action/qaa-p/12259996#M4591815</guid>
      <dc:creator>MioYasutake</dc:creator>
      <dc:date>2020-10-15T21:27:43Z</dc:date>
    </item>
    <item>
      <title>Re: CAP: Select inside Action</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-select-inside-action/qaa-p/12259997#M4591816</link>
      <description>&lt;P&gt;Title: ErroreMessage: Non è stato possibile aprire l’app perché il componente SAP UI5 dell’applicazione non è stato caricato.Details: {"info": "Il componente UI5 non è stato caricato per l’intento \"#Action-toappstateformsample\"","technicalMessage": "failed to load 'sap/ushell/demo/AppStateFormSample/Component.js' from ../../../../../test-resources/sap/ushell/demoapps/AppStateFormSample/Component.js: 404 - Not Found\nError: failed to load 'sap/ushell/demo/AppStateFormSample/Component.js' from ../../../../../test-resources/sap/ushell/demoapps/AppStateFormSample/Component.js: 404 - Not Found\n    at makeNestedError (https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:94:37)\n    at requireModule (https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:102:2782)\n    at requireAll (https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:104:527)\n    at Object.r [as require] (https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:109:597)\n    at &lt;A href="https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:671:6952\n" target="test_blank"&gt;https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:671:6952\n&lt;/A&gt;    at new Promise (&amp;lt;anonymous&amp;gt;)\n    at &lt;A href="https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:671:6919\nCaused" target="test_blank"&gt;https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:671:6919\nCaused&lt;/A&gt; by: Error: 404 - Not Found\n    at a (https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:98:88)\n    at XMLHttpRequest.&amp;lt;anonymous&amp;gt; (https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:98:321)\n    at loadSyncXHR (https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:98:415)\n    at requireModule (https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:102:2737)\n    at requireAll (https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:104:527)\n    at Object.r [as require] (https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:109:597)\n    at &lt;A href="https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:671:6952\n" target="test_blank"&gt;https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:671:6952\n&lt;/A&gt;    at new Promise (&amp;lt;anonymous&amp;gt;)\n    at &lt;A href="https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:671:6919&amp;quot;}" target="test_blank"&gt;https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:671:6919"}&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Oct 2020 12:43:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-select-inside-action/qaa-p/12259997#M4591816</guid>
      <dc:creator>carmenpalmisano</dc:creator>
      <dc:date>2020-10-16T12:43:53Z</dc:date>
    </item>
  </channel>
</rss>

