<?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: Getting database table keys via RTTS in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaa-p/478423#M82174</link>
    <description>&lt;P&gt;I know that FM, it's GET_KEY_FIELDS_OF_TABLE. I'm begging for pure RTTS solution.&lt;/P&gt;</description>
    <pubDate>Mon, 07 Aug 2017 11:52:56 GMT</pubDate>
    <dc:creator>Astashonok</dc:creator>
    <dc:date>2017-08-07T11:52:56Z</dc:date>
    <item>
      <title>Getting database table keys via RTTS</title>
      <link>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaq-p/478419</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;I cannot get table keys via the RTTS technique. I use following code:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;    DATA: the_table TYPE REF TO data.
    CREATE DATA the_table TYPE TABLE OF ('MARA').
    DATA typedescription TYPE REF TO cl_abap_tabledescr.
    typedescription ?= cl_abap_tabledescr=&amp;gt;describe_by_data_ref( the_table ).
    DATA keys TYPE abap_table_keydescr_tab.
    keys = typedescription-&amp;gt;get_keys( ).&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;It always returns &lt;STRONG&gt;full list&lt;/STRONG&gt; of fields, not only primary key, which I don't want. &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;I also tried the detection of keys from static internal table, but got the same result.&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;DATA: itab LIKE mara OCCURS 0 WITH HEADER LINE,
      lt_tabdescr     TYPE abap_keydescr_tab,
      ref_table_descr TYPE REF TO cl_abap_tabledescr.

ref_table_descr ?=  cl_abap_typedescr=&amp;gt;describe_by_data( itab[] ).
lt_tabdescr[] = ref_table_descr-&amp;gt;key[].&amp;lt;br&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Detecting the key fields via &lt;EM&gt;describe_by_name( )&lt;/EM&gt; doesn't work either.&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Any suggestions? System release is SAP ECC 7.40 SP09&lt;/P&gt;</description>
      <pubDate>Sun, 30 Jul 2017 07:39:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaq-p/478419</guid>
      <dc:creator>Astashonok</dc:creator>
      <dc:date>2017-07-30T07:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: Getting database table keys via RTTS</title>
      <link>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaa-p/478420#M82171</link>
      <description>&lt;P&gt;You are confusing the primary key of the database table MARA, and the primary key of the internal table, which are completely different.&lt;/P&gt;
  &lt;P&gt;In your case, you have created a &lt;STRONG&gt;standard&lt;/STRONG&gt; internal table with a &lt;STRONG&gt;default&lt;/STRONG&gt; primary key (because you have not defined anything), which is made of all initial fields of the structure (MARA) up to the first non-character-type field (excluded).&lt;/P&gt;
  &lt;P&gt;If you want specific key fields, use DATA ... TABLE OF ... WITH [NON-]UNIQUE KEY field1 field2, or CREATE DATA ... TABLE OF ... WITH [NON-]UNIQUE KEY (dynamic list of fields).&lt;/P&gt;
  &lt;P&gt;For more information, refer to the ABAP documentation.&lt;/P&gt;
  &lt;P&gt;PS: please forget the obsolete notations OCCURS and WITH HEADER LINE.&lt;/P&gt;</description>
      <pubDate>Sun, 30 Jul 2017 08:00:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaa-p/478420#M82171</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2017-07-30T08:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: Getting database table keys via RTTS</title>
      <link>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaa-p/478421#M82172</link>
      <description>&lt;P&gt;Okkay, got it. But how to get key fields of &lt;STRONG&gt;dictionary&lt;/STRONG&gt; transparent table?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 09:55:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaa-p/478421#M82172</guid>
      <dc:creator>Astashonok</dc:creator>
      <dc:date>2017-08-07T09:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: Getting database table keys via RTTS</title>
      <link>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaa-p/478422#M82173</link>
      <description>&lt;P&gt;I don't know the FM off the top of my head, but you can query table DD03L to get the key fields of a DB table.&lt;/P&gt;
  &lt;P&gt;PS. Adding this as a comment because Sandra technically provided the answer to your question as you asked it.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 11:19:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaa-p/478422#M82173</guid>
      <dc:creator>pokrakam</dc:creator>
      <dc:date>2017-08-07T11:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: Getting database table keys via RTTS</title>
      <link>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaa-p/478423#M82174</link>
      <description>&lt;P&gt;I know that FM, it's GET_KEY_FIELDS_OF_TABLE. I'm begging for pure RTTS solution.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 11:52:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaa-p/478423#M82174</guid>
      <dc:creator>Astashonok</dc:creator>
      <dc:date>2017-08-07T11:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: Getting database table keys via RTTS</title>
      <link>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaa-p/478424#M82175</link>
      <description>&lt;P&gt;There is a method GET_DDIC_FIELD_LIST in CL_ABAP_STRUCTDESCR.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 12:00:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaa-p/478424#M82175</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-08-07T12:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: Getting database table keys via RTTS</title>
      <link>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaa-p/478425#M82176</link>
      <description>&lt;P&gt;Nope. Just tested and GET_DDIC_FIELD_LIST always returns ALL fields, not only key ones. Maybe there is some trick?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 13:09:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaa-p/478425#M82176</guid>
      <dc:creator>Astashonok</dc:creator>
      <dc:date>2017-10-11T13:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: Getting database table keys via RTTS</title>
      <link>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaa-p/478426#M82177</link>
      <description>&lt;P&gt;Use DD03L as Mike said. RTTS doesn't need to know anything about keys/indexes of the database, as RTTS is only the dynamic part of the ABAP typing system.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 19:52:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaa-p/478426#M82177</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2018-03-07T19:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: Getting database table keys via RTTS</title>
      <link>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaa-p/478427#M82178</link>
      <description>&lt;P&gt;Filter returning table and you will get just key fields &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;DELETE lt_field_list WHERE keyflag &amp;lt;&amp;gt; 'X'.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Mar 2018 08:59:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaa-p/478427#M82178</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2018-03-29T08:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Getting database table keys via RTTS</title>
      <link>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaa-p/478428#M82179</link>
      <description>&lt;P&gt;You should put that as answer &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 15:59:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaa-p/478428#M82179</guid>
      <dc:creator>Astashonok</dc:creator>
      <dc:date>2018-03-29T15:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: Getting database table keys via RTTS</title>
      <link>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaa-p/478429#M82180</link>
      <description>&lt;P&gt;Well, as suggested by &lt;SPAN class="mention-scrubbed"&gt;horst.keller&lt;/SPAN&gt; in comments, you can use method &lt;STRONG&gt;get_ddic_field_list&lt;/STRONG&gt; of class &lt;STRONG&gt;CL_ABAP_STRUCTDESCR&lt;/STRONG&gt;.&lt;/P&gt;
  &lt;P&gt;And filter its returning table by &lt;STRONG&gt;KEYFLAG&lt;/STRONG&gt; field value &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; For example:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;DELETE lt_field_list WHERE keyflag &amp;lt;&amp;gt; 'X'.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Apr 2018 06:40:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/getting-database-table-keys-via-rtts/qaa-p/478429#M82180</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2018-04-03T06:40:37Z</dc:date>
    </item>
  </channel>
</rss>

