Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
Showing results for 
Search instead for 
Did you mean: 


Former Member
0 Kudos

hi all..

ur answers are very helpful and can u say when we go for alv function modules and and alv classes and methods..


Former Member
0 Kudos

that entirely depends on what your specs are...........and what ur functional person is looking for

Former Member
0 Kudos

Hi Ashu,

If your requirement is to display some

field in ALV grid means, u can go for

ALV Function modules.

But, if they ask to do edit some thing

in the displayed output means, u can

use class and method concept.

( This type of ALV is called Editable ALV,

Through which we can edit the

records in the output and we can save

it in the database table. )

I hope u got it.

Reward for all useful answers.

0 Kudos

Hi Ashu,

Simple ALV function modules are used when you want to display some data

ALV classes and objects are used when you want the ALV reports to be interactive.

How to use controls



Set up event handling for controls

Declare a reference variable before the class has been defined

Set focus to a control


Control Framework and enheritance hierarchy

The control framework consists of 2 parts:

CL_GUI_CFW contains methods that provide services for communication with the frontend, and can be used both by control wrapper calsses and by control progtrammers

The CL_GUI_OBJECT encapsulates ActiveX or JavaBeans methods, while CL_GUI_CONTROL is responsible for displaying the control on the screen.

CL_GUI_OBJECT -> CL_GUI_CONTROL -> CL_GUI_* (Wrapper class)

These classes contains methods that are enherited by subsequent classes in the enheritance tree.


RFC calls is used to synchronize the front and backend. This synchronization takes palce at some predifined points in the program flow. However you should not rely entirely on automatic synchronization, but force synchronization with the Flush method when necessary.

Bear in mind that the synchronization/RFC calls represenmts a bottleneck, so you should keep the not use the Flush method to a minimum.



Set up event handling for controls

There are two types of events:

Application events. T

The flow logic of the screen is processed after the event (The PAI module is processed).

In the events table the event must be registred as an application event by setting then field appl_event to 'X':

wa_events-eventid = cl_gui_textedit=>event_double_click.

wa_events-appl_event = 'X'.

append wa_events to i_events.

Important: The dispatch method of cl_gui_cfw must be called in the PAI module:

CALL METHOD cl_gui_cfw=>dispatch.

System events.

For system events the flow-logic of the screen is not executed. That means that the PAI and PBO modules are not processed.

In the events table the the field appl_event must be set to SAPCE:

wa_events-eventid = cl_gui_textedit=>event_double_click.

wa_events-appl_event = space.

append wa_events to i_events.

The dispatch method of cl_gui_cfw must NOT be called.


It is presumed that a SAP toolbar control named go_toolbar of class cl_gui_toolbar has been defined. To see a complete example of how to handle events, refer to The SAP toolbar control.


  • 1. Define and instance of the eventhandler class.

  • If the event handler class is defined after the data decalaration

  • the class must be declared as DEFERRED in the top of the program: CLASS cls_event_handler DEFINITION DEFERRED.

go_event_handler TYPE REF TO cls_event_handler,

  • 2. Define table for registration of events.

  • Note that a TYPE REF to cls_event_handler must be created before you can

  • reference types cntl_simple_events and cntl_simple_event

gi_events TYPE cntl_simple_events,

  • Workspace for table gi_events

g_event TYPE cntl_simple_event.

  • 3. Define and implement eventhandler class

CLASS cls_event_handler DEFINITION.



  • Syntax:

  • <method name> FOR EVENT <event of control - see the control documentation>

  • OF <class of object> <importing parameters l - see the control documentation>


FOR EVENT function_selected OF cl_gui_toolbar



CLASS cls_event_handler IMPLEMENTATION.

METHOD on_function_selected.

  • Do something when the event is raised



  • 4. Append events to the events table

  • The Event Id can be found in the control documentation. Note that The event below is registred as an application event

g_event-eventid = go_toolbar->m_id_function_selected.

g_event-appl_event = 'X'. "This is an application event

APPEND g_event TO gi_events.

.... append more events i necessary...

  • 5. Use the events table to register events for the control

CALL METHOD go_toolbar->set_registered_events


events = gi_events.

  • 6. Create event handler

CREATE OBJECT go_event_handler.

  • Syntax:

  • SET HANDLER <event handler class> -> <Event handler method>

  • FOR <control>

SET HANDLER go_event_handler->on_function_selected

FOR go_toolbar.

Declare a reference variable before the class has been defined


DATA: o_my_class TYPE REF TO lcl_myclass.

CLASS lcl_myclass.....


This will cause an error because the definition of class lcl_myclass is after the declaration.


Define the class in the beginning of the program with DEFINITION DEFERRED:


DATA: o_my_class TYPE REF TO lcl_myclass.

CLASS lcl_myclass.....


Set focus to a control

Set the focus to a control named go_grid:

CALL METHOD cl_gui_control=>set_focus

EXPORTING control = go_grid.

Good Luck and thanks


Active Contributor
0 Kudos


Go to SE37 and type ALV anf press F4, you will find all the function modules related to ALV..

reward if helpful,



Former Member
0 Kudos

Hi Ashu,

Just send the mail to my mail id. I will give the ALV material which has the details explanation.

Warm Regards,