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 table with multilevel column header

Former Member
0 Likes
724

Hi all ,

Can u please tell me how to create dynamic internal table and display which has two level column header using alv.

For example : | amount | year | Month |

in $

in #

oct

nov

Thanks in advance ,

SA

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
568

Try filling in row_pos in IT_FIELDCAT.

Rob

3 REPLIES 3
Read only

Former Member
0 Likes
568

Hi

To list in several lines you have to set the row number in catalog table.

To create a dynamic internal table u can use the method CREATE_DYNAMIC_TABLE of class CL_ALV_TABLE_CREATE.

DATA: gt_fieldcat  TYPE TABLE OF lvc_s_fcat.

DATA: MY_TABLE TYPE REF TO DATA.
FIELD-SYMBOLS: <MY_TABLE> TYPE TABLE.

* Here fill the catalog table with the fields of internal table

CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
  EXPORTING
    IT_FIELDCATALOG = GT_FIELDCAT
  IMPORTING
    EP_TABLE = MY_TABLE
  EXCEPTIONS
    GENERATE_SUBPOOL_DIR_FULL = 1
    OTHERS = 2.

ASSIGN MY_TABLE->* TO <MY_TABLE>.

Max

Read only

Former Member
0 Likes
569

Try filling in row_pos in IT_FIELDCAT.

Rob

Read only

messier31
Active Contributor
0 Likes
568

Hi SA,

For your first question - Creating dynamic table refer code below...

PARAMETERS: p_input TYPE i OBLIGATORY.

START-OF-SELECTION.

DATA: v_fieldname TYPE char30.

DATA: v_char TYPE numc4.

DATA: it_fldcat TYPE lvc_t_fcat.

DATA: wa_it_fldcat LIKE LINE OF it_fldcat.

DATA: gp_table TYPE REF TO data.

FIELD-SYMBOLS: <gt_table> TYPE table.

DO p_input TIMES.

v_fieldname = 'COL'.

v_char = sy-index.

CONCATENATE v_fieldname v_char INTO v_fieldname.

CONDENSE v_fieldname.

CLEAR wa_it_fldcat.

wa_it_fldcat-fieldname = v_fieldname.

wa_it_fldcat-datatype = 'CHAR'.

wa_it_fldcat-outputlen = 5.

wa_it_fldcat-intlen = 5.

APPEND wa_it_fldcat TO it_fldcat .

ENDDO.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING it_fieldcatalog = it_fldcat

IMPORTING ep_table = gp_table.

ASSIGN gp_table->* TO <gt_table>.

Now you can use <gt_table> ..

2. It is not possible to have multiple format column for ALV..

Hope this solves ur prob..

Enjoy SAP.

Pankaj Singh.