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

multiple headers in alv output

Former Member
0 Likes
4,850

i want multiple header lines as follows in my alv grid output of a report.

Month and year

mm/yyyy mm/yyyy mm/yyyy

<b>qty val qty val qty val</b>

I already have the part in bold above directly from the internal table. Please advise how to manage the 'Month & Year' in the first row and then the mon/yyyy in the second row.....these are for the qty and value fields only. Means qty and value are displayed for different month-year combinations for a specified date range.

thanks & regards,

Priyank

Message was edited by:

Priyank Jain

Message was edited by:

Priyank Jain

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,018

Note this piece of code there:

PERFORM COMMENT_BUILD USING GT_LIST_TOP_OF_PAGE[].

FORM COMMENT_BUILD USING LT_TOP_OF_PAGE TYPE

SLIS_T_LISTHEADER.

DATA: LS_LINE TYPE SLIS_LISTHEADER.

*

  • LIST HEADING LINE: TYPE H

CLEAR LS_LINE.

LS_LINE-TYP = 'H'.

  • LS_LINE-KEY: NOT USED FOR THIS TYPE

LS_LINE-INFO = TEXT-100.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

  • STATUS LINE: TYPE S

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = TEXT-101.

LS_LINE-INFO = TEXT-102.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

LS_LINE-KEY = TEXT-103.

LS_LINE-INFO = TEXT-104.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

  • ACTION LINE: TYPE A

CLEAR LS_LINE.

LS_LINE-TYP = 'A'.

  • LS_LINE-KEY: NOT USED FOR THIS TYPE

LS_LINE-INFO = TEXT-105.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

ENDFORM.

regards

navjot

reward if helpfull

Note this piece of code there:

PERFORM COMMENT_BUILD USING GT_LIST_TOP_OF_PAGE[].

FORM COMMENT_BUILD USING LT_TOP_OF_PAGE TYPE

SLIS_T_LISTHEADER.

DATA: LS_LINE TYPE SLIS_LISTHEADER.

*

  • LIST HEADING LINE: TYPE H

CLEAR LS_LINE.

LS_LINE-TYP = 'H'.

  • LS_LINE-KEY: NOT USED FOR THIS TYPE

LS_LINE-INFO = TEXT-100.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

  • STATUS LINE: TYPE S

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = TEXT-101.

LS_LINE-INFO = TEXT-102.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

LS_LINE-KEY = TEXT-103.

LS_LINE-INFO = TEXT-104.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

  • ACTION LINE: TYPE A

CLEAR LS_LINE.

LS_LINE-TYP = 'A'.

  • LS_LINE-KEY: NOT USED FOR THIS TYPE

LS_LINE-INFO = TEXT-105.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

ENDFORM.

regards

navjot

reward if helpfull

11 REPLIES 11
Read only

Former Member
0 Likes
3,019

Note this piece of code there:

PERFORM COMMENT_BUILD USING GT_LIST_TOP_OF_PAGE[].

FORM COMMENT_BUILD USING LT_TOP_OF_PAGE TYPE

SLIS_T_LISTHEADER.

DATA: LS_LINE TYPE SLIS_LISTHEADER.

*

  • LIST HEADING LINE: TYPE H

CLEAR LS_LINE.

LS_LINE-TYP = 'H'.

  • LS_LINE-KEY: NOT USED FOR THIS TYPE

LS_LINE-INFO = TEXT-100.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

  • STATUS LINE: TYPE S

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = TEXT-101.

LS_LINE-INFO = TEXT-102.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

LS_LINE-KEY = TEXT-103.

LS_LINE-INFO = TEXT-104.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

  • ACTION LINE: TYPE A

CLEAR LS_LINE.

LS_LINE-TYP = 'A'.

  • LS_LINE-KEY: NOT USED FOR THIS TYPE

LS_LINE-INFO = TEXT-105.

APPEND LS_LINE TO LT_TOP_OF_PAGE.

ENDFORM.

regards

navjot

reward if helpfull

Read only

Former Member
0 Likes
3,018

Check this thread::

Regards,

Ravi

Read only

Former Member
0 Likes
3,018

hi,

You can make use of event 'TOP_OF_PAGE' and write the headers by using write statements in case of ALV LIST.

It is not possible to have different headers in ALV by using Field catalog.

Regards

sailaja.

Read only

Former Member
0 Likes
3,018

Hi!

Check out this coding...


...
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
...
     i_callback_top_of_page            = 'TOP_OF_PAGE'
...

*-----------------------------------------------------------------------
*      Form top_of_page
*-----------------------------------------------------------------------
FORM top_of_page.   "ALV GRID 
  DATA: lv_fejlec(100) TYPE c,
        lv_statuszok(200) TYPE c.

  REFRESH gt_top_of_page.

