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

alv reports

Former Member
0 Likes
575

hi,

using function modules in alv reports how applay the top of page and end of page ?

hi,

using function modules in alv reports how applay the top of page and end of page ?

4 REPLIES 4
Read only

Former Member
0 Likes
554

Hi,

See the example bcalv_grid_01.

1) create a local class

2) Create the object

3) Add after the method

set_table_for_first_display

********

  • ->Create Object to receive events and link them to handler methods.

  • When the ALV Control raises the event for the specified instance

  • the corresponding method is automatically called.

*

  • § 4. Link used print events and event handler methods.

CREATE OBJECT EVENT_RECEIVER.

SET HANDLER EVENT_RECEIVER->HANDLE_TOP_OF_LIST FOR GRID1.

SET HANDLER EVENT_RECEIVER->HANDLE_TOP_OF_PAGE FOR GRID1.

SET HANDLER EVENT_RECEIVER->HANDLE_END_OF_LIST FOR GRID1.

SET HANDLER EVENT_RECEIVER->HANDLE_END_OF_PAGE FOR GRID1.

also see this......

You cannot use sy-pagno because Grid does not use those variables system. You have to catch the event of creation of page of the class. It is what demonstrates the example bcalv_grid_01. Decide where you want to put the number of page finds the event to connect, in this case it is at the end of the page, then makes a conter in this method which you make show the number of page. In bcalv_grid_01 the method ANDLE_END_OF_PAGE was called at end of page event is thus logical to tell to put a conter which will indicate the number of page, because it will be call each time a new page is called.

SO first create a local class

CLASS LCL_EVENT_RECEIVER DEFINITIOn.

PUBLIC SECTION.

HANDLE_END_OF_PAGE

FOR EVENT PRINT_END_OF_PAGE OF CL_GUI_ALV_GRID.

PRIVATE SECTION.

DATA: PAGENUM TYPE I.

ENDCLASS.

CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.

METHOD HANDLE_END_OF_PAGE.

DATA: TABLENAME(30) TYPE C.

ADD 1 TO PAGENUM.

WRITE: /,'Event: PRINT_END_OF_PAGE'(003),

'Number of pages so far: '(004), PAGENUM.

ENDMETHOD. "handle_end_of_page

Endclass.

Then in your report

Put some where

CREATE OBJECT EVENT_RECEIVER.

SET HANDLER EVENT_RECEIVER->HANDLE_END_OF_PAGE FOR GRID1.

Then it will display the number of page at each end-of page but dont forgette to reserve space for the end of page when you creat your grid.

GS_PRINT-RESERVELNS = 2.

CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING I_STRUCTURE_NAME = 'SFLIGHT'

IS_PRINT = GS_PRINT

IS_LAYOUT = GS_LAYOUT

CHANGING IT_OUTTAB = GT_SFLIGHT.

Regards,

Sankar

Read only

RaymondGiuseppi
Active Contributor
0 Likes
554

Look at a sample at the end of this thread : <a href="http://www.sapfans.com/forums/viewtopic.php?t=16629">Writing select-option values on top-of-page</a>

Regards

Read only

paruchuri_nagesh
Active Contributor
0 Likes
554

hi by using

TYPE POOL : SLIS

u can provide top of page & end of page events in alvs

reward for use ful points

regards

Nagesh.Paruchuri

Read only

Former Member
0 Likes
554

hi,

&----


*& Report ZPROGRAM

*&

&----


*&

*&

&----


REPORT ZPROGRAM.

  • table declaration.

tables : zemployee, zdepartment,zproject.

*type-pools declaration

type-pools : slis , icon.

  • type specification

types : begin of ty_emp,

empid type zempid,

empname type zempname,

empaddress type zempaddress,

city type zcity,

ponumber type zponumber,

detid type zdeptid,

salary type zsalary,

end of ty_emp.

types : begin of ty_dept,

detid type zdeptid,

deptname type zdeptname,

designation type zdesignation,

projectid type zprojectid,

end of ty_dept.

types : begin of ty_project,

projectid type zprojectid,

technology type ztechnology,

clientname type zclientname,

end of ty_project.

types : begin of ty_final,

empid type zempid,

empname type zempname,

empaddress type zempaddress,

city type zcity,

ponumber type zponumber,

detid type zdeptid,

deptname type zdeptname,

designation type zdesignation,

projectid type zprojectid,

technology type ztechnology,

clientname type zclientname,

