2016 Aug 09 6:24 AM
Hi,
This is the code regarding user_commnad.
Inside TOP_INCLUDE
class event_class definition.
public section.
methods :
handle_approve for event user_command of cl_gui_alv_grid
importing e_ucomm.
endclass. "lcl_rcvr_class DEFINITION
class event_class implementation.
method handle_approve.
break-point.
"code will be here
endmethod.
endclass.
data : lp_rcvr type ref to event_class.
after alv display
create object lp_rcvr.
set handler lp_rcvr->handle_approve for obj_grid_proj.
though the control is coming to set handler after any PAI event, But it is not calling the method. Please help.
obj_grid_proj is the object of the container.
2016 Aug 09 6:37 AM
Hi,
You should declare the create object (for event handler class), and set handler for event in PBO module of you program.
Are you doing that.?
And the set handler command is wrong.
You have to register it like this - set handler lp_rcvr->handle_approve for <Object for alv grid class> (NOT FOR CONTAINER)
Regards
Ashish
2016 Aug 09 6:37 AM
Hi,
You should declare the create object (for event handler class), and set handler for event in PBO module of you program.
Are you doing that.?
And the set handler command is wrong.
You have to register it like this - set handler lp_rcvr->handle_approve for <Object for alv grid class> (NOT FOR CONTAINER)
Regards
Ashish
2016 Aug 09 7:20 AM
Hi,
I have here two screens 200 ( selection screen) 300 (ALV output screen). After it display the output at screen 300. I want to select few rows and after clicking 'SAVE' button i want to process those data. So, I created the object and set handler at the PAI of the screen 300. Are you asking me to do that at PBO of screen 300? screen 300 is my alv output screen.
2016 Aug 09 7:26 AM
yes, in the PBO of 300 screen, wherever you are calling set_table_for_first_display.
And the set handler command is wrong.
You have to register the event method for the object whic you have created for cl_gui_alv_grid, by which you are showing display. That is -
set handler lp_rcvr->handle_approve for <Object for alv grid class> (NOT FOR CONTAINER)
2016 Aug 09 7:44 AM
Hi,
I changed the it to object of the grid class and wrote the set handler and created object at PBO of screen 300. though it is calling the set handler but not going inside the method. I cannot figure out what mistake i have done.
this is the o/p screen 300. am clicking on button after selecting a row.
it is stopping at the set handler
but control not going inside the methof handle_approve. where i gave the break point. as per the code it should go there.
please suggest.
2016 Aug 09 7:57 AM
Hi,
Did you create a new module in PBO.??
The set handler is given at the time of display in PBO module where we call the
set_table_for_first_display method. Not by creating any other module. just put these two statement after that method.
And you are again giving the container object in set handler. You have to pass the object by which you are calling set_table_for_first_display method.
2016 Aug 09 8:19 AM
first of all it is object of grid class.
So it is the grid class object . and i again wrote it after calling set_table_for_first_display method.
but still it not going inside the method.
2016 Aug 09 8:29 AM
You said in the beginning that - obj_grid_proj is the object of the container.
That's why I was taking it as container object.
Can you tell me one thing, how did you declare the ICON which you are clicking .?
Did you declare that in PF-STATUS.?
That ICON which you are clicking is not the part of alv grid toolbar. I think that's why it is not going inside the method.
It will be checked in PAI module using sy-ucomm.
2016 Aug 09 8:32 AM
Hi,
on user command you are registering the event handler method, which will handle the event on the next user command, and each time when PAI will trigger , statement to register the method will execute which is not appropriate.
so register your event just after method set_table_for_first_display.
thank you!!
2016 Aug 09 8:36 AM
Hi Chintu,
The screenshot clearly tells that the icon is not the part of alv grid toolbar.
There is no need for any event method. It can be simply handeled in PAI module using SY-UCOMM.
2016 Aug 09 8:36 AM
Thank You. The icon am clicking is declared in PBO of screen 300 in pf-status.
module status_0300 output.
set pf-status 'ZTEST'.
endmodule.
Inside 'ZTEST' I put that button
Is this wright? or what else i need to do. I created double click event . that was working fine. But not this one. Thanks for helping me till now.
Or I should i handle this type of event in PAI by simple sy-ucomm event?
2016 Aug 09 8:41 AM
Hi,
If you want the working to be done in same way which you wanted, the do a case statement for
sy-ucomm in PAI module, in case you can check that value for that icon.
Call method GET_SELECTED_ROWS inside that case statement and then you can put the code which you were using in the event method.
2016 Aug 09 8:48 AM
Thnaks this helped me. though my purpose has solved. but wan to know when user_command event triggers ?
2016 Aug 09 8:50 AM
It will trigger if you are using the icons/buttons which are the part of your alv grid toolbar.
2016 Aug 09 11:52 AM
I got a program BCALV_GRID_05 where i found the process to create button in custom container. Now I understood how to use the user_command.
Thanks
2016 Aug 09 6:41 AM
Hi,
Can you please paste your complete code after for displaying the ALV and then events.
You can also check the report BCALV_GRID_02 in SAP.
Thanks
Deepak