Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

dynamic internal table

Former Member
0 Likes
1,729

what is the process to generate a dynamic internal table in our program.

Title was edited by:

Alvaro Tejada Galindo

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
924

Hi,

Also have a look at below weblog:

/people/ravikumar.allampallam/blog/2005/05/31/expand-the-list-of-columns-in-a-report-dynamically

/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table

/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap

/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table%3Fpage%3Dlast%26x-showcontent%3Doff

http://www.sap-img.com/ab030.htm

/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap

http://searchsap.techtarget.com/tip/1,289483,sid21_gci912390,00.html

It gives you info abt how to create dynamic internal table.

<b><REMOVED BY MODERATOR></b>

<b>Manish</b>

Message was edited by:

Alvaro Tejada Galindo

4 REPLIES 4
Read only

Former Member
0 Likes
925

Hi,

Also have a look at below weblog:

/people/ravikumar.allampallam/blog/2005/05/31/expand-the-list-of-columns-in-a-report-dynamically

/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table

/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap

/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table%3Fpage%3Dlast%26x-showcontent%3Doff

http://www.sap-img.com/ab030.htm

/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap

http://searchsap.techtarget.com/tip/1,289483,sid21_gci912390,00.html

It gives you info abt how to create dynamic internal table.

<b><REMOVED BY MODERATOR></b>

<b>Manish</b>

Message was edited by:

Alvaro Tejada Galindo

Read only

Former Member
0 Likes
924

hi,

report z_dynamic.

type-pools : abap.

field-symbols: <dyn_table> type standard table,

<dyn_wa>,

<dyn_field>.

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.

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=>describe_by_name( p_table ).

idetails[] = ref_table_des->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.

  • Create dynamic internal table and assign to FS

call method cl_alv_table_create=>create_dynamic_table

exporting

it_fieldcatalog = ifc

importing

ep_table = dy_table.

assign dy_table->* to <dyn_table>.

  • Create dynamic work area and assign to FS

create data dy_line like line of <dyn_table>.

assign dy_line->* to <dyn_wa>.

endform.

form get_data.

  • Select Data from table.

select * into table <dyn_table>

from (p_table).

endform.

  • Write out data from table.

loop at <dyn_table> into <dyn_wa>.

do.

assign component sy-index

of structure <dyn_wa> to <dyn_field>.

if sy-subrc <> 0.

exit.

endif.

if sy-index = 1.

write:/ <dyn_field>.

else.

write: <dyn_field>.

endif.

enddo.

endloop.

check the link for the same.

Dynamic Internal table -weblog in sdn

/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table

/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table

http://www.sap-img.com/ab030.htm

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/dynamicInternalTable&

/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table

/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap

thanks...

<b><REMOVED BY MODERATOR></b>

Message was edited by:

Alvaro Tejada Galindo

Read only

Former Member
0 Likes
924

Hi Sandeep,

I have a snippet, i hope this will help...


data: TABNAME LIKE DD02l-TABNAME
FIELD-SYMBOLS: <l_table> TYPE table.

tabname = 'KNA1'.

CREATE DATA dref TYPE STANDARD TABLE
OF (tabname)
INITIAL SIZE 5.
ASSIGN dref->* TO <l_table>.

I hope this helped ...

Happy coding ...

Regards,

SJ