Skip to end of metadata
Go to start of metadata

PARAMETERS: p_tab TYPE dd02l-tabname . " Input data table name

FIELD-SYMBOLS: <fsym_itab> TYPE ANY TABLE, " Field symbol for internal table
<fsym_field> TYPE ANY. " Field symbol for field value

DATA: ref_line_type TYPE REF TO cl_abap_structdescr, " Rowtype ref to RTTS
ref_tabletype TYPE REF TO cl_abap_tabledescr. " Internal table type ref to RTTS

DATA: ref_wa TYPE REF TO data, " Declaration of work area instance
ref_itab TYPE REF TO data, " Declaration of internal table instance
ref_out TYPE REF TO cl_salv_table. " Declaration of output table type.

DATA: ref_header TYPE REF TO cl_salv_form_layout_grid, " To display header
ref_label TYPE REF TO cl_salv_form_label," to write label
ref_tab TYPE string."text to be displayed in header




  • Create line type and tabletype by RTTC technique
    ref_line_type ?= cl_abap_typedescr=>describe_by_name( p_tab ).
    ref_tabletype = cl_abap_tabledescr=>create( p_line_type = ref_line_type ).
  • Object type created by RTTC.
    CREATE DATA ref_itab TYPE HANDLE ref_tabletype.
    CREATE DATA ref_wa TYPE HANDLE ref_line_type.

*Type assignment
ASSIGN ref_itab->* TO <fsym_itab>.

  • Value assignment to the internal table
    SELECT *
    FROM (p_tab)
    INTO TABLE <fsym_itab>.

*calling ALV for output.
CALL METHOD cl_salv_table=>factory
r_salv_table = ref_out
t_table = <fsym_itab>.
CATCH cx_salv_msg .

CREATE OBJECT ref_header.
CREATE OBJECT ref_label.
ref_label = ref_header->create_label( row = 1 column = 1 ).
CONCATENATE 'The data of table:' p_tab INTO ref_tab SEPARATED BY space.
ref_label->set_text( ref_tab ).
ref_out->set_top_of_list( ref_header ).
ref_out->set_top_of_list_print( ref_header ).
ref_out->display( ).

**clearing the field symbols
UNASSIGN : <fsym_itab>.
FREE ref_out.

1 Comment

  1. This program is used to pick up the data from the given table dynamically and display in ALV using SALV factory method