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: 

for mor than one header in alv report

Former Member
0 Kudos

I stuck in alv  report can any one help me to resolve my problem?

I want to display report on week basis.

if we input date as 1/4/2012 to 31/5/2013

how I maintain dynamically two column headers one for week and other for month in alv report.

like below.

JAN-2012
WEEK 1WEEK 2WEEK3WEEK 4WEEK 5

and so on...

1 ACCEPTED SOLUTION

Mohamed_Mukhtar
Active Contributor
0 Kudos

Hello Samiksha,

Poluate filed row_pos and col_pos in field catlogue table to achieve this .

wa_fieldcat-row_pos   = '1'.
  wa_fieldcat-col_pos   = '1'.
  wa_fieldcat-Seltext_L   = 'Jan-2012'.
  wa_fieldcat-outputlen = '10'.

  APPEND wa_fieldcat TO t_alv_fieldcat.

  CLEAR wa_fieldcat.

  CLEAR: wa_fieldcat.

  wa_fieldcat-row_pos   = '2'.
  wa_fieldcat-col_pos   = '1'.
  wa_fieldcat-Seltext_L   = 'Week1'. 

  APPEND wa_fieldcat TO t_alv_fieldcat.

  CLEAR: wa_fieldcat.

  wa_fieldcat-row_pos   = '2'.
  wa_fieldcat-col_pos   = '2'.
  wa_fieldcat-Seltext_L   = 'Week2'. 

  APPEND wa_fieldcat TO t_alv_fieldcat.

and so on

Thanks

5 REPLIES 5

Mohamed_Mukhtar
Active Contributor
0 Kudos

Hello Samiksha,

Poluate filed row_pos and col_pos in field catlogue table to achieve this .

wa_fieldcat-row_pos   = '1'.
  wa_fieldcat-col_pos   = '1'.
  wa_fieldcat-Seltext_L   = 'Jan-2012'.
  wa_fieldcat-outputlen = '10'.

  APPEND wa_fieldcat TO t_alv_fieldcat.

  CLEAR wa_fieldcat.

  CLEAR: wa_fieldcat.

  wa_fieldcat-row_pos   = '2'.
  wa_fieldcat-col_pos   = '1'.
  wa_fieldcat-Seltext_L   = 'Week1'. 

  APPEND wa_fieldcat TO t_alv_fieldcat.

  CLEAR: wa_fieldcat.

  wa_fieldcat-row_pos   = '2'.
  wa_fieldcat-col_pos   = '2'.
  wa_fieldcat-Seltext_L   = 'Week2'. 

  APPEND wa_fieldcat TO t_alv_fieldcat.

and so on

Thanks

0 Kudos

Hi,

In the REUSE_ALV_LIST_DISPLAY we have done this.

TYPE-POOLS: slis.

DATA: x_fieldcat TYPE slis_fieldcat_alv,

it_fieldcat TYPE slis_t_fieldcat_alv,

l_layout TYPE slis_layout_alv,

x_events TYPE slis_alv_event,

it_events TYPE slis_t_event.

DATA: BEGIN OF itab OCCURS 0,

vbeln LIKE vbak-vbeln,

posnr LIKE vbap-posnr,

male TYPE i,

female TYPE i,

plane(10),

actual(10),

plane1(10),

actual1(10),

END OF itab.

SELECT VBELN  posnr

from vbap

up to 20 rows

into table itab.

x_fieldcat-fieldname = 'PLANE'.

x_fieldcat-seltext_l = 'Planned cost'.

x_fieldcat-tabname = 'ITAB'.

x_fieldcat-col_pos = 1.

x_fieldcat-outputlen = 10 .

APPEND x_fieldcat TO it_fieldcat.

CLEAR x_fieldcat.

x_fieldcat-fieldname = 'ACTUAL'.

x_fieldcat-seltext_l = 'Actual cost '.

x_fieldcat-tabname = 'ITAB'.

x_fieldcat-col_pos = 1.

APPEND x_fieldcat TO it_fieldcat.

CLEAR x_fieldcat.

x_fieldcat-fieldname = 'MALE'.

x_fieldcat-seltext_l = 'MALE'.

x_fieldcat-tabname = 'ITAB'.

x_fieldcat-col_pos = 3.

APPEND x_fieldcat TO it_fieldcat.

CLEAR x_fieldcat.

x_fieldcat-fieldname = 'FEMALE'.

x_fieldcat-seltext_l = 'FEMALE'.

x_fieldcat-tabname = 'ITAB'.

x_fieldcat-col_pos = 3.

APPEND x_fieldcat TO it_fieldcat.

CLEAR x_fieldcat.

x_events-name = slis_ev_top_of_page.

x_events-form = 'TOP_OF_PAGE'.

APPEND x_events TO it_events.

