<?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 Dynamic Internal Table for reading data from external file in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-for-reading-data-from-external-file/m-p/864381#M48702</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The task was to create a internal table with dynamic columns,&lt;/P&gt;&lt;P&gt; Actually this is my first task in the WebAS 6.20, my program is based on input file provided by user with certain effort. this file can have different effort for a one yr to five year frame..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I needed to read the raw data from file, based on months create a internal table to hold the data, after this i need to validate the data...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have browsed thru dynamic internal table topic, but couldn't find any dynamic appending structure, the dynamic structure would contains 12 month fileds.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can any one help me in getting my task completed..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Kumar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 Mar 2005 20:01:56 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-03-11T20:01:56Z</dc:date>
    <item>
      <title>Dynamic Internal Table for reading data from external file</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-for-reading-data-from-external-file/m-p/864381#M48702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The task was to create a internal table with dynamic columns,&lt;/P&gt;&lt;P&gt; Actually this is my first task in the WebAS 6.20, my program is based on input file provided by user with certain effort. this file can have different effort for a one yr to five year frame..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I needed to read the raw data from file, based on months create a internal table to hold the data, after this i need to validate the data...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have browsed thru dynamic internal table topic, but couldn't find any dynamic appending structure, the dynamic structure would contains 12 month fileds.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can any one help me in getting my task completed..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Kumar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Mar 2005 20:01:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-for-reading-data-from-external-file/m-p/864381#M48702</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-03-11T20:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Internal Table for reading data from external file</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-for-reading-data-from-external-file/m-p/864382#M48703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is a sample program that demonstates dynamic internal tables.  This will not solve your problem, but maybe give you some ideas.  Good Luck&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0001
       no standard page heading.

* Field symbols
field-symbols:

      &amp;lt;dyn_table&amp;gt; type standard table,
      &amp;lt;dyn_wa&amp;gt;.

* Selection Screen
selection-screen begin of block b1 with frame title text-001.
parameters: p_numcol type c.
selection-screen end of block b1.


perform build_dyn_itab.
perform build_report.


************************************************************************
*  Build_dyn_itab - Build dynamic internal table definition
************************************************************************
form build_dyn_itab.

  data: new_table    type ref to data,
        new_line     type ref to data,
        wa_it_fldcatg type lvc_s_fcat,
       it_fldcatg type lvc_t_fcat.

* Build dynamic internal table field catalog

* Create fields for all dates in iDates.
  do p_numcol times.
    clear wa_it_fldcatg.
    wa_it_fldcatg-fieldname = sy-index.
    wa_it_fldcatg-datatype  = 'CHAR'.
    wa_it_fldcatg-intlen    = 5.
    append wa_it_fldcatg to it_fldcatg .
  enddo.

* Create dynamic internal table and assign to FS
  call method cl_alv_table_create=&amp;gt;create_dynamic_table
               exporting
                  it_fieldcatalog = it_fldcatg
               importing
                  ep_table        = new_table.

* assign ref variable  to a field symbol
  assign new_table-&amp;gt;* to &amp;lt;dyn_table&amp;gt;.

* Create dynamic work area and assign to FS
  create data new_line like line of &amp;lt;dyn_table&amp;gt;.
  assign new_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;.

endform.

*********************************************************************
* Form  build_report - Fill dynamic internal table with data
*********************************************************************
form build_report.

  data: xstring type string.
  data: xint(10) type c.

* Fill the dynamic internal table
  do 10 times.

    clear xstring.

    do p_numcol times.

      xint = sy-index.
      shift xint right deleting trailing space.
* now add to the front of the string.
      concatenate xstring xint into xstring.

    enddo.

* Now move the string into dynamic internal table work area.
    &amp;lt;dyn_wa&amp;gt; = xstring.

* Append to the dynamic internal table
    append &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_table&amp;gt;.

  enddo.

endform.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Mar 2005 20:24:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-for-reading-data-from-external-file/m-p/864382#M48703</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-03-11T20:24:18Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Internal Table for reading data from external file</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-for-reading-data-from-external-file/m-p/864383#M48704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rich, &lt;/P&gt;&lt;P&gt;Thanks for a quick response,&lt;/P&gt;&lt;P&gt;I looked into the example .. my task is to create dynamic header data so that i can populate data accordingly..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to be more clear if file has 2 month data  my internal table shud have 2 fields to capture that data.. similarly if my file has 4month data than my internal table shud include 2 more month fileds to hold all 4 months data..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope I did not confuse .But truly appreciate your quick response..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Kumar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Mar 2005 21:09:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-for-reading-data-from-external-file/m-p/864383#M48704</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-03-11T21:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Internal Table for reading data from external file</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-for-reading-data-from-external-file/m-p/864384#M48705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the only dynamic part of your data is the number of months of data, then you can define your internal table as a "deep" table, i.e. each row of your table would itself have an internal table as a component.  Here is some sample code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT  zcdf_dynamic_table.

* ------------------------------------------------------
* Internal table with dynamic number of months.
* Tested in 4.7/6.20
* Charles Folwell - cfolwell@csc.com - March 11, 2005
* ------------------------------------------------------
* Type definitions for building internal table.  I would
*  usually put these definitions in the dictionary but
*  for easy posting, I have included them here.

TYPES:
  BEGIN OF tys_month,
    amt(12) TYPE p DECIMALS 2,
  END OF tys_month.

TYPES:
  tyt_month TYPE STANDARD TABLE OF tys_month WITH DEFAULT KEY.

TYPES:
  BEGIN OF tys_my_data,
    fixed_data(20) TYPE c,
    number_months  TYPE i,
    t_month        TYPE tyt_month,
  END OF tys_my_data.

* Internal table with variable number of months.

DATA:
  t_my_table  TYPE STANDARD TABLE OF tys_my_data WITH DEFAULT KEY.

* Work areas for internal table and for the internal table
*  inside the internal table.

DATA:
  wa_my_table         LIKE LINE OF t_my_table,
  wa_month            TYPE tys_month.

START-OF-SELECTION.

* Populate internal table from somewhere, similar to this.
*  If you know where the months start, and their size, then
*  a field symbol can be used to move thru the data.

  CLEAR wa_my_table.

  wa_my_table-fixed_data    = 'Key Data1'.
  wa_my_table-number_months = 3.

  DO wa_my_table-number_months TIMES.

    CLEAR wa_month.
    wa_month-amt = sy-index.
    APPEND wa_month TO wa_my_table-t_month.

  ENDDO.

  APPEND wa_my_table TO t_my_table.

* Read back and write your table data similar to this.

  LOOP AT t_my_table INTO wa_my_table.

    WRITE:/ wa_my_table-fixed_data, wa_my_table-number_months.

    LOOP AT wa_my_table-t_month INTO wa_month.

      WRITE:/ wa_month-amt.

    ENDLOOP.

  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Mar 2005 23:59:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-for-reading-data-from-external-file/m-p/864384#M48705</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-03-11T23:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Internal Table for reading data from external file</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-for-reading-data-from-external-file/m-p/864385#M48706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is similar to Rich Heilman's effort:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;a href="/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table Internal Table&amp;lt;/a&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Subramanian V.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Mar 2005 06:11:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-for-reading-data-from-external-file/m-p/864385#M48706</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-03-14T06:11:02Z</dc:date>
    </item>
  </channel>
</rss>

