REPORT zdemo01.
DATA:gt_t001 TYPE TABLE OF t001,
gs_t001 TYPE t001.
DATA:gt_fieldcatalog TYPE lvc_t_fcat,
gs_fieldcatalog TYPE lvc_s_fcat,
gt_table TYPE REF TO data.
FIELD-SYMBOLS: TYPE any.
SELECT * INTO TABLE gt_t001 FROM t001.
DATA:gt_components LIKE TABLE OF rstrucinfo,
gs_components LIKE LINE OF gt_components.
CALL FUNCTION 'GET_COMPONENT_LIST'
EXPORTING
program = 'ZDEMO02'
fieldname = 'GS_T001'
TABLES
components = gt_components.
LOOP AT gt_components INTO gs_components.
gs_fieldcatalog-fieldname = gs_components-compname.
gs_fieldcatalog-datatype = gs_components-type.
gs_fieldcatalog-inttype = gs_components-type.
gs_fieldcatalog-intlen = gs_components-leng.
gs_fieldcatalog-decimals = gs_components-decs.
APPEND gs_fieldcatalog TO gt_fieldcatalog.
ENDLOOP.
*根据结构创建内表
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_fieldcatalog
IMPORTING
ep_table = gt_table
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
ASSIGN gt_table->* TO .
= gt_t001.
WRITE 1.
阅读(1011) | 评论(0) | 转发(0) |