메뉴 건너뛰기

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.

번호 제목 글쓴이 날짜 조회 수
549 REPORT ZSMARTFORMS_08. [2] sapjoy 2009.02.27 2602
548 REPORT Z18_000 [1] sapjoy 2008.04.16 2602
547 Include Z16_001TOP sapjoy 2007.04.26 2601
546 REPORT z09_002 sapjoy 2006.12.15 2601
545 REPORT z18_025 sapjoy 2007.03.16 2598
544 REPORT Z04_005 . sapjoy 2006.12.02 2595
543 INCLUDE Z16_001O01 [1] sapjoy 2007.04.26 2595
542 Z16_001TOP sapjoy 2009.09.21 2593
541 REPORT ZBAPI_002. sapjoy 2009.02.09 2590
540 Include ZXCSAU05 sapjoy 2008.12.15 2587
» REPORT ZRTTS_02 sapjoy 2009.12.24 2586
538 REPORT z18_013 [1] sapjoy 2007.03.09 2585
537 Z18_001_PBO sapjoy 2007.03.02 2585
536 REPORT zmacro_01. sapjoy 2010.10.09 2582
535 REPORT ZDYNAMIC_ITAB_07. sapjoy 2009.02.16 2582
534 REPORT ZSMARTFORMS_01. sapjoy 2008.11.26 2582
533 REPORT Z_15_012 sapjoy 2008.04.15 2581
532 REPORT Z03_002 [4] sapjoy 2007.05.11 2580
531 REPORT Z14_011 sapjoy 2007.01.22 2580
530 REPORT z15_032 sapjoy 2007.02.05 2578