<?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 programming: send data to function module, mapping... in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-programming-send-data-to-function-module-mapping/m-p/6016859#M1347034</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Augastrarian and Amit, I will try out your suggestions and report back.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Aug 2009 16:53:27 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-08-25T16:53:27Z</dc:date>
    <item>
      <title>dynamic programming: send data to function module, mapping...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-programming-send-data-to-function-module-mapping/m-p/6016856#M1347031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello abappers,&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;I have a requirement to be able to send a the name of a table and a table-field to a function module, it can be a table of any type, so the function module should be generic in nature, the function module receives the table name and table-field name and then selects data for the field specified from the table specified (in the import parameter of the FM). Within the function module, I want to be able to determine the fields type? and then send this field to an internal table representing a a destination table (also specified in the import parameters).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the idea is to be able to map a field from any table to a specified field in another table, the table(source and destination) and field names will only determined at run time as specified by the user.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;any assistance will be appreciated, I am not very familiar with dynamic\generic programming.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Aug 2009 12:19:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-programming-send-data-to-function-module-mapping/m-p/6016856#M1347031</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-23T12:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic programming: send data to function module, mapping...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-programming-send-data-to-function-module-mapping/m-p/6016857#M1347032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Bijo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Following are the steps to implement this requirement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Create import parameter for table name i.e. TABLE_NAME&lt;/P&gt;&lt;P&gt;2. Create tables parameter for fields table&lt;/P&gt;&lt;P&gt;3. Define table. DATA TABLE TYPE REF TO DATA. Also create single column internal table for fields and load all fields to select from database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Inside function module you can implement following steps:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. Load all the fields name into internal table. for this you can use DD03L for field details and use TABLE_NAME as key.&lt;/P&gt;&lt;P&gt;5. Once you have all the fields ready in internal table then construct fieldcatlog using these fields&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at internal table with all the fields.&lt;/P&gt;&lt;P&gt;move it to field catalog.&lt;/P&gt;&lt;P&gt;append field catalog.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;6. Pass this field catalog table to static method create_dynamic_table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call method cl_alv_table_create=&amp;gt;create_dynamic_table&lt;/P&gt;&lt;P&gt;exporting&lt;/P&gt;&lt;P&gt;it_fieldcatalog = fieldcatalog_tab&lt;/P&gt;&lt;P&gt;importing&lt;/P&gt;&lt;P&gt;ep_table = table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here table is defined with data object type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now assign table reference to field symbol of type table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ASSIGN table-&amp;gt;* to &amp;lt;field-tab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also create work area &amp;lt;field-wa&amp;gt; using refrence of table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create data object wa LIKE LINE OF &amp;lt;field-tab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ASSIGN wa-&amp;gt;* to &amp;lt;field-wa&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also define field symbol for field name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for e.g. &amp;lt;field_name&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;7. Dynamic internal table is ready&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    Now using can use select as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    SELECT (fields)  "--&amp;gt; fields is single column internal table to hold fields need to be selected&lt;/P&gt;&lt;P&gt;         INTO CORRESPONDING FIELDS OF TABLE &amp;lt;itab&amp;gt; "--&amp;gt; itab created dynamically at runtime&lt;/P&gt;&lt;P&gt;        FROM (TABLE_NAME) --&amp;gt; Table name imported &lt;/P&gt;&lt;P&gt;     WHERE (where_clause). --&amp;gt; where_clause is single column internal table with data type CHAR72.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select data into &amp;lt;itab&amp;gt; and use ASSIGN COMPONENT to move data from one table to another as follows:&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;8. To fill this dynamic internal table using ASSIGN COMPONENT &amp;lt;Comp_number&amp;gt; OF STRUCTURE &amp;lt;field-wa&amp;gt; TO &amp;lt;field-name&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So in this case if first field of structure STRUCT1 is user_id then sudo-code will be &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at internal table containing list of fields into field_wa &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ASSIGN COMPONENT field_wa OF STRUCTURE &amp;lt;field-wa&amp;gt; TO &amp;lt;field&amp;gt;. "Here field_wa is wa area for single column internal table holding all the fieldnames.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now &amp;lt;field-name&amp;gt; points to user_id field. Move some value into it as nornally we do with variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;move '001' to &amp;lt;field-name&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;field-name&amp;gt; = '001'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;after completing all the fields one row will be ready in &amp;lt;field_wa&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;APPEND &amp;lt;field_wa&amp;gt; to &amp;lt;field_tab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know incase you face any issues!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Augustin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Augustarian on Aug 23, 2009 7:02 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Augustarian on Aug 23, 2009 7:08 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Augustarian on Aug 23, 2009 7:09 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Aug 2009 13:32:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-programming-send-data-to-function-module-mapping/m-p/6016857#M1347032</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-23T13:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic programming: send data to function module, mapping...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-programming-send-data-to-function-module-mapping/m-p/6016858#M1347033</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 dont think there's anything dynamic in this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Specify a table name type any or as LIST_COL_C-TABNAME in import parameters of the FM and a field name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try using FM K_LIST_GET_FIELDS_OF_STRUCTURE which gives you all fields of a table and call it internally in your FM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your export parameters specify a table of type LIST_COL_C-TABNAME which you can callback from your program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amit&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Aug 2009 04:01:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-programming-send-data-to-function-module-mapping/m-p/6016858#M1347033</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-24T04:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic programming: send data to function module, mapping...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-programming-send-data-to-function-module-mapping/m-p/6016859#M1347034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Augastrarian and Amit, I will try out your suggestions and report back.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2009 16:53:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-programming-send-data-to-function-module-mapping/m-p/6016859#M1347034</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-25T16:53:27Z</dc:date>
    </item>
  </channel>
</rss>

