<?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 Internal Table with the same name in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-with-the-same-name/m-p/3597573#M866347</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hai.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; we can create an internal table based on a type that we have locally declared, but you have to use data instead of types like.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of ty_demo.&lt;/P&gt;&lt;P&gt;var1(1) type c,&lt;/P&gt;&lt;P&gt;var2 type p,&lt;/P&gt;&lt;P&gt;end of ty_demo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check the example notes for dynamic itab .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dynamic internal table is internal table that we create on the fly with flexible column numbers. &lt;/P&gt;&lt;P&gt;For sample code, please look at this code tutorial. Hopefully it can help you &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&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;A href="http://www.saptechnical.com/Tutorials/ABAP/DynamicInternaltable/DynamicInternalTable.htm" target="test_blank"&gt;http://www.saptechnical.com/Tutorials/ABAP/DynamicInternaltable/DynamicInternalTable.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sample code:&lt;/P&gt;&lt;P&gt;DATA: l_cnt(2) TYPE n,&lt;/P&gt;&lt;P&gt;l_cnt1(3) TYPE n,&lt;/P&gt;&lt;P&gt;l_nam(12),&lt;/P&gt;&lt;P&gt;l_con(18) TYPE c,&lt;/P&gt;&lt;P&gt;l_con1(18) TYPE c,&lt;/P&gt;&lt;P&gt;lf_mat TYPE matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT it_bom_expl BY bom_comp bom_mat level.&lt;/P&gt;&lt;P&gt;CLEAR: l_cnt1, &amp;lt;fs_dyn_wa&amp;gt;.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Looping the component internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;LOOP AT it_bom_expl INTO gf_it_bom_expl.&lt;/P&gt;&lt;P&gt;CLEAR: l_cnt1.&lt;/P&gt;&lt;P&gt;AT NEW bom_comp.&lt;/P&gt;&lt;P&gt;CLEAR: l_cnt, &amp;lt;fs_dyn_wa&amp;gt;, lf_mat.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;For every new bom component the material data is moved to&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;temp material table which will be used for assigning the levels&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;checking the count&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;it_mat_temp[] = it_mat[].&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Component data is been assigned to the field symbol which is checked&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;against the field of dynamic internal table and the value of the&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;component number is been passed to the dynamic internal table field&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;value.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;ASSIGN COMPONENT c_comp_list OF STRUCTURE &amp;lt;fs_dyn_wa&amp;gt; TO&lt;/P&gt;&lt;P&gt;&amp;lt;fs_check&amp;gt;.&lt;/P&gt;&lt;P&gt;&amp;lt;fs_check&amp;gt; = gf_it_bom_expl-bom_comp.&lt;/P&gt;&lt;P&gt;ENDAT.&lt;/P&gt;&lt;P&gt;AT NEW bom_mat.&lt;/P&gt;&lt;P&gt;CLEAR l_con.&lt;/P&gt;&lt;P&gt;ENDAT.&lt;/P&gt;&lt;P&gt;lf_mat = gf_it_bom_expl-bom_mat.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Looping the temp internal table and looping the dynamic internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*by reading line by line into workarea, the materialxxn is been assigned&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;to field symbol which will be checked and used.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;LOOP AT it_mat_temp.&lt;/P&gt;&lt;P&gt;l_nam = c_mat.&lt;/P&gt;&lt;P&gt;l_cnt1 = l_cnt1 + 1.&lt;/P&gt;&lt;P&gt;CONCATENATE l_nam l_cnt1 INTO l_nam.&lt;/P&gt;&lt;P&gt;LOOP AT &amp;lt;fs_dyn_table2&amp;gt; ASSIGNING &amp;lt;fs_dyn_wa2&amp;gt;.&lt;/P&gt;&lt;P&gt;ASSIGN COMPONENT l_nam OF STRUCTURE &amp;lt;fs_dyn_wa2&amp;gt; TO &amp;lt;fs_xy&amp;gt;.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;IF &amp;lt;fs_xy&amp;gt; = lf_mat.&lt;/P&gt;&lt;P&gt;CLEAR lf_mat.&lt;/P&gt;&lt;P&gt;l_con1 = l_con.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Checking whether the material exists for a component and if so it is&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;been assigned to the field symbol which is checked against the field&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;of dynamic internal table and the level of the component number&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;against material is been passed to the dynamic internal table field&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;value.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;IF &amp;lt;fs_xy&amp;gt; = gf_it_bom_expl-bom_mat.&lt;/P&gt;&lt;P&gt;ASSIGN COMPONENT l_nam OF STRUCTURE &amp;lt;fs_dyn_wa&amp;gt; TO &amp;lt;fs_check&amp;gt;.&lt;/P&gt;&lt;P&gt;CLEAR l_con.&lt;/P&gt;&lt;P&gt;MOVE gf_it_bom_expl-level TO l_con.&lt;/P&gt;&lt;P&gt;CONCATENATE c_val_l l_con INTO l_con.&lt;/P&gt;&lt;P&gt;CONDENSE l_con NO-GAPS.&lt;/P&gt;&lt;P&gt;IF l_con1 NE space.&lt;/P&gt;&lt;P&gt;CONCATENATE l_con1 l_con INTO l_con SEPARATED BY c_comma.&lt;/P&gt;&lt;P&gt;CLEAR l_con1.&lt;/P&gt;&lt;P&gt;l_cnt = l_cnt - 1.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&amp;lt;fs_check&amp;gt; = l_con.&lt;/P&gt;&lt;P&gt;l_cnt = l_cnt + 1.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AT END OF bom_comp.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;At end of every new bom component the count is moved to the field&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;symbol which is checked against the field of dynamic internal table&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;and the count is been passed to the dynamic internal table field&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;value.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;ASSIGN COMPONENT c_count OF STRUCTURE &amp;lt;fs_dyn_wa&amp;gt; TO &amp;lt;fs_check&amp;gt;.&lt;/P&gt;&lt;P&gt;&amp;lt;fs_check&amp;gt; = l_cnt.&lt;/P&gt;&lt;P&gt;INSERT &amp;lt;fs_dyn_wa&amp;gt; INTO TABLE &amp;lt;fs_dyn_table&amp;gt;.&lt;/P&gt;&lt;P&gt;ENDAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards.&lt;/P&gt;&lt;P&gt;sowjanya.b&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 24 Mar 2008 11:12:43 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-03-24T11:12:43Z</dc:date>
    <item>
      <title>Dynamic Internal Table with the same name</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-with-the-same-name/m-p/3597570#M866344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Guys&lt;/P&gt;&lt;P&gt;I have a question.&lt;/P&gt;&lt;P&gt;I know that we can create dynamic internal table taking a struct dynamically.&lt;/P&gt;&lt;P&gt;But I have 2 ques on the same subject.&lt;/P&gt;&lt;P&gt;1. Can we create an internal table based on a type that we have locally declared eg&lt;/P&gt;&lt;P&gt;types: begin of ty_demo.&lt;/P&gt;&lt;P&gt;           var1(1) type c,&lt;/P&gt;&lt;P&gt;           var2     type p,&lt;/P&gt;&lt;P&gt;          end of ty_demo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. If an internal table is already declared based on the above type say data: i_tab type standard table of ty_demo.&lt;/P&gt;&lt;P&gt;    If i need to enhance the struct of this internal table. Can i do that by dynamically redefining it based on a different structure but keepin the same name i_tab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a nut shell I cannot change the name of my itab but I want to enhance the structure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I Hope I am clear.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Help will be greatly apprcieated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Sameer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Mar 2008 16:17:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-with-the-same-name/m-p/3597570#M866344</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-22T16:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Internal Table with the same name</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-with-the-same-name/m-p/3597571#M866345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. With CREATE DATA ... TYPE ... , you can reference a local type:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data ref type ref to data.
