2009 Mar 05 4:20 PM
Hello,
Is there a possibility to call a user command from within an ALV method? I want the PAI module of the ALV's screen to run.
best regards
Roland
2009 Mar 06 9:17 AM
Hi,
Yes you can make an ALV interactive which will execute is PAI (USER COMMAND) when user performs any action.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy_repid " report id
i_callback_pf_status_set = 'PF' " for PF-STATUS
i_callback_user_command = 'COMMAND' " for User-Command
is_layout = wa_layout " for layout
it_fieldcat = it_field " field catalog
TABLES
t_outtab = it_final " internal table
EXCEPTIONS
program_error = 1
OTHERS = 2.
When you double-click on any cell of alv grid, use this code to fetch the data of the line that you currently clicked, its working:-
When you double click on the ALV grid line, you will have sy-ucomm = '&IC1'.
So when you define a i_callback_user_command for the FM reuse_alv_grid_display, and create it as:-
FORM command USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
DATA : ok_code TYPE sy-ucomm.
ok_code = ucomm.
CASE ok_code.
WHEN '&IC1'. "for double click on alv grid line
" your code
ENDCASE.
ENDFORM.
As you have used selfield TYPE slis_selfield, the field selfield will hold all the values.
To know on which row you have clicked and to retain that line, use code:-
Suppose you are currently displaying data from internal table itab and corresponding to it you have work area wa.
read table itab into wa index selfield-tabindex. "index value of line you clicked
" now you have the contents of line that you double clicked currently
Now to know the field name that you clicked, use:-
selfield-fieldname " will fetch you the name of field that you clicked
Now using the work-area and the name of field that you clicked, you can easily make out the details of the field i.e., field name and field value and you can code as per your requirement.
Also you can refer this wiki by me on:-
ALV Grid Display with checkbox to process selected records at runtime
To have checkbox with each record in alv and display on those records on next display which were selected by the user on initial grid.
Hope this helps you.
Regards,
Tarun
Edited by: Tarun Gambhir on Mar 6, 2009 2:48 PM
Hello,
Is there a possibility to call a user command from within an ALV method? I want the PAI module of the ALV's screen to run.
best regards
Roland
2009 Mar 05 4:23 PM
2009 Mar 05 4:27 PM
I have an ALV that lies on a screen. This screen has a PBO and a PAI module (that are called before and after the user can do stuff).
I want to the ALV to be able to call the PAI module (as if the user would click a button or select a menu item or hits return).
Roland
2009 Mar 05 4:32 PM
Hi,
If you have created the Push button on the application toolbar then PAI module is called.
If you have created the Push button on the ALV toolbar than the Perform you specify in the AT_USER_COMMAND parameter is called.
2009 Mar 05 4:41 PM
I never said I have a push button.
I want to call PAI from the data_changed_finished event handler.
Roland
2009 Mar 05 5:03 PM
Hi,
I don't think, that you can do something in your ALV coding to call the screen PAI. What you can do is Call the screen in your code. That will first trigger you PBO of that screen then PAI, if that screen doesn't have any selction screen, then directly you can have the PAI of that screen.
Kuntal
2009 Mar 05 5:20 PM
Hi,
when you call set_table_for_first_display method then
use this line
SET HANDLER lcl_event_handler=>data_changed FOR t_grid.
"define and implement a class method in the public section.
CLASS-METHODS data_changed_method FOR EVENT data_changed
OF cl_gui_alv_grid
IMPORTING es_row_no.
" Dont forget to implement this class method....Regards,
Siddarth
2009 Mar 06 7:32 AM
Kuntal,
I already tried that. It's not possible to do a call screen from the event handler method. I thought about calling a function module and do the call screen there, but I can't try until next week.
-
Siddarth,
This is not what I asked.
-
Roland
2009 Mar 06 9:17 AM
Hi,
Yes you can make an ALV interactive which will execute is PAI (USER COMMAND) when user performs any action.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy_repid " report id
i_callback_pf_status_set = 'PF' " for PF-STATUS
i_callback_user_command = 'COMMAND' " for User-Command
is_layout = wa_layout " for layout
it_fieldcat = it_field " field catalog
TABLES
t_outtab = it_final " internal table
EXCEPTIONS
program_error = 1
OTHERS = 2.
When you double-click on any cell of alv grid, use this code to fetch the data of the line that you currently clicked, its working:-
When you double click on the ALV grid line, you will have sy-ucomm = '&IC1'.
So when you define a i_callback_user_command for the FM reuse_alv_grid_display, and create it as:-
FORM command USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
DATA : ok_code TYPE sy-ucomm.
ok_code = ucomm.
CASE ok_code.
WHEN '&IC1'. "for double click on alv grid line
" your code
ENDCASE.
ENDFORM.
As you have used selfield TYPE slis_selfield, the field selfield will hold all the values.
To know on which row you have clicked and to retain that line, use code:-
Suppose you are currently displaying data from internal table itab and corresponding to it you have work area wa.
read table itab into wa index selfield-tabindex. "index value of line you clicked
" now you have the contents of line that you double clicked currently
Now to know the field name that you clicked, use:-
selfield-fieldname " will fetch you the name of field that you clicked
Now using the work-area and the name of field that you clicked, you can easily make out the details of the field i.e., field name and field value and you can code as per your requirement.
Also you can refer this wiki by me on:-
ALV Grid Display with checkbox to process selected records at runtime
To have checkbox with each record in alv and display on those records on next display which were selected by the user on initial grid.
Hope this helps you.
Regards,
Tarun
Edited by: Tarun Gambhir on Mar 6, 2009 2:48 PM
2009 Mar 06 9:26 AM
Tarun,
> Yes you can make an ALV interactive which will execute is PAI (USER
> COMMAND) when user performs any action.
This sounds interesting. Do you happen to know how this is done when I'm NOT using the REUSE function modules, but OO programming?
best regards
Roland
2009 Mar 06 9:30 AM
Hi,
You can refer:-
Interactive Editable OO ALV grid with dynamic itab,FCAT and ENTER key event trigger
object oriented Programming in ALV
Hope this helps you.
Regards,
Tarun
2009 Mar 06 9:43 AM
Hi Ronald,
You can create user command for your alv,first create the pf-status for your alv like:
FORM pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'FIRST'.
ENDFORM. "PF_STATUS
Then pass subroutine to function module Reuse..parameter:
i_callback_pf_status_set = 'PF_STATUS'
Then for the user command can be created like:
FORM comm USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
DATA: okcode TYPE sy-ucomm.
okcode = ucomm.
CASE okcode.
WHEN 'REF'.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'MANSI'
txt1 = 'CREATED BY'
txt2 = SY-UNAME
* TXT3 = ' '
* TXT4 = ' '
.
endcase.
And pass this subroutine in the parameter:
i_callback_user_command = 'COMM'
Hope it helps
Regrds
Mansi
2009 Mar 06 9:49 AM
For your information:
I think I found the solution myself. I have to pass the parameter I_APPL_EVENTS (Register Events as Application Events) to the constructor of the ALV. This should cause the ALV events to trigger PAI too.
I can't try this today, but I assume it'll work.
Roland
2010 Nov 12 9:32 AM
Hi,
you can trigger PAI the following way:
cl_gui_cfw=>set_new_ok_code( EXPORTING new_code = 'YOUR_OK_CODE_HERE' ).
This triggers PAI. You must not set the i_appl_events option for the Grid.
2013 Feb 26 7:13 AM
2016 Jan 29 12:56 PM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |