Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7185432
  • 博文数量: 655
  • 博客积分: 10264
  • 博客等级: 上将
  • 技术积分: 8278
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-04 17:47
个人简介

ABAP顾问

文章分类

全部博文(655)

文章存档

2017年(2)

2014年(8)

2013年(3)

2012年(2)

2011年(18)

2010年(102)

2009年(137)

2008年(274)

2007年(134)

分类:

2007-06-04 17:52:20

REPORT  z_barry_test                            .

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.
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.

  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 + xdetails-decimals.
    xfc-decimals = xdetails-decimals.
    APPEND xfc TO ifc.
  ENDLOOP.
ENDFORM.                    "get_structure
*---------------------------------------------------------------------*
*       FORM create_dynamic_itab                                      *
*---------------------------------------------------------------------*
FORM create_dynamic_itab.

  CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog = ifc
    IMPORTING
      ep_table        = dy_table.
  ASSIGN dy_table->* TO .

  CREATE DATA dy_line LIKE LINE OF .
  ASSIGN dy_line->* TO .
ENDFORM.                    "create_dynamic_itab

*---------------------------------------------------------------------*
*       FORM get_data                                                 *
*---------------------------------------------------------------------*
FORM get_data.
  DATA: BEGIN OF itab OCCURS 0 .
          INCLUDE STRUCTURE spfli.
  DATA: END OF itab.

  SELECT * INTO CORRESPONDING FIELDS OF TABLE
             FROM (p_table).
ENDFORM.                    "get_data
*---------------------------------------------------------------------*
*       FORM write_out                                                *
*---------------------------------------------------------------------*
FORM  write_out.
  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.                    "write_out

阅读(9815) | 评论(9) | 转发(0) |
0

上一篇:没有了

下一篇:UP_DOWN_REQUEST

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

chinaunix网友2008-11-29 22:18:42

http://blog.chinaunix.net/u1/40527/showart.php?id=411190 这个好像是为你的要求定制的哈

chinaunix网友2008-11-28 16:49:44

前辈:你好,最近做个程序,是创建动态内表,使用alv输出,并且显示alv的单元格颜色,不知怎么弄?我的msn:liudelun1234@hotmail.com thank you!

chinaunix网友2008-07-31 10:53:59

很不错

qdbarry2008-05-23 13:11:46

仅用于非UNICODE系统

qdbarry2008-05-23 12:46:59

还有一个UNICODE的错误