* LIST HEADING LINE: TYPE H
*  CONCATENATE sy-repid ' --- ' sy-title INTO lv_fejlec.
  MOVE sy-title TO lv_fejlec.
  CLEAR gs_line.
  gs_line-typ  = 'H'.
  gs_line-info = lv_fejlec.
  APPEND gs_line TO gt_top_of_page.

* STATUS LINE: TYPE S
  CLEAR gs_line.
  gs_line-typ  = 'S'.
  gs_line-key  = text-501.
  MOVE sy-repid TO gs_line-info.
  APPEND gs_line TO gt_top_of_page.

  CLEAR gs_line.
  gs_line-typ  = 'S'.
  gs_line-key  = text-502.
  CONCATENATE
      s_fkdat-low(4) '.' s_fkdat-low+4(2) '.' s_fkdat-low+6(2) ' - '
      s_fkdat-high(4) '.' s_fkdat-high+4(2) '.' s_fkdat-high+6(2)
    INTO gs_line-info.
  APPEND gs_line TO gt_top_of_page.

  CLEAR gs_line.
  gs_line-typ  = 'S'.
  gs_line-key  = text-503.
  CONCATENATE sy-uname ','
              sy-datum(4) '.' sy-datum+4(2) '.' sy-datum+6(2) ' - '
              sy-uzeit(2) ':' sy-uzeit+2(2) ':' sy-uzeit+4(2)
         INTO gs_line-info.
  APPEND gs_line TO gt_top_of_page.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary       = gt_top_of_page
*     I_LOGO                   =
*     I_END_OF_LIST_GRID       =
          .

ENDFORM.                    "top_of_page

Regards

Tamá

Read only

Former Member
0 Likes
3,018

u can also try this

Use fM REUSE_ALV_COMMENTARY_WRITE to display multiple headers.

Check this thread to know how to make use of this function module.

regards

navjot

Read only

Former Member
0 Likes
3,018

Hello Priyank,

Please check this code:


*--- ALV List Display
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            I_CALLBACK_PROGRAM          = G_PROGNAME
            I_CALLBACK_HTML_TOP_OF_PAGE = 'TOP_OF_PAGE'     " Check here
            IT_FIELDCAT                 = G_T_FIELDCAT
            IT_EVENTS                   = IT_EVENTS
       TABLES
            T_OUTTAB                    = G_T_DETAIL
       EXCEPTIONS
            PROGRAM_ERROR               = 1
            OTHERS                      = 2.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

*&---------------------------------------------------------------------*
*&      Form  TOP-OF-PAGE
*&---------------------------------------------------------------------*
*        For Top of page
*----------------------------------------------------------------------*
FORM TOP_OF_PAGE USING CL_DD TYPE REF TO CL_DD_DOCUMENT.    "#EC *
  DATA: LT_TEXTS TYPE SDYDO_TEXT_TABLE.
  DATA: LV_NUMC(8) TYPE N.
  DATA: LV_COUNT(255).
* To write the Ist Block
  CALL METHOD CL_DD->ADD_TEXT
    EXPORTING
      TEXT         = TEXT-010
      SAP_STYLE    = CL_DD_DOCUMENT=>SMALL
      SAP_COLOR    = CL_DD_DOCUMENT=>LIST_HEADING_INT
      SAP_FONTSIZE = CL_DD_DOCUMENT=>SMALL
      SAP_EMPHASIS = CL_DD_DOCUMENT=>STRONG
      STYLE_CLASS  = SPACE.
  CALL METHOD CL_DD->UNDERLINE.
  CALL METHOD CL_DD->ADD_TEXT
    EXPORTING
      TEXT         = TEXT-013
      SAP_STYLE    = CL_DD_DOCUMENT=>SMALL
      SAP_COLOR    = CL_DD_DOCUMENT=>LIST_HEADING_INT
      SAP_FONTSIZE = CL_DD_DOCUMENT=>SMALL
      SAP_EMPHASIS = CL_DD_DOCUMENT=>STRONG
      STYLE_CLASS  = SPACE.
  CALL METHOD CL_DD->ADD_GAP
    EXPORTING
      WIDTH = 29.
  CALL METHOD CL_DD->ADD_TEXT
    EXPORTING
      TEXT         = TEXT-012
      SAP_STYLE    = CL_DD_DOCUMENT=>SMALL
      SAP_COLOR    = CL_DD_DOCUMENT=>LIST_HEADING_INT
      SAP_FONTSIZE = CL_DD_DOCUMENT=>SMALL
      SAP_EMPHASIS = CL_DD_DOCUMENT=>STRONG
      STYLE_CLASS  = SPACE.
  CALL METHOD CL_DD->UNDERLINE.

  LV_NUMC = G_F_COUNT_I1.
  LV_COUNT = LV_NUMC.
  CONDENSE LV_COUNT NO-GAPS.
  CALL METHOD CL_DD->ADD_TEXT
    EXPORTING
      TEXT         = LV_COUNT
      SAP_STYLE    = CL_DD_DOCUMENT=>SMALL
      SAP_COLOR    = CL_DD_DOCUMENT=>LIST_HEADING_INT
      SAP_FONTSIZE = CL_DD_DOCUMENT=>SMALL
      SAP_EMPHASIS = CL_DD_DOCUMENT=>STRONG
      STYLE_CLASS  = SPACE.

  CALL METHOD CL_DD->ADD_GAP
    EXPORTING
      WIDTH = 26.
  CALL METHOD CL_DD->ADD_TEXT
    EXPORTING
      TEXT         = '1'
      SAP_STYLE    = CL_DD_DOCUMENT=>SMALL
      SAP_COLOR    = CL_DD_DOCUMENT=>LIST_HEADING_INT
      SAP_FONTSIZE = CL_DD_DOCUMENT=>SMALL
      SAP_EMPHASIS = CL_DD_DOCUMENT=>STRONG
      STYLE_CLASS  = SPACE.
  CALL METHOD CL_DD->NEW_LINE
    EXPORTING
      REPEAT = 0.
  LV_NUMC = G_F_COUNT_I2.
  LV_COUNT = LV_NUMC.
  CONDENSE LV_COUNT NO-GAPS.
  CALL METHOD CL_DD->ADD_TEXT
    EXPORTING
      TEXT         = LV_COUNT
      SAP_STYLE    = CL_DD_DOCUMENT=>SMALL
      SAP_COLOR    = CL_DD_DOCUMENT=>LIST_HEADING_INT
      SAP_FONTSIZE = CL_DD_DOCUMENT=>SMALL
      SAP_EMPHASIS = CL_DD_DOCUMENT=>STRONG
      STYLE_CLASS  = SPACE.
