2009 Jan 29 8:14 AM
Hi All,
I need to trigger an event at the instant when a whole row is selected in ALV.
Not any HOTSPOT.
Is there any SY-UCOMM when a single row will be selected in ALV?
Thanks in advance,
Tabraiz
2009 Jan 29 8:17 AM
hi,
rs_selfield-sel_tab_field gives the internal table name and field.
rs_selfield-value gives the value of the clicked field.
or
data: gs_layout type slis_layout_alv.
gs_layout-box_fieldname = g_boxnam..
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_callback_user_command = 'USER_COMMAND1'
is_layout = gs_layout
it_fieldcat = i_fieldcat1
TABLES
t_outtab = otab3
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
it allows single or multiple selection of a row
Edited by: abap on Jan 29, 2009 9:17 AM
2009 Jan 29 8:22 AM
Hi,
I'm not sure of the whole row selections but you can handle the events for a double click in ALV using call back user command option in ALV function module.
Sample code
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = gd_layout
i_callback_user_command = 'LIST1'
i_callback_top_of_page = 'TOP_OF_PAGE'
it_fieldcat = itfieldcat[]
i_save = 'A'
is_print = gd_prntparams
it_sort = itsort[]
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
FORM for LIST1 user command
Check function code
CASE r_ucomm.
WHEN '&IC1'.
Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'LFBNR'.
Read data table, using index of row user clicked on
READ TABLE itab
INTO wa_ekko
INDEX rs_selfield-tabindex.
Set parameter ID for transaction screen field
SET PARAMETER ID 'MBN' FIELD itab-lfbnr.
SET PARAMETER ID 'GJR' FIELD itab-gjahr.
Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'MB03' AND SKIP FIRST SCREEN.
ENDIF.
Regards
Khanna
2009 Jan 29 8:23 AM
you can add a field to you internal table ( data: a type c.)
which u can use as a check box. in the alv display
and can process the whole record
2009 Jan 29 8:24 AM
Hi
If u're using the FM REUSE_ALV_GRID_DISPLAY for ALV grid u need to define a flag field in your outputtable to be used as MARK field.
In this way u need to eleaborate the record where the MARK field is equal to X:
DATA: BEGIN OF T_OUTPUT...
.......................
MARK,
END OF T_OUTPUT.
DATA: LT_LAYOUT TYPE SLIS_LAYOUT_ALV.
LT_LAYOUT-BOX_FIELDNAME = 'MARK'.
.....................
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
I_CALLBACK_PROGRAM = GT_REPID
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = LT_LAYOUT
.............
TABLES
T_OUTTAB = T_OUTPUT.
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
LOOP AT T_OUTPUT WHERE MARK = 'X'.
ENDLOOP.
ENDFORM.
If u're using OO ALV there's a method in ordert to get the selected lines: GET_SELECTED_ROWS
Max
2009 Jan 29 8:28 AM
Hi Tabraiz,
is that right that you will trigger your report direct if you mark a whole row (similar as hotspot)?
Regards, Dieter
2009 Jan 29 8:34 AM
Hi,
Please try this below code:-
DATA:
fieldtab TYPE slis_t_fieldcat_alv,
layout TYPE slis_layout_alv,
events TYPE slis_t_event,
boxnam TYPE slis_fieldname VALUE 'BOX',
repname LIKE sy-cprog,
g_save(1) TYPE c,
gx_variant LIKE disvariant.
Add the BOX Statement at the END (If IT_DATA-BOX is declared).....
FIELD-SYMBOLS: <box_test> TYPE ANY.
DATA: box_test(15).
IF <it_data> IS ASSIGNED.
MOVE 'IT_DATA-BOX' TO box_test.
ASSIGN (box_test) TO <box_test>.
IF sy-subrc IS INITIAL.
layout-box_fieldname = boxnam.
ENDIF.
ENDIF.
DELETE fieldtab WHERE fieldname = boxnam.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = repname
i_bypassing_buffer = 'X'
i_callback_user_command = 'LUSER_COMMAND'
is_layout = layout
it_fieldcat = fieldtab
i_default = 'X'
i_save = g_save
is_variant = gx_variant
it_events = events[]
TABLES
t_outtab = <it_data>.
Thanks,
Mamta
2009 Jan 29 8:35 AM
Hello Tabraiz,
I donot think you have any SY-UCOMM when a single row will be selected in ALV.
What exactly do you want?
@ Max: I think this sub-routine 'USER_COMMAND' will trigger only in case of a user-command. Is there any user-command triggered when an ALV row is triggered?
BR,
Suhas
Edited by: Suhas Saha on Jan 29, 2009 2:07 PM
2009 Jan 29 8:41 AM
Hi,
In the below function module:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
i_callback_pf_status_set = 'PF_STATUS'
i_callback_user_command = 'COMM' -->this statement is used to catch the user command actions , i.e a subroutine will be created of this name
i_callback_top_of_page = 'TOP'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
i_grid_title = it_grid_title
I_GRID_SETTINGS =
is_layout = it_layout
it_fieldcat = it_field
it_excluding = itab_exclude
IT_SPECIAL_GROUPS =
it_sort = itab_sort
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = ''
I_SAVE = 'A'
IS_VARIANT = SVARIANT
it_events = itab_events
-->The subroutine created is 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.
Hope it helps you
Regrds
Mansi
2009 Jan 29 8:42 AM
Hello Tabraiz
Assuming that your ALV list is OO-based (CL_GUI_ALV_GRID) you can use event DELAYED_CHANGED_SEL_CALLBACK.
For more details please refer to
Regards
Uwe