07-21-2005 6:51 AM
Hi all,
I have displayed data in alv grid now if user click on any field i have to process further. I'm not able to call interactive events. Please suggest.
Thanks,
Anup.
07-22-2005 6:41 AM
Hey Anup,
Did u check the sample code I have attached.
It will work fine. It's very simple buddy.
Try it and let me know by EOD.
Regs,
Venkat
07-21-2005 6:58 AM
Hi Anup,
To be able to handle the events, you will have to register them. you have not specified whether you are using the Function Module approach or the OO approach.
Look at the demo program BCALV_TEST_GRID_EVENTS. It should help you understand how this is done. If you have further doubts, please get back.
Regards,
Anand Mandalika.
07-21-2005 7:21 AM
Hi Anup,
If you are using "REUSE_ALV_LIST_DISPLAY", then there will be one field by name
" i_callback_user_command = g_f_callback_user_command ".
you uncomment that field.
for that user command write perform.
FORM user_command USING i_f_ucomm LIKE sy-ucomm
i_r_selfield TYPE slis_selfield.
CASE i_f_ucomm.
WHEN '&IC1'.
PERFORM fcode_item_lines USING i_r_selfield.
endcase.
now in this perform you code what has to be displayed.
07-21-2005 8:03 AM
Hi,
Here is the complete example code, refer. This will definitely help you.
REPORT ZVENKAT NO STANDARD PAGE HEADING.
TYPE-POOLS: slis.
DATA: BEGIN OF i_data OCCURS 0,
qmnum LIKE qmel-qmnum,
qmart LIKE qmel-qmart,
END OF i_data.
DATA: report_id LIKE sy-repid.
DATA: ws_title TYPE lvc_title VALUE 'An ALV Report'.
DATA: i_layout TYPE slis_layout_alv.
DATA: i_fieldcat TYPE slis_t_fieldcat_alv.
DATA: i_events TYPE slis_t_event.
DATA: i_header TYPE slis_t_listheader.
SELECT qmnum
qmart
qmtxt
INTO TABLE i_data
FROM qmel
WHERE qmnum <= '00030000010'.
LOOP AT i_data.
i_data-ws_row = sy-tabix.
i_data-ws_char = 'AAAAA'.
MODIFY i_data.
ENDLOOP.
report_id = sy-repid.
PERFORM f1000_layout_init CHANGING i_layout.
PERFORM f2000_fieldcat_init CHANGING i_fieldcat.
PERFORM f3000_build_header CHANGING i_header.
PERFORM f4000_events_init CHANGING i_events.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = report_id
i_grid_title = ws_title
is_layout = i_layout
it_fieldcat = i_fieldcat
i_save = 'A'
it_events = i_events
TABLES
t_outtab = i_data
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 f1000_layout_init USING i_layout TYPE slis_layout_alv.
CLEAR i_layout.
i_layout-colwidth_optimize = 'X'.
i_layout-edit = 'X'.
ENDFORM. " F1000_Layout_Init
&----
*&----
FORM f2000_fieldcat_init CHANGING i_fieldcat TYPE slis_t_fieldcat_alv.
DATA: line_fieldcat TYPE slis_fieldcat_alv.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'QMNUM'. " The field name and the table
line_fieldcat-tabname = 'I_DATA'. " name are the two minimum req.
line_fieldcat-key = 'X'. " Specifies the column as a key (Blue)
line_fieldcat-seltext_m = 'Notification No.'. " Column Header
APPEND line_fieldcat TO i_fieldcat.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'QMART'.
line_fieldcat-ref_tabname = 'I_DATA'.
line_fieldcat-hotspot = 'X'. " Shows the field as a hotspot.
line_fieldcat-seltext_m = 'Notif Type'.
APPEND line_fieldcat TO i_fieldcat.
ENDFORM. " f2000_fieldcat_init
&----
*&----
FORM f3000_build_header USING i_header TYPE slis_t_listheader.
DATA: gs_line TYPE slis_listheader.
CLEAR gs_line.
gs_line-typ = 'H'.
gs_line-info = 'This is line of type HEADER'.
APPEND gs_line TO i_header.
ENDFORM. " f3000_build_header
&----
*&----
FORM f4000_events_init CHANGING i_events TYPE slis_t_event.
DATA: line_event TYPE slis_alv_event.
CLEAR line_event.
line_event-name = 'TOP_OF_PAGE'.
line_event-form = 'F4100_TOP_OF_PAGE'.
APPEND line_event TO i_events.
ENDFORM. " f3000_events_init
----
*----
FORM f4100_top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = i_header.
ENDFORM.
Cheers,
Venkat
07-21-2005 2:59 PM
Hey Anup,
Did u check the sample code I gave u.
it will work fine.
Regs,
Venkat
07-22-2005 3:07 AM
Hi anup,
You can display data using ALVs function module like
REUSE_ALV_LIST_DISPLAY .
To handle the events use SLIS structure.
To get the information about the field on which the user has clicked use
GET CURSOR FIELD <fname> VALUE <fvalue >. in AT LINE-SELECTION event.
I hope it may help u.
With regards
Prasad.
07-22-2005 6:41 AM
Hey Anup,
Did u check the sample code I have attached.
It will work fine. It's very simple buddy.
Try it and let me know by EOD.
Regs,
Venkat