Chinaunix首页 | 论坛 | 博客
  • 博客访问: 285144
  • 博文数量: 62
  • 博客积分: 2966
  • 博客等级: 少校
  • 技术积分: 615
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-07 23:16
个人简介

Be a simple man

文章分类

全部博文(62)

文章存档

2012年(6)

2011年(15)

2010年(6)

2009年(3)

2008年(5)

2007年(27)

我的朋友

分类:

2007-08-20 11:06:34

REPORT z_jason_test_itab .

TYPE-POOLS : abap.
FIELD-SYMBOLS: TYPE STANDARD TABLE,
               ,
               .
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 TITLE TEXT-001.
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                                            *
*---------------------------------------------------------------------*
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-intlen = xdetails-length.
    xfc-decimals = xdetails-decimals.
    APPEND xfc TO ifc.
  ENDLOOP.
ENDFORM.
*---------------------------------------------------------------------*
*       FORM create_dynamic_itab                                      *
*---------------------------------------------------------------------*
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 .
* Create dynamic work area and assign to FS
  CREATE DATA dy_line LIKE LINE OF .
  ASSIGN dy_line->* TO .
ENDFORM.

*---------------------------------------------------------------------*
*       FORM get_data                                                 *
*---------------------------------------------------------------------*
FORM get_data.
* Select Data from table.
  SELECT * INTO TABLE
             FROM (p_table).
ENDFORM.
*---------------------------------------------------------------------*
*       FORM write_out                                                *
*---------------------------------------------------------------------*
FORM  write_out.
* Write out data from table.
  LOOP AT INTO .
    DO.
      ASSIGN COMPONENT  sy-index
         OF STRUCTURE TO .
      IF sy-subrc <> 0.
        EXIT.
      ENDIF.
      IF sy-index = 1.
        WRITE:/ .
      ELSE.
        WRITE: .
      ENDIF.
    ENDDO.
  ENDLOOP.
ENDFORM.

阅读(1306) | 评论(0) | 转发(0) |
0

上一篇:HIDE & AT LINE-SELECTION

下一篇:SAP平台迁移

给主人留下些什么吧!~~