Skip to Content
0
Former Member
Mar 23, 2007 at 08:41 PM

ALV footer problem

26 Views

hello experts

I have to print the footer under each and every page of the report, I designed with end_of_page event even though it is not working... I am getting those lines end of list after the completion of list in the next page

where I am going wrong can any one guide me....

here is my code..

TYPE-POOLS slis .

  • ---------------------------------------------------------------------*

  • TABLES STATEMENT

----


TABLES:ekko,

ekpo,

eket,

mara,

mard,

t001l,

makt.

----


  • *

  • SELECTION SCREEN *

----


SELECTION-SCREEN BEGIN OF BLOCK blc1 WITH FRAME TITLE text-b01.

SELECT-OPTIONS: p_lifnr FOR ekko-lifnr,

p_matnr FOR ekpo-matnr,

p_ebeln FOR ekko-ebeln,

p_ekgrp FOR ekko-ekgrp,

p_aedat FOR ekko-aedat,

p_eindt FOR eket-eindt,

p_ernam FOR ekko-ernam.

PARAMETERS: blind AS CHECKBOX.

SELECTION-SCREEN END OF BLOCK blc1.

----


  • *

  • INTERNAL TABLES DECLARATION *

----


TYPES: BEGIN OF t_ekko,

ebeln TYPE ekko-ebeln,

aedat TYPE ekko-aedat,

ekgrp TYPE ekko-ekgrp,

ekorg TYPE ekko-ekorg,

lifnr TYPE ekko-lifnr,

ebelp TYPE ekpo-ebelp,

MENGE TYPE ekpo-menge,

meins TYPE ekpo-meins,

matnr TYPE ekpo-matnr,

txz01 TYPE ekpo-txz01,

idnlf TYPE ekpo-idnlf,

WERKS TYPE MARD-WERKS,

  • lgort TYPE mard-lgort,

lgort TYPE t001l-lgort,

lgpbe TYPE mard-lgpbe,

lgobe TYPE t001l-lgobe,

MENGE1 TYPE ekes-menge,

  • wemng TYPE eket-wemng,

QUANTITY TYPE C,

comments type c,

  • line_color(4) type c,

END OF t_ekko.

TYPES: BEGIN OF t_ekko_itm,

ebeln TYPE ekko-ebeln,

ebelp TYPE ekpo-ebelp,

MENGE TYPE ekpo-menge,

meins TYPE ekpo-meins,

matnr TYPE ekpo-matnr,

txz01 TYPE ekpo-txz01,

idnlf TYPE ekpo-idnlf,

WERKS TYPE MARD-WERKS,

  • lgort TYPE mard-lgort,

lgort TYPE t001l-lgort,

lgpbe TYPE mard-lgpbe,

lgobe TYPE t001l-lgobe,

MENGE1 TYPE ekes-menge,

  • wemng TYPE eket-wemng,

QUANTITY TYPE C,

comments type c,

END OF t_ekko_itm.

DATA: it_ekko TYPE STANDARD TABLE OF t_ekko WITH HEADER LINE,

wa_ekko TYPE t_ekko.

DATA: IT_EKKO_HDR TYPE STANDARD TABLE OF t_ekko WITH HEADER LINE.

DATA: IT_EKKO_ITM TYPE STANDARD TABLE OF T_EKKO_ITM WITH HEADER LINE.

*ALV data declarations

DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,

gd_tab_group TYPE slis_t_sp_group_alv,

gd_layout TYPE slis_layout_alv,

gd_repid LIKE sy-repid.

gd_repid = sy-repid.

  • Data declaration for EVENT and PRINT PARAMETER.

DATA: gt_events TYPE slis_t_event,

gd_prntparams TYPE slis_print_alv.

  • data declaration for sorting.

DATA : it_sortcat TYPE slis_sortinfo_alv OCCURS 1,

wa_sort LIKE LINE OF it_sortcat.

DATA : i_list_comments TYPE slis_t_listheader.

*DATA int_fcat TYPE slis_t_fieldcat_alv.

DATA:ls_int_fcat TYPE slis_fieldcat_alv.

