<?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 can we access a field in an internal table field using variable in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/can-we-access-a-field-in-an-internal-table-field-using-variable/m-p/3545587#M853049</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;&lt;/P&gt;&lt;P&gt;I have a requirement like this..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let we have an internal table with fields d01, d02 and so on&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;we build this field name at runtime like in a loop &lt;/P&gt;&lt;P&gt;I can make the VAR value to d01 at runtime like concatenate 'd' syindex into &lt;STRONG&gt;VAR&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then we assign a value to that field like itab-d01 at runtime&lt;/P&gt;&lt;P&gt;now I want to assign itab-VAR = xyz&lt;/P&gt;&lt;P&gt;here it shoud take itab-d01 = xyz as &lt;STRONG&gt;VAR&lt;/STRONG&gt; = d01&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope explained the requirement properly?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me in this issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Mar 2008 06:54:00 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-03-19T06:54:00Z</dc:date>
    <item>
      <title>can we access a field in an internal table field using variable</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/can-we-access-a-field-in-an-internal-table-field-using-variable/m-p/3545587#M853049</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;&lt;/P&gt;&lt;P&gt;I have a requirement like this..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let we have an internal table with fields d01, d02 and so on&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;we build this field name at runtime like in a loop &lt;/P&gt;&lt;P&gt;I can make the VAR value to d01 at runtime like concatenate 'd' syindex into &lt;STRONG&gt;VAR&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then we assign a value to that field like itab-d01 at runtime&lt;/P&gt;&lt;P&gt;now I want to assign itab-VAR = xyz&lt;/P&gt;&lt;P&gt;here it shoud take itab-d01 = xyz as &lt;STRONG&gt;VAR&lt;/STRONG&gt; = d01&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope explained the requirement properly?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me in this issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2008 06:54:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/can-we-access-a-field-in-an-internal-table-field-using-variable/m-p/3545587#M853049</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-19T06:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: can we access a field in an internal table field using variable</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/can-we-access-a-field-in-an-internal-table-field-using-variable/m-p/3545588#M853050</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;u an do like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  DATA: BEGIN OF STR,
          A VALUE 'a',
          B VALUE 'b',
          C VALUE 'c',
          D VALUE 'd',
        END   OF STR,
        CN(5) VALUE 'D'.
  FIELD-SYMBOLS &amp;lt;FS&amp;gt; TYPE ANY.
  DO 3 TIMES.
    ASSIGN COMPONENT SY-INDEX OF
           STRUCTURE STR TO &amp;lt;FS&amp;gt;.
    IF SY-SUBRC &amp;lt;&amp;gt; 0. EXIT. ENDIF.
    WRITE &amp;lt;FS&amp;gt;.
  ENDDO.
  ASSIGN COMPONENT CN OF STRUCTURE STR TO &amp;lt;FS&amp;gt;.
  WRITE &amp;lt;FS&amp;gt;.

   move '1' to &amp;lt;fs&amp;gt;.
  WRITE str-d.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;your case.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  DATA: BEGIN OF STR OCCURS 0,
          d01(5),
          d02(5),
          d03(5),
          d04(5),
        END   OF STR,
        CN(5) VALUE 'd04'.
  DATA:ind(2).
  FIELD-SYMBOLS &amp;lt;FS&amp;gt; TYPE ANY.

  DO 4 TIMES.
    ASSIGN COMPONENT SY-INDEX OF
           STRUCTURE STR TO &amp;lt;FS&amp;gt;.
    IF SY-SUBRC &amp;lt;&amp;gt; 0.
      EXIT.
    ENDIF.
    ind = sy-index.
    CONCATENATE 'val' ind into &amp;lt;FS&amp;gt;.
  ENDDO.
  APPEND str.

  DO 4 TIMES.
    ASSIGN COMPONENT SY-INDEX OF
               STRUCTURE STR TO &amp;lt;FS&amp;gt;.
    write: &amp;lt;fs&amp;gt;.
  ENDDO.

    ASSIGN COMPONENT CN OF STRUCTURE STR TO &amp;lt;FS&amp;gt;.
    WRITE:/ &amp;lt;FS&amp;gt;.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rgds,&lt;/P&gt;&lt;P&gt;bharat.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2008 07:02:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/can-we-access-a-field-in-an-internal-table-field-using-variable/m-p/3545588#M853050</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-19T07:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: can we access a field in an internal table field using variable</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/can-we-access-a-field-in-an-internal-table-field-using-variable/m-p/3545589#M853051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bharat,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that I have not explained the requirement well,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check the program below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: begin of itab occurs 0,
  	d01 type char2,
	d02 type char2,
  	d03 type char2,
       end of itab.

data: begin of jtab occurs 0,
	item type num2,
	value type char2,
       end of jtab.


jtab-item = 01.
jtab-value = 'na'.
append jtab.

jtab-item = 02.
jtab-value = 'nb'.
append jtab.

jtab-item = 03.
jtab-value = 'zy'.
append jtab.

do 3 times.
  concatenate 'd' sy-index into field.

  read table jtab with key item = sy-index.
    if sy-subrc = 0.
      itab-(field) = jtab-value. "&amp;lt;&amp;lt; here I want actually to assign to d01, d02 and to d03.
    endif.
enddo.

append itab.

* here actually 3 records in jtab will create only one record in itab.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Like this I want to assign the values dynamically to fill itab from the values of jtab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;work around to this will be&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: begin of itab occurs 0,
	d01 type char2,
	d02 type char2,
	d03 type char2,
       end of itab.

data: begin of jtab occurs 0,
	item type num2,
	value type char2,
       end of jtab.


jtab-item = 01.
jtab-value = 'na'.
append jtab.

jtab-item = 02.
jtab-value = 'nb'.
append jtab.

jtab-item = 03.
jtab-value = 'zy'.
append jtab.

do 3 times.

  concatenate 'd' sy-index into field.
  read table jtab with key item = sy-index.
  if sy-subrc = 0.
    case sy-index.
      when '01'.
        itab-d01 = jtab-value. 
      when '02'.
        itab-d02 = jtab-value. 
      when '03'.
        itab-d03 = jtab-value. 
    endcase.

  endif.
enddo.

append itab.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the above case only 3 fields are there if more fields are there it will be cumbersome to handle all the situations by code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope now you understood the requierement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2008 07:33:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/can-we-access-a-field-in-an-internal-table-field-using-variable/m-p/3545589#M853051</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-19T07:33:25Z</dc:date>
    </item>
  </channel>
</rss>

