<?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>topic Re: READ TABLE on REF TO DATA Table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-on-ref-to-data-table/m-p/5091443#M1181841</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kamil,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;key = 'POSNR'   " the structire zzccbo_belpos&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am not sure what is structure &lt;STRONG&gt;zzccbo_belpos&lt;/STRONG&gt; but here all you need is row type with &lt;EM&gt;POSNR&lt;/EM&gt; field as key field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What you wrote is interpreted like: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
"create a pointer to a table (typed zzcca_t_data) 
CREATE DATA dref TYPE zzcca_t_data.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
"declare a field symbol which is able to get the content of a table under address stored by pointer
field-symbols:
&amp;lt;fs1&amp;gt; type zzcca_t_data, 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
"now poiter still has table address by also field symbol allows us to get table content (as it doesn't have name)
assign dref-&amp;gt;* to &amp;lt;fs1&amp;gt; .
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
read table &amp;lt;fs&amp;gt; with key (key) = '00001'. "NUMC5
"now read table content (which is get throught field symbol) where key field is POSNR
"this is wrong because your table seems not to have this field, you said it is of row type ref to data so it is type like this

types: begin of zzcca_t_data,
            some_ref_field type ref to data,
          end of zzcca_t_data.

"and should be 

types: begin of zzcca_t_data,
            posnr type  numc5,        "this field is must exist otherwise you can't read this table supplyijng this field as key field
            some_ref_field type ref to data,   
           end of zzcca_t_data.

"I gusess what you did is that you replaced 

types: zzcca_t_data type table of ref to data.

"...with above 1st declaration, but these statements are excatly the same. In second case you only use
"field name to address table row but no difference in logic (still you can't read it with key access as there is no such)

"what I suggest you is either add POSNR field to a table type (as above) or read it with index access as my predeccesors said
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this claryfies you bug&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS:  Advait's code is correct because he is typing his table with &lt;STRONG&gt;VBAK&lt;/STRONG&gt; so it already has key fields inside, therefore he is later able to access that table with particular key&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Marcin Pciak on Jan 30, 2009 2:32 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 30 Jan 2009 13:31:49 GMT</pubDate>
    <dc:creator>MarcinPciak</dc:creator>
    <dc:date>2009-01-30T13:31:49Z</dc:date>
    <item>
      <title>READ TABLE on REF TO DATA Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-on-ref-to-data-table/m-p/5091437#M1181835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Folks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And again I got a little question abount accessing dynamically created data structures &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I got a table type called zzcca_t_data which has a REF TO DATA as rowtype.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am creating the type of each row in runtime, because it depends on users input.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was wondering, if there is a way to random access a certain row in that table by using a key, like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;READ TABLE ..... WITH KEY = ...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am afraid, that there is no standard way to do that, maybe some special object components etc?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My idea is to make sure, that the table is sorted by a certain criteria and the implement a binary search on it using an index and access the table using&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;READ TABLE ..... INDEX ...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a better way to do that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot in advance!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kamil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2009 11:47:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-on-ref-to-data-table/m-p/5091437#M1181835</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-29T11:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: READ TABLE on REF TO DATA Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-on-ref-to-data-table/m-p/5091438#M1181836</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried "FROM wa" instead of "WITH KEY ..."? But even "FROM wa" needs to know the key of the table, so this might not work...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Otherwise the form "WHERE table_key CS ..." might work...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the above solutions are only tricks. I suggest that you build a new table where you store only the search key AND the tabix to the original table. Even if you don't know the key you should be able to use "WITH KEY table_line = ..." (note the equality operator) and then use the tabix to access the big table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2009 20:26:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-on-ref-to-data-table/m-p/5091438#M1181836</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-29T20:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: READ TABLE on REF TO DATA Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-on-ref-to-data-table/m-p/5091439#M1181837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I got a table type called zzcca_t_data which has a REF TO DATA as rowtype.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As each of your table row can only store reference of some data objects you can't read this table with &lt;STRONG&gt;read table ... with key...&lt;/STRONG&gt;. You simply don't know what will be the address inside a row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suggest to rebuild your table adding first field as a key field&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
types: begin of t_tab, 
           key_field type ...,
           data type ref to data,
          end of t_tab.

types: tt_tab type table of t_tab with key key_field.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you can access in with a key. Otherwise you can't even sort such table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2009 20:47:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-on-ref-to-data-table/m-p/5091439#M1181837</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2009-01-29T20:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: READ TABLE on REF TO DATA Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-on-ref-to-data-table/m-p/5091440#M1181838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to assign the data to the Field Symbol (type any table) to do any operation like: READ, LOOP etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  DATA: L_REF    TYPE REF TO DATA.

  FIELD-SYMBOLS: &amp;lt;LT_TEXT&amp;gt;     TYPE ANY TABLE,
                 &amp;lt;LA_TEXT&amp;gt;     TYPE ANY.

  ASSIGN L_REF-&amp;gt;* TO &amp;lt;LT_TEXT&amp;gt;.

      READ TABLE &amp;lt;LT_TEXT&amp;gt; ASSIGNING &amp;lt;LA_TEXT&amp;gt; INDEX 1.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2009 21:13:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-on-ref-to-data-table/m-p/5091440#M1181838</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2009-01-29T21:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: READ TABLE on REF TO DATA Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-on-ref-to-data-table/m-p/5091441#M1181839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You probably deref it to a field-symbol.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