salary type zsalary,

  • average type p decimals 2,

end of ty_final.

  • table type specification.

types : tt_emp type standard table of ty_emp,

tt_dept type standard table of ty_dept,

tt_project type standard table of ty_project,

tt_final type standard table of ty_final.

  • work area creation.

data : wa_emp type ty_emp,

wa_dept type ty_dept,

wa_project type ty_project,

wa_final type ty_final.

  • internal table declaration

data : itab_emp type tt_emp,

itab_dept type tt_dept,

itab_project type tt_project,

itab_final type tt_final.

  • layout declaration

data : gd_layout type slis_layout_alv.

  • assigning current program name.

data : gd_repid like sy-repid.

gd_repid = sy-repid.

  • fieldcatalog declaration.

data : d_fieldcat type slis_t_fieldcat_alv,

d_fieldcat_wa type slis_fieldcat_alv.

  • header declaration.

data : t_header type slis_t_listheader,

wa_header type slis_listheader,

linecount(10) type c,

line(10) type c.

  • selection-screen.

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

select-options : s_empid for zemployee-empid.

parameters : p_dname like zdepartment-deptname.

parameters : p_name like zemployee-empname matchcode object ZSEARCH_EMP.

selection-screen : begin of line.

parameters : p_rad1 radiobutton group r1.

selection-screen comment 3(10) text-002.

parameters : p_rad2 radiobutton group r1.

selection-screen comment 16(10) text-003.

selection-screen : end of line.

parameters : chk1 as checkbox.

selection-screen : end of block blk1.

  • end of selection screen.

  • start of selection.

select empid empname empaddress city salary ponumber detid from zemployee into corresponding fields of table itab_emp where empid in s_empid.

if not itab_emp is initial.

select detid deptname designation projectid from zdepartment into corresponding fields of table itab_dept for all entries in itab_emp where detid = itab_emp-detid .

if not itab_dept is initial.

select projectid technology clientname from zproject into corresponding fields of table itab_project for all entries in itab_dept where projectid = itab_dept-projectid.

endif.

endif.

*end of selection.

  • populating data into itab_final from itab_emp.

loop at itab_emp into wa_emp.

wa_final-empid = wa_emp-empid.

wa_final-empname = wa_emp-empname.

wa_final-empaddress = wa_emp-empaddress.

wa_final-ponumber = wa_emp-ponumber.

wa_final-city = wa_emp-city.

wa_final-salary = wa_emp-salary.

wa_final-detid = wa_emp-detid.

append wa_final to itab_final.

clear wa_final.

endloop.

*populating data into itab_final from itab_dept and itab_project

loop at itab_final into wa_final.

read table itab_dept into wa_dept with key detid = wa_final-detid.

if sy-subrc = 0.

wa_final-deptname = wa_dept-deptname.

wa_final-designation = wa_dept-designation.

wa_final-projectid = wa_dept-projectid.

modify itab_final from wa_final transporting deptname designation projectid .

endif.

read table itab_project into wa_project with key projectid = wa_final-projectid.

if sy-subrc = 0.

wa_final-technology = wa_project-technology.

wa_final-clientname = wa_project-clientname.

modify itab_final from wa_final transporting technology clientname.

endif.

endloop.

if p_rad1 = 'X' or chk1 = 'X'.

d_fieldcat_wa-fieldname = 'EMPID'.

d_fieldcat_wa-seltext_l = 'Employee Id'.

d_fieldcat_wa-emphasize = 'X'.

d_fieldcat_wa-col_pos = 1.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'EMPNAME'.

d_fieldcat_wa-seltext_l = 'Employee Name'.

d_fieldcat_wa-emphasize = 'C710'.

d_fieldcat_wa-col_pos = 2.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'EMPADDRESS'.

d_fieldcat_wa-seltext_l = 'Employee Address'.

d_fieldcat_wa-emphasize = 'C710'.

d_fieldcat_wa-col_pos = 3.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'CITY'.

d_fieldcat_wa-seltext_l = 'City'.

d_fieldcat_wa-emphasize = 'C710'.

d_fieldcat_wa-col_pos = 4.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'PONUMBER'.

d_fieldcat_wa-seltext_l = 'Postal Number'.

d_fieldcat_wa-emphasize = 'C710'.

d_fieldcat_wa-col_pos = 5.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'DETID'.

d_fieldcat_wa-seltext_l = 'Department Id'.