*data: rs_selfield type slis_selfield.

----


  • START-OF-SELECTION *

----


START-OF-SELECTION.

PERFORM data_retrieval.

PERFORM build_fieldcatalog.

  • PERFORM build_sortcat.

  • PERFORM top-of-page.

PERFORM build_events.

perform build_print_params.

  • PERFORM top-of-page.

perform end_of_page.

  • perform end_of_list.

  • perform print_parameters.

PERFORM display_alv_report.

----


  • END-OF-SELECTION *

----


END-OF-SELECTION.

*TOP-OF-PAGE.

  • PERFORM top-of-page.

*&----


*& Form build_fieldcatalog

*&----


FORM build_fieldcatalog.

fieldcatalog-fieldname = 'EBELN'.

fieldcatalog-seltext_m = 'PO NUMBER'.

fieldcatalog-col_pos = 0.

fieldcatalog-outputlen = 10.

fieldcatalog-emphasize = 'X'.

  • fieldcatalog-group = '*'.

fieldcatalog-ref_tabname = 'EKKO'.

fieldcatalog-ref_fieldname = 'EBELN'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'AEDAT'.

fieldcatalog-seltext_m = 'PO DATE'.

fieldcatalog-col_pos = 1.

fieldcatalog-ref_tabname = 'EKKO'.

fieldcatalog-ref_fieldname = 'AEDAT'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'EKGRP'.

fieldcatalog-seltext_m = 'PUR GRP/BUYER'.

fieldcatalog-col_pos = 2.

fieldcatalog-ref_tabname = 'EKKO'.

fieldcatalog-ref_fieldname = 'EKGRP'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'EKORG'.

fieldcatalog-seltext_m = 'PUR ORG.'.

fieldcatalog-col_pos = 3.

fieldcatalog-ref_tabname = 'EKKO'.

fieldcatalog-ref_fieldname = 'EKORG'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'LIFNR'.

fieldcatalog-seltext_m = 'VENDOR NO'.

fieldcatalog-col_pos = 4.

fieldcatalog-outputlen = 4.

fieldcatalog-ref_tabname = 'EKKO'.

fieldcatalog-ref_fieldname = 'LIFNR'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'EBELP'.

fieldcatalog-seltext_m = 'PO LINE'.

fieldcatalog-col_pos = 5.

fieldcatalog-outputlen = 4.

fieldcatalog-ref_tabname = 'EKPO'.

fieldcatalog-ref_fieldname = 'EBELP'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

IF blind = ' '. " if the check box is not checked.

fieldcatalog-fieldname = 'MENGE'.

fieldcatalog-seltext_m = 'ORD QTY'.

fieldcatalog-col_pos = 6.

fieldcatalog-ref_tabname = 'EKET'.

fieldcatalog-ref_fieldname = 'MENGE'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

ENDIF.

fieldcatalog-fieldname = 'MEINS'.

fieldcatalog-seltext_m = 'UNIT'.

fieldcatalog-col_pos = 7.

fieldcatalog-ref_tabname = 'EKPO'.

fieldcatalog-ref_fieldname = 'MEINS'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'MATNR'.

fieldcatalog-seltext_m = 'MATERIAL'.

fieldcatalog-col_pos = 8.

fieldcatalog-outputlen = 10.

fieldcatalog-ref_tabname = 'EKPO'.

fieldcatalog-ref_fieldname = 'MATNR'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'TXZ01'.

fieldcatalog-seltext_m = 'DESCRIPTION'.

fieldcatalog-col_pos = 9.

fieldcatalog-ref_tabname = 'EKPO'.

fieldcatalog-ref_fieldname = 'TXZ01'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'IDNLF'.

fieldcatalog-seltext_m = 'VEND MAT'.

fieldcatalog-col_pos = 10.

fieldcatalog-outputlen = 8.

fieldcatalog-ref_tabname = 'EKPO'.

fieldcatalog-ref_fieldname = 'IDNLF'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'WERKS'.

fieldcatalog-seltext_m = 'PLANT'.

fieldcatalog-col_pos = 11.

fieldcatalog-ref_tabname = 'MARD'.

fieldcatalog-ref_fieldname = 'WERKS'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'LGORT'.

fieldcatalog-seltext_m = 'STORAGE LOCATION'.

fieldcatalog-col_pos = 12.

fieldcatalog-ref_tabname = 't001l'.

fieldcatalog-ref_fieldname = 'LGORT'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'LGPBE'.

fieldcatalog-seltext_m = 'ST.LOC SHELF BIN'.

fieldcatalog-col_pos = 13.

  • fieldcatalog-outputlen = 6.

fieldcatalog-ref_tabname = 'MARD'.

fieldcatalog-ref_fieldname = 'LGPBE'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'LGOBE'.

fieldcatalog-seltext_m = 'ST.LOC DESCRIPTION'.

fieldcatalog-col_pos = 14.

fieldcatalog-ref_tabname = 'T001L'.

fieldcatalog-ref_fieldname = 'LGOBE'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

IF blind = ' '. " if the check box is not checked.

fieldcatalog-fieldname = 'MENGE1'.

fieldcatalog-seltext_m = 'QTY TO RECEIVE'.

fieldcatalog-col_pos = 15.

fieldcatalog-ref_tabname = 'EKES'.

fieldcatalog-ref_fieldname = 'MENGE'.

  • fieldcatalog-rollname = 'MENGE_D'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

ENDIF.

fieldcatalog-fieldname = 'QUANTITY'.

fieldcatalog-seltext_m = 'QTYR'.

fieldcatalog-col_pos = 16 .

fieldcatalog-decimals_out = 0.

fieldcatalog-no_zero = 'X'.

  • fieldcatalog-ref_tabname = 'EKET'.

  • fieldcatalog-ref_fieldname = 'WEMNG'.

fieldcatalog-outputlen = 4.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'COMMENTS'.

fieldcatalog-seltext_m = 'COMMENTS TO WRITE'.

fieldcatalog-col_pos = 17 .

fieldcatalog-decimals_out = 0.

fieldcatalog-no_zero = 'X'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

LOOP AT fieldcatalog INTO ls_int_fcat.

ls_int_fcat-col_pos = syst-tabix.

MODIFY fieldcatalog FROM ls_int_fcat INDEX syst-tabix.

ENDLOOP.

LOOP AT fieldcatalog INTO ls_int_fcat.

CHECK ls_int_fcat-fieldname EQ 'EBELN'

OR ls_int_fcat-fieldname EQ 'LIFNR'.

ls_int_fcat-hotspot = 'X'.

MODIFY fieldcatalog FROM ls_int_fcat TRANSPORTING hotspot.

ENDLOOP.

ENDFORM. " build_fieldcatalog

*&----


*& Form data_retrieval

*&----


FORM data_retrieval.

DATA: ld_color(1) TYPE c.

DATA: V_TABIX TYPE SYTABIX.

SELECT ebeln aedat ekgrp ekorg lifnr

INTO CORRESPONDING FIELDS OF TABLE IT_EKKO_HDR FROM ekko

WHERE lifnr IN p_lifnr

AND ebeln IN p_ebeln

AND ekgrp IN p_ekgrp

AND aedat IN p_aedat

AND ernam IN p_ernam.

SELECT ekpo~ebeln

ekpo~ebelp

ekpo~menge

ekpo~meins

ekpo~matnr

ekpo~txz01

ekpo~idnlf

MARD~WERKS

  • mard~lgort

t001l~lgort

mard~lgpbe

t001l~lgobe

ekes~menge

  • eket~wemng

INTO TABLE it_ekko_itm FROM ekpo

INNER JOIN eket ON ekpoebeln = eketebeln AND ekpoebelp = eketebelp

  • INNER JOIN t001l ON ekpowerks = t001lwerks

INNER JOIN mard ON ekpomatnr = mardmatnr AND ekpowerks = mardwerks

INNER JOIN t001l ON ekpowerks = t001lwerks

INNER JOIN ekes ON ekpoebeln = ekesebeln AND ekpoebelp = ekesebelp

FOR ALL entries IN it_ekko_hdr WHERE ekpo~ebeln = it_ekko_hdr-ebeln

AND ekpo~matnr IN p_matnr.

  • AND eket~eindt IN p_eindt.

*sort it_ekko_itm ascending by it_ekko_itm-ebeln it_ekko_itm-ebelp.

*DELETE ADJACENT DUPLICATES COMPARING it_ekko_itm-ebeln.

LOOP AT IT_EKKO_itm.

MOVE-CORRESPONDING IT_EKKO_ITM TO IT_EKKO.

READ TABLE IT_EKKO_HDR WITH KEY EBELN = IT_EKKO-EBELN.

IF SY-SUBRC = 0.

IT_EKKO-aedat = IT_EKKO_HDR-AEDAT.

IT_EKKO-ekgrp = IT_EKKO_HDR-EKGRP.

IT_EKKO-ekorg = IT_EKKO_HDR-EKORG.

IT_EKKO-lifnr = IT_EKKO_HDR-LIFNR.

ENDIF.

IF IT_EKKO-LGORT = '0003'.

CLEAR: IT_EKKO-ebelp, IT_EKKO-lifnr, IT_EKKO-menge, IT_EKKO-meins, IT_EKKO-matnr, IT_EKKO-txz01, IT_EKKO-idnlf, IT_EKKO-werks.

ENDIF.

APPEND IT_EKKO.

CLEAR: IT_EKKO.

ENDLOOP.

sort it_ekko ascending by ebeln ebelp.

loop at it_ekko.

DELETE it_ekko where lgort = 0002.

DELETE it_ekko where lgort = 0004.

delete adjacent duplicates from it_ekko comparing ebelp lgort.

*If it_ekko-lgort = '0003'.

**it_ekko_itm-lifnr = ''.

*move space to it_ekko-matnr.

*endif.

endloop.

*IF IT_EKKO-LGORT = '0003'.

*CLEAR: IT_EKKO-menge, IT_EKKO-meins, IT_EKKO-matnr, IT_EKKO-txz01, IT_EKKO-idnlf, IT_EKKO-werks.

*ENDIF.

*APPEND IT_EKKO.

*CLEAR IT_EKKO.

LOOP AT it_ekko INTO wa_ekko.

CLEAR wa_ekko-QUANTITY.

MODIFY it_ekko FROM wa_ekko INDEX sy-tabix.

  • ld_color = ld_color + 1.

  • if ld_color = 8.

  • ld_color = 1.

  • endif.

  • concatenate 'C' ld_color '10' into wa_ekko-line_color.

modify it_ekko from wa_ekko.

ENDLOOP.

ENDFORM. " data_retrieval

*&----


*& Form display_alv_report

*&----


FORM display_alv_report.

DATA:user_command TYPE slis_formname,

set_pf_status TYPE slis_formname.

set_pf_status = 'ZSTANDARD_FULLSCREEN'.

user_command = 'ALV_USER_COMMAND'.

DATA: gt_events TYPE slis_t_event.

DATA : ls_print TYPE slis_print_alv.

data: gd_layout type slis_layout_alv.

gd_layout-colwidth_optimize = ' '.

*ls_print-no_print_selinfos = 'X'.

*ls_print-no_print_listinfos = 'X'.

*CONSTANTS: lc_3 TYPE c VALUE '3'. "Value 3

*pr_print-no_print_listinfos = c_chk. "Display no listinfos

*pr_print-reserve_lines = lc_3. "Lines reserved for footer

*pr_print-no_coverpage = c_chk. "No coverpage

*data: gd_prntparams type slis_print_alv.

*gd_prntparams-NO_PRINT_SELINFOS = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = gd_repid

is_layout = gd_layout

i_callback_top_of_page = 'TOP-OF-PAGE'

is_print = ls_print

i_callback_user_command = 'USER_COMMAND'

*i_callback_top_of_page = 'TOP-OF-PAGE'

it_events = gt_events

it_fieldcat = fieldcatalog[]

it_sort = it_sortcat

i_save = 'A'

TABLES

t_outtab = it_ekko

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.

ENDFORM. " DISPLAY_ALV_REPORT

