* 출처 http://sdn.sap.com
REPORT ZRTTS_02.
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.
form write_out.
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.
댓글 0
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
371 | report zsalv_021 . | sapjoy | 2010.08.20 | 2293 |
370 | report zsalv_020 . | sapjoy | 2010.08.20 | 2381 |
369 | report zsalv_019 . | sapjoy | 2010.08.20 | 2272 |
368 | report zsalv_018 . | sapjoy | 2010.08.20 | 2327 |
367 | report zsalv_017 . | sapjoy | 2010.08.20 | 2270 |
366 | report zsalv_015 | sapjoy | 2010.08.20 | 2280 |
365 | report zsalv_014 | sapjoy | 2010.08.20 | 2299 |
364 | report zsalv_013 | sapjoy | 2010.08.20 | 2361 |
363 | report zsalv_012 | sapjoy | 2010.08.20 | 2271 |
362 | report zsalv_011 | sapjoy | 2010.08.20 | 2331 |
361 | report zsalv_010 | sapjoy | 2010.08.20 | 2294 |
360 | report zsalv_004 | sapjoy | 2010.08.20 | 3078 |
359 | report zsalv_003 | sapjoy | 2010.08.20 | 2336 |
358 | report zsalv_002 [1] | sapjoy | 2010.08.20 | 2476 |
357 | report zsalv_001 | sapjoy | 2010.08.20 | 2442 |
356 | zsalv_edit [1] | sapjoy | 2010.08.20 | 3235 |
» | REPORT ZRTTS_02 | sapjoy | 2009.12.24 | 2586 |
354 | REPORT ZRTTS_01 . | sapjoy | 2009.12.24 | 2670 |
353 | Z16_005TOP | sapjoy | 2009.09.22 | 2549 |
352 | Z16_005 | sapjoy | 2009.09.22 | 2579 |