d_fieldcat_wa-emphasize = 'X'.

d_fieldcat_wa-col_pos = 6.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'DEPTNAME'.

d_fieldcat_wa-seltext_l = 'Department Name'.

d_fieldcat_wa-emphasize = 'C710'.

d_fieldcat_wa-col_pos = 7.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'DESIGNATION'.

d_fieldcat_wa-seltext_l = 'Designation'.

d_fieldcat_wa-emphasize = 'C710'.

d_fieldcat_wa-col_pos = 8.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'PROJECTID'.

d_fieldcat_wa-seltext_l = 'Project Id'.

d_fieldcat_wa-emphasize = 'X'.

d_fieldcat_wa-col_pos = 9.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'TECHNOLOGY'.

d_fieldcat_wa-seltext_l = 'technology'.

d_fieldcat_wa-emphasize = 'C710'.

d_fieldcat_wa-col_pos = 10.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'CLIENTNAME'.

d_fieldcat_wa-seltext_l = 'Client Name'.

d_fieldcat_wa-emphasize = 'C710'.

d_fieldcat_wa-col_pos = 11.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'SALARY'.

d_fieldcat_wa-seltext_l = 'Employee Salary'.

d_fieldcat_wa-do_sum = 'X'.

d_fieldcat_wa-emphasize = 'C710'.

d_fieldcat_wa-col_pos = 12.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

endif.

if p_rad2 = 'X' or chk1 = 'X'.

refresh itab_emp.

d_fieldcat_wa-fieldname = 'DETID'.

d_fieldcat_wa-seltext_l = 'Department Id'.

d_fieldcat_wa-emphasize = 'C710'.

d_fieldcat_wa-col_pos = 6.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'DEPTNAME'.

d_fieldcat_wa-seltext_l = 'Department Name'.

d_fieldcat_wa-emphasize = 'C710'.

d_fieldcat_wa-col_pos = 7.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'DESIGNATION'.

d_fieldcat_wa-seltext_l = 'Designation'.

d_fieldcat_wa-emphasize = 'C710'.

d_fieldcat_wa-col_pos = 8.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'PROJECTID'.

d_fieldcat_wa-seltext_l = 'Project Id'.

d_fieldcat_wa-emphasize = 'C710'.

d_fieldcat_wa-col_pos = 9.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'TECHNOLOGY'.

d_fieldcat_wa-seltext_l = 'technology'.

d_fieldcat_wa-emphasize = 'C710'.

d_fieldcat_wa-col_pos = 10.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'CLIENTNAME'.

d_fieldcat_wa-seltext_l = 'Client Name'.

d_fieldcat_wa-emphasize = 'C710'.

d_fieldcat_wa-col_pos = 11.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

endif.

  • Grid display function module

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_repid

I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'

  • I_CALLBACK_USER_COMMAND = ' '

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'EMPLOYEE DETAILS'

  • I_GRID_SETTINGS =

IS_LAYOUT = gd_layout

IT_FIELDCAT = d_fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab_final

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.

  • set pf_status for creating client specified icons.

form set_pf_status using rt_extab type slis_t_extab.

set pf-status 'NEWSTATUS'.

endform.

  • populating data into header using top_of_page

form top_of_page.

wa_header-typ = 'H'.

wa_header-info = 'ALV REPORT'.

append wa_header to t_header.

clear wa_header.

wa_header-typ = 'S'.

wa_header-key = 'Date :'.

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

sy-datum+4(2) '.'

sy-datum(4) into wa_header-info.

append wa_header to t_header.

clear wa_header.

wa_header-typ = 'S'.

wa_header-key = 'Time :'.

Concatenate sy-Uzeit(2) '.'

sy-datum+2(2) '.'

sy-datum+4(2) into wa_header-info.

append wa_header to t_header.

clear wa_header.

describe table itab_final lines line.

wa_header-typ = 'A'.

linecount = line.

Concatenate 'Total number of records :' linecount into wa_header-info separated by space.

append wa_header to t_header.

clear wa_header.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = t_header

I_LOGO ='VMCADMIN'

  • I_END_OF_LIST_GRID =

  • I_ALV_FORM =

.

endform.

*designing layout.

form gd_layout.

gd_layout-zebra = 'X'.

gd_layout-edit = 'X'.

gd_layout-no_hotspot = ''.

gd_layout-no_colhead = ''.

gd_layout-colwidth_optimize = 'X'.

endform.

Reward with points if helpful.