05-20-2005 10:43 AM
Hi developers,
i'm wanna do something after a user has pressed the return button in a alv grid control. For that i need probably a event. But i can not find a proper event in the documentation. Could one of you guys help me?
Best regards christian
05-20-2005 10:49 AM
Hi,
Could u plz brief ur problem clearly.
RETURN Button?????????/
Thanks & Regards,
Judith.
05-20-2005 11:17 AM
Hi Judith,
yes of course. not a button at the screen. i'm talking about the key board "return" button.
thanks christian
05-20-2005 11:26 AM
Hi,
Do u mean
<b>In PAI</b>
MODULE user_command_0100 INPUT.
<b>DATA: i_return_code TYPE i .</b>
CALL METHOD cl_gui_cfw=>dispatch
IMPORTING return_code = i_return_code.
ws_save_ok = ok_code.
CASE ws_save_ok.
<b> WHEN 'BACK' OR 'EXIT' OR 'CANC'.</b>
PERFORM exit_program.
ENDCASE.
CLEAR ws_save_ok.
ENDMODULE. " USER_COMMAND_0100 INPUT
<b>FORM exit_program</b>.
CALL METHOD o_grid_container->free.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
Error in FLush
ENDIF.
<b>LEAVE TO SCREEN 0.</b>
ENDFORM. " EXIT_PROGRAM
Thanks & Regards,
Judith.
05-20-2005 11:23 AM
Hi,
I think you are talking about GUI.
If you want to perform something with the GUI status, you can do that by creating your own GUI and then coding in PBO and PAI as per your requirement.
*&----
*& Module USER_COMMAND_9001 INPUT
*&----
This is used for PAI details
*----
MODULE user_command_9001 INPUT.
CASE sy-ucomm.
WHEN 'EXIT' OR 'CANC'.
"write your coding here.
LEAVE PROGRAM.
WHEN 'BACK'.
"write your coding here.
SET SCREEN '0'.
LEAVE SCREEN.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " USER_COMMAND_9001 INPUT
05-20-2005 11:29 AM
Hi Christian,
as return triggers pai, you can raise whatever event at that point. The thing is, we need to know what you want to do. May be you can raise the data_changed event ..., but also you need to register it before.
So your question is not really clear.
regards
Siggi
05-20-2005 11:47 AM
Hi Christian
As Siggi mentioned, pressing the return key will trigger the PAI and afterwards (if the processing is not terminated or branched to somewhere else) the PBO block of the screen in which ALV is embedded. So, you can code in one of these blocks whatever you want to do with the ALV grid.
<b><u>e.g.</u></b>
<u>AT PBO:</u>
IF gr_alvgrid IS INITIAL .
*--Creating instance for container if required
*--Cretaing instance for the ALV Grid control
ELSE .
<b>*--"This part is suitable for your requirement"</b>
CALL METHOD gr_alvgrid->refresh_table_display .
CALL METHOD gr_alvgrid->set_toolbar_interactive .
...
ENDIF .
Regards
*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>
05-20-2005 11:56 AM
Sorry guys,
no answer could help me.
may be i did not explain the problem exactly. i try it again.
i've got a editable alv grid on a screen.
a user made some input and has still the cursor in one of these alv-fields. if he pushes now the return button on the keyboard there won't be a pai/pbo because this command is fired within the alv grid. But i wanna do something after the user has pressed the return button. for that i need a proper event. the event data_changed or data_changed finished are not really what i need because they are used to often. it will cause to mutch traffic.
i hope the problem will now be a litle bit clearer.
best regards christian
05-20-2005 12:03 PM
Hi again
The ALV grid seems not so good for data inputting purposes since as you mentioned the editable data handling events causes much traffic.
So, you can define your events as application events and implement your handler class (i.e. with switches) so that it can handle the logic to lessen the traffic at dispatch time.
Regards
*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>
05-20-2005 12:20 PM
Hello Shristian,
You have to register the 'return' button for edit event. For this, you need to use the method 'register_edit_event' of class 'cl_gui_alv_grid'. After you do this, when the user presses the return (enter) key on the key board the control goes to 'data_changed' event.
Hope this solves your problem.
Regards,
Jitendar
05-20-2005 12:38 PM
Hi,
Any event triggered in and by ALV can be captured in before_user_command event.
Also there is after_user_command event.
If you want to handle the event your self and dont want SAP to handle it further , you can handle it in before_user_command and then clear the sy-ucomm to avoid further processing.
This can be done by calling method set_user_command
exporting i_ucomm = space.
05-20-2005 12:53 PM
Hi Nagaraju Donikena,
are you sure that a return on the keyboard will trigger the before_user_command / user_command event. it doesen't work at my programm maybe i did some other mistake.
regards christian
05-20-2005 12:56 PM
Hi Christian
Pressing return key will trigger the event "data_changed" after you enter data on an editable ALV Grid. As I mentioned before, you must utilize this event as an object or application event to do what you require.
Regards
*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>
05-20-2005 1:01 PM
05-20-2005 1:10 PM
Hi Christian
ALV grid is an encapsulated object, so it seems there is no way, you ought to implement the data_changed event. So if you want to make bulk data input and after trigger the event by pressing the return key, you should make the ALV Grid get your changes after pressing the key but not after a cell change of a modified cell.
To set this attribute:
CALL METHOD gr_alvgrid->register_edit_event
EXPORTING i_event_id = cl_gui_alv_grid=>mc_evt_enter .
This way "data_changed" event will be triggered whenever you press the return key while editing.
For some more information you can also refer to the tutorial <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/an%20easy%20reference%20for%20alv%20grid%20control.pdf">"An Easy Reference for ALV Grid Control"</a>.
Regards
*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>
06-24-2006 12:41 PM
Hi Serdar/Christian
I am new to ABAP. I am also facing the same issue.I need to trigger one function by pressing the enter key (return key) from ALV Grid.
Can you please give some sample source code for register and call the class module.
Thanks
Muthukumar
06-27-2006 7:55 AM
hi muthukumar ,
Did u get answer for ur query if yes pls send me the coding Im strugling to get the output after 'Enter' key
Please forward me to shankimail@gmail.com
Thanks
Shankar S