<?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 dynamical columns in internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamical-columns-in-internal-table/m-p/1561755#M253944</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 need to make an internal table with dynamical columns(i have 3 static columns and the rest depends on the number of clients that i have in a month). If it's possible, how can i do it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone please help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Sep 2006 16:05:30 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-09-28T16:05:30Z</dc:date>
    <item>
      <title>dynamical columns in internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamical-columns-in-internal-table/m-p/1561755#M253944</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 need to make an internal table with dynamical columns(i have 3 static columns and the rest depends on the number of clients that i have in a month). If it's possible, how can i do it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone please help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Sep 2006 16:05:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamical-columns-in-internal-table/m-p/1561755#M253944</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-28T16:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: dynamical columns in internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamical-columns-in-internal-table/m-p/1561756#M253945</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Define the field catalog like you were building an ALV report and create an internal table using the following method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

DATA: S_FCAT         TYPE LVC_S_FCAT,
      T_FCAT         TYPE LVC_T_FCAT,
      RE_TABLE       TYPE REF TO DATA,
      RE_HEAD        TYPE REF TO DATA.

FIELD-SYMBOLS: &amp;lt;re_table&amp;gt; TYPE TABLE,
               &amp;lt;re_head&amp;gt;.

ADD 1 TO L_CNT.
MOVE: L_CNT  TO S_FCAT-COL_POS,
      'TYPE' TO S_FCAT-FIELDNAME,
      'C'    TO S_FCAT-INTTYPE,
      '1'    TO S_FCAT-INTLEN.
APPEND S_FCAT TO T_FCAT.

ADD 1 TO L_CNT.
MOVE: L_CNT  TO S_FCAT-COL_POS,
      'DATE' TO S_FCAT-FIELDNAME,
      'D'    TO S_FCAT-INTTYPE,
      '8'    TO S_FCAT-INTLEN.
APPEND S_FCAT TO T_FCAT.

ADD 1 TO L_CNT.
MOVE: L_CNT  TO S_FCAT-COL_POS,
      'TIME' TO S_FCAT-FIELDNAME,
      'T'    TO S_FCAT-INTTYPE,
      '6'    TO S_FCAT-INTLEN.
APPEND S_FCAT TO T_FCAT.

ADD 1 TO L_CNT.
MOVE: L_CNT  TO S_FCAT-COL_POS,
      'NAME' TO S_FCAT-FIELDNAME,
      'C'    TO S_FCAT-INTTYPE,
      '12'   TO S_FCAT-INTLEN.
APPEND S_FCAT TO T_FCAT.

CALL METHOD CL_ALV_TABLE_CREATE=&amp;gt;CREATE_DYNAMIC_TABLE
  EXPORTING
    IT_FIELDCATALOG           = T_FCAT
  IMPORTING
    EP_TABLE                  = RE_TABLE
        .
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;T_FCAT contains the list of fields to be included.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After the table has been created you can access it using field-symbols.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
ASSIGN RE_TABLE-&amp;gt;* TO &amp;lt;re_table&amp;gt;.
CREATE DATA RE_HEAD LIKE LINE OF &amp;lt;re_table&amp;gt;.
ASSIGN RE_HEAD-&amp;gt;* TO &amp;lt;re_head&amp;gt;.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;re_table&amp;gt; is your internal table and &amp;lt;re_head&amp;gt; is a header record defined like the table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Sep 2006 16:20:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamical-columns-in-internal-table/m-p/1561756#M253945</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-28T16:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: dynamical columns in internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamical-columns-in-internal-table/m-p/1561757#M253946</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is difficult to define an internal table with dynamic number of colns...but you can use the below logic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab&lt;/P&gt;&lt;P&gt; f1&lt;/P&gt;&lt;P&gt; f2&lt;/P&gt;&lt;P&gt; f3&lt;/P&gt;&lt;P&gt; client&lt;/P&gt;&lt;P&gt; value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can collect all the values in itab and when you want to print it you can use the below logic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort itab by client.&lt;/P&gt;&lt;P&gt;iclient[] = itab[]&lt;/P&gt;&lt;P&gt;delete adjacent duplicate from iclient.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*For headings&lt;/P&gt;&lt;P&gt;write : / 'Headf1', 'HeadF2', 'HeadF3'.&lt;/P&gt;&lt;P&gt;loop at iclient.&lt;/P&gt;&lt;P&gt;  write iclient-client.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;  at new f3.&lt;/P&gt;&lt;P&gt;     write : / itab-f1, itab-f2, itab-f3.&lt;/P&gt;&lt;P&gt;  endat.&lt;/P&gt;&lt;P&gt;  read table iclient with key client = itab-client.&lt;/P&gt;&lt;P&gt;  lcnt = sy-tabix * 10.  "10 is the field length. &lt;/P&gt;&lt;P&gt;  write : (lcnt) itab-value.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Sep 2006 16:23:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamical-columns-in-internal-table/m-p/1561757#M253946</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-28T16:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: dynamical columns in internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamical-columns-in-internal-table/m-p/1561758#M253947</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;PRE&gt;&lt;CODE&gt;type-pools : abap. 
  field-symbols: &amp;lt;dyn_table&amp;gt; type standard table, 
               &amp;lt;dyn_wa&amp;gt;, 
               &amp;lt;dyn_field&amp;gt;. 
  data: dy_table type ref to data, 
      dy_line  type ref to data, 
      xfc type lvc_s_fcat, 
      ifc type lvc_t_fcat. 
  selection-screen begin of block b1 with frame. 
