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

Explanation about the code

Former Member
0 Likes
610

Hi,

I have limited knowledge on OOPs, can any one explain me the what exactly happen for each line of the below code.

 
*-For Single click functionality
  CREATE OBJECT gv_event_handler.
  SET HANDLER gv_event_handler->handle_single_click FOR gv_alv_grid1.


*-Call method register_edit_event - To track changes on Enter
  CALL METHOD gv_alv_grid1->register_edit_event
       EXPORTING
              i_event_id = cl_gui_alv_grid=>mc_evt_enter.

*-To Exclude unwanted standard functions of the ALV
*-Copy
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.
  APPEND ls_exclude TO gt_exclude.


CALL METHOD cl_gui_cfw=>flush.  " To flush the memory

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
582

Data: gv_event_handler type ref to Cl_Gui_ALV_GRID.

First you make reference to a class.

1)CREATE OBJECT gv_event_handler. -


>This statements creates the actual Objec whose reference we had created earlier.

2) SET HANDLER gv_event_handler->handle_single_click FOR gv_alv_grid1.

In a class an Action is an Event.So when ever an event occurs(Say Mouse click) if itneeds

to be handled you need a Handler method to Handle the Event.Say Execute some task based on CLICK.

3) CALL METHOD gv_alv_grid1->register_edit_event

EXPORTING

i_event_id = cl_gui_alv_grid=>mc_evt_enter.

If there is any New event that needs to be handle if its not registered in the class.So at runtime to handle it Explicitly it needs to be Registered first.

4) *-To Exclude unwanted standard functions of the ALV

*-Copy

ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.

APPEND ls_exclude TO gt_exclude.

On A Grid we have many Buttons our requirement is only some of the buttons .We Exclude the Unwanted button by passing the method associated to the internal table gt_exclude.

Which is passed in the Method 'SET_TABLE_FOR_FIRST_DISPLAY'.

5) CALL METHOD cl_gui_cfw=>flush.

It is used to just Clear/Flush the Program memory at runtime.

[Refer this link|https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/object%252boriented%252balv%252bguide]

Hope this is clear...

Regards,

Gurpreet

5 REPLIES 5
Read only

Former Member
0 Likes
583

Data: gv_event_handler type ref to Cl_Gui_ALV_GRID.

First you make reference to a class.

1)CREATE OBJECT gv_event_handler. -


>This statements creates the actual Objec whose reference we had created earlier.

2) SET HANDLER gv_event_handler->handle_single_click FOR gv_alv_grid1.

In a class an Action is an Event.So when ever an event occurs(Say Mouse click) if itneeds

to be handled you need a Handler method to Handle the Event.Say Execute some task based on CLICK.

3) CALL METHOD gv_alv_grid1->register_edit_event

EXPORTING

i_event_id = cl_gui_alv_grid=>mc_evt_enter.

If there is any New event that needs to be handle if its not registered in the class.So at runtime to handle it Explicitly it needs to be Registered first.

4) *-To Exclude unwanted standard functions of the ALV

*-Copy

ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.

APPEND ls_exclude TO gt_exclude.

On A Grid we have many Buttons our requirement is only some of the buttons .We Exclude the Unwanted button by passing the method associated to the internal table gt_exclude.

Which is passed in the Method 'SET_TABLE_FOR_FIRST_DISPLAY'.

5) CALL METHOD cl_gui_cfw=>flush.

It is used to just Clear/Flush the Program memory at runtime.

[Refer this link|https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/object%252boriented%252balv%252bguide]

Hope this is clear...

Regards,

Gurpreet

Read only

0 Likes
582

Hi,

Thanks for your explanation, I know purpose of code, but looking for technical process flow, how really system will provide the functionality. lets take for the below code...

3) CALL METHOD gv_alv_grid1->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.

what will happen if we pass 'cl_gui_alv_grid=>mc_evt_enter' & why we are using '=>' symbol here.

Read only

0 Likes
582

The above method is called to register an Event.It Set Handler before table is set for display.

As soon as an event is Triggered it is its is caught by an handler classs for those events.

=> Its is used to call Static method of a calss.If you are calling static method of a calls you donot have to instansiate it.

Example:

gv_alv_grid1->register_edit_event

Gv_alv_grid1 is an instance of class cl_gui_alv_grid(Create Object)

to access methods of a class other then static you need to create instance of that class.

But static method no instance of the class is required.

Regards,

Gurpreet

Read only

Former Member
0 Likes
582

Hi Satya,

while refering to static class, the method or the events of the static class are accessed via =>

symbol ,

thus is a class say cl_gui_alv_grid is a static class and has a method DISPLAY then to access this method the code is

data:
   cl_grid type ref to cl_gui_alv_grid.

create object cl_grid.

cl_grid=>display.

this shall call the Method DISPLAY.

thanks

Read only

matt
Active Contributor
0 Likes
582

There's no such thing as a "static class". Please be careful with your terminology.

matt