‎2008 Jun 28 10:49 AM
‎2008 Jun 28 10:57 AM
hi check this..
RTTS (Run Time Type Services)
Instead of building the fieldcatalog using the function module NAMETAB_GET and creating the dynamic table using cl_alv_table_create, you can use the following approach using the RTTS (Run Time Type Services):
DATA:
dref TYPE REF TO data,
gr_table TYPE REF TO cl_salv_table,
tab_name TYPE ddobjname VALUE 'SPFLI',
linetype TYPE REF TO cl_abap_structdescr,
tabletype TYPE REF TO cl_abap_tabledescr.
FIELD-SYMBOLS:
<newtab> TYPE STANDARD TABLE.
START-OF-SELECTION.
linetype ?= cl_abap_typedescr=>describe_by_name( tab_name ).
tabletype = cl_abap_tabledescr=>create(
p_line_type = linetype
p_table_kind = cl_abap_tabledescr=>tablekind_std ).
CREATE DATA dref TYPE HANDLE tabletype.
ASSIGN dref->* TO <newtab>.
SELECT * FROM spfli INTO TABLE <newtab>
UP TO 25 ROWS.
END-OF-SELECTION.
*... Create Instance
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = <newtab>.
CATCH cx_salv_msg.
ENDTRY.
*Display table
gr_table->display( ).
Here in the above code, you can also specify your own internal type (defined in your report) with fields of ABAP dictionary type like:
TYPES:
BEGIN OF my_own_type,
sample_field_1 TYPE spfli-carrid,
sample_field_2 TYPE spfli-connid,
END OF my_own_type.
linetype ?= cl_abap_typedescr=>describe_by_name( 'MY_OWN_TYPE' ).
The cl_salv_table=>factory method will automatically pickup the field descriptions from the ABAP Dictionary.
Of course, you can also define your headings using the other methods of the SALV classes.
More information about the RTTS can be found in the class documentations. These are really useful when you have to create dynamic tables using your own types defined in your report.
‎2008 Jun 28 10:57 AM
Abhijeet,
these are new design tool for ABAP.
just refer for more info:
Amit.
‎2008 Jun 28 10:57 AM
hi check this..
RTTS (Run Time Type Services)
Instead of building the fieldcatalog using the function module NAMETAB_GET and creating the dynamic table using cl_alv_table_create, you can use the following approach using the RTTS (Run Time Type Services):
DATA:
dref TYPE REF TO data,
gr_table TYPE REF TO cl_salv_table,
tab_name TYPE ddobjname VALUE 'SPFLI',
linetype TYPE REF TO cl_abap_structdescr,
tabletype TYPE REF TO cl_abap_tabledescr.
FIELD-SYMBOLS:
<newtab> TYPE STANDARD TABLE.
START-OF-SELECTION.
linetype ?= cl_abap_typedescr=>describe_by_name( tab_name ).
tabletype = cl_abap_tabledescr=>create(
p_line_type = linetype
p_table_kind = cl_abap_tabledescr=>tablekind_std ).
CREATE DATA dref TYPE HANDLE tabletype.
ASSIGN dref->* TO <newtab>.
SELECT * FROM spfli INTO TABLE <newtab>
UP TO 25 ROWS.
END-OF-SELECTION.
*... Create Instance
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = <newtab>.
CATCH cx_salv_msg.
ENDTRY.
*Display table
gr_table->display( ).
Here in the above code, you can also specify your own internal type (defined in your report) with fields of ABAP dictionary type like:
TYPES:
BEGIN OF my_own_type,
sample_field_1 TYPE spfli-carrid,
sample_field_2 TYPE spfli-connid,
END OF my_own_type.
linetype ?= cl_abap_typedescr=>describe_by_name( 'MY_OWN_TYPE' ).
The cl_salv_table=>factory method will automatically pickup the field descriptions from the ABAP Dictionary.
Of course, you can also define your headings using the other methods of the SALV classes.
More information about the RTTS can be found in the class documentations. These are really useful when you have to create dynamic tables using your own types defined in your report.