<?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: Dynamic Fields in Internal Table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-internal-table/m-p/3856114#M926922</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi a®s,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know is pointless my example, but it's just a test that I'm doing so I can learn how to&lt;/P&gt;&lt;P&gt;handle dynamic fields. I'm not going to put WA_USERS-NAME in the program that I'm&lt;/P&gt;&lt;P&gt;doing, it's just that I want to know how to access to the dynamic field. In the program&lt;/P&gt;&lt;P&gt;that I'm working on I have the name of the fields in an Excel file, and then I put them&lt;/P&gt;&lt;P&gt;in an internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Isaac Melendez&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 13 May 2008 18:17:46 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-05-13T18:17:46Z</dc:date>
    <item>
      <title>Dynamic Fields in Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-internal-table/m-p/3856106#M926914</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;I want something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: BEGIN OF IT_USERS OCCURS 0,
         NAME(30),
         AGE(2),
      END OF IT_USERS,
      WA_USERS LIKE LINE OF IT_USERS.

FIELD-SYMBOLS: &amp;lt;DYN_FIELD&amp;gt;.

ASSIGN 'WA_USERS-NAME' TO &amp;lt;DYN_FIELD&amp;gt;.

CLEAR: WA_USERS.
&amp;lt;DYN_FIELD&amp;gt; = 'John'.
APPEND WA_USERS TO IT_USERS.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to give the name of the fields in runtime, and then assign a value to them.&lt;/P&gt;&lt;P&gt;Can someone help me?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Isaac Melendez&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2008 17:23:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-internal-table/m-p/3856106#M926914</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-13T17:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Fields in Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-internal-table/m-p/3856107#M926915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can take the field name in the one variable than assing that to the field symbol. It will automatically assign that value to field also.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Like&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: BEGIN OF IT_USERS OCCURS 0,
         NAME(30),
         AGE(2),
      END OF IT_USERS,
      WA_USERS LIKE LINE OF IT_USERS.
 
FIELD-SYMBOLS: &amp;lt;DYN_FIELD&amp;gt;.
 
DATA: L_FIELD(20).

L_FIELD = 'WA_USERS-NAME'.
ASSIGN (L_FIELD) TO &amp;lt;DYN_FIELD&amp;gt;.
* ASSIGN 'WA_USERS-NAME' TO &amp;lt;DYN_FIELD&amp;gt;.
 
CLEAR: WA_USERS.
&amp;lt;DYN_FIELD&amp;gt; = 'John'.
APPEND WA_USERS TO IT_USERS.

&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>Tue, 13 May 2008 17:28:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-internal-table/m-p/3856107#M926915</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2008-05-13T17:28:33Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Fields in Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-internal-table/m-p/3856108#M926916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Isaac.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: lv_var(13) TYPE c VALUE 'WA_USERS-NAME'.

DATA: BEGIN OF it_users OCCURS 0,
         name(30),
         age(2),
      END OF it_users,
      wa_users LIKE LINE OF it_users.

FIELD-SYMBOLS: &amp;lt;dyn_field&amp;gt;.

ASSIGN (lv_var) TO &amp;lt;dyn_field&amp;gt;.

CLEAR: wa_users.
&amp;lt;dyn_field&amp;gt; = 'John'.
APPEND wa_users TO it_users.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;&lt;P&gt;Valter Oliveira.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2008 17:29:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-internal-table/m-p/3856108#M926916</guid>
      <dc:creator>valter_oliveira</dc:creator>
      <dc:date>2008-05-13T17:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Fields in Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-internal-table/m-p/3856109#M926917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: BEGIN OF IT_USERS OCCURS 0,
         NAME(30),
         AGE(2),
      END OF IT_USERS,
      WA_USERS LIKE LINE OF IT_USERS.
DATA: V_FIELD   LIKE DD03L-FIELDNAME.
 
FIELD-SYMBOLS: &amp;lt;DYN_FIELD&amp;gt;.
MOVE 'WA_USERS-NAME' TO V_FIELD.
CONDENSE V_FIELD NO-GAPS.
 
ASSIGN (V_FIELD) TO &amp;lt;DYN_FIELD&amp;gt;.
 
CLEAR: WA_USERS.
WRITE 'John' TO &amp;lt;DYN_FIELD&amp;gt;.
APPEND WA_USERS TO IT_USERS.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; a®&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2008 17:30:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-internal-table/m-p/3856109#M926917</guid>
      <dc:creator>former_member194669</dc:creator>
      <dc:date>2008-05-13T17:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Fields in Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-internal-table/m-p/3856110#M926918</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi check this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/assign.htm" target="test_blank"&gt;http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/assign.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;venkat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2008 17:32:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-internal-table/m-p/3856110#M926918</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-13T17:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Fields in Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-internal-table/m-p/3856111#M926919</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've already solved the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I made a mistake. I just need to put it without quotes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;ASSIGN WA_USERS-NAME TO &amp;lt;DYN_FIELD&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks Naimesh and Valter, your answers help me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Isaac Melendez&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2008 17:35:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-internal-table/m-p/3856111#M926919</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-13T17:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Fields in Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-internal-table/m-p/3856112#M926920</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your requirement is a little unclear, as if you want a table with name and ages, then you have already defined it correctly, just fill in the values for NAME and AGE.  Now if you want a dynanic structure of your internal table, where the column names are the actuall names, and the value of age column is the age, then you can do something like this.  Here we are creating the internal table as well as the structure, not sure how you would use the internal table in this case, but you could of course use the structure, each column would be a different person and the the value for that column is the age.  See this example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT  rich_0001.

