<?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: AMDP select from document store collection in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/amdp-select-from-document-store-collection/qaa-p/11946045#M4489897</link>
    <description>&lt;P&gt;Does the query work w/o the where condition? For what you need the single quotes within the where-clause variable? That is something different compared to that you are doing in the console.&lt;/P&gt;</description>
    <pubDate>Sun, 19 May 2019 06:53:35 GMT</pubDate>
    <dc:creator>pfefferf</dc:creator>
    <dc:date>2019-05-19T06:53:35Z</dc:date>
    <item>
      <title>AMDP select from document store collection</title>
      <link>https://community.sap.com/t5/technology-q-a/amdp-select-from-document-store-collection/qaq-p/11946044</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;
  &lt;P&gt;I have a DocStore collection named &lt;STRONG&gt;food_collection&lt;/STRONG&gt; from which I'm getting data into the ABAP world through an AMDP. &lt;/P&gt;
  &lt;P&gt;The code for the AMDP looks like this:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;PUBLIC SECTION.
    INTERFACES if_amdp_marker_hdb.
    TYPES:
      BEGIN OF ty_food_json,
        food_collection TYPE string,
      END OF ty_food_json,

      tt_food_json TYPE STANDARD TABLE OF ty_food_json WITH DEFAULT KEY.

    CLASS-METHODS:
      read_by_group IMPORTING VALUE(group)    TYPE string
                    EXPORTING VALUE(result) TYPE tt_food_json.

CLASS zfetch_food_collection IMPLEMENTATION .
  METHOD read_by_group BY DATABASE PROCEDURE
                                FOR HDB
                                LANGUAGE SQLSCRIPT
                                OPTIONS READ-ONLY.
      result =
        SELECT * FROM "MYSCHEMA"."FOOD_COLLECTION"
            where "group" = :group;
  ENDMETHOD.
ENDCLASS.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Now, when I try to call to this AMDP with something like:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;zfetch_food_collection=&amp;gt;read_by_group(  
EXPORTING  group  = `'Vegetables'`  
IMPORTING  et_result = data(food)).  

cl_demo_output=&amp;gt;display( food ).&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt; I get the following error:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;feature not supported: ... line 9 col 5 (at pos 302): a where clause has an expression that cannot be supported by collection tables&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;So for some reason I can't query JSON properties from the AMDP. This query works perfectly in the SQL console:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;SELECT * FROM "MYSCHEMA"."FOOD_COLLECTION"where "group" = 'Vegetables';


Statement 'SELECT * FROM "MYSCHEMA"."FOOD_COLLECTION" where "group" = 'Vegetables'' 
successfully executed in 44 ms 26 µs  (server processing time: 5 ms 994 µs)
Fetched 3 row(s) in 0 ms 44 µs (server processing time: 0 ms 0 µs)
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;I tried changing the parameter name to &lt;STRONG&gt;|'Vegetables'|&lt;/STRONG&gt;, didn't work. I also tried concatenating the single quotes inside the AMDP body rather than from the caller, didn't work either. &lt;/P&gt;
  &lt;P&gt;Has anyone experienced this?&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 15:39:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/amdp-select-from-document-store-collection/qaq-p/11946044</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-05-17T15:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: AMDP select from document store collection</title>
      <link>https://community.sap.com/t5/technology-q-a/amdp-select-from-document-store-collection/qaa-p/11946045#M4489897</link>
      <description>&lt;P&gt;Does the query work w/o the where condition? For what you need the single quotes within the where-clause variable? That is something different compared to that you are doing in the console.&lt;/P&gt;</description>
      <pubDate>Sun, 19 May 2019 06:53:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/amdp-select-from-document-store-collection/qaa-p/11946045#M4489897</guid>
      <dc:creator>pfefferf</dc:creator>
      <dc:date>2019-05-19T06:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: AMDP select from document store collection</title>
      <link>https://community.sap.com/t5/technology-q-a/amdp-select-from-document-store-collection/qaa-p/11946046#M4489898</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;group=`'Vegetables'` &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;looks wrong try&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;group=`Vegetables`&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 19 May 2019 10:58:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/amdp-select-from-document-store-collection/qaa-p/11946046#M4489898</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2019-05-19T10:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: AMDP select from document store collection</title>
      <link>https://community.sap.com/t5/technology-q-a/amdp-select-from-document-store-collection/qaa-p/11946047#M4489899</link>
      <description>&lt;P&gt;could you try to declare a help variable first:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DECLARE food_group string := group;
