网站建议:179001057@qq.com

ABAP--如何创建动态结构的报表

技术2022-05-11  1

1、使用cl_alv_table_create=>create_dynamic_table

REPORT zmaschl_create_data_dynamic .

TYPE-POOLS: slis.

DATA: it_fcat TYPE slis_t_fieldcat_alv,      is_fcat LIKE LINE OF it_fcat.DATA: it_fieldcat TYPE lvc_t_fcat,      is_fieldcat LIKE LINE OF it_fieldcat.DATA: new_table TYPE REF TO data.DATA: new_line  TYPE REF TO data.FIELD-SYMBOLS: TYPE ANY TABLE,                  TYPE ANY,                TYPE ANY.

* Build fieldcatCALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'       EXPORTING           i_structure_name = 'SYST'       CHANGING           ct_fieldcat      = it_fcat[].   LOOP AT it_fcat INTO is_fcat WHERE NOT reptext_ddic IS initial.        MOVE-CORRESPONDING is_fcat TO is_fieldcat.        is_fieldcat-fieldname = is_fcat-fieldname.        is_fieldcat-ref_field = is_fcat-fieldname.        is_fieldcat-ref_table = is_fcat-ref_tabname.        APPEND is_fieldcat TO it_fieldcat.   ENDLOOP.

* Create a new TableCALL METHOD cl_alv_table_create=>create_dynamic_table       EXPORTING        it_fieldcatalog = it_fieldcat       IMPORTING        ep_table        = new_table.

* Create a new Line with the same structure of the table.ASSIGN new_table->* TO . CREATE DATA new_line LIKE LINE OF . ASSIGN new_line->* TO .

* Test it...   DO 30 TIMES.      ASSIGN COMPONENT 'SUBRC' OF STRUCTURE TO .       = sy-index.       INSERT INTO TABLE .    ENDDO.

   LOOP AT ASSIGNING .       ASSIGN COMPONENT 'SUBRC' OF STRUCTURE TO .       WRITE .    ENDLOOP. 

2、使用动态创建临时程序  generate subroutine pool code name prog                           message msg                           line    lin                           word    wrd                           offset  off.并调。

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1175996


最新回复(0)