Skip to Content
author's profile photo Former Member
Former Member

ALV-Grid Layout-top_of_page

Hi all i wants to know about Header printing in the ALV-Grid report,my problem is i wants to print the some heading in the center position of the Grid-report,so anybody have any idea?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Aug 19, 2005 at 09:28 AM

    Hi,

    Check the following.You will get an idea.

    http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_rephead.htm

    http://www.sapdevelopment.co.uk/reporting/alv/alvlist_code.htm

    If it is useful,kindly reward points by cliking the star on the left of reply.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 19, 2005 at 09:29 AM

    Please use the following code.

    call function 'REUSE_ALV_GRID_DISPLAY'

    exporting

    i_callback_program = gd_repid

    i_callback_top_of_page = 'TOP-OF-PAGE' <- Check the form top-of-page

    is_layout = gd_layout

    it_fieldcat = fieldcatalog[]

    i_save = 'X'

    tables

    t_outtab = i_data

    exceptions

    program_error = 1

    others = 2.

    Form top-of-page.

    *ALV Header declarations

    data: t_header type slis_t_listheader,

    wa_header type slis_listheader,

    t_line like wa_header-info,

    ld_lines type i,

    ld_linesc(10) type c.

    • Title

    wa_header-typ = 'H'.

    wa_header-info = 'Header'.

    append wa_header to t_header.

    clear wa_header.

    • Date

    wa_header-typ = 'S'.

    wa_header-key = 'Date'.

    CONCATENATE sy-datum+6(2) '.'

    sy-datum+4(2) '.'

    sy-datum(4) INTO wa_header-info. "todays date

    append wa_header to t_header.

    clear: wa_header.

    call function 'REUSE_ALV_COMMENTARY_WRITE'

    exporting

    it_list_commentary = t_header.

    endform.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 19, 2005 at 09:39 AM

    Hi,

    Here is a sample code.

    tables: wyt3,

    lfa1.

    ----


    • ALV DATA DECLARATION *******

    ***----


    ****

    type-pools: slis.

    data: i_layout type slis_layout_alv, " ALV LAYOUT

    i_fieldcat type slis_t_fieldcat_alv, "ALV FIELD CATALOG WITH TABLE

    wa_fieldcat type slis_fieldcat_alv, "ALV FIELD CATALOG IN WORK AREA

    i_events type slis_t_event, "ALV EVENT WITH TABLE

    wa_events like line of i_events,"ALV EVENT IN WORK AREA

    i_header type slis_t_listheader,"ALV HEADER WITH TABLE

    wa_header type slis_listheader. "ALV HEADER IN WORK AREA

    ----


    • VARIABLE DATA DECLARATION *******

    ***----


    ****

    data: ws_program like sy-repid,

    ws_date like sy-datum,

    ws_time like sy-uzeit,

    ws_user like sy-uname.

    data: ws_line1 type i,

    ws_line2 type i.

    ----


    • INTERNAL TABLE DECLARATION *******

    ***----


    ****

    data: begin of i_lfa1,

    lifnr like lfa1-lifnr,

    name1 like lfa1-name1,

    end of i_lfa1.

    ----


    • OUTPUT TABLE DECLARATION *******

    ***----


    ****

    data: begin of final_itab occurs 0,

    lifnr like wyt3-lifnr,

    lifnrnam like lfa1-name1,

    werks like wyt3-werks,

    parvw like wyt3-parvw,

    ernam like wyt3-ernam,

    erdat like wyt3-erdat,

    lifn2 like wyt3-lifn2,

    lifn2nam like lfa1-name1,

    ekorg like wyt3-ekorg,

    ltsnr like wyt3-ltsnr,

    linecolor(4) type c,

    end of final_itab.

    data: t_i_lfa1 like table of i_lfa1 with header line.

    ----


    • WORK AREA DECLARATION *******

    ***----


    ****

    data: wa_final like table of final_itab with header line,

    wa_i_lfa1 like line of t_i_lfa1.

    ----


    • SELECTION SCREEN *******

    ***----


    ****

    selection-screen begin of block b1 with frame title text-001.

    select-options: s_lifnr for wyt3-lifnr.

    select-options: s_werks for wyt3-werks.

    select-options: s_parvw for wyt3-parvw.

    select-options: s_ernam for wyt3-ernam.

    select-options: s_erdat for wyt3-erdat.

    select-options: s_lifn2 for wyt3-lifn2.

    select-options: s_ekorg for wyt3-ekorg.

    select-options: s_ltsnr for wyt3-ltsnr.

    selection-screen end of block b1.

    *****----


    ***************

    • INITIALIZATION **************

    ***----


    **

    ws_program = sy-repid.

    ws_date = sy-datum.

    ws_time = sy-uzeit.

    ws_user = sy-uname.

    *t1 = 'VENDOR SELECTION'.

    *----


    *

    • LAYOUT DECLARATION ****

    ***----


    i_layout-zebra = 'X'.

    i_layout-detail_titlebar = 'DETAILS OF EACH RECORD'.

    start-of-selection.

    select lifnr

    werks

    parvw

    ernam

    erdat

    lifn2

    ekorg

    ltsnr

    from wyt3

    into corresponding fields of table final_itab

    where lifnr in s_lifnr

    and werks in s_werks

    and parvw in s_parvw

    and ernam in s_ernam

    and erdat in s_erdat

    and lifn2 in s_lifn2

    and ekorg in s_ekorg

    and ltsnr in s_ltsnr.

    describe table final_itab lines ws_line1.

    if ws_line1 = 0.

    message i001.

    else.

    message i002 with ws_line1.

    endif.

    select lifnr

    name1

    from lfa1

    into corresponding fields of table t_i_lfa1

    for all entries in final_itab

    where lifnr = final_itab-lifnr.

    describe table final_itab lines ws_line2.

    if ws_line2 = 0.

    message i001.

    endif.

    sort t_i_lfa1 by lifnr.

    loop at t_i_lfa1 into wa_i_lfa1.

    loop at final_itab.

    if wa_i_lfa1-lifnr = final_itab-lifnr.

    move wa_i_lfa1-name1 to final_itab-lifnrnam.

    endif.

    if wa_i_lfa1-lifnr = final_itab-lifn2.

    move wa_i_lfa1-name1 to final_itab-lifn2nam.

    endif.

    modify final_itab.

    endloop.

    endloop.

    **----


    ***

    • CALLING THE FUNCTION FOR FIELD CATALOG *****

    ***----


    *

    call function 'REUSE_ALV_FIELDCATALOG_MERGE'

    exporting

    i_program_name = ws_program

    i_internal_tabname = 'FINAL_ITAB'

    • I_STRUCTURE_NAME =

    • I_CLIENT_NEVER_DISPLAY = 'X'

    i_inclname = ws_program

    • I_BYPASSING_BUFFER =

    • I_BUFFER_ACTIVE =

    changing

    ct_fieldcat = i_fieldcat

    • EXCEPTIONS

    • INCONSISTENT_INTERFACE = 1

    • PROGRAM_ERROR = 2

    • OTHERS = 3

    .

    if sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSiY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    endif.

    **----


    ***

    • CALLING THE FUNCTION FOR EVENTS *****

    ***----


    *

    call function 'REUSE_ALV_EVENTS_GET'

    exporting

    i_list_type = 0

    importing

    et_events = i_events

    exceptions

    list_type_wrong = 1

    others = 2.

    if sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSiY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    endif.

    read table i_events

    with key name = slis_ev_top_of_page

    into wa_events.

    if sy-subrc = 0.

    move 'TOP_OF_PAGE' to wa_events-form.

    modify i_events from wa_events index sy-tabix.

    endif.

    ***----


    ***

    • FIELDCATALOG CHANGING

    ****

    **----


    **

    loop at i_fieldcat into wa_fieldcat.

    case wa_fieldcat-fieldname.

    when 'LIFNR'.

    wa_fieldcat-key = 'X'.

    wa_fieldcat-tabname = final_itab.

    wa_fieldcat-seltext_l = 'VENDOR NUMBER'.

    wa_fieldcat-ddictxt = 'L'.

    wa_fieldcat-outputlen = 19.

    wa_fieldcat-fix_column = 'X'.

    • wa_fieldcat-emphasize = 'C710'.

    when 'LIFNRNAM'.

    wa_fieldcat-key = space.

    wa_fieldcat-tabname = final_itab.

    wa_fieldcat-seltext_l = 'NAME1'.

    wa_fieldcat-ddictxt = 'L'.

    wa_fieldcat-edit = 'X'.

    wa_fieldcat-outputlen = 10.

    • wa_fieldcat-emphasize = 'C710'.

    when 'WERKS'.

    wa_fieldcat-key = space.

    wa_fieldcat-tabname = final_itab.

    wa_fieldcat-seltext_l = 'PLANT'.

    wa_fieldcat-ddictxt = 'L'.

    wa_fieldcat-outputlen = 18.

    • wa_fieldcat-emphasize = 'C510'.

    when 'PARVW'.

    wa_fieldcat-key = space.

    wa_fieldcat-tabname = final_itab.

    wa_fieldcat-seltext_l = 'PARTNER FUNCTION'.

    wa_fieldcat-ddictxt = 'L'.

    wa_fieldcat-outputlen = 18.

    • wa_fieldcat-emphasize = 'C610'.

    when 'ERNAM'.

    wa_fieldcat-key = space.

    wa_fieldcat-tabname = final_itab.

    wa_fieldcat-seltext_l = 'CREATOR'.

    wa_fieldcat-ddictxt = 'L'.

    wa_fieldcat-outputlen = 30.

    • wa_fieldcat-emphasize = 'C810'.

    when 'ERDAT'.

    wa_fieldcat-key = space.

    wa_fieldcat-tabname = final_itab.

    wa_fieldcat-hotspot = 'X'.

    wa_fieldcat-do_sum = 'X'.

    wa_fieldcat-seltext_l = 'CREATION DATE'.

    wa_fieldcat-ddictxt = 'L'.

    wa_fieldcat-outputlen = 14.

    • wa_fieldcat-emphasize = 'C210'.

    when 'LIFN2'.

    wa_fieldcat-key = space.

    wa_fieldcat-tabname = final_itab.

    wa_fieldcat-seltext_l = 'REF.OTHERS'.

    wa_fieldcat-ddictxt = 'L'.

    wa_fieldcat-outputlen = 15.

    • wa_fieldcat-emphasize = 'C410'.

    when 'LIFN2NAM'.

    wa_fieldcat-key = space.

    wa_fieldcat-tabname = final_itab.

    wa_fieldcat-seltext_l = 'NAME1'.

    wa_fieldcat-ddictxt = 'L'.

    wa_fieldcat-outputlen = 18.

    • wa_fieldcat-emphasize = 'C110'.

    • wa_fieldcat-icon = 'X'.

    when 'EKORG'.

    wa_fieldcat-key = space.

    wa_fieldcat-tabname = final_itab.

    wa_fieldcat-seltext_l = 'PURCHASING ORDER'.

    wa_fieldcat-ddictxt = 'L'.

    wa_fieldcat-outputlen = 14.

    • wa_fieldcat-emphasize = 'C310'.

    when 'LTSNR'.

    wa_fieldcat-key = space.

    wa_fieldcat-tabname = final_itab.

    wa_fieldcat-seltext_l = 'VENDOR SUB-RANGE'.

    wa_fieldcat-ddictxt = 'L'.

    wa_fieldcat-outputlen = 14.

    • wa_fieldcat-emphasize = 'C310'.

    endcase.

    modify i_fieldcat from wa_fieldcat.

    clear wa_fieldcat.

    endloop.

    ***----


    ***

    • FINAL DISPLAY ****

    **----


    **

    call function 'REUSE_ALV_LIST_DISPLAY'

    exporting

    i_callback_program = ws_program

    is_layout = i_layout

    it_fieldcat = i_fieldcat

    it_excluding = i_exclude

    it_sort = i_sort

    i_save = 'A'

    • IS_VARIANT =

    it_events = i_events

    tables

    t_outtab = final_itab.

    ----


    • FORM TOP_OF_PAGE *

    ----


    • ........ *

    ----


    form top_of_page.

    clear wa_header.

    wa_header-typ = 'H'.

    wa_header-info = 'VENDOR REPORT - ALL PARTNERS'.

    append wa_header to i_header.

    clear wa_header.

    wa_header-typ = 'S'.

    wa_header-key = 'List Of Items'.

    wa_header-info = sy-title.

    append wa_header to i_header.

    clear wa_header.

    wa_header-typ = 'S'.

    wa_header-key = 'Date'.

    write ws_date mm/dd/yyyy to wa_header-info.

    append wa_header to i_header.

    clear wa_header.

    wa_header-typ = 'S'.

    wa_header-key = 'Time'.

    wa_header-info = ws_time.

    append wa_header to i_header.

    clear wa_header.

    wa_header-typ = 'S'.

    wa_header-key = 'User'.

    wa_header-info = ws_user.

    append wa_header to i_header.

    call function 'REUSE_ALV_COMMENTARY_WRITE'

    exporting

    it_list_commentary = i_header

    i_logo = 'WEYER-LOGO'

    • I_END_OF_LIST_GRID =

    .

    endform.

    Hope this helps you.

    Thanks&Regards,

    Ruthra.R

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.