DATA: lo_struct_type TYPE REF TO cl_abap_structdescr.
DATA: lo_table_type TYPE REF TO cl_abap_tabledescr.
DATA: lo_dataref TYPE REF TO data.

DATA: lt_comp_tab TYPE cl_abap_structdescr=&amp;gt;component_table.
DATA: ls_comp_tab LIKE LINE OF lt_comp_tab.

FIELD-SYMBOLS: &amp;lt;lt_table&amp;gt; TYPE STANDARD TABLE,
               &amp;lt;ls_table&amp;gt; TYPE ANY,
               &amp;lt;lv_field&amp;gt; TYPE ANY.

* Add components
ls_comp_tab-name = 'JOHN'.
ls_comp_tab-type ?= cl_abap_datadescr=&amp;gt;describe_by_name( 'INT4' ).
APPEND ls_comp_tab TO lt_comp_tab.
ls_comp_tab-name = 'BOB'.
ls_comp_tab-type ?= cl_abap_datadescr=&amp;gt;describe_by_name( 'INT4' ).
APPEND ls_comp_tab TO lt_comp_tab.
ls_comp_tab-name = 'SAM'.
ls_comp_tab-type ?= cl_abap_datadescr=&amp;gt;describe_by_name( 'INT4' ).
APPEND ls_comp_tab TO lt_comp_tab.

* Create dynamic internal table based on LT_COMP_TAB
lo_struct_type = cl_abap_structdescr=&amp;gt;create( lt_comp_tab ).
lo_table_type = cl_abap_tabledescr=&amp;gt;create( p_line_type = lo_struct_type ).

* Create references to dyn internal table and work area
CREATE DATA lo_dataref TYPE HANDLE lo_table_type.
ASSIGN lo_dataref-&amp;gt;* TO &amp;lt;lt_table&amp;gt;.
CREATE DATA lo_dataref TYPE HANDLE lo_struct_type.
ASSIGN lo_dataref-&amp;gt;* TO &amp;lt;ls_table&amp;gt;.

* Fill work area with values.
ASSIGN COMPONENT 'JOHN' OF STRUCTURE &amp;lt;ls_table&amp;gt; TO &amp;lt;lv_field&amp;gt;.
IF sy-subrc  = 0.
  &amp;lt;lv_field&amp;gt; = '29'.
ENDIF.
ASSIGN COMPONENT 'BOB' OF STRUCTURE &amp;lt;ls_table&amp;gt; TO &amp;lt;lv_field&amp;gt;.
IF sy-subrc  = 0.
  &amp;lt;lv_field&amp;gt; = '35'.
ENDIF.
ASSIGN COMPONENT 'SAM' OF STRUCTURE &amp;lt;ls_table&amp;gt; TO &amp;lt;lv_field&amp;gt;.
IF sy-subrc  = 0.
  &amp;lt;lv_field&amp;gt; = '42'.
ENDIF.

* Append this work area to the internal table.
APPEND &amp;lt;ls_table&amp;gt; TO &amp;lt;lt_table&amp;gt;.

CHECK sy-subrc  = 0.&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;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2008 17:42:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-internal-table/m-p/3856112#M926920</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2008-05-13T17:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Fields in Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-internal-table/m-p/3856113#M926921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Issac,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have question &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you are putting without quotes&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ASSIGN WA_USERS-NAME TO  pointing to ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what will be the value of WA_USERS-NAME?.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;APPEND WA_USERS TO IT_USERS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; a®&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2008 17:43:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-internal-table/m-p/3856113#M926921</guid>
      <dc:creator>former_member194669</dc:creator>
      <dc:date>2008-05-13T17:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Fields in Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-internal-table/m-p/3856114#M926922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi a®s,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know is pointless my example, but it's just a test that I'm doing so I can learn how to&lt;/P&gt;&lt;P&gt;handle dynamic fields. I'm not going to put WA_USERS-NAME in the program that I'm&lt;/P&gt;&lt;P&gt;doing, it's just that I want to know how to access to the dynamic field. In the program&lt;/P&gt;&lt;P&gt;that I'm working on I have the name of the fields in an Excel file, and then I put them&lt;/P&gt;&lt;P&gt;in an internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Isaac Melendez&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2008 18:17:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-internal-table/m-p/3856114#M926922</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-13T18:17:46Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Fields in Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-internal-table/m-p/3856115#M926923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rich,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The example that I put was an example of a test that I was doing to know to handle&lt;/P&gt;&lt;P&gt;dynamic fields. In my case I don´t need a dynamic structure, just dynamic fields. But&lt;/P&gt;&lt;P&gt;your example is very helpful. Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Isaac Melendez&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2008 18:33:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-internal-table/m-p/3856115#M926923</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-13T18:33:55Z</dc:date>
    </item>
  </channel>
</rss>

