‎2008 Nov 14 11:17 AM
Hi All,
I am working on dynmaic internal table.
I have written the code from the SDN like this
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. *********Creates a dyanamic internal table*********
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.
For the table T001 it is working fine.
If i want get the table from from or any other table.It is giving runtime error.
could body any know the solution please le me know
‎2008 Nov 15 6:40 AM
hi swapna
what the error i find was that the database table size is more than the internal table size
say for e.g if you are passing table name T002 is not getting dumped .
but for tables like EKKO and SFLIGHT size is more than the internal tbale size.
find out the ways for which u can increase the size of the Dynamic table.(dy_table)
mean while i try for the solution
‎2008 Nov 17 4:17 PM
Hello ,
But if i get the data only 10 rows only from the table it is going to dump.
what would be the problem.
Did you get any solution for this.
If so please let me know.
Thanks,
Swapna.
‎2008 Nov 17 4:45 PM
the problem comes up, when there are fields in the table which represent numbers with decimals (type p). Best is to reference the field directly what comes from SAP. Replace the LOOP At idetails ... ENDLOOP with:
LOOP AT idetails INTO xdetails.
CLEAR xfc.
xfc-fieldname = xfc-ref_field = xdetails-name .
xfc-ref_table = p_table.
* xfc-datatype = xdetails-type_kind.
* xfc-inttype = xdetails-type_kind.
* xfc-intlen = xdetails-length.
* xfc-decimals = xdetails-decimals.
APPEND xfc TO ifc.
ENDLOOP.
‎2008 Nov 17 5:24 PM
Hello Eric,
Now also i am geeting dump.It is giving the error like output table is very small.
Thanks,
Swapna.