08-21-2007 1:33 PM
Dear all,
I get results in rows & columnwise in ALV report. Suppose I select any field & double click , I want to call any function further.
Pl' tell the example how to give this event action in code ??
Pl ' give sample examples.....
Thanks..
08-21-2007 1:34 PM
hi
<b>
Pushbuttons On The List</b>
To make a cell to be displayed as a pushbutton, we have two steps. Firstly, insert a new inner table of type LVC_T_STYL into your list data table.
Inserting an inner table to store cell display styles
*--- Internal table holding list data
DATA BEGIN OF gt_list OCCURS 0 .
INCLUDE STRUCTURE SFLIGHT .
DATA rowcolor(4) TYPE c .
DATA cellcolors TYPE lvc_t_scol .
DATA carrid_handle TYPE int4 .
DATA connid_handle TYPE int4 .
DATA cellstyles TYPE lvc_t_styl .
DATA END OF gtlist .
Fill this inner table for each field to be displayed as pushbutton.
A sample code to make the cell at row 7 and column SEATSMAX displayed as pushbutton
DATA ls_style TYPE lvc_s_styl .
...
READ TABLE gt_list INDEX 7 .
ls_style-fieldname = 'SEATSMAX' .
ls_style-style = cl_gui_alv_grid=>mc_style_button .
APPEND ls_style TO gt_list-cellstyles .
MODIFY gt_list INDEX 7 .
As usual, we state our list data table field related with styles in the layout structure at field STYLEFNAME.
e.g. ps_layout-stylefname = 'CELLSTYLES' .
Button click event is handled like hotspot click via the event button_click through its parameters es_col_id and es_row_no which contain the address of the clicked pushbutton cell.
Regards
Ravish
<b>Reward if useful</b>
08-21-2007 1:34 PM
hi
<b>
Pushbuttons On The List</b>
To make a cell to be displayed as a pushbutton, we have two steps. Firstly, insert a new inner table of type LVC_T_STYL into your list data table.
Inserting an inner table to store cell display styles
*--- Internal table holding list data
DATA BEGIN OF gt_list OCCURS 0 .
INCLUDE STRUCTURE SFLIGHT .
DATA rowcolor(4) TYPE c .
DATA cellcolors TYPE lvc_t_scol .
DATA carrid_handle TYPE int4 .
DATA connid_handle TYPE int4 .
DATA cellstyles TYPE lvc_t_styl .
DATA END OF gtlist .
Fill this inner table for each field to be displayed as pushbutton.
A sample code to make the cell at row 7 and column SEATSMAX displayed as pushbutton
DATA ls_style TYPE lvc_s_styl .
...
READ TABLE gt_list INDEX 7 .
ls_style-fieldname = 'SEATSMAX' .
ls_style-style = cl_gui_alv_grid=>mc_style_button .
APPEND ls_style TO gt_list-cellstyles .
MODIFY gt_list INDEX 7 .
As usual, we state our list data table field related with styles in the layout structure at field STYLEFNAME.
e.g. ps_layout-stylefname = 'CELLSTYLES' .
Button click event is handled like hotspot click via the event button_click through its parameters es_col_id and es_row_no which contain the address of the clicked pushbutton cell.
Regards
Ravish
<b>Reward if useful</b>
08-21-2007 1:50 PM
How the following code useful for the same?
I have no idea.......we can call Transaction CO27 when double click on field of ALV output report.....
----
form pf_status_set using extab type slis_t_extab.
set pf-status 'STD' excluding extab.
endform. "pf_status_set
calling transaction CO27 ******************
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
case r_ucomm.
when '&IC1'.
if rs_selfield-fieldname = 'AUFNR'.
read table itab into wa_itab index rs_selfield-tabindex.
submit ppiom000
and return
with p_profid eq 'PPPP'
with s_aufnr eq wa_itab-aufnr.
endif.
endcase.
endform. "user_command
08-21-2007 1:53 PM
hi
take help' of this code
*&---------------------------------------------------------------------*
*& Report ZTESTDEMO_INTERACTIVE_LIST_2
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZTESTDEMO_INTERACTIVE_LIST_2.
TABLES: MARA,MARC,MARD.
* internal table itab_mara 3 fields matnr, ernam,mtart
DATA: BEGIN OF ITAB_MARA OCCURS 0,
MATNR LIKE MARA-MATNR, " material number
ERNAM LIKE MARA-ERNAM, " name of person who create
MTART LIKE MARA-MTART, " Material Type
END OF ITAB_MARA.
* internal table itab_marc 3 fields matnr, werks,lvorm
DATA: BEGIN OF ITAB_MARC OCCURS 0,
MATNR LIKE MARC-MATNR,
WERKS LIKE MARC-WERKS, " Plant
LVORM LIKE MARC-LVORM, " Flag Material for Deletion at Plant Level
END OF ITAB_MARC.
* internal table itab_mard 2 fields
DATA: BEGIN OF ITAB_MARD OCCURS 0,
MATNR LIKE MARD-MATNR,
LGORT LIKE MARD-LGORT, " Storage Location
END OF ITAB_MARD.
SELECT-OPTIONS: S_MTART FOR MARA-MTART.
INITIALIZATION.
S_MTART-LOW = 'HALB'.
S_MTART-HIGH = 'HAWA'.
S_MTART-OPTION = 'BT'.
APPEND S_MTART.
START-OF-SELECTION.
SELECT MATNR ERNAM MTART FROM MARA INTO TABLE ITAB_MARA WHERE MTART IN
S_MTART.
PERFORM DISPLAY.
TOP-OF-PAGE.
WRITE:/2(15) 'MATERIAL NO',20(20) 'CREATED BY',45(15) 'MATERIAL TYPE'.
FORM DISPLAY.
LOOP AT ITAB_MARA.
WRITE:/ ITAB_MARA-MATNR UNDER 'MATERIAL NO' HOTSPOT ON,ITAB_MARA-ERNAM
UNDER 'CREATED BY',ITAB_MARA-MTART UNDER 'MATERIAL TYPE'.
HIDE: ITAB_MARA-MATNR.
ENDLOOP.
ENDFORM.
AT LINE-SELECTION.
CASE SY-LSIND.
WHEN 1.
SELECT MATNR WERKS LVORM FROM MARC INTO TABLE ITAB_MARC WHERE MATNR =
ITAB_MARA-MATNR.
PERFORM DISPLAY1.
WHEN 2.
SELECT MATNR LGORT FROM MARD INTO TABLE ITAB_MARD WHERE MATNR =
ITAB_MARC-MATNR.
PERFORM DISPLAY2.
when 3.
sy-lsind = 0.
ENDCASE.
FORM DISPLAY1.
LOOP AT ITAB_MARC.
WRITE:/ ITAB_MARC-MATNR HOTSPOT ON, ITAB_MARC-WERKS,ITAB_MARC-LVORM.
HIDE: ITAB_MARC-MATNR.
ENDLOOP.
WRITE:/ SY-LSIND.
ENDFORM.
FORM DISPLAY2.
LOOP AT ITAB_MARD.
WRITE:/ ITAB_MARD-MATNR, ITAB_MARD-LGORT.
ENDLOOP.
WRITE:/ SY-LSIND.
ENDFORM.
regards
ravish
<b>plz reward points if helpful</b>
08-21-2007 2:41 PM
See following link for various simple examples of ALV grid functionality
http://www.sapdevelopment.co.uk/reporting/alv/alvgrid.htm
Hope this helps
Regards
Mart