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: 

dynamic Alv grid display

Former Member
0 Kudos

I need to display an alv report.

the number of rows are fixed. but the number of columns can vary.

Any suggestion on how to go for this.

year 1 year 2 year 3 .... year n.

A

B

C

D

E

I am trying to create the internal table dynamically using field symbols but i am finding difficulty in filling up the internal table with data.

Please help.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

better to change the layout columns as A B C D E F

and rows as years

y don't u think like this

bcz internal table can handle rows dynamically

2 REPLIES 2

Former Member
0 Kudos

better to change the layout columns as A B C D E F

and rows as years

y don't u think like this

bcz internal table can handle rows dynamically

former_member583013
Active Contributor
0 Kudos

It's not that easy...But surely it can be done -;)


DATA:  dataref TYPE REF TO data.

  FIELD-SYMBOLS: <l_line> TYPE ANY,
                 <l_field> TYPE ANY

  CREATE DATA dataref TYPE data.

  LOOP AT gt_bukrs_table ASSIGNING <fs_bukrs>.
    w_tabix_field = sy-tabix.
    wa_fcat-fieldname = <fs_bukrs>-bukrs.
    wa_fcat-inttype = 'I'.
    APPEND wa_fcat TO it_fieldcatalog.
    CONCATENATE 'TOT' w_tabix_field
    INTO w_tot_field.
    wa_fcat-fieldname = w_tot_field.
    wa_fcat-inttype = 'I'.
    APPEND wa_fcat TO it_fieldcatalog.
  ENDLOOP.

  CALL METHOD cl_alv_table_create=>create_dynamic_table
     EXPORTING
       it_fieldcatalog           = it_fieldcatalog
     IMPORTING
       ep_table                  = dataref
     EXCEPTIONS
       generate_subpool_dir_full = 1
       OTHERS                    = 2.

  ASSIGN dataref->* TO <row>.
  CREATE DATA new_line LIKE LINE OF <row>.
  ASSIGN new_line->* TO <l_line>.

Before that, you need to use...


      ASSIGN COMPONENT sy-tabix OF STRUCTURE <l_line> TO <l_field>.

And...


INSERT <l_line> INTO TABLE <row>.

Just use <ROW> in the ALV FM and you're done -;)

Greetings,

Blag.