create data ref type ty_demo.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Then you can use ref by&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;field-symbols &amp;lt;stru&amp;gt; type any.
assign ref-&amp;gt;* to &amp;lt;stru&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;etc. (see sap doc for more info)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. To create anything dynamically, refer to RTTC classes. Demo program:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT  ZDYNSTRUCTCREATE.

PERFORM MAIN.

FORM MAIN.

type-pools abap.
data:
ls_component type abap_componentdescr,
lt_component type abap_component_tab.

*... (1) define structure components :

clear ls_component.
ls_component-name = 'CARRID'.
ls_component-type ?= cl_abap_typedescr=&amp;gt;describe_by_name( 'SFLIGHT-CARRID' ).
insert ls_component into table lt_component.

clear ls_component.
ls_component-name = 'CONNID'.
ls_component-type ?= cl_abap_elemdescr=&amp;gt;get_n( 4 ).
insert ls_component into table lt_component.

*... (2) create structure
data lr_strucdescr type ref to cl_abap_structdescr.
data lr_data_struc type ref to data.

lr_strucdescr = cl_abap_structdescr=&amp;gt;create( lt_component ).
create data lr_data_struc type handle lr_strucdescr.

*... (2b) fill structure
field-symbols: &amp;lt;ls_struc&amp;gt; type any.
assign lr_data_struc-&amp;gt;* to &amp;lt;ls_struc&amp;gt;.