CLEAR x_events .

l_layout-no_colhead = 'X'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

  EXPORTING

    i_callback_program = sy-repid

    is_layout          = l_layout

    it_fieldcat        = it_fieldcat

    it_events          = it_events

  TABLES

    t_outtab           = itab

  EXCEPTIONS

    program_error      = 1

    OTHERS             = 2.

*&--------------------------------------------------------------------*

*&      Form  TOP_OF_PAGE

*&--------------------------------------------------------------------*

*       text

*---------------------------------------------------------------------*

FORM top_of_page.

*-To display the headers for main list

  FORMAT COLOR COL_HEADING.

  WRITE: / sy-uline(143).

  WRITE: / sy-vline,

  (8) 'LAST YEAR' ,

       sy-vline,

  (10) ' ' ,

  sy-vline,

  (19) 'CURRENT YEAR'(020) CENTERED,

  sy-vline.

  WRITE: / sy-vline,

  (8) 'PLANE'(053) ,

  sy-vline,

  (8) 'ACTUAL'(054) ,

  sy-vline,

  (8) 'MALE'(056) ,

  sy-vline,

  (9) 'FEMALE'(057) ,

  sy-vline.

  FORMAT COLOR OFF.

ENDFORM.                    "TOP_OF_PAGE

Regards,

Srikanth

0 Kudos

that above method you told is ok. but i want these columns dynamically .

  so how I get dynamically?

I also want within first header more than one subcolumns.

for ex.  first header is for month and second header below month header contains 5 distinct columns for week and both are dynamically depends on input date.

pls tell me how I achieve this?

0 Kudos

Hi Samiksha,

Please find the psuedo logic. Hope it helps you.

Data : wa_begda type begda value '20140101',
        wa_endda type endda value '20140209',
        wa_week  type i .

CALL FUNCTION 'HR_99S_INTERVAL_BETWEEN_DATES'
   EXPORTING
    BEGDA           = wa_begda
     ENDDA           = wa_endda
*   TAB_MODE        = ' '
  IMPORTING
*   DAYS            =
    C_WEEKS         = wa_week.
*   C_MONTHS        =
*   C_YEARS         =
*   WEEKS           =
*   MONTHS          =
*   YEARS           =
*   D_MONTHS        =
*   MONTH_TAB       =


do wa_week times.
  
*fill your field catalogue table here.
*Increment week by 1 for every iteration and fill your field catalgue table accordignly.

enddo.

Thanks

former_member206650
Active Participant
0 Kudos

Hi samiksha,

use the FM HR_99S_INTERVAL_BETWEEN_DATES to get the number of weeks.then u will get the weeks between two dates.

then

it will return a value in l_value (C_WEEKS).

TYPE-POOLS: slis.

TYPE: BEGIN OF my_struct,

FIELD_1 TYPE ANY,

END OF my_struct.

DATA: it_fcat TYPE slis_t_fieldcat_alv,

      is_fcat LIKE LINE OF it_fcat.

DATA: it_fieldcat TYPE lvc_t_fcat,

      is_fieldcat LIKE LINE OF it_fieldcat.

DATA: new_table TYPE REF TO data.

DATA: new_line  TYPE REF TO data.

FIELD-SYMBOLS: <l_table> TYPE ANY TABLE,

               <l_line>  TYPE ANY,

               <l_field> TYPE ANY.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

       EXPORTING

           i_structure_name = 'my_struct'

       CHANGING

           ct_fieldcat      = it_fcat[].

   LOOP AT it_fcat INTO is_fcat WHERE NOT reptext_ddic IS initial.

        MOVE-CORRESPONDING is_fcat TO is_fieldcat.

        is_fieldcat-fieldname = is_fcat-fieldname.

        is_fieldcat-ref_field = is_fcat-fieldname.

        is_fieldcat-ref_table = is_fcat-ref_tabname.

        APPEND is_fieldcat TO it_fieldcat.

   ENDLOOP.

CALL METHOD cl_alv_table_create=>create_dynamic_table

       EXPORTING

        it_fieldcatalog = it_fieldcat

       IMPORTING

        ep_table        = new_table.

ASSIGN new_table->* TO <l_table>.

CREATE DATA new_line LIKE LINE OF <l_table>.

ASSIGN new_line->* TO <l_line>.

   DO l_values TIMES.

      ASSIGN COMPONENT 'field_1' OF STRUCTURE <l_line> TO <l_field>.

      <l_field> = sy-index.

      INSERT <l_line> INTO TABLE <l_table>.

   ENDDO.

   LOOP AT <l_table> ASSIGNING <l_line>.

      ASSIGN COMPONENT 'field_1' OF STRUCTURE <l_line> TO <l_field>.

      WRITE <l_field>.

   ENDLOOP.

hope it helps.