07-20-2007 5:15 AM
Hi all,
what is a dynamic table ? How do i go about creating one. Actually, my requirement is to display a set of fields based on selection screen with 3 input fields. Any help/suggestion is appreciated. Thank you.
07-20-2007 5:28 AM
Hi
Use this method
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fldcat
IMPORTING
ep_table = new_table.
ASSIGN new_table->* TO <dyn_table>.
Create dynamic work area and assign to FS
CREATE DATA new_line LIKE LINE OF <dyn_table>.
ASSIGN new_line->* TO <dyn_wa>.
Also see:
/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table
/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap
Thanks & Regards
Ravish Garg
<b>
*REWARD IF USEFUL</b>
07-20-2007 5:28 AM
Hi
Use this method
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fldcat
IMPORTING
ep_table = new_table.
ASSIGN new_table->* TO <dyn_table>.
Create dynamic work area and assign to FS
CREATE DATA new_line LIKE LINE OF <dyn_table>.
ASSIGN new_line->* TO <dyn_wa>.
Also see:
/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table
/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap
Thanks & Regards
Ravish Garg
<b>
*REWARD IF USEFUL</b>
07-20-2007 5:31 AM
Hi,
Can u b more clear in ur requirement?
As to wat i hav understood, its actually simple to specify the fileds in ur selection screen thro parameters or select options.
Then fetch the required fields based on ur selection screen values, jus by writing a select query with a "where condition".
Then display the content in ur it_tab using ALV or write statements.
*****Reward points if helpful.
07-20-2007 5:33 AM
hi,
<b>go thru these links..</b>
/people/achim.bangert/blog/2006/08/02/dynamic-proxies-in-abap
<b>Below is a example to create a dynamic table.</b>
field-symbols: <dyn_table> type standard table ,
<dyn_wa> type any,
<dyn_field> type any.
data: dy_table type ref to data, "variable used to build table str
dy_line type ref to data, "variable for dynamic table creation
it_fcat type lvc_t_fcat, "internal table to create dynamic table
&----
*& Form f_create_table
&----
text
----
-->P_P_TABLE text
----
form f_create_table using in_tabname. "#EC *)
FIELD-SYMBOLS: <fcat> TYPE lvc_s_fcat.
data: wa_fcat like line of it_fcat.
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = in_tabname
changing
ct_fieldcat = it_fcat
exceptions
others = 1.
if sy-subrc = 0.
move: in_tabname to wa_fcat-tabname.
modify it_fcat from wa_fcat transporting tabname where fieldname is
not initial.
else.
write: text-t01.
leave program.
endif.
endform. " f_create_table
&----
*& Form create_dynamic_itab
&----
text
----
--> p1 text
<-- p2 text
----
form create_dynamic_itab .
Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fcat
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. " create_dynamic_itab
form get_data .
select * into corresponding fields of table <dyn_table>
from (p_table) where (v_where) .
form write_out .
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.
endform. " write_out
07-20-2007 5:36 AM
07-20-2007 5:46 AM
hi ,
u can see the following code for creating dynamic int table.
Rmbr, u have to create a screen as well u need uncomment the PBO and PAI modules,in ur screen.Then only u can c the o/p.
&----
*& Report ZNEW_DYN_IT
*&
&----
*&
*&
&----
REPORT ZNEW_DYN_IT.
parameters : pr_table type DD02L-TABNAME default 'spfli'.
**..... Dynamic internal table creation.
DATA : it_table TYPE REF TO data.
**..... Work area
DATA : wa_table LIKE it_table.
**..... ALV Grid
DATA : r_dock type ref to cl_gui_docking_container,
r_alv type ref to cl_gui_alv_grid.
call screen 100.
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
module STATUS_0100 output.
SET PF-STATUS space.
if pr_table is not initial.
CREATE DATA it_table TYPE STANDARD TABLE OF (pr_table).
FIELD-SYMBOLS : <fs_table> TYPE STANDARD TABLE.
ASSIGN it_table->* TO <fs_table>.
**..... Filling Internal Table.
SELECT * FROM (pr_table) INTO TABLE <fs_table> UP TO 10 ROWS.
create object r_dock exporting extension = 2000.
create object r_alv exporting i_parent = r_dock.
call method r_alv->set_table_for_first_display
Exporting
i_structure_name = pr_table
Changing
it_outtab = <fs_table>.
endif.
endmodule. " STATUS_0100 OUTPUT
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
----
module USER_COMMAND_0100 input.
leave to screen 0.
endmodule. " USER_COMMAND_0100 INPUT
Hope this helps.
*****Reward points if helpful