You are on page 1of 4

12/11/2017 ALV - ALV Utility Program

Custom Search Search

Home • Trainings • Quiz • Tips • Tutorials • Functional • Cert Q's • Interview Q's • Jobs • Testimonials • Advertise • Contact Us

SAP Virtual/Onsite ALV Utility Program


Trainings By Agnihotro Sinha, Dell Services

Document Categories: Introduction – The Idea

ABAPTM Developers would like build the various ALV interactive Event handlers of a Report with the minimum effort and would like to
Adobe Forms
devote more time on the data extraction and data display logic. At the same time Client would like to have all the Reports
ABAP-HR
maintain a consistence Event pattern like Top-of-page, End-of-Page pattern and invest more time in verifying data display in ALV.
ALE & IDocs
ALV
This document will help in implementing a global ALV Utility class which can be used by all Reports for displaying output in ALV
BAPI
BASIS
format.
BSP
Developers will be able to create ALV handlers just by calling a method of this ALV Utility global class and passing the name of
Business Objects
Business Workflow
the Report Program. Details of the Report will be automatically picked by the Utility class.
CRM NEW
LSMW
Moreover this Class has options for enhancements and hence can be customized as per the Project need.
SAP Script/Smart Forms
BI/BW
This Guide will demonstrate how to automate the creation of Top-Of-Page event of an ALV output.
eXchange Infrastructure (XI)
Enterprise Portals (EP)
eCATT
How to reach there?
Object Oriented Programming
SAP Query
Userexits/BADIs
We have developed a Utility Class ZCL_ALV_HEADER_UTILITY which can be used to implement Top-of-page section of any
WebDynpro for Java/ABAPTM ALV Report with minimum coding effort. This class has different methods which, if used in proper sequence, can build a Top-of-
Others page in any customized way.

Basic steps to implement the Top-of-page logic using this Utility class:
What's New? Create Object of this Class.

ABAP Test Cockpit HOT Pass the current Report name to this Object.
SAP ABAP Pragmas
Understanding SE32 (ABAP Display the Top-of-page by passing the desired Report header text to this Object.
Text Element Maintenance)
Creating an IDoc File on SAP
Application Server Prerequisite:
Understanding “Advance with
dialog” option of SAP Workflow
SAP Workflow Scenario: 1. Selection screen naming convention should be as per Project naming convention guideline. This will help in configuring
Maintenance Notification the Utility program for generic use.
Approval
Enhancements to a standard
class
For example:
Working with Floating Field in
Adobe Forms 1.1. Parameter: P_<NAME>
Inserting data from Internal
Table into the step “Send Mail” 1.2. Select-options: S_<NAME>
Display GL Account long text
using enhancement framework
2. All the Selection screen elements should have their correspondence Text created in the Text pool of the Report
Differences between
polymorphism in JAVA and program. This is crucial since the Utility class reads the Text pool of the report.
ABAP
Passing multiline parameters 3. Report program can use either ALV with OOPs approach or ALV with Function Module approach.
from an ABAP Class event to a
Workflow container
Concept of Re-evaluate agents Steps to use the class in an ALV OOPs Report
for active work items in SAP
Workflow
Dynamic creation of component
usage in ABAP WebDynpro
Adobe Forms: Display symbols
ALV using OOPs approach – CL_GUI_ALV_GRID
like copyright and others
Deactivate Hold functionality in
Purchase order (ME21N) 4. For events of ALV grid we always create a Local Class to handle the events. Design the Local class in the Program to handle
Quiz on OOABAP TOP-OF-PAGE. This Local Class should have a method to write code for TOP_OF_PAGE of Class CL_GUI_ALV_GRID.
Add fields in FBL5N using Here this method is LCL_EVENT_HANDLER.
BADIs
Tutorial on Wide casting
Defining a Range in Module CLASS lcl_event_handler DEFINITION FINAL.
Pool Program * Event receiver definitions for ALV actions
Copy fields from one
structure/table into another
PUBLIC SECTION. METHODS:
structure/table *Handle grid Top_Of_Page
Side Panel Usage in NWBC on_grid_top_of_page
FOR EVENT top_of_page OF cl_gui_alv_grid
IMPORTING
Contribute? e_dyndoc_id,

Sample Specs CLASS lcl_event_handler IMPLEMENTATION.

* Create the Text to be dispalyed at top of page of ALV Grid Output


What's Hot? METHOD on_grid_top_of_page.
* top-of-page event for grid Display
Web Dynpro for ABAP Tutorials

