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: 

Multiple line header and dynamic ALV fieldcat

ssharma28
Participant
0 Kudos
462

Hi,

I have a requirement to develope a report like this.

first line      --->                10/07/2013  | 10/08/2013 | 10/09/2013  |

second line----> Payer | QA | QB | QC| QA| QB QC | QA QB QC |

Every date in first line should have 3 column in second line.

For dynamic column part I have created dynamic fieldcat and dynamic table using create_dynamic_table method.

To make it multiple header I have given row pos as 1 for first line and 2 for second line.

Issue -> Fieldcat is ok but the dynamic table which gets created from this method is not correct. the fieldcat has fields like this.

payer

07/10/2013

QA1

QB1

QC1

08/10/2013

QA2

QB2

QC2

which is fine.

But dynamic table has fields like

Payer

07/10/2013

QA1

08/10/2013

QB1

09/10/2013

QC1

which is wrong as for single date it should have QA1 QB1 and QC1.

how can I achieve this?

2) I am gettingerror that multiple lines can only be supported in print or print preview.

I am not sure if this error is for header because i created that giving row pos of fieldcat.

What went wrong here?

Thanks,

Seema

1 REPLY 1

custodio_deoliveira
Active Contributor
0 Kudos
108

Hi Seema,

Yes, multiple lines can only be supported in print or print preview, because it's not supported on ALV grid, only in ALV list.

I don't see any need for a dynamic table here, if the second line will always have 3 columns. Have a look at the code below:

REPORT (sy-repid).

TYPES: BEGIN OF mytype,

   dates TYPE datum,

   qa TYPE char10,

   qb TYPE char10,

   qc TYPE char10,

   END OF mytype.

DATA lt_mytable TYPE STANDARD TABLE OF mytype.

DATA ls_mytable LIKE LINE OF lt_mytable.

DATA lo_alv TYPE REF TO cl_salv_table.

START-OF-SELECTION.

   DO 3 TIMES.

     ls_mytable-dates = sy-datum + sy-index.

     ls_mytable-qa = 'A' && sy-index.

     ls_mytable-qb = 'B' && sy-index.

     ls_mytable-qc = 'C' && sy-index.

     APPEND ls_mytable TO lt_mytable.

   ENDDO.

   TRY.

       cl_salv_table=>factory(

       EXPORTING

         list_display = if_salv_c_bool_sap=>true

         IMPORTING

           r_salv_table   = lo_alv

         CHANGING

           t_table        = lt_mytable

              ).

     CATCH cx_salv_msg .

   ENDTRY.

   lo_alv->get_columns( )->get_column( 'QA' )->set_row( 2 ).

   lo_alv->get_columns( )->get_column( 'QB' )->set_row( 2 ).

   lo_alv->get_columns( )->get_column( 'QC' )->set_row( 2 ).

   lo_alv->display( ).

Cheers,

Custodio