<?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: using table field name as a variable in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-table-field-name-as-a-variable/m-p/6071300#M1355623</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tamas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for ur post ! it did certainly help. However, I need some more help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is what I need - &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will have a string coming up from an interface which would be something like : Val1;Val2;Val3&lt;/P&gt;&lt;P&gt;And in SAP R/3 I have a variable maintained as : Field1;Field2;Field3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Field1 Field2 and Field3 are fields of a ZTABLE.&lt;/P&gt;&lt;P&gt;So , at runtime, using the variable I have to determine which Value goes to which field and then insert this field in ZTABLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, ultimately , code should perform the following actions:&lt;/P&gt;&lt;P&gt;ZTABLE-FIELD1 = Val1&lt;/P&gt;&lt;P&gt;ZTABLE-FIELD2 = Val2&lt;/P&gt;&lt;P&gt;ZTABLE-FIELD3 = Val3&lt;/P&gt;&lt;P&gt;Insert ZTABLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Going by code you provided, I can assign individual values, But then ultimately I need to map it to a structure which can be used to insert in a DB table. How can I do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks-&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 Sep 2009 14:27:54 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-09-11T14:27:54Z</dc:date>
    <item>
      <title>using table field name as a variable</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-table-field-name-as-a-variable/m-p/6071297#M1355620</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;Is it possible to map some values to a field in a Ztable , if I have the field name of the Ztable in a variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For ex:&lt;/P&gt;&lt;P&gt;I have a ZTABLE -- which has some fields - ZF1 and ZF2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my code, I determine the field in which I want to put data at runtime. For ex, in my code i determine at runtime I want to update field ZF2 , but I have this field name in a variable &amp;lt;V_FIELDNAME&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, Is it possible to do something as:&lt;/P&gt;&lt;P&gt;&amp;lt;V_FIELDNAME&amp;gt; = ZF2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ZTABLE-&amp;lt;V_FIELDNAME&amp;gt;    =    &amp;lt;VARIABLE -SOME VALUE&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and this value should actually maps to ZTABLE-ZF2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it is possible , how to do it ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks-&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Sep 2009 21:51:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-table-field-name-as-a-variable/m-p/6071297#M1355620</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-09-10T21:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: using table field name as a variable</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-table-field-name-as-a-variable/m-p/6071298#M1355621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, it's possible using a dynamic ASSIGN via a field-symbol.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could have something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: fieldname(20) type c,
          fname(10) type c.
field-symbols: &amp;lt;f&amp;gt;.

If [condition].
  fname = 'ZF1'.
else.
  fname = 'ZF2'.
endif.
concatenate 'ZTABLE-' fname into fieldname.

assign (fieldname) to &amp;lt;f&amp;gt;.

&amp;lt;f&amp;gt; = 'abc'.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will result in the value of ZTABLE-ZF1 or ZTABLE-ZF2 to be 'abc', depending on the condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Look up the help for the ASSIGN statement - there are many variations and possibilities.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Sep 2009 22:35:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-table-field-name-as-a-variable/m-p/6071298#M1355621</guid>
      <dc:creator>Tamas_Hoznek</dc:creator>
      <dc:date>2009-09-10T22:35:36Z</dc:date>
    </item>
    <item>
      <title>Re: using table field name as a variable</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-table-field-name-as-a-variable/m-p/6071299#M1355622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Check this thread for Dynamic programming:&lt;/P&gt;&lt;P&gt;&lt;A href="http://sap.ittoolbox.com/groups/technical-functional/sap-abap/abap-dynamic-programing-2354885" target="test_blank"&gt;http://sap.ittoolbox.com/groups/technical-functional/sap-abap/abap-dynamic-programing-2354885&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Subramanian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Sep 2009 22:41:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-table-field-name-as-a-variable/m-p/6071299#M1355622</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-09-10T22:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: using table field name as a variable</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-table-field-name-as-a-variable/m-p/6071300#M1355623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tamas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for ur post ! it did certainly help. However, I need some more help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is what I need - &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will have a string coming up from an interface which would be something like : Val1;Val2;Val3&lt;/P&gt;&lt;P&gt;And in SAP R/3 I have a variable maintained as : Field1;Field2;Field3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Field1 Field2 and Field3 are fields of a ZTABLE.&lt;/P&gt;&lt;P&gt;So , at runtime, using the variable I have to determine which Value goes to which field and then insert this field in ZTABLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, ultimately , code should perform the following actions:&lt;/P&gt;&lt;P&gt;ZTABLE-FIELD1 = Val1&lt;/P&gt;&lt;P&gt;ZTABLE-FIELD2 = Val2&lt;/P&gt;&lt;P&gt;ZTABLE-FIELD3 = Val3&lt;/P&gt;&lt;P&gt;Insert ZTABLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Going by code you provided, I can assign individual values, But then ultimately I need to map it to a structure which can be used to insert in a DB table. How can I do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks-&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Sep 2009 14:27:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-table-field-name-as-a-variable/m-p/6071300#M1355623</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-09-11T14:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: using table field name as a variable</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-table-field-name-as-a-variable/m-p/6071301#M1355624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure I understand exactly what the issue is... I mean, in the most simplistic example, if ZTABLE is your DB table and it was declared with TABLES, then using INSERT ZTABLE after assigning values to fields ZTABLE-FIELD1...-FIELD3 will just do what you need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or, if ZTABLE is not your DB table but a field string representing one record in a DB table, then using INSERT &amp;lt;dbtable&amp;gt; FROM ZTABLE will do the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please explain if this isn't your goal?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Sep 2009 14:54:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-table-field-name-as-a-variable/m-p/6071301#M1355624</guid>
      <dc:creator>Tamas_Hoznek</dc:creator>
      <dc:date>2009-09-11T14:54:02Z</dc:date>
    </item>
  </channel>
</rss>