parameters: p_table(30) type c default 'T001'. 
selection-screen end of block b1. 
  start-of-selection. 
    perform get_structure. 
  perform create_dynamic_itab.  &amp;lt;b&amp;gt; *Creates a dyanamic internal table **&amp;lt;/b&amp;gt;  
 perform get_data. 
  perform write_out. 
  form get_structure. 
  data : idetails type abap_compdescr_tab, 
       xdetails type abap_compdescr. 
  data : ref_table_des type ref to cl_abap_structdescr. 
  * Get the structure of the table. 
  ref_table_des ?=  
      cl_abap_typedescr=&amp;gt;describe_by_name( p_table ). 
  idetails[] = ref_table_des-&amp;gt;components[]. 
    loop at idetails into xdetails. 
    clear xfc. 
    xfc-fieldname = xdetails-name . 
    xfc-datatype = xdetails-type_kind. 
    xfc-inttype = xdetails-type_kind. 
    xfc-intlen = xdetails-length. 
    xfc-decimals = xdetails-decimals. 
    append xfc to ifc. 
  endloop. 
  endform. 
  form create_dynamic_itab. 
  &amp;lt;b&amp;gt;* Create dynamic internal table and assign to FS&amp;lt;/b&amp;gt; 
  call method cl_alv_table_create=&amp;gt;create_dynamic_table 
               exporting 
                  it_fieldcatalog = ifc 
               importing 
                  ep_table        = dy_table. 
    assign dy_table-&amp;gt;* to &amp;lt;dyn_table&amp;gt;. 
  * Create dynamic work area and assign to FS 
  create data dy_line like line of &amp;lt;dyn_table&amp;gt;. 
  assign dy_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;. 
  endform. 
    
  form get_data. 
  * Select Data from table. 
  select * into table &amp;lt;dyn_table&amp;gt; 
             from (p_table). 
  endform. 
   Write out data from table. 
  loop at &amp;lt;dyn_table&amp;gt; into &amp;lt;dyn_wa&amp;gt;. 
    do. 
      assign component  sy-index   
         of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_field&amp;gt;. 
      if sy-subrc &amp;lt;&amp;gt; 0. 
        exit. 
      endif. 
      if sy-index = 1. 
        write:/ &amp;lt;dyn_field&amp;gt;. 
      else. 
        write: &amp;lt;dyn_field&amp;gt;. 
      endif. 
    enddo. 
  endloop. 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sudheer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Sep 2006 16:45:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamical-columns-in-internal-table/m-p/1561758#M253947</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-28T16:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: dynamical columns in internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamical-columns-in-internal-table/m-p/1561759#M253948</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Michael.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is very helpful, but how can i introduce data in the internal table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Sep 2006 17:17:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamical-columns-in-internal-table/m-p/1561759#M253948</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-28T17:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: dynamical columns in internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamical-columns-in-internal-table/m-p/1561760#M253949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use another field-symbol to represent a specific field of your header record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
FIELD-SYMBOLS: &amp;lt;field&amp;gt;  TYPE ANY.

ASSIGN COMPONENT 'FIELD1'
  OF STRUCTURE &amp;lt;re_head&amp;gt; TO &amp;lt;field&amp;gt;.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now &amp;lt;re_head&amp;gt;-FIELD1 can be populated by moving a value to &amp;lt;field&amp;gt;.&lt;/P&gt;&lt;P&gt;Once your header record is populated, just append it like normal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
APPEND &amp;lt;re_head&amp;gt; TO &amp;lt;re_table&amp;gt;. CLEAR &amp;lt;re_head&amp;gt;.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Sep 2006 17:49:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamical-columns-in-internal-table/m-p/1561760#M253949</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-28T17:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: dynamical columns in internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamical-columns-in-internal-table/m-p/1561761#M253950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You can create the internal table with the help of above answers, after creating the Dynamic one, you can use as a normal internal table.. see the above example, you will find a Select statment and Loop at statment etc ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sudheer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Sep 2006 17:51:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamical-columns-in-internal-table/m-p/1561761#M253950</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-28T17:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: dynamical columns in internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamical-columns-in-internal-table/m-p/1561762#M253951</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot Michael &amp;amp; Sudheer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Sep 2006 18:24:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamical-columns-in-internal-table/m-p/1561762#M253951</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-28T18:24:50Z</dc:date>
    </item>
  </channel>
</rss>

