<?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 source code generation in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-source-code-generation/m-p/5393400#M1239593</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's the sample program for Dynamic source code generation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: begin of itab occurs 0,
        line(150),
        end of itab.

data: v_name like sy-repid.

parameters: p_table like dd02l-tabname.

itab-line = 'Report sy-repid.'.
append itab. clear itab.
itab-line = 'tables:'.
append itab. clear itab.
concatenate p_table '.' into itab.
itab-line = 'data: begin of itab occurs 0.'.
append itab. clear itab.
concatenate 'include structure' p_table '.' into itab separated by space.
itab-line = 'data:end of itab.'.
append itab. clear itab.
itab-line = 'form f_select.'.
append itab. clear itab.
itab-line = 'select * into table itab'.
append itab. clear itab.
concatenate 'FROM' p_table '.' INTO itab separated by space.
itab-line = 'endform.'.
append itab. clear itab.


generate subroutine pool itab name v_name.
perform f_select in program (v_name).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mahesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Mar 2009 08:27:02 GMT</pubDate>
    <dc:creator>former_member222860</dc:creator>
    <dc:date>2009-03-25T08:27:02Z</dc:date>
    <item>
      <title>dynamic source code generation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-source-code-generation/m-p/5393399#M1239592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;       I would like to declare TYPES with five fields dynamically in my program and then use the same type in program later on. For that i have written the following code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  it_code-line = 'TYPES : BEGIN OF TY_TABLE,'.&lt;/P&gt;&lt;P&gt;  APPEND it_code. CLEAR it_code.&lt;/P&gt;&lt;P&gt;  CONCATENATE f1 'TYPE' f1 ',' INTO it_code separated by space.&lt;/P&gt;&lt;P&gt;  APPEND it_code. CLEAR it_code.&lt;/P&gt;&lt;P&gt;  CONCATENATE f2 'TYPE' f2 ',' INTO it_code separated by space.&lt;/P&gt;&lt;P&gt;  APPEND it_code. CLEAR it_code.&lt;/P&gt;&lt;P&gt;  CONCATENATE f3 'TYPE' f3 ',' INTO it_code separated by space.&lt;/P&gt;&lt;P&gt;  APPEND it_code. CLEAR it_code.&lt;/P&gt;&lt;P&gt;  CONCATENATE f4 'TYPE' f4 ',' INTO it_code separated by space.&lt;/P&gt;&lt;P&gt;  APPEND it_code. CLEAR it_code.&lt;/P&gt;&lt;P&gt;  CONCATENATE f5 'TYPE' f5 ',' INTO it_code separated by space.&lt;/P&gt;&lt;P&gt;  APPEND it_code. CLEAR it_code.&lt;/P&gt;&lt;P&gt;  it_code-line = 'END OF TY_TABLE.'.&lt;/P&gt;&lt;P&gt;  APPEND it_code. CLEAR it_code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  INSERT REPORT 'ZIBM_DYN_INCLUDE' FROM it_code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But i am getting syntax error ' Type TY_TABLE is unknown'. How to rectify this error. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your help will be deeply appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ibrahim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Mar 2009 07:56:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-source-code-generation/m-p/5393399#M1239592</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-25T07:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic source code generation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-source-code-generation/m-p/5393400#M1239593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's the sample program for Dynamic source code generation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: begin of itab occurs 0,
        line(150),
        end of itab.

data: v_name like sy-repid.

parameters: p_table like dd02l-tabname.

itab-line = 'Report sy-repid.'.
append itab. clear itab.
itab-line = 'tables:'.
append itab. clear itab.
concatenate p_table '.' into itab.
itab-line = 'data: begin of itab occurs 0.'.
append itab. clear itab.
concatenate 'include structure' p_table '.' into itab separated by space.
itab-line = 'data:end of itab.'.
append itab. clear itab.
itab-line = 'form f_select.'.
append itab. clear itab.
itab-line = 'select * into table itab'.
append itab. clear itab.
concatenate 'FROM' p_table '.' INTO itab separated by space.
itab-line = 'endform.'.
append itab. clear itab.


generate subroutine pool itab name v_name.
perform f_select in program (v_name).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mahesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Mar 2009 08:27:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-source-code-generation/m-p/5393400#M1239593</guid>
      <dc:creator>former_member222860</dc:creator>
      <dc:date>2009-03-25T08:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic source code generation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-source-code-generation/m-p/5393401#M1239594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Mahesh but i have already seen this code on SDN. It wasn't helpful so i posted my query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ibrahim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Mar 2009 08:35:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-source-code-generation/m-p/5393401#M1239594</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-25T08:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic source code generation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-source-code-generation/m-p/5393402#M1239595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;why don't you use form fields for dynamic table generation ??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in &lt;A href="https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/individual" target="test_blank"&gt;https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/individual&lt;/A&gt;&lt;EM&gt;cell&lt;/EM&gt;coloring&lt;EM&gt;in&lt;/EM&gt;dynamic+alv&lt;/P&gt;&lt;P&gt;I have made an example where you add the fields to the fieldcat. you generate the dynamic table and line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in this report I create fields (employeenumbers) depending on the selection on the selection screen.&lt;/P&gt;&lt;P&gt;so if someone selects company A on the selection screen the programm creates a table with all the employees from company a where the employeenumber is the fieldname.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;further on you can also declare static fields as well to this structure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so perhaps I misunderstood you're requirement but dynamic generation is normally done with form fields&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can also search for the method that creates the table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table

EXPORTING

it_fieldcatalog = it_lvc_cat

IMPORTING

*ep_table = ta_output.*** Create a new Line with the same structure of the table.

ASSIGN ta_output-&amp;gt;* TO &amp;lt;ta_output&amp;gt;.*

CREATE DATA new_line LIKE LINE OF &amp;lt;ta_output&amp;gt;.

ASSIGN new_line-&amp;gt;* TO &amp;lt;l_line&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;kind regards&lt;/P&gt;&lt;P&gt;arthur&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Mar 2009 08:50:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-source-code-generation/m-p/5393402#M1239595</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-25T08:50:32Z</dc:date>
    </item>
  </channel>
</rss>

