title: How to set dynamic key for READ TABLE?
body: <p>I'm trying to work out a way to read an internal table that has to be created dynamically. I have created the following report that fills a dynamic internal table with data.</p>
  
  <p>On the last line, I'm trying to read it with a key (<code>mandt</code> for example), but I I get this syntax error:</p>
  
  <blockquote>
    <p>The specified type has no structure and therefore no component called MANDT</p>
  </blockquote>
  
  <p>I have debugged and I can see that <code>&lt;any_tab&gt;</code> has been populated successfully and the structure of the table (field names) are correct. The problem presents itself when I try to read the table into a work area. Maybe I'm doing this wrong, but it seems like something that should be possible to do, and I have a feeling I'm missing something small.</p>
  
  <p>The reason I am trying this out is that I have found identical selects happening in a program and want to buffer records in memory and read them from there to avoid DB accesses. This is easy to implement, however I haven't done this when the table, <code>where</code> clause and <code>into</code> clause of the OPEN SQL statement I'm trying to optimize are dynamic. </p>
  
  <p>How to correct the syntax error?</p>
  
  <pre><code>DATA: t681_rep TYPE TABLE OF t681 , wa_681 LIKE LINE OF t681_rep,
        tabref TYPE REF TO data , waref TYPE REF TO data.
  
  FIELD-SYMBOLS: &lt;any_tab&gt; TYPE ANY TABLE,
                 &lt;any_wa&gt; TYPE ANY,
                 &lt;var1&gt; TYPE ANY.
  "fill t681_rep
  SELECT *
    FROM t681
    INTO TABLE t681_rep
     UP TO 1 ROWS WHERE kotab = 'A002'.
  
  READ TABLE t681_rep INTO wa_681 WITH KEY kotab = 'A002'.
  IF sy-subrc = 0.
  
    "if A002 is found create a table of that type and fill it
    CREATE DATA tabref TYPE TABLE OF (wa_681-kotab).
    ASSIGN tabref-&gt;* TO &lt;any_tab&gt;.
    SELECT * UP TO 10 ROWS
      FROM (wa_681-kotab)
      INTO TABLE &lt;any_tab&gt;.
  
  ENDIF.
  
  CREATE DATA waref TYPE a002.
  ASSIGN waref-&gt;* TO &lt;any_wa&gt;.
  
  READ TABLE &lt;any_tab&gt; ASSIGNING &lt;any_wa&gt; WITH KEY mandt = '800'. &lt;- problem area
  IF sy-subrc = 0.
    "do stuff with &lt;any_wa&gt;...
  ENDIF.
  </code></pre>