点击此处---> 群内免费提供SAP练习系统(在群公告中)
加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)
PARAMETERS p_name TYPE rsrd1-tbma_val. DATA: lr_struc TYPE REF TO cl_abap_structdescr, lr_data TYPE REF TO cl_abap_datadescr, lr_table TYPE REF TO cl_abap_tabledescr, dyn_table TYPE REF TO data, dyn_wa TYPE REF TO data. DATA:l_tabname TYPE tabname. FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE, <dyn_wa> TYPE any. l_tabname = p_name. lr_struc ?= cl_abap_typedescr=>describe_by_name( l_tabname ). lr_table ?= cl_abap_tabledescr=>create( p_line_type = lr_struc ). CREATE DATA dyn_wa TYPE HANDLE lr_struc. CREATE DATA dyn_table TYPE HANDLE lr_table. ASSIGN dyn_wa->* TO <dyn_wa>. ASSIGN dyn_table->* TO <dyn_table>. SELECT * INTO CORRESPONDING FIELDS OF TABLE <dyn_table> UP TO 100 ROWS FROM (l_TABNAME). CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_structure_name = l_TABNAME TABLES t_outtab = <dyn_table> EXCEPTIONS program_error = 1 OTHERS = 2. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF.