Skip to Content
2
Jul 01, 2014 at 06:21 AM

I want to use RTTC but.....

68 Views

Hi,

Some time ago I wrote this program http://scn.sap.com/community/abap/blog/2013/12/26/sdbadbc--the-program

that utilize cl_sql_connection .

In this program I used cl_alv_table_create=>create_dynamic_table .

Now I want to move to RTTC.

I ran into a problem represented in "Y_R_EITAN_TEST_04_07" .

REPORT  Y_R_EITAN_TEST_04_07 .
*----------------------------------------------------------------------*
START-OF-SELECTION .
PERFORM at_start_of_selection .
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
FORM at_start_of_selection .
PERFORM test_08 .
ENDFORM . "at_start_of_selection
*----------------------------------------------------------------------*
FORM test_08 . * Hard coded structure .
* If I will use this table with CL_SALV_TABLE I will not get the standard headings
TYPES: BEGIN OF tp_sum_1 .
TYPES: carrid TYPE sbook-carrid ,
luggweight TYPE p DECIMALS 4 .
TYPES: END OF tp_sum_1 . data: it_sum_1 TYPE TABLE OF tp_sum_1 . SELECT carrid SUM( luggweight ) AS luggweight
INTO CORRESPONDING FIELDS OF TABLE it_sum_1
FROM sbook
GROUP BY
carrid . * it_sum_1 looks ok . BREAK-POINT . DATA: it_component TYPE cl_abap_structdescr=>component_table .
DATA: st_component LIKE LINE OF it_component . DATA: ob_abap_structdescr TYPE REF TO cl_abap_structdescr,
ob_abap_tabledescr TYPE REF TO cl_abap_tabledescr . st_component-name = 'CARRID'.
st_component-type ?= cl_abap_elemdescr=>describe_by_name( 'S_CARR_ID' ).
APPEND st_component TO it_component . st_component-name = 'LUGGWEIGHT'.
st_component-type ?= cl_abap_elemdescr=>describe_by_name( 'S_LUGWEIGH' ). * At this point I want to increase the size of LUGGWEIGHT so I can use it as
* a target to SQL sum function . * The equivalent of using :
* cl_alv_table_create=>create_dynamic_table
* lvc_t_fcat-intlen = 12 ."Hope that this is enough....
* lvc_t_fcat-inttype = 'P' . APPEND st_component TO it_component . DATA: r_data_tab TYPE REF TO data,
r_data_str TYPE REF TO data. TRY.
ob_abap_structdescr = cl_abap_structdescr=>create( it_component ).
CATCH cx_sy_struct_creation .
ENDTRY. TRY.
ob_abap_tabledescr = cl_abap_tabledescr=>create( ob_abap_structdescr ).
CATCH cx_sy_table_creation .
ENDTRY. CREATE DATA: r_data_tab TYPE HANDLE ob_abap_tabledescr ,
r_data_str TYPE HANDLE ob_abap_structdescr . FIELD-SYMBOLS: <it_data> TYPE INDEX TABLE,
<st_data> TYPE ANY. ASSIGN: r_data_tab->* TO <it_data> ,
r_data_str->* TO <st_data> . * I get a dump here...
SELECT carrid SUM( luggweight ) AS luggweight
INTO CORRESPONDING FIELDS OF TABLE <it_data>
FROM sbook
GROUP BY
carrid . BREAK-POINT . ENDFORM . "test_08

Attachments