<?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 Function Modue with Dynamic Table as output parameter in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-modue-with-dynamic-table-as-output-parameter/m-p/7995367#M1606070</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have function (below) which reads "dynamically" data from table which is specify as input parameter, the data are "saved" in &amp;lt;ft&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can i return &amp;lt;ft&amp;gt; as output parameter of function module (table) ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;function&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import parameter  - &amp;gt; IC_TABLE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;***&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;source code&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data :   lt_OPTIONS   type standard table of RFC_DB_OPT,&lt;/P&gt;&lt;P&gt;         lt_fields    type standard table of rfc_db_fld,&lt;/P&gt;&lt;P&gt;         lt_data      type standard table of tab512,&lt;/P&gt;&lt;P&gt;         la_rfcdata   type tab512,&lt;/P&gt;&lt;P&gt;         la_rfcfields type rfc_db_fld,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;         lr_dref      type ref to data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;ft&amp;gt;         type table.&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;structure&amp;gt;  type any.&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;field_to&amp;gt;   type any.&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;field_from&amp;gt; type any.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'RFC_READ_TABLE'&lt;/P&gt;&lt;P&gt;  EXPORTING&lt;/P&gt;&lt;P&gt;    query_table                = IC_TABLE&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  DELIMITER                  = ' '&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  NO_DATA                    = ' '&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  ROWSKIPS                   = 0&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  ROWCOUNT                   = 0&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  tables&lt;/P&gt;&lt;P&gt;    OPTIONS                    = lt_OPTIONS&lt;/P&gt;&lt;P&gt;    fields                     = lt_fields&lt;/P&gt;&lt;P&gt;    data                       = lt_data&lt;/P&gt;&lt;P&gt; EXCEPTIONS&lt;/P&gt;&lt;P&gt;   TABLE_NOT_AVAILABLE        = 1&lt;/P&gt;&lt;P&gt;   TABLE_WITHOUT_DATA         = 2&lt;/P&gt;&lt;P&gt;   OPTION_NOT_VALID           = 3&lt;/P&gt;&lt;P&gt;   FIELD_NOT_VALID            = 4&lt;/P&gt;&lt;P&gt;   NOT_AUTHORIZED             = 5&lt;/P&gt;&lt;P&gt;   DATA_BUFFER_EXCEEDED       = 6&lt;/P&gt;&lt;P&gt;   OTHERS                     = 7.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  create data lr_dref type table of (ic_table).&lt;/P&gt;&lt;P&gt;  assign lr_dref-&amp;gt;* to &amp;lt;ft&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Fill data from OLTP table into ct_table.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  assign local copy of initial line of &amp;lt;ft&amp;gt; to &amp;lt;structure&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  loop at lt_data into la_rfcdata.&lt;/P&gt;&lt;P&gt;    loop at lt_fields into la_rfcfields.&lt;/P&gt;&lt;P&gt;      assign component sy-tabix of structure &amp;lt;structure&amp;gt; to &amp;lt;field_to&amp;gt;.&lt;/P&gt;&lt;P&gt;      if sy-subrc is initial.&lt;/P&gt;&lt;P&gt;        assign la_rfcdata+la_rfcfields-offset(la_rfcfields-length)&lt;/P&gt;&lt;P&gt;          to &amp;lt;field_from&amp;gt;.&lt;/P&gt;&lt;P&gt;        &amp;lt;field_to&amp;gt; = &amp;lt;field_from&amp;gt;.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    endloop.&lt;/P&gt;&lt;P&gt;    append &amp;lt;structure&amp;gt; to &amp;lt;ft&amp;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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Martin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 01 Jul 2011 12:25:57 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-07-01T12:25:57Z</dc:date>
    <item>
      <title>Function Modue with Dynamic Table as output parameter</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-modue-with-dynamic-table-as-output-parameter/m-p/7995367#M1606070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have function (below) which reads "dynamically" data from table which is specify as input parameter, the data are "saved" in &amp;lt;ft&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can i return &amp;lt;ft&amp;gt; as output parameter of function module (table) ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;function&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import parameter  - &amp;gt; IC_TABLE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;***&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;source code&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data :   lt_OPTIONS   type standard table of RFC_DB_OPT,&lt;/P&gt;&lt;P&gt;         lt_fields    type standard table of rfc_db_fld,&lt;/P&gt;&lt;P&gt;         lt_data      type standard table of tab512,&lt;/P&gt;&lt;P&gt;         la_rfcdata   type tab512,&lt;/P&gt;&lt;P&gt;         la_rfcfields type rfc_db_fld,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;         lr_dref      type ref to data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;ft&amp;gt;         type table.&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;structure&amp;gt;  type any.&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;field_to&amp;gt;   type any.&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;field_from&amp;gt; type any.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'RFC_READ_TABLE'&lt;/P&gt;&lt;P&gt;  EXPORTING&lt;/P&gt;&lt;P&gt;    query_table                = IC_TABLE&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  DELIMITER                  = ' '&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  NO_DATA                    = ' '&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  ROWSKIPS                   = 0&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  ROWCOUNT                   = 0&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  tables&lt;/P&gt;&lt;P&gt;    OPTIONS                    = lt_OPTIONS&lt;/P&gt;&lt;P&gt;    fields                     = lt_fields&lt;/P&gt;&lt;P&gt;    data                       = lt_data&lt;/P&gt;&lt;P&gt; EXCEPTIONS&lt;/P&gt;&lt;P&gt;   TABLE_NOT_AVAILABLE        = 1&lt;/P&gt;&lt;P&gt;   TABLE_WITHOUT_DATA         = 2&lt;/P&gt;&lt;P&gt;   OPTION_NOT_VALID           = 3&lt;/P&gt;&lt;P&gt;   FIELD_NOT_VALID            = 4&lt;/P&gt;&lt;P&gt;   NOT_AUTHORIZED             = 5&lt;/P&gt;&lt;P&gt;   DATA_BUFFER_EXCEEDED       = 6&lt;/P&gt;&lt;P&gt;   OTHERS                     = 7.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  create data lr_dref type table of (ic_table).&lt;/P&gt;&lt;P&gt;  assign lr_dref-&amp;gt;* to &amp;lt;ft&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Fill data from OLTP table into ct_table.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  assign local copy of initial line of &amp;lt;ft&amp;gt; to &amp;lt;structure&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  loop at lt_data into la_rfcdata.&lt;/P&gt;&lt;P&gt;    loop at lt_fields into la_rfcfields.&lt;/P&gt;&lt;P&gt;      assign component sy-tabix of structure &amp;lt;structure&amp;gt; to &amp;lt;field_to&amp;gt;.&lt;/P&gt;&lt;P&gt;      if sy-subrc is initial.&lt;/P&gt;&lt;P&gt;        assign la_rfcdata+la_rfcfields-offset(la_rfcfields-length)&lt;/P&gt;&lt;P&gt;          to &amp;lt;field_from&amp;gt;.&lt;/P&gt;&lt;P&gt;        &amp;lt;field_to&amp;gt; = &amp;lt;field_from&amp;gt;.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    endloop.&lt;/P&gt;&lt;P&gt;    append &amp;lt;structure&amp;gt; to &amp;lt;ft&amp;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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Martin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jul 2011 12:25:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-modue-with-dynamic-table-as-output-parameter/m-p/7995367#M1606070</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-01T12:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Function Modue with Dynamic Table as output parameter</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-modue-with-dynamic-table-as-output-parameter/m-p/7995368#M1606071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My first thought would be to try to create an export parameter of TYPE ANY TABLE or TYPE STANDARD TABLE. I haven't tried it so I'm not positive it will work though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another option would be to return a reference to the table, instead of returning the table itself. The calling program could then assign that reference to a field symbol.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jul 2011 14:22:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-modue-with-dynamic-table-as-output-parameter/m-p/7995368#M1606071</guid>
      <dc:creator>alex_campbell</dc:creator>
      <dc:date>2011-07-01T14:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: Function Modue with Dynamic Table as output parameter</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-modue-with-dynamic-table-as-output-parameter/m-p/7995369#M1606072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Martin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;parameters with generic types are not allowed. So TYPE ANY TABLE etc. will not work. As Alex alreads said, you could return a reference to your table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your parameter should be typed like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;re_table type ref to data.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At the end of your function module get a reference of your table into your parameter:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;get reference of &amp;lt;ft&amp;gt; into re_table&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After the call of your function module you can now handle and work with your table as wished:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
* Declaration
data: re_table type ref to data.
field-symbols: &amp;lt;my_table&amp;gt; type standard table.

* Assign reference to fieldsymbol
assign re_table-&amp;gt;* to &amp;lt;my_table&amp;gt;
if sy-subrc NE 0.
 " Error: Could not assign reference
endif.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Fabian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jul 2011 13:26:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-modue-with-dynamic-table-as-output-parameter/m-p/7995369#M1606072</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-04T13:26:06Z</dc:date>
    </item>
  </channel>
</rss>