field-symbols: &amp;lt;l_field&amp;gt; type any.
data l_fieldname type fieldname.

l_fieldname = 'CARRID'.
assign component l_fieldname of structure &amp;lt;ls_struc&amp;gt; to &amp;lt;l_field&amp;gt;.
if sy-subrc = 0.
&amp;lt;l_field&amp;gt; = 'AF'.
endif.

l_fieldname = 'CONNID'.
assign component l_fieldname of structure &amp;lt;ls_struc&amp;gt; to &amp;lt;l_field&amp;gt;.
if sy-subrc = 0.
&amp;lt;l_field&amp;gt; = '3878'.
endif.

*... (3) create table
data lr_tabledescr type ref to cl_abap_tabledescr.
data lr_data_table type ref to data.

lr_tabledescr = cl_abap_tabledescr=&amp;gt;create( p_line_type = lr_strucdescr ).

create data lr_data_table type handle lr_tabledescr.

*... (3b) fill table
field-symbols:
&amp;lt;lt_table&amp;gt; type standard table.

assign lr_data_table-&amp;gt;* to &amp;lt;lt_table&amp;gt;.

append &amp;lt;ls_struc&amp;gt; to &amp;lt;lt_table&amp;gt;.

ENDFORM.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Mar 2008 17:28:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-with-the-same-name/m-p/3597571#M866345</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2008-03-22T17:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Internal Table with the same name</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-with-the-same-name/m-p/3597572#M866346</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; type-pools : abap. &lt;/P&gt;&lt;P&gt;  field-symbols: &amp;lt;dyn_table&amp;gt; type standard table, &lt;/P&gt;&lt;P&gt;               &amp;lt;dyn_wa&amp;gt;, &lt;/P&gt;&lt;P&gt;               &amp;lt;dyn_field&amp;gt;. &lt;/P&gt;&lt;P&gt;  data: dy_table type ref to data, &lt;/P&gt;&lt;P&gt;      dy_line  type ref to data, &lt;/P&gt;&lt;P&gt;      xfc type lvc_s_fcat, &lt;/P&gt;&lt;P&gt;      ifc type lvc_t_fcat. &lt;/P&gt;&lt;P&gt;  selection-screen begin of block b1 with frame. &lt;/P&gt;&lt;P&gt;parameters: p_table(30) type c default 'T001'. &lt;/P&gt;&lt;P&gt;selection-screen end of block b1. &lt;/P&gt;&lt;P&gt;  start-of-selection. &lt;/P&gt;&lt;P&gt;    perform get_structure. &lt;/P&gt;&lt;P&gt;  perform create_dynamic_itab.      *********&lt;STRONG&gt;Creates a dyanamic internal table&lt;/STRONG&gt;********* &lt;/P&gt;&lt;P&gt;  perform get_data. &lt;/P&gt;&lt;P&gt;  perform write_out. &lt;/P&gt;&lt;P&gt;  form get_structure. &lt;/P&gt;&lt;P&gt;  data : idetails type abap_compdescr_tab, &lt;/P&gt;&lt;P&gt;       xdetails type abap_compdescr. &lt;/P&gt;&lt;P&gt;  data : ref_table_des type ref to cl_abap_structdescr. &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get the structure of the table. &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  ref_table_des ?=  &lt;/P&gt;&lt;P&gt;      cl_abap_typedescr=&amp;gt;describe_by_name( p_table ). &lt;/P&gt;&lt;P&gt;  idetails[] = ref_table_des-&amp;gt;components[]. &lt;/P&gt;&lt;P&gt;    loop at idetails into xdetails. &lt;/P&gt;&lt;P&gt;    clear xfc. &lt;/P&gt;&lt;P&gt;    xfc-fieldname = xdetails-name . &lt;/P&gt;&lt;P&gt;    xfc-datatype = xdetails-type_kind. &lt;/P&gt;&lt;P&gt;    xfc-inttype = xdetails-type_kind. &lt;/P&gt;&lt;P&gt;    xfc-intlen = xdetails-length. &lt;/P&gt;&lt;P&gt;    xfc-decimals = xdetails-decimals. &lt;/P&gt;&lt;P&gt;    append xfc to ifc. &lt;/P&gt;&lt;P&gt;  endloop. &lt;/P&gt;&lt;P&gt;  endform. &lt;/P&gt;&lt;P&gt;  form create_dynamic_itab. &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create dynamic internal table and assign to FS &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 = ifc &lt;/P&gt;&lt;P&gt;               importing &lt;/P&gt;&lt;P&gt;                  ep_table        = dy_table. &lt;/P&gt;&lt;P&gt;    assign dy_table-&amp;gt;* to &amp;lt;dyn_table&amp;gt;. &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create dynamic work area and assign to FS &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  create data dy_line like line of &amp;lt;dyn_table&amp;gt;. &lt;/P&gt;&lt;P&gt;  assign dy_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;. &lt;/P&gt;&lt;P&gt;  endform. &lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;P&gt;  form get_data. &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select Data from table. &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  select * into table &amp;lt;dyn_table&amp;gt; &lt;/P&gt;&lt;P&gt;             from (p_table). &lt;/P&gt;&lt;P&gt;  endform. &lt;/P&gt;&lt;P&gt;   Write out data from table. &lt;/P&gt;&lt;P&gt;  loop at &amp;lt;dyn_table&amp;gt; into &amp;lt;dyn_wa&amp;gt;. &lt;/P&gt;&lt;P&gt;    do. &lt;/P&gt;&lt;P&gt;      assign component  sy-index   &lt;/P&gt;&lt;P&gt;         of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_field&amp;gt;. &lt;/P&gt;&lt;P&gt;      if sy-subrc &amp;lt;&amp;gt; 0. &lt;/P&gt;&lt;P&gt;        exit. &lt;/P&gt;&lt;P&gt;      endif. &lt;/P&gt;&lt;P&gt;      if sy-index = 1. &lt;/P&gt;&lt;P&gt;        write:/ &amp;lt;dyn_field&amp;gt;. &lt;/P&gt;&lt;P&gt;      else. &lt;/P&gt;&lt;P&gt;        write: &amp;lt;dyn_field&amp;gt;. &lt;/P&gt;&lt;P&gt;      endif. &lt;/P&gt;&lt;P&gt;    enddo. &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;with regards,&lt;/P&gt;&lt;P&gt;sowjanya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Mar 2008 10:16:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-with-the-same-name/m-p/3597572#M866346</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-24T10:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Internal Table with the same name</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-with-the-same-name/m-p/3597573#M866347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hai.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; we can create an internal table based on a type that we have locally declared, but you have to use data instead of types like.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of ty_demo.&lt;/P&gt;&lt;P&gt;var1(1) type c,&lt;/P&gt;&lt;P&gt;var2 type p,&lt;/P&gt;&lt;P&gt;end of ty_demo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check the example notes for dynamic itab .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dynamic internal table is internal table that we create on the fly with flexible column numbers. &lt;/P&gt;&lt;P&gt;For sample code, please look at this code tutorial. Hopefully it can help you &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&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;A href="http://www.saptechnical.com/Tutorials/ABAP/DynamicInternaltable/DynamicInternalTable.htm" target="test_blank"&gt;http://www.saptechnical.com/Tutorials/ABAP/DynamicInternaltable/DynamicInternalTable.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sample code:&lt;/P&gt;&lt;P&gt;DATA: l_cnt(2) TYPE n,&lt;/P&gt;&lt;P&gt;l_cnt1(3) TYPE n,&lt;/P&gt;&lt;P&gt;l_nam(12),&lt;/P&gt;&lt;P&gt;l_con(18) TYPE c,&lt;/P&gt;&lt;P&gt;l_con1(18) TYPE c,&lt;/P&gt;&lt;P&gt;lf_mat TYPE matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT it_bom_expl BY bom_comp bom_mat level.&lt;/P&gt;&lt;P&gt;CLEAR: l_cnt1, &amp;lt;fs_dyn_wa&amp;gt;.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Looping the component internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;LOOP AT it_bom_expl INTO gf_it_bom_expl.&lt;/P&gt;&lt;P&gt;CLEAR: l_cnt1.&lt;/P&gt;&lt;P&gt;AT NEW bom_comp.&lt;/P&gt;&lt;P&gt;CLEAR: l_cnt, &amp;lt;fs_dyn_wa&amp;gt;, lf_mat.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;For every new bom component the material data is moved to&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;temp material table which will be used for assigning the levels&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;checking the count&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;it_mat_temp[] = it_mat[].&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Component data is been assigned to the field symbol which is checked&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;against the field of dynamic internal table and the value of the&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;component number is been passed to the dynamic internal table field&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;value.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;ASSIGN COMPONENT c_comp_list OF STRUCTURE &amp;lt;fs_dyn_wa&amp;gt; TO&lt;/P&gt;&lt;P&gt;&amp;lt;fs_check&amp;gt;.&lt;/P&gt;&lt;P&gt;&amp;lt;fs_check&amp;gt; = gf_it_bom_expl-bom_comp.&lt;/P&gt;&lt;P&gt;ENDAT.&lt;/P&gt;&lt;P&gt;AT NEW bom_mat.&lt;/P&gt;&lt;P&gt;CLEAR l_con.&lt;/P&gt;&lt;P&gt;ENDAT.&lt;/P&gt;&lt;P&gt;lf_mat = gf_it_bom_expl-bom_mat.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Looping the temp internal table and looping the dynamic internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*by reading line by line into workarea, the materialxxn is been assigned&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;to field symbol which will be checked and used.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;LOOP AT it_mat_temp.&lt;/P&gt;&lt;P&gt;l_nam = c_mat.&lt;/P&gt;&lt;P&gt;l_cnt1 = l_cnt1 + 1.&lt;/P&gt;&lt;P&gt;CONCATENATE l_nam l_cnt1 INTO l_nam.&lt;/P&gt;&lt;P&gt;LOOP AT &amp;lt;fs_dyn_table2&amp;gt; ASSIGNING &amp;lt;fs_dyn_wa2&amp;gt;.&lt;/P&gt;&lt;P&gt;ASSIGN COMPONENT l_nam OF STRUCTURE &amp;lt;fs_dyn_wa2&amp;gt; TO &amp;lt;fs_xy&amp;gt;.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;IF &amp;lt;fs_xy&amp;gt; = lf_mat.&lt;/P&gt;&lt;P&gt;CLEAR lf_mat.&lt;/P&gt;&lt;P&gt;l_con1 = l_con.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Checking whether the material exists for a component and if so it is&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;been assigned to the field symbol which is checked against the field&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;of dynamic internal table and the level of the component number&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;against material is been passed to the dynamic internal table field&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;value.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;IF &amp;lt;fs_xy&amp;gt; = gf_it_bom_expl-bom_mat.&lt;/P&gt;&lt;P&gt;ASSIGN COMPONENT l_nam OF STRUCTURE &amp;lt;fs_dyn_wa&amp;gt; TO &amp;lt;fs_check&amp;gt;.&lt;/P&gt;&lt;P&gt;CLEAR l_con.&lt;/P&gt;&lt;P&gt;MOVE gf_it_bom_expl-level TO l_con.&lt;/P&gt;&lt;P&gt;CONCATENATE c_val_l l_con INTO l_con.&lt;/P&gt;&lt;P&gt;CONDENSE l_con NO-GAPS.&lt;/P&gt;&lt;P&gt;IF l_con1 NE space.&lt;/P&gt;&lt;P&gt;CONCATENATE l_con1 l_con INTO l_con SEPARATED BY c_comma.&lt;/P&gt;&lt;P&gt;CLEAR l_con1.&lt;/P&gt;&lt;P&gt;l_cnt = l_cnt - 1.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&amp;lt;fs_check&amp;gt; = l_con.&lt;/P&gt;&lt;P&gt;l_cnt = l_cnt + 1.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AT END OF bom_comp.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;At end of every new bom component the count is moved to the field&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;symbol which is checked against the field of dynamic internal table&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;and the count is been passed to the dynamic internal table field&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;value.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;ASSIGN COMPONENT c_count OF STRUCTURE &amp;lt;fs_dyn_wa&amp;gt; TO &amp;lt;fs_check&amp;gt;.&lt;/P&gt;&lt;P&gt;&amp;lt;fs_check&amp;gt; = l_cnt.&lt;/P&gt;&lt;P&gt;INSERT &amp;lt;fs_dyn_wa&amp;gt; INTO TABLE &amp;lt;fs_dyn_table&amp;gt;.&lt;/P&gt;&lt;P&gt;ENDAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards.&lt;/P&gt;&lt;P&gt;sowjanya.b&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Mar 2008 11:12:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-with-the-same-name/m-p/3597573#M866347</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-24T11:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Internal Table with the same name</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-with-the-same-name/m-p/3597574#M866348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanx guys&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Mar 2008 15:00:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-internal-table-with-the-same-name/m-p/3597574#M866348</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-26T15:00:32Z</dc:date>
    </item>
  </channel>
</rss>

