<?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 column,How to create . in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-column-how-to-create/m-p/1731573#M318490</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;My requirement is to convert the layout as bellow:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;before:&lt;/P&gt;&lt;P&gt;column1   column2   column3&lt;/P&gt;&lt;P&gt;1              A             1&lt;/P&gt;&lt;P&gt;1              B             1&lt;/P&gt;&lt;P&gt;1              C             2&lt;/P&gt;&lt;P&gt;2              A             1&lt;/P&gt;&lt;P&gt;2              C             1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;convert to :&lt;/P&gt;&lt;P&gt;column1    A     B     C&lt;/P&gt;&lt;P&gt;1              1      1      2&lt;/P&gt;&lt;P&gt;2              1      0      1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The detail requirement is first to select all the customers and then to get the customers sales informations . the customer's name should be the internal  field name .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can anyone give me some suggestions? thanks a lot.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Nov 2006 04:00:45 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-11-29T04:00:45Z</dc:date>
    <item>
      <title>Dynamic internal table column,How to create .</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-column-how-to-create/m-p/1731573#M318490</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;My requirement is to convert the layout as bellow:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;before:&lt;/P&gt;&lt;P&gt;column1   column2   column3&lt;/P&gt;&lt;P&gt;1              A             1&lt;/P&gt;&lt;P&gt;1              B             1&lt;/P&gt;&lt;P&gt;1              C             2&lt;/P&gt;&lt;P&gt;2              A             1&lt;/P&gt;&lt;P&gt;2              C             1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;convert to :&lt;/P&gt;&lt;P&gt;column1    A     B     C&lt;/P&gt;&lt;P&gt;1              1      1      2&lt;/P&gt;&lt;P&gt;2              1      0      1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The detail requirement is first to select all the customers and then to get the customers sales informations . the customer's name should be the internal  field name .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can anyone give me some suggestions? thanks a lot.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Nov 2006 04:00:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-column-how-to-create/m-p/1731573#M318490</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-29T04:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic internal table column,How to create .</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-column-how-to-create/m-p/1731574#M318491</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;chk this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Types: begin of ttab,
fld1(10) type c,
fld2 type sy-datum,
end of ttab.

data: itab type table of ttab.

You can also build an internal table at runtime.
Here is a sample program.





report zxy_0003
       no standard page heading.
 
type-pools: slis.
 
field-symbols: &amp;lt;dyn_table&amp;gt; type standard table,
               &amp;lt;dyn_wa&amp;gt;.
 
data: alv_fldcat type slis_t_fieldcat_alv,
      it_fldcat type lvc_t_fcat.
 
 
selection-screen begin of block b1 with frame title text-001.
parameters: p_check type c.
selection-screen end of block b1.
 
start-of-selection.
 
  perform build_dyn_itab.
  perform build_report.
 
  loop at &amp;lt;dyn_table&amp;gt; into &amp;lt;dyn_wa&amp;gt;.
    write:/ &amp;lt;dyn_wa&amp;gt;.
  endloop.
 
 
************************************************************************
*  Build_dyn_itab
************************************************************************
form build_dyn_itab.
 
  data: index(3) type c.
 
  data: new_table type ref to data,
        new_line  type ref to data,
        wa_it_fldcat type lvc_s_fcat.
 
* Create fields
  clear index.
  do 10 times.
    index = sy-index.
    clear wa_it_fldcat.
    concatenate 'Field' index into
             wa_it_fldcat-fieldname .
    condense  wa_it_fldcat-fieldname no-gaps.
    wa_it_fldcat-datatype = 'CHAR'.
    wa_it_fldcat-intlen = 5.
    append wa_it_fldcat to it_fldcat .
  enddo.
 
* Create dynamic internal table and assign to FS
  call method cl_alv_table_create=&amp;gt;create_dynamic_table
               exporting
                  it_fieldcatalog = it_fldcat
               importing
                  ep_table        = new_table.
 
  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
*********************************************************************
form build_report.
 
  data: fieldname(20) type c.
  data: fieldvalue(5) type c.
  data: index(3) type c.
  field-symbols: &amp;lt;fs1&amp;gt;.
 
  do 10 times.
 
    index = sy-index.
 
* Set up fieldname
    concatenate 'FIELD' index into
             fieldname .
    condense   fieldname  no-gaps.
 
* Set up fieldvalue
    concatenate 'FLD' index into
             fieldvalue.
    condense   fieldvalue no-gaps.
 
    assign component  fieldname  of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;fs1&amp;gt;.
    &amp;lt;fs1&amp;gt; =  fieldvalue.
 
  enddo.
 
* Append to the dynamic internal table
  append &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_table&amp;gt;.
 
