Google Search - Blog...........

ABAp - Dynamic Internal Table Single Field.

report zdynamic_table_all_fields.

type-pools: slis.

field-symbols: type standard table,
,
.

data: alv_fldcat type slis_t_fieldcat_alv,
it_fldcat type lvc_t_fcat.

type-pools : abap.

data : it_details type abap_compdescr_tab,
wa_details type abap_compdescr.

data : ref_descr type ref to cl_abap_structdescr.

data: new_table type ref to data,
new_line type ref to data,
wa_it_fldcat type lvc_s_fcat.

selection-screen begin of block b1 with frame title text .
parameters: p_table(30) type c.
selection-screen end of block b1.


* Get the structure of the table.
ref_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).
it_details[] = ref_descr->components[].

loop at it_details into wa_details.
clear wa_it_fldcat.
wa_it_fldcat-fieldname = wa_details-name .
wa_it_fldcat-datatype = wa_details-type_kind.
wa_it_fldcat-intlen = wa_details-length.
wa_it_fldcat-decimals = wa_details-decimals.
append wa_it_fldcat to it_fldcat .
endloop.

* Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fldcat
importing
ep_table = new_table.

assign new_table->* to .

* Create dynamic work area and assign to FS
create data new_line like line of .
assign new_line->* to .

* Select Data from table.
select * into table
from (p_table).

* Write out data from table.
loop at into .
do.
assign component sy-index of structure to .
if sy-subrc ne 0.
exit.
endif.
if sy-index = 1.
write:/ .
else.
write: .
endif.
enddo.
endloop.



ALSO READ:



No comments:

Post a Comment