DATA: dref TYPE REF TO data,
CREATE DATA dref TYPE vbak.

assign dref-&amp;gt;* to &amp;lt;fs&amp;gt;  "&amp;lt;fs&amp;gt; points to internal table

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now you can read this table using the following syntax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data key(20) type c.
key = 'VBELN'   " for example

read table &amp;lt;fs&amp;gt; with key (key) = '0000000001'.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Advait&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2009 21:22:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-on-ref-to-data-table/m-p/5091441#M1181839</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-29T21:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: READ TABLE on REF TO DATA Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-on-ref-to-data-table/m-p/5091442#M1181840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;EDITED:&lt;/P&gt;&lt;P&gt;Problem solved!! &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The Problem was that I haven created the table with a certain type but I created every row on its own. Now I created the data reference with a certain table type and now it works the way below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards from Vienna!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kamil&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi all!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your helpful replies.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to user the way of Advait Gode  with &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

DATA: dref TYPE REF TO data,
CREATE DATA dref TYPE zzcca_t_data.
 
field-symbols:
&amp;lt;fs1&amp;gt; type zzcca_t_data, "Tabletype with REF TO DATA as ROWTYPE
&amp;lt;fs2&amp;gt; type any.

assign dref-&amp;gt;* to &amp;lt;fs1&amp;gt; .

data key(20) type c.
key = 'POSNR'   " the structire zzccbo_belpos
 
read table &amp;lt;fs&amp;gt; with key (key) = '00001'. "NUMC5

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately I get a pretty shortdump "ITAB_ILLEGAL_COMPONENT" because it says that there is no element POSNR in &amp;lt;fs1&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Kamil&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Kamil Kubicki on Jan 30, 2009 11:35 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2009 10:12:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-on-ref-to-data-table/m-p/5091442#M1181840</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-30T10:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: READ TABLE on REF TO DATA Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-on-ref-to-data-table/m-p/5091443#M1181841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kamil,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;key = 'POSNR'   " the structire zzccbo_belpos&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am not sure what is structure &lt;STRONG&gt;zzccbo_belpos&lt;/STRONG&gt; but here all you need is row type with &lt;EM&gt;POSNR&lt;/EM&gt; field as key field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What you wrote is interpreted like: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
"create a pointer to a table (typed zzcca_t_data) 
CREATE DATA dref TYPE zzcca_t_data.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
"declare a field symbol which is able to get the content of a table under address stored by pointer
field-symbols:
&amp;lt;fs1&amp;gt; type zzcca_t_data, 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
"now poiter still has table address by also field symbol allows us to get table content (as it doesn't have name)
assign dref-&amp;gt;* to &amp;lt;fs1&amp;gt; .
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
read table &amp;lt;fs&amp;gt; with key (key) = '00001'. "NUMC5
"now read table content (which is get throught field symbol) where key field is POSNR
"this is wrong because your table seems not to have this field, you said it is of row type ref to data so it is type like this

types: begin of zzcca_t_data,
            some_ref_field type ref to data,
          end of zzcca_t_data.

"and should be 

types: begin of zzcca_t_data,
            posnr type  numc5,        "this field is must exist otherwise you can't read this table supplyijng this field as key field
            some_ref_field type ref to data,   
           end of zzcca_t_data.

"I gusess what you did is that you replaced 

types: zzcca_t_data type table of ref to data.

"...with above 1st declaration, but these statements are excatly the same. In second case you only use
"field name to address table row but no difference in logic (still you can't read it with key access as there is no such)

"what I suggest you is either add POSNR field to a table type (as above) or read it with index access as my predeccesors said
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this claryfies you bug&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS:  Advait's code is correct because he is typing his table with &lt;STRONG&gt;VBAK&lt;/STRONG&gt; so it already has key fields inside, therefore he is later able to access that table with particular key&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Marcin Pciak on Jan 30, 2009 2:32 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2009 13:31:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-on-ref-to-data-table/m-p/5091443#M1181841</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2009-01-30T13:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: READ TABLE on REF TO DATA Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-on-ref-to-data-table/m-p/5091444#M1181842</link>
      <description>&lt;P&gt;This cant work, check attached pic.&lt;A href="https://answers.sap.com/storage/temp/2212101-2023-09-25-11-43-07-window.jpg" data-attachment="2212101"&gt;2023-09-25-11-43-07-window.jpg&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2023 09:43:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-on-ref-to-data-table/m-p/5091444#M1181842</guid>
      <dc:creator>migiiiii</dc:creator>
      <dc:date>2023-09-25T09:43:29Z</dc:date>
    </item>
  </channel>
</rss>