ENDFORM

Hope this helps you...

REgards,

Vasanth

Read only

Former Member
0 Likes
3,018

Hi..

See the following links.....

Regards,

Suresh.......

Read only

0 Likes
3,018

let me just clarify a bit more...

the headers i m talking about are actually not alv headers....they are column headers in a sense.

there are multiple qty and value columns...each qty-value column pair is for a particular month-year combination. So i want the respective month-year combination to be displayed above each qty-value pair. and over all of these month-year columns, i want to display the text "Month & Year".

also note that before the qty-value pairs start, there are a few other columns in the grid as well . so these texts should not look like covering those fields too.

i hope that was not confusing...

regards,

Priyank

Read only

0 Likes
3,018

It is not possible to have multiple headers in ALV

Read only

Former Member
0 Likes
3,018

Priyak,

with small adjustments you can get .See the prog.

REPORT ZTEST11 .

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,

end of itab.

select vbeln

posnr

from vbap

up to 20 rows

into table itab.

x_fieldcat-fieldname = 'VBELN'.

x_fieldcat-seltext_l = 'VBELN'.

x_fieldcat-tabname = 'ITAB'.

x_fieldcat-col_pos = 1.

append x_fieldcat to it_fieldcat.

clear x_fieldcat.

x_fieldcat-fieldname = 'POSNR'.

x_fieldcat-seltext_l = 'POSNR'.

x_fieldcat-tabname = 'ITAB'.

x_fieldcat-col_pos = 2.

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'.

data : v_prog like sy-repid.

v_prog = sy-repid.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

i_callback_program = v_prog

is_layout = l_layout

it_fieldcat = it_fieldcat

it_events = it_events

tables

t_outtab = itab

exceptions

program_error = 1

others = 2.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

form top_of_page.

*-To display the headers for main list

format color col_heading.

write: / sy-uline(103).

write: / sy-vline,

(8) ' ' ,

sy-vline,

(8) ' ' ,

sy-vline,

(19) 'SEX'(015) centered,

sy-vline.

write: / sy-vline,

(8) 'VBELN'(013) ,

sy-vline,

(8) 'POSNR'(014) ,

sy-vline,

(8) 'MALE'(016) ,

sy-vline,

(8) 'FMALE'(017) ,

sy-vline.

format color off.

endform.

Don't forget to reward if useful..

Read only

Former Member
0 Likes
3,018

Hi,

Try this,

DATA: L_LISTHEADER TYPE SLIS_LISTHEADER.

REFRESH P_I_LISTHEADER.

CLEAR L_LISTHEADER.

L_LISTHEADER-TYP = 'H'.

L_LISTHEADER-INFO = TEXT-001.

APPEND L_LISTHEADER TO P_I_LISTHEADER.

CLEAR L_LISTHEADER.

L_LISTHEADER-TYP = 'H'.

L_LISTHEADER-INFO = TEXT-002.

APPEND L_LISTHEADER TO P_I_LISTHEADER.

so on for multiple headers,

Thanks,