endform.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check these links:&lt;/P&gt;&lt;P&gt;&lt;A href="http://searchsap.techtarget.com/tip/1,289483,sid21_gci554038,00.html" target="test_blank"&gt;http://searchsap.techtarget.com/tip/1,289483,sid21_gci554038,00.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rgds&lt;/P&gt;&lt;P&gt;Anver&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Nov 2006 04:03:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-column-how-to-create/m-p/1731574#M318491</guid>
      <dc:creator>anversha_s</dc:creator>
      <dc:date>2006-11-29T04:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic internal table column,How to create .</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-column-how-to-create/m-p/1731575#M318492</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;Check this piece of code which I got from SDN.&lt;/P&gt;&lt;P&gt;REPORT zmaschl_create_data_dynamic . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPE-POOLS: slis. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: it_fcat TYPE slis_t_fieldcat_alv, &lt;/P&gt;&lt;P&gt;      is_fcat LIKE LINE OF it_fcat. &lt;/P&gt;&lt;P&gt;DATA: it_fieldcat TYPE lvc_t_fcat, &lt;/P&gt;&lt;P&gt;      is_fieldcat LIKE LINE OF it_fieldcat. &lt;/P&gt;&lt;P&gt;DATA: new_table TYPE REF TO data. &lt;/P&gt;&lt;P&gt;DATA: new_line  TYPE REF TO data. &lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;l_table&amp;gt; TYPE ANY TABLE, &lt;/P&gt;&lt;P&gt;               &amp;lt;l_line&amp;gt;  TYPE ANY, &lt;/P&gt;&lt;P&gt;               &amp;lt;l_field&amp;gt; TYPE ANY. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Build fieldcat &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' &lt;/P&gt;&lt;P&gt;       EXPORTING &lt;/P&gt;&lt;P&gt;           i_structure_name = 'SYST' &lt;/P&gt;&lt;P&gt;       CHANGING &lt;/P&gt;&lt;P&gt;           ct_fieldcat      = it_fcat[]. &lt;/P&gt;&lt;P&gt;   LOOP AT it_fcat INTO is_fcat WHERE NOT reptext_ddic IS initial. &lt;/P&gt;&lt;P&gt;        MOVE-CORRESPONDING is_fcat TO is_fieldcat. &lt;/P&gt;&lt;P&gt;        is_fieldcat-fieldname = is_fcat-fieldname. &lt;/P&gt;&lt;P&gt;        is_fieldcat-ref_field = is_fcat-fieldname. &lt;/P&gt;&lt;P&gt;        is_fieldcat-ref_table = is_fcat-ref_tabname. &lt;/P&gt;&lt;P&gt;        APPEND is_fieldcat TO it_fieldcat. &lt;/P&gt;&lt;P&gt;   ENDLOOP. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create a new Table &lt;/P&gt;&lt;/LI&gt;&lt;/UL&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 = it_fieldcat &lt;/P&gt;&lt;P&gt;       IMPORTING &lt;/P&gt;&lt;P&gt;        ep_table        = new_table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create a new Line with the same structure of the table. &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;ASSIGN new_table-&amp;gt;* TO &amp;lt;l_table&amp;gt;. &lt;/P&gt;&lt;P&gt;CREATE DATA new_line LIKE LINE OF &amp;lt;l_table&amp;gt;. &lt;/P&gt;&lt;P&gt;ASSIGN new_line-&amp;gt;* TO &amp;lt;l_line&amp;gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Test it... &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;   DO 30 TIMES. &lt;/P&gt;&lt;P&gt;      ASSIGN COMPONENT 'SUBRC' OF STRUCTURE &amp;lt;l_line&amp;gt; TO &amp;lt;l_field&amp;gt;. &lt;/P&gt;&lt;P&gt;      &amp;lt;l_field&amp;gt; = sy-index. &lt;/P&gt;&lt;P&gt;      INSERT &amp;lt;l_line&amp;gt; INTO TABLE &amp;lt;l_table&amp;gt;. &lt;/P&gt;&lt;P&gt;   ENDDO. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   LOOP AT &amp;lt;l_table&amp;gt; ASSIGNING &amp;lt;l_line&amp;gt;. &lt;/P&gt;&lt;P&gt;      ASSIGN COMPONENT 'SUBRC' OF STRUCTURE &amp;lt;l_line&amp;gt; TO &amp;lt;l_field&amp;gt;. &lt;/P&gt;&lt;P&gt;      WRITE &amp;lt;l_field&amp;gt;. &lt;/P&gt;&lt;P&gt;   ENDLOOP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Nov 2006 04:04:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-column-how-to-create/m-p/1731575#M318492</guid>
      <dc:creator>jayanthi_jayaraman</dc:creator>
      <dc:date>2006-11-29T04:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic internal table column,How to create .</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-column-how-to-create/m-p/1731576#M318493</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;&lt;/P&gt;&lt;P&gt;check this link&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Nov 2006 04:20:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-column-how-to-create/m-p/1731576#M318493</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-29T04:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic internal table column,How to create .</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-column-how-to-create/m-p/1731577#M318494</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Anversha &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you very much for your powerful help~~&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Nov 2006 05:45:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-column-how-to-create/m-p/1731577#M318494</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-29T05:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic internal table column,How to create .</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-column-how-to-create/m-p/1731578#M318495</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; &lt;/P&gt;&lt;P&gt;REPORT zmaschl_create_data_dynamic . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPE-POOLS: slis. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: it_fcat TYPE slis_t_fieldcat_alv, &lt;/P&gt;&lt;P&gt;is_fcat LIKE LINE OF it_fcat. &lt;/P&gt;&lt;P&gt;DATA: it_fieldcat TYPE lvc_t_fcat, &lt;/P&gt;&lt;P&gt;is_fieldcat LIKE LINE OF it_fieldcat. &lt;/P&gt;&lt;P&gt;DATA: new_table TYPE REF TO data. &lt;/P&gt;&lt;P&gt;DATA: new_line TYPE REF TO data. &lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;l_table&amp;gt; TYPE ANY TABLE, &lt;/P&gt;&lt;P&gt;&amp;lt;l_line&amp;gt; TYPE ANY, &lt;/P&gt;&lt;P&gt;&amp;lt;l_field&amp;gt; TYPE ANY. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Build fieldcat &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' &lt;/P&gt;&lt;P&gt;EXPORTING &lt;/P&gt;&lt;P&gt;i_structure_name = 'SYST' &lt;/P&gt;&lt;P&gt;CHANGING &lt;/P&gt;&lt;P&gt;ct_fieldcat = it_fcat[]. &lt;/P&gt;&lt;P&gt;LOOP AT it_fcat INTO is_fcat WHERE NOT reptext_ddic IS initial. &lt;/P&gt;&lt;P&gt;MOVE-CORRESPONDING is_fcat TO is_fieldcat. &lt;/P&gt;&lt;P&gt;is_fieldcat-fieldname = is_fcat-fieldname. &lt;/P&gt;&lt;P&gt;is_fieldcat-ref_field = is_fcat-fieldname. &lt;/P&gt;&lt;P&gt;is_fieldcat-ref_table = is_fcat-ref_tabname. &lt;/P&gt;&lt;P&gt;APPEND is_fieldcat TO it_fieldcat. &lt;/P&gt;&lt;P&gt;ENDLOOP. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create a new Table &lt;/P&gt;&lt;/LI&gt;&lt;/UL&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 = it_fieldcat &lt;/P&gt;&lt;P&gt;IMPORTING &lt;/P&gt;&lt;P&gt;ep_table = new_table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create a new Line with the same structure of the table. &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;ASSIGN new_table-&amp;gt;* TO &amp;lt;l_table&amp;gt;. &lt;/P&gt;&lt;P&gt;CREATE DATA new_line LIKE LINE OF &amp;lt;l_table&amp;gt;. &lt;/P&gt;&lt;P&gt;ASSIGN new_line-&amp;gt;* TO &amp;lt;l_line&amp;gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Test it... &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DO 30 TIMES. &lt;/P&gt;&lt;P&gt;ASSIGN COMPONENT 'SUBRC' OF STRUCTURE &amp;lt;l_line&amp;gt; TO &amp;lt;l_field&amp;gt;. &lt;/P&gt;&lt;P&gt;&amp;lt;l_field&amp;gt; = sy-index. &lt;/P&gt;&lt;P&gt;INSERT &amp;lt;l_line&amp;gt; INTO TABLE &amp;lt;l_table&amp;gt;. &lt;/P&gt;&lt;P&gt;ENDDO. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT &amp;lt;l_table&amp;gt; ASSIGNING &amp;lt;l_line&amp;gt;. &lt;/P&gt;&lt;P&gt;ASSIGN COMPONENT 'SUBRC' OF STRUCTURE &amp;lt;l_line&amp;gt; TO &amp;lt;l_field&amp;gt;. &lt;/P&gt;&lt;P&gt;WRITE &amp;lt;l_field&amp;gt;. &lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/ab030.htm" target="test_blank"&gt;http://www.sap-img.com/ab030.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Laxmi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Nov 2006 05:48:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-column-how-to-create/m-p/1731578#M318495</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-29T05:48:00Z</dc:date>
    </item>
  </channel>
</rss>

