메뉴 건너뛰기

SAP 한국 커뮤니티

REPORT ZRTTS_02

sapjoy 2009.12.24 12:05 조회 수 : 2586

* 출처 http://sdn.sap.com   Rich Heilman


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(30type 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.

번호 제목 글쓴이 날짜 조회 수
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 2269
366 report zsalv_015 sapjoy 2010.08.20 2280
365 report zsalv_014 sapjoy 2010.08.20 2296
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 3076
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 3210
» REPORT ZRTTS_02 sapjoy 2009.12.24 2586
354 REPORT ZRTTS_01 . sapjoy 2009.12.24 2652
353 Z16_005TOP sapjoy 2009.09.21 2549
352 Z16_005 sapjoy 2009.09.21 2577
351 Z16_001TOP sapjoy 2009.09.21 2593