<?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: Retrieve name of a variable dynamically in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481924#M15886</link>
    <description>&lt;P&gt;That is as close to the solution as I have gotten. But what about singular FS or variables that are not part of any structure? Thanks for the valuable input.&lt;/P&gt;</description>
    <pubDate>Thu, 27 Jul 2017 07:45:03 GMT</pubDate>
    <dc:creator>former_member488913</dc:creator>
    <dc:date>2017-07-27T07:45:03Z</dc:date>
    <item>
      <title>Retrieve name of a variable dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481917#M15879</link>
      <description>&lt;P&gt;Dear friends,&lt;/P&gt;
  &lt;P&gt;I want to store the name of a variable in a string for later use. Assume that the name of the variable is not known till runtime.&lt;/P&gt;
  &lt;P&gt;Something like:&lt;/P&gt;
  &lt;P&gt;DATA: v_myvar TYPE c. " v_myvar may not be known till runtime&lt;/P&gt;
  &lt;P&gt;DATA: varname TYPE string.&lt;/P&gt;
  &lt;P&gt;I need a way to retrieve and store 'v_myvar' in varname @ runtime.&lt;/P&gt;
  &lt;P&gt;I have tried using the cl_abap_*descr classes, but all I could get was the data type, not the name of the variable. For structures and tables it is possible to get the component list, but again how to get the name of the structure or table itself? Similarly for field-symbiols,&lt;/P&gt;
  &lt;P&gt;DATA: &amp;lt;fs&amp;gt; TYPE any.&lt;/P&gt;
  &lt;P&gt;ASSIGN v_myvar TO &amp;lt;fs&amp;gt;.&lt;/P&gt;
  &lt;P&gt;&amp;lt;fs&amp;gt; can be used to retrieve the value of v_myvar, but is it possible to retrieve the name of the var/structure/table that the field-symbol is pointing to @ runtime?&lt;/P&gt;
  &lt;P&gt;Any help would be appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 05:53:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481917#M15879</guid>
      <dc:creator>former_member488913</dc:creator>
      <dc:date>2017-07-27T05:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve name of a variable dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481918#M15880</link>
      <description>&lt;P&gt;One question. Why? A little more explanation of why the variable name isn't known until runtime would help. &lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 06:49:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481918#M15880</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2017-07-27T06:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve name of a variable dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481919#M15881</link>
      <description>&lt;P&gt;It's almost impossible to do it in ABAP, and anyway programs usually never need the name of a variable, they only need the value.&lt;/P&gt;
  &lt;P&gt;Usually, we use the statements GET REFERENCE, CREATE DATA, ASSIGN dref-&amp;gt;* (dereferencing), or the equivalent constructor operators (REF, NEW). Please refer to the ABAP documentation.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 07:06:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481919#M15881</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2017-07-27T07:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve name of a variable dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481920#M15882</link>
      <description>&lt;P&gt;With a FM like WB_TREE_SELECT you can get a list of the variable/structures defined in the program and then perform some check with some assignments, but what is your purpose, can you elaborate on it. Also how is defined the variable some obsolete global data, some attribute of a class, without clear context too many options are available...&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 07:14:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481920#M15882</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2017-07-27T07:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve name of a variable dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481921#M15883</link>
      <description>&lt;P&gt;One possible scenario would be the use of &lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;ASSIGN COMPONENT sy-index OF STRUCTURE &amp;lt;fs_wa&amp;gt; TO &amp;lt;fs&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Now, I modify the value of &amp;lt;fs&amp;gt; @ runtime based on a condition and want to have a log of structure components that got modified.&lt;/P&gt;
  &lt;P&gt;I think we would have to retrieve the fieldnames for that?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 07:17:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481921#M15883</guid>
      <dc:creator>former_member488913</dc:creator>
      <dc:date>2017-07-27T07:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve name of a variable dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481922#M15884</link>
      <description>&lt;P&gt;Yep. In the end, you have to parse the code.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 07:30:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481922#M15884</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-07-27T07:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve name of a variable dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481923#M15885</link>
      <description>&lt;P&gt;In your example&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;ASSIGN COMPONENT sy-index OF STRUCTURE &amp;lt;fs_wa&amp;gt; TO &amp;lt;fs&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;you can determine the component name with cl_abap_structdescr and sy-index.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 07:35:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481923#M15885</guid>
      <dc:creator>pokrakam</dc:creator>
      <dc:date>2017-07-27T07:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve name of a variable dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481924#M15886</link>
      <description>&lt;P&gt;That is as close to the solution as I have gotten. But what about singular FS or variables that are not part of any structure? Thanks for the valuable input.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 07:45:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481924#M15886</guid>
      <dc:creator>former_member488913</dc:creator>
      <dc:date>2017-07-27T07:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve name of a variable dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481925#M15887</link>
      <description>&lt;P&gt;I can't think of a scenario where this is unknown or cannot be derived. Next example? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 08:26:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481925#M15887</guid>
      <dc:creator>pokrakam</dc:creator>
      <dc:date>2017-07-27T08:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve name of a variable dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481926#M15888</link>
      <description>&lt;P&gt;That use case is answered by Mike Pokraka. But what is the use case for "But what about singular FS or variables that are not part of any structure?"? Or is it just curiosity?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 08:29:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481926#M15888</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2017-07-27T08:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve name of a variable dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481927#M15889</link>
      <description>&lt;P&gt;Yes, I'm definitely curious as to wether such a thing is possible via ABAP.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 09:21:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481927#M15889</guid>
      <dc:creator>former_member488913</dc:creator>
      <dc:date>2017-07-27T09:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve name of a variable dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481928#M15890</link>
      <description>&lt;P&gt;As before, I'm curious as to why?&lt;/P&gt;
  &lt;P&gt;It's a bit like working with an importing parameter and saying "I want to know what the programmer called it in their code before calling my method". I don't care. I shouldn't care; if it were important then I have a fundamental design flaw somewhere.&lt;/P&gt;
  &lt;P&gt;Of course &lt;A href="https://help.sap.com/http.svc/rc/abapdocu_750_index_htm/7.50/en-US/abenunnamed_data_object_glosry.htm"&gt;unnamed data objects&lt;/A&gt; are standard ABAP features, so I still see no scenario where knowing a name would ever be important.&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;assign 'Hello World' to field-symbol(&amp;lt;fs&amp;gt;).&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Jul 2017 10:58:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481928#M15890</guid>
      <dc:creator>pokrakam</dc:creator>
      <dc:date>2017-07-27T10:58:02Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve name of a variable dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481929#M15891</link>
      <description>&lt;P&gt;Inside a method, I want to know the name of the actual parameter passed to a formal parameter.&lt;/P&gt;
  &lt;P&gt;See CL_DEMO_INPUT and CL_DEMO_OUTPUT. It took me hours and hours to get that done. &lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 11:25:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481929#M15891</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-07-27T11:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve name of a variable dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481930#M15892</link>
      <description>&lt;P&gt;&lt;/P&gt;
  &lt;P&gt;"It's a bit like working with an importing parameter and saying "I want to know what the programmer called it in their code before calling my method". I don't care."&lt;/P&gt;
  &lt;P&gt;See CL_DEMO_INPUT/CL_DEMO_OUTPUT. They want to know.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 11:28:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481930#M15892</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-07-27T11:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve name of a variable dynamically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481931#M15893</link>
      <description>&lt;P&gt;Nice one Horst! Is that why CL_DEMO_OUTPUT is clearly marked as 'not for productive use'? &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/P&gt;
  &lt;P&gt;(sorry, it was the best response I could come up with &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
  &lt;P&gt;OK things like compiler, SCI or other language tools may need this type of functionality because the semantics are different: here the program is the subject matter (= business data). But I still still can't think of a 'regular application' scenario where good program structure can't provide the information the OP is after.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 11:25:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-name-of-a-variable-dynamically/m-p/481931#M15893</guid>
      <dc:creator>pokrakam</dc:creator>
      <dc:date>2017-08-01T11:25:07Z</dc:date>
    </item>
  </channel>
</rss>