*&----


*& Form top-of-page

*&----


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 = 'STOCK PO RECEIVER REPORT'.

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.

  • IT_LIST_COMMENTARY = SD_HEADING.

  • i_logo = 'GANESH_LOGO'.

*

*DATA: listwidth TYPE i,

*ld_pagepos(10) TYPE c,

*ld_page(10) TYPE c.

*SKIP. WRITE:/40 'Page:', sy-pagno .

ENDFORM. " top-of-page

----


  • FORM user_command *

----


FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

  • case r_ucomm.

  • when '&IC1'.

IF rs_selfield-fieldname = 'EBELN'.

READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.

SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.

CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.

ENDIF.

  • when 'ULHAS'.

IF rs_selfield-fieldname = 'LIFNR'.

READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.

SET PARAMETER ID 'BES' FIELD wa_ekko-lifnr.

CALL TRANSACTION 'XK03' AND SKIP FIRST SCREEN.

ENDIF.

ENDFORM. "user_command

&----


*& Form build_events

&----


FORM build_events.

DATA: ls_event TYPE slis_alv_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = gt_events[].

IF sy-subrc <> 0.

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

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

ENDIF.

READ TABLE gt_events WITH KEY name = slis_ev_end_of_page

INTO ls_event.

IF sy-subrc = 0.

MOVE 'end_OF_PAGE' TO ls_event-form.

APPEND ls_event TO gt_events.

ENDIF.

READ TABLE gt_events WITH KEY name = slis_ev_end_of_list

INTO ls_event.

IF sy-subrc = 0.

MOVE 'USER_COMMAND' TO ls_event-form.

APPEND ls_event TO gt_events.

ENDIF.

IF sy-subrc = 0.

MOVE 'END_OF_LIST' TO ls_event-form.

APPEND ls_event TO gt_events.

ENDIF.

ENDFORM. " build_events

----


  • FORM END_OF_PAGE *

----


FORM end_of_page.

DATA: listwidth TYPE i,

ld_pagepos(10) TYPE c,

ld_page(10) TYPE c.

*WRITE: sy-uline(255).

*SKIP. WRITE:/40 'Page:', sy-pagno .

WRITE: /

'RECEIVED BY:...........................',

50 'DATA:......................',

90 'NO OF CARTOONS RECEIVED:.............'.

ENDFORM. "end_of_page

----


  • FORM END_OF_LIST *

----


FORM end_of_list.

DATA: listwidth TYPE i,

ld_pagepos(10) TYPE c,

ld_page(10) TYPE c.

*SKIP. WRITE:/40 'Page:', sy-pagno .

ENDFORM. "end_of_list

&----


*& Form build_sortcat

&----


FORM build_sortcat.

wa_sort-spos = 1.

wa_sort-fieldname = 'EBELN'.

wa_sort-group = '*'.

APPEND wa_sort TO it_sortcat.

wa_sort-spos = 2.

wa_sort-fieldname = 'EBELP'.

wa_sort-group = '*'.

APPEND wa_sort TO it_sortcat.

ENDFORM. " build_sortcat

form print_parameters.

endform.

&----


*& Form build_print_params

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form build_print_params.

gd_prntparams-reserve_lines = '3'. "Lines reserved for footer

gd_prntparams-no_coverpage = 'X'.

endform. " build_print_params

*&----


**& Form BUILD_LAYOUT

*&----


  • Build layout for ALV grid report

*----


*form build_layout.

  • gd_layout-no_input = 'X'.

  • gd_layout-colwidth_optimize = 'X'.

  • gd_layout-totals_text = 'Totals'(201).

  • Set layout field for row attributes(i.e. color)

  • gd_layout-info_fieldname = 'LINE_COLOR'.

    • gd_layout-totals_only = 'X'.

    • gd_layout-f2code = 'DISP'. "Sets fcode for when double

    • "click(press f2)

    • gd_layout-zebra = 'X'.

    • gd_layout-group_change_edit = 'X'.

    • gd_layout-header_text = 'helllllo'.

    *endform. " BUILD_LAYOUT

    SIRI