Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

RTTS

Former Member
0 Kudos

What is RTTS and RTTI?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

2 REPLIES 2

former_member181995
Active Contributor
0 Kudos

Abhijeet,

these are new design tool for ABAP.

just refer for more info:

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/50456d27-0a01-0010-ed95-ba71d8f0...

Amit.

Former Member
0 Kudos

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.