SELECT * FROM "MYSCHEMA"."FOOD_COLLECTION" WHERE "group" = :food_group;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 May 2019 01:14:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/amdp-select-from-document-store-collection/qaa-p/11946047#M4489899</guid>
      <dc:creator>DoanManhQuynh</dc:creator>
      <dc:date>2019-05-20T01:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: AMDP select from document store collection</title>
      <link>https://community.sap.com/t5/technology-q-a/amdp-select-from-document-store-collection/qaa-p/11946048#M4489900</link>
      <description>&lt;P&gt;The query works without the where condition. The string 'Vegetables' must be enclosed in single quotes and the field name in double quotes. It's weird but that's how the document store works, as it is documented in the sample queries here &lt;/P&gt;&lt;P&gt;&lt;A href="https://help.sap.com/viewer/4505d0bdaf4948449b7f7379d24d0f0d/2.0.01/en-US/fc6a0ab114c8416eb561c9b5aba8fc7d.html" target="test_blank"&gt;https://help.sap.com/viewer/4505d0bdaf4948449b7f7379d24d0f0d/2.0.01/en-US/fc6a0ab114c8416eb561c9b5aba8fc7d.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 09:07:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/amdp-select-from-document-store-collection/qaa-p/11946048#M4489900</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-05-20T09:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: AMDP select from document store collection</title>
      <link>https://community.sap.com/t5/technology-q-a/amdp-select-from-document-store-collection/qaa-p/11946049#M4489901</link>
      <description>&lt;P&gt;Managed to solve it in a very weird way. Makes me realizae the flexibility offered by the document store is lost when using the integration with the ABAP layer through AMDPs.&lt;/P&gt;&lt;P&gt;I had to specify the exact fields I want to fetch in the types definition of the AMDP class:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;    TYPES:
      BEGIN OF ty_food_json,
        name        TYPE string,
        fgroup       TYPE string,
        nutrients   TYPE string,
        description TYPE string,
      END OF ty_food_json,

      tt_food_json TYPE STANDARD TABLE OF ty_food_json WITH DEFAULT KEY.

    CLASS-METHODS:

      read_by_group IMPORTING VALUE(imgroup)   TYPE string
                    EXPORTING VALUE(et_result) TYPE tt_food_json.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Then in the implementation I used a CTE. But here's the tricky part, the field names from the collection have to be renamed in uppercase!!! My guess is that ABAP internally uppercases the types definition from above, so the names wouldn't match otherwise (also renamed the GROUP field because it's a reserved word in SQL). With the CTE in place I can just query in traditional SQLScript (no single quotes or double quotes needed):&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  METHOD read_by_group BY DATABASE PROCEDURE
                                FOR HDB
                                LANGUAGE SQLSCRIPT
                                OPTIONS READ-ONLY.

    et_result = WITH food_view AS (
      SELECT "name"  AS NAME,
             "group" AS FGROUP,
             "nutrients" AS NUTRIENTS,
             "description" AS DESCRIPTION
     FROM "MYSCHEMA"."FOOD_COLLECTION" )

      SELECT * FROM food_view 
      WHERE FGROUP = :imgroup;

  ENDMETHOD.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Then the caller :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;zfetch_food_collection=&amp;gt;read_by_group(
  EXPORTING
    imgroup     = `Vegetables`
  IMPORTING
    et_result = data(food)
).

cl_demo_output=&amp;gt;display( food ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And finally the results from the console:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" /&gt;&lt;/P&gt;&lt;P&gt;Within the nutrients column there's another JSON, so to extract those values I would need a nested structure.&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 09:32:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/amdp-select-from-document-store-collection/qaa-p/11946049#M4489901</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-05-20T09:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: AMDP select from document store collection</title>
      <link>https://community.sap.com/t5/technology-q-a/amdp-select-from-document-store-collection/qaa-p/11946050#M4489902</link>
      <description>&lt;P&gt;i had the same problem when  use inside amdp a function like that:&lt;/P&gt;&lt;P&gt;BIND_AS_VALUE&lt;/P&gt;&lt;P&gt;example:&lt;/P&gt;&lt;P&gt;METHOD ins_doc BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT.  &lt;/P&gt;&lt;P&gt;  delete     from "TYRHANA"."APPLCONFIG" where  "Basic"."Id" =  BIND_AS_VALUE(:applid);&lt;/P&gt;&lt;P&gt;endmethod.&lt;/P&gt;&lt;P&gt;then the system treats the importing variable - here applid - as value and it works, normally the optimizer decides if he interprets the variable as parameter or value, but with this function you can tell him that this is a value. &lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2020 04:47:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/amdp-select-from-document-store-collection/qaa-p/11946050#M4489902</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-05-06T04:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: AMDP select from document store collection</title>
      <link>https://community.sap.com/t5/technology-q-a/amdp-select-from-document-store-collection/qaa-p/11946051#M4489903</link>
      <description>&lt;P&gt;Macro,&lt;/P&gt;&lt;P&gt;I did follow SAP Help documenetaion and then found your question on SCN. I actually get below error in AMDOP class. However I am able to do all CRUD in SQL console on HANA Studio.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;"DEMOCOLLECTION" is unknown. ABAP objects and DDIC objects must be declared in the METHOD statement. Local names must start with ":" here.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This error comes when accessing from system schema(example SAPCAR or SAPSLT etc) however works fine with user schema(example KDASS)&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kevin Dass&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 13:32:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/amdp-select-from-document-store-collection/qaa-p/11946051#M4489903</guid>
      <dc:creator>kevindass</dc:creator>
      <dc:date>2020-06-19T13:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: AMDP select from document store collection</title>
      <link>https://community.sap.com/t5/technology-q-a/amdp-select-from-document-store-collection/qaa-p/13602983#M4817856</link>
      <description>Hi Kevin, Did you find any solution for this ? I am facing the same issue</description>
      <pubDate>Mon, 12 Feb 2024 20:55:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/amdp-select-from-document-store-collection/qaa-p/13602983#M4817856</guid>
      <dc:creator>Mr_A</dc:creator>
      <dc:date>2024-02-12T20:55:23Z</dc:date>
    </item>
  </channel>
</rss>

