Application Development and Automation 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: 
Read only

Dynamic Internal Table problem

Former Member
0 Likes
569

Hello all,

I have created a Dynamic ALV using RTTS classes like cl_abap_structdescr,cl_abap_tabledescr and cl_abap_datadescr.

The number of columns to be displayed is dynamic and i am able to display the same.

Now i need to perform SUBTOTAL on few of the columns.

In dynamic table how do i assign those columns as Type 'I' so that i can perform DO_SUM.

I used the method GET_I of class cl_abap_elemdescr but unable to achive the same.

Kindly suggest.

Regards,

Arun

4 REPLIES 4
Read only

Former Member
0 Likes
525

Hi,

Could you please let us know your definition part of source code on the GET_I ?

BTW, you also need to set the DO SUM attribute in the fieldcatalog.

Cheers,

Read only

Former Member
0 Likes
525

I know when I need to create a dynamic alv I use the following (plumbing code removed).

DATA: it_field_catalog      TYPE lvc_t_fcat.
DATA: dyn_table             TYPE REF TO data.
FIELD-SYMBOLS: <dyn_table>         TYPE table. 

create your alv as normal. Or auto create the entries based on the tables, whatever conditions you use to determine the structure of the table at run time.


  ls_fcat-fieldname   = '???'.
  ls_fcat-inttype     = '?' .
  ls_fcat-outputlen   = '?' .
  ls_fcat-coltext     = '?' .
  ls_fcat-seltext     = '?' .
  ls_fcat-f4availabl  = '?'.
  ls_fcat-edit        = '?'.
  ls_fcat-key         = '?'.
  APPEND ls_fcat TO it_field_catalog .

.....


    CALL METHOD cl_alv_table_create=>create_dynamic_table
       EXPORTING it_fieldcatalog = it_field_catalog
       IMPORTING ep_table        = dyn_table
       EXCEPTIONS
              generate_subpool_dir_full = 1.

   ASSIGN dyn_table->* TO <dyn_table>.

This field symbol to the table can then be passed in place of the table when calling your alv and performing operations on it.

Read only

0 Likes
525

You can use the below code, lt_components will have the details of type of each component in your dynamic structure.

lo_struc_descr ?= cl_abap_typedescr=>describe_by_data( <workarea> ).
 lt_components = lo_struc_descr->get_components( ).

Hope it helps.

Cheers,

Ravikiran

Read only

Former Member
0 Likes
525

Thx