http://www.saptechnical.com/Tutorials/ALV/Utility/Index.htm 1/4
12/11/2017 ALV - ALV Utility Program
PERFORM f_event_top_of_page USING e_dyndoc_id.
Join the Mailing List ENDMETHOD. "On_top_of_page
Enter name and email address below:
Name: 5. The FORM will have an object of the Class CL_DD_DOCUMENT. This Object has to be designed to display the TOP-OF-
PAGE form. Here this object is E_DYNDOC_ID.
Email:

FORM f_event_top_of_page USING p_dyndoc_id TYPE REF TO cl_dd_document.


Subscribe Unsubscribe
GO ***********************************************************
* Begin of use of Utiltiy Class
***********************************************************

* Define Object for Utility Class


DATA: obj_sel_opt TYPE REF TO zcl_alv_header_utility.

* Create Object of Utility Class by passing the


* CL_DD_DOCUMENT object to it
CREATE OBJECT obj_sel_opt
EXPORTING
p_dyndoc_obj = p_dyndoc_id.
* Read the current Report Selection screen
CALL METHOD obj_sel_opt->read_selection_screen
EXPORTING
repid = sy-repid
.
* Add any special parameter of Selection Screen(if present)
CALL METHOD obj_sel_opt->add_special_param
EXPORTING
param_name = 'S_DATE'
param_type = 'D'
.
* Display the ALV Top of Page by passing the desired Titles
* of the Report
CALL METHOD obj_sel_opt->set_grid_top
EXPORTING
title1 = 'XXX XXXXXXXX XXX Report'
title2 = 'Test Report for Utility'
* title3 =
* title4 = .

***********************************************************
* End of use of Utiltiy Class
***********************************************************
* populating data to html control
PERFORM f_html_header USING p_dyndoc_id.

ENDFORM. " EVENT_TOP_OF_PAGE

In the above code:

5.1. The Object for the Utility Class is built using the Constructor method. This Constructor needs a reference object of Class
CL_DD_DOCUMENT, which will be used internally by the Class to build up the TOP_OF_PAGE.

The reference Object shown here is P_DYNDOC_ID. This Object has been created while creating the implementation
of the local class event.

* Define Object for Utility Class


DATA: obj_sel_opt TYPE REF TO zcl_alv_header_utility.

* Create Object of Utility Class by passing the


* CL_DD_DOCUMENT object to it
CREATE OBJECT obj_sel_opt
EXPORTING
p_dyndoc_obj = p_dyndoc_id.

5.2. After the Utility Class object is created, we have to use the READ_SELECTION_SCREEN method of this class to read
the Selection screen elements of our current program. This is done by simply passing the Report program name using
SY-REPID system variable.

* Read the current Report Selection screen


CALL METHOD obj_sel_opt->read_selection_screen
EXPORTING
repid = sy-repid
.

5.3. If there are any Parameters or Select Options in the Selection screen which has to have special formatting while display,
then the method ADD_SPECIAL_PARAM has to be used. In this method we have to pass the name of the special
parameter/select-option and also pass the type of this parameter.

Presently in this example, we wanted to display S_DATE select-option of the selection screen using External Date
formatting. Passing the details of the parameter to this class method, internally the class will be converting the Date
entry for this select-option to external user recognized format and will display it.

* Add any special parameter of Selection Screen(if present)


CALL METHOD obj_sel_opt->add_special_param
EXPORTING
param_name = 'S_DATE'
http://www.saptechnical.com/Tutorials/ALV/Utility/Index.htm 2/4
12/11/2017 ALV - ALV Utility Program
param_type = 'D'
.

5.4. Finally call the method SET_GRID_TOP to display the top of the page. In this method interface we can define a
maximum of 4 titles for the Report. These titles will be displayed in the top before the Selection parameters are listed.

* Display the ALV Top of Page by passing the desired Titles


* of the Report
CALL METHOD obj_sel_opt->set_grid_top
EXPORTING
title1 = 'XXX XXXXXXXX XXX Report'
title2 = 'Test Report for Utility'
* title3 =
* title4 =
.

Result:

Program:
ZUTILITY_TEST

http://www.saptechnical.com/Tutorials/ALV/Utility/Index.htm 3/4
12/11/2017 ALV - ALV Utility Program

Click here to continue...

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM


Home • Contribute • About Us • Privacy • Terms Of Use • Disclaimer • Safe • Companies: Advertise on SAPTechnical.COM | Post Job • Contact Us
©2006-2007 SAPTechnical.COM. All rights reserved.
All product names are trademarks of their respective companies. SAPTechnical.COM is in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver, and and any other SAP trademarks are registered trademarks of SAP AG in Germany and in several other countries.
Every effort is made to ensure content integrity. Use information on this site at your own risk.

Graphic Design by Round the Bend Wizards

http://www.saptechnical.com/Tutorials/ALV/Utility/Index.htm 4/4