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

USER_COMMAND not getting called in interactive alv module pool.

Former Member
0 Likes
3,789

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.

1 ACCEPTED SOLUTION
Read only

Ashg1402
Contributor
0 Likes
3,470

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

15 REPLIES 15
Read only

Ashg1402
Contributor
0 Likes
3,471

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

Read only

Former Member
0 Likes
3,470

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.

Read only

0 Likes
3,470

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)


Read only

Former Member
0 Likes
3,470

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.

Read only

0 Likes
3,470

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.

Read only

Former Member
0 Likes
3,470

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.

Read only

0 Likes
3,470

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.


Read only

0 Likes
3,470

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!!

Read only

0 Likes
3,470

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.

Read only

Former Member
0 Likes
3,470

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?

Read only

0 Likes
3,470

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.

Read only

Former Member
0 Likes
3,470

Thnaks this helped me. though my purpose has solved. but wan to know when user_command event triggers ?

Read only

0 Likes
3,470

It will trigger if you are using the icons/buttons which are the part of your alv grid toolbar.

Read only

Former Member
0 Likes
3,470

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

Read only

deepak_sharma_sap
Active Participant
0 Likes
3,470

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