<?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 statement with dynamic key in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-statement-with-dynamic-key/m-p/2747733#M638844</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have already tried using field symbols but that doesn't work either. Plus the fact that I would not even know the value '2021'. Means the whole condition is to be taken from another table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also tried using the work area but it doesnt work. Is there a tested code you have tried ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 11 Sep 2007 08:43:21 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-09-11T08:43:21Z</dc:date>
    <item>
      <title>Read table statement with dynamic key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-statement-with-dynamic-key/m-p/2747728#M638839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I want to read a table for which a key is defined in another z table. So basically I want to achieve the following :-&lt;/P&gt;&lt;P&gt;Ideally we write a read statement like this :-&lt;/P&gt;&lt;P&gt;READ TABLE ITAB WITH KEY MATNR = '2021'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I want to read in the following way :-&lt;/P&gt;&lt;P&gt;data : var1 type string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var1 = 'MATNR = ''2021'''.&lt;/P&gt;&lt;P&gt;READ TABLE ITAB WITH KEY VAR1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The fields and conditions for the key are defined in a z table so I have to pass them dynamically to the read statement.&lt;/P&gt;&lt;P&gt;Please suggest how I can achieve this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Archana.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2007 08:29:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-statement-with-dynamic-key/m-p/2747728#M638839</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-11T08:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: Read table statement with dynamic key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-statement-with-dynamic-key/m-p/2747729#M638840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;u cud try to use use field symbols&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;fs_f&amp;gt;.&lt;/P&gt;&lt;P&gt;  lv_feld        = 'MATNR'.&lt;/P&gt;&lt;P&gt; assign (lv_feld) to &amp;lt;fs_f&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE ITAB WITH KEY &amp;lt;fs_f&amp;gt; = '022'.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2007 08:34:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-statement-with-dynamic-key/m-p/2747729#M638840</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-11T08:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: Read table statement with dynamic key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-statement-with-dynamic-key/m-p/2747730#M638841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi archana,&lt;/P&gt;&lt;P&gt;assing var1 value to work area. and use that work area as key.&lt;/P&gt;&lt;P&gt;Bohra.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2007 08:36:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-statement-with-dynamic-key/m-p/2747730#M638841</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-11T08:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: Read table statement with dynamic key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-statement-with-dynamic-key/m-p/2747731#M638842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Archana,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can do this by reading all MATNR values from DB table into an internal table and then looping it. You can give READ statment inside this loop and do further processing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;DATA: BEGIN OF itab1 occurs 0,&lt;/P&gt;&lt;P&gt;matnr TYPE MATNR.&lt;/P&gt;&lt;P&gt;END OF itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT MATNR FROM &amp;lt;TABLE&amp;gt; INTO itab1 WHERE &amp;lt;conditions&amp;gt;.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;LOOP AT itab1.&lt;/P&gt;&lt;P&gt;READ TABLE ITAB WITH KEY matnr = itab1-matnr.&lt;/P&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;&lt;P&gt;ENDLOOP.&amp;lt;/b&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;*Reward points if it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amit&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2007 08:39:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-statement-with-dynamic-key/m-p/2747731#M638842</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-11T08:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: Read table statement with dynamic key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-statement-with-dynamic-key/m-p/2747732#M638843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;good&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call function 'DDIF_FIELDINFO_GET'&lt;/P&gt;&lt;P&gt;  exporting&lt;/P&gt;&lt;P&gt;    tabname        = v_tabname "&amp;lt;&amp;lt; dynamic table name&lt;/P&gt;&lt;P&gt;    langu          = sy-langu&lt;/P&gt;&lt;P&gt;  tables&lt;/P&gt;&lt;P&gt;    dfies_tab      = i_dfies&lt;/P&gt;&lt;P&gt;  exceptions&lt;/P&gt;&lt;P&gt;    not_found      = 1&lt;/P&gt;&lt;P&gt;    internal_error = 2&lt;/P&gt;&lt;P&gt;    others         = 3.&lt;/P&gt;&lt;P&gt;if sy-subrc eq 0.&lt;/P&gt;&lt;P&gt;  loop at i_dfies where fieldname ne 'MANDT' and keyflag eq 'X'.&lt;/P&gt;&lt;P&gt;    assign component i_dfies-position of structure &amp;lt;xtab&amp;gt; to &amp;lt;f3&amp;gt;.&lt;/P&gt;&lt;P&gt;    &amp;lt;&amp;lt; Here you get the key field value in the field symbol&amp;gt;&amp;gt; &lt;/P&gt;&lt;P&gt;  endloop.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;mrutyun^&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2007 08:43:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-statement-with-dynamic-key/m-p/2747732#M638843</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-11T08:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: Read table statement with dynamic key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-statement-with-dynamic-key/m-p/2747733#M638844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have already tried using field symbols but that doesn't work either. Plus the fact that I would not even know the value '2021'. Means the whole condition is to be taken from another table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also tried using the work area but it doesnt work. Is there a tested code you have tried ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2007 08:43:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-statement-with-dynamic-key/m-p/2747733#M638844</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-11T08:43:21Z</dc:date>
    </item>
    <item>
      <title>Re: Read table statement with dynamic key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-statement-with-dynamic-key/m-p/2747734#M638845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try this...it is the way how we get the field dynamically...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tables: spfli.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;parameters&amp;lt;/b&amp;gt;: field(10) type c,&lt;/P&gt;&lt;P&gt;            value(10) type c.&lt;/P&gt;&lt;P&gt;data:&lt;/P&gt;&lt;P&gt;  itab like standard table of spfli,&lt;/P&gt;&lt;P&gt;  wa like line of itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  select * from spfli into table itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;condense field.&lt;/P&gt;&lt;P&gt;condense value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table itab with key &amp;lt;b&amp;gt;(field) = value&amp;lt;/b&amp;gt; into wa.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-subrc eq 0.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2007 08:58:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-statement-with-dynamic-key/m-p/2747734#M638845</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-11T08:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Read table statement with dynamic key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-statement-with-dynamic-key/m-p/2747735#M638846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;Actually I have a z table as follows :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RULE                      CONDITION&lt;/P&gt;&lt;P&gt;MER                       prodid = '10'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now in the program I will select this row. I have an internal table which will already have a field 'prodid'. Now I want to read the records which satifies the condition 'prodid = 10'. This condition is only defined in the table and can be any field and any operand and any fixed value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So i have this condition stored in a variable of string type var 1, where var1 = 'prodid=''10'''.&lt;/P&gt;&lt;P&gt;now I have to read the table with this condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE ITAB WITH KEY VAR1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now this syntax is not accepted, so can anybody please suggest how we can achieve this ? I tries using field symbols as well but nothing worked.&lt;/P&gt;&lt;P&gt;The operand and fixed value are also not known so the whole condition has to be taken from the ztable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please suggest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Archana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2007 10:13:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-statement-with-dynamic-key/m-p/2747735#M638846</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-11T10:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: Read table statement with dynamic key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-statement-with-dynamic-key/m-p/2747736#M638847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This approach did not work out so changed the approach.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Feb 2009 09:23:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-statement-with-dynamic-key/m-p/2747736#M638847</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-27T09:23:34Z</dc:date>
    </item>
  </channel>
</rss>

