<?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 internal table fields in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-fields/m-p/3949668#M944327</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt; thanks for the prompt response. The code you posted allows me to copy all the fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm interested to see only few fields in particular..and in case those fields doesn't exist in the dynamic table, it should not give a short dump.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know your comments.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;KK&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 May 2008 16:43:20 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-05-27T16:43:20Z</dc:date>
    <item>
      <title>dynamic internal table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-fields/m-p/3949666#M944325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt; I need to move fields from a dynamic internal table to another table. I have to check whether those fields which i'm interested in exists in that dynamic table or not before i assign the values in these fields to other fields. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Let me know how to do this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;KK.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 16:27:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-fields/m-p/3949666#M944325</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T16:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic internal table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-fields/m-p/3949667#M944326</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See the code bellow:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  DATA dref TYPE REF TO data.

  FIELD-SYMBOLS:
    &amp;lt;tab&amp;gt;   TYPE ANY TABLE,
    &amp;lt;wa&amp;gt;    TYPE ANY,
    &amp;lt;field&amp;gt; TYPE ANY.


  TRY.
      CREATE DATA dref
        TYPE STANDARD TABLE OF (dbtab) WITH NON-UNIQUE DEFAULT KEY.
      ASSIGN dref-&amp;gt;* TO &amp;lt;tab&amp;gt;.

      SELECT *
             FROM (dbtab) UP TO rows ROWS
             INTO TABLE &amp;lt;tab&amp;gt;.

      LOOP AT &amp;lt;tab&amp;gt; ASSIGNING &amp;lt;wa&amp;gt;.

        DO.
          ASSIGN COMPONENT sy-index OF STRUCTURE &amp;lt;wa&amp;gt; TO &amp;lt;field&amp;gt;.
          IF sy-subrc = 0.
            WRITE / &amp;lt;field&amp;gt;.
          ELSE.
            EXIT.
          ENDIF.
        ENDDO.

        ULINE.
      ENDLOOP.
    CATCH cx_sy_create_data_error.
      WRITE 'Wrong Database!'.
  ENDTRY.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can do the check that you need using the code between DO and ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ASSIGN COMPONENT&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... COMPONENT comp OF STRUCTURE struc &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;With this expression for mem_area, the memory area of a component comp of a structure struc is assigned to the field symbol. While the structure struc is specified directly, a data object must be specified for comp. The evaluation depends on the data type of comp: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the field comp has a text-type type (c or string), or a flat structure, its content is interpreted as the name of the component. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the field comp has a non-text, elementary type, the content is converted to the type i and interpreted as a position of the component in the structure. if the value for comp is 0, the storage area of the entire structure is assigned to the field symbol. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If struc is not a structure, the assignment is not executed and sy-subrc is set to 4. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 16:35:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-fields/m-p/3949667#M944326</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T16:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic internal table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-fields/m-p/3949668#M944327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt; thanks for the prompt response. The code you posted allows me to copy all the fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm interested to see only few fields in particular..and in case those fields doesn't exist in the dynamic table, it should not give a short dump.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know your comments.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;KK&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 16:43:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-fields/m-p/3949668#M944327</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T16:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic internal table fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-fields/m-p/3949669#M944328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to use the &lt;STRONG&gt;assign component&lt;/STRONG&gt; command to get the fields from the structure like described before.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the field doesn't exist the &lt;STRONG&gt;sy-subrc&lt;/STRONG&gt; field will be set to &lt;STRONG&gt;4&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  CONSTANTS:
    lc1 TYPE c LENGTH 10 VALUE 'FIELD1',
    lc2 TYPE c LENGTH 10 VALUE 'FIELD2'.
  DATA:
    dref      TYPE REF TO data,
    fieldname TYPE c LENGTH 10,
    lv_i      TYPE n LENGTH 1.

  FIELD-SYMBOLS:
    &amp;lt;tab&amp;gt;   TYPE ANY TABLE,
    &amp;lt;wa&amp;gt;    TYPE ANY,
    &amp;lt;field&amp;gt; TYPE ANY,
    &amp;lt;fieldname&amp;gt; TYPE ANY.


  TRY.
      CREATE DATA dref
        TYPE STANDARD TABLE OF (dbtab) WITH NON-UNIQUE DEFAULT KEY.
      ASSIGN dref-&amp;gt;* TO &amp;lt;tab&amp;gt;.

      SELECT *
             FROM (dbtab) UP TO rows ROWS
             INTO TABLE &amp;lt;tab&amp;gt;.

      LOOP AT &amp;lt;tab&amp;gt; ASSIGNING &amp;lt;wa&amp;gt;.


        DO 2 TIMES.
          lv_i = sy-index.
          CONCATENATE 'LC' lv_i INTO fieldname.
          ASSIGN (fieldname) TO &amp;lt;fieldname&amp;gt;.

          ASSIGN COMPONENT &amp;lt;fieldname&amp;gt; OF STRUCTURE &amp;lt;wa&amp;gt; TO &amp;lt;field&amp;gt;.
          IF sy-subrc = 0.
            WRITE / &amp;lt;field&amp;gt;.
          ELSE.
            EXIT.
          ENDIF.
        ENDDO.


        ULINE.
      ENDLOOP.
    CATCH cx_sy_create_data_error.
      WRITE 'Wrong Database!'.
  ENDTRY.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 16:55:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-fields/m-p/3949669#M944328</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T16:55:13Z</dc:date>
    </item>
  </channel>
</rss>

