on 2006 Mar 21 12:49 PM
In case of the report generated through REUSE_ALV_GRID_DISPLAY, If user doubles clicks on one of the fields in the ALV output, then i want to get the data of the entire row on which the user has clicked. Is there any way to do so? Please help.
Note:- I have tried using the index. The problem using the index is that the index value gets changed if the user sorts the output before double clicking on the ALV output.
Hi sravan,
1. There are some parameters
in the FM which are passed,
and a new FORM has to be written.
2. Just copy paste this code in new program.
3. It will display list of company.
On double-clicking on the alv,
it will again display the clicked company code.
<b>(there will be no problem of SORTING and index)</b>
Important code has been marked.
4.
REPORT abc.
TYPE-POOLS : slis.
*----
Data
DATA : BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE t001.
DATA : END OF itab.
DATA : alvfc TYPE slis_t_fieldcat_alv.
*----
Select Data
SELECT * FROM t001 INTO TABLE itab.
*------- Field Catalogue
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*----
Display
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = alvfc
i_callback_program = sy-repid "<-------Important
i_callback_user_command = 'ITAB_USER_COMMAND' "<------ Important
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
*----
CALL BACK FORM
*----
FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE
slis_selfield.
READ TABLE itab INDEX whatrow-tabindex.
WRITE itab-bukrs.
ENDFORM. "ITAB_user_command
regards,
amit m.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
1. As per the forum etiquette,
u may pls award points
to helpful answers by clicking the STAR
on the left of that reply.
regards,
amit m.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sravan,
Check this code,
types: begin of it_sflight,
carrid type sflight-carrid,
connid type sflight-connid,
fldate type sflight-fldate,
price type sflight-price,
currency type sflight-currency,
line_color(4) type c,
end of it_sflight.
data: itab type table of it_sflight with header line,
itab1 type it_sflight.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&IC1'.
IF rs_selfield-fieldname = 'CONNID'.
select single * from sflight into corresponding fields of itab1 where connid = rs_selfield-value.
ENDIF.
ENDCASE.
ENDFORM.
In this case itab1 is a structure and after select statement itab1 contains all the corresponding data.
This is the case when u click on any value of CONNID. Now you can either extend this to other fields or you can use a field symbol kind of technique whereby you can find which field is selected and act accordingly.
I hope your query is satisfied.
Regards,
Sylendra.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
In layout structure you indicate the OK-CODE for double click:
iS_LAYOUT-f2code = 'DETA'.
In the parameter I_CALLBACK_USER_COMMAND indicate the name of routine for USER_COMAND event. Which routine has to be like following:
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
ENDFORM.
Here insert your code for doubleclick:
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE R_UCOMM.
WHEN 'DETA'.
READ TABLE <T_OUTPUT> INDEX rs_selfield-TABINDEX.
*---> Now you have the header line of record where *doubleclik was done.
...............
ENDCASE.
ENDFORM.
Max
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Look at the sample code..............
****************************************
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = i_repid
i_callback_user_command = 'USER_COMMAND_PERNR'
it_fieldcat = header
is_layout = gt_layout
i_callback_top_of_page = 'TOP-OF-PAGE1'
i_grid_title = text-t05
it_sort = gt_sort[]
i_default = 'X'
i_save = 'U'
is_variant = gt_variant
it_events = gt_events
TABLES
t_outtab = ITAB.
clear itab.
----
FORM USER_COMMAND_PERNR
----
FORM USER_COMMAND_PERNR USING u_ucomm LIKE sy-ucomm
us_selfield TYPE slis_selfield."#EC CALLED
CASE u_ucomm.
when '&IC1'.
if us_selfield-fieldname = 'PERNR'.
set parameter id 'PER' field us_selfield-value.
call transaction 'ZDMR03' and skip first screen.
endif.
ENDCASE.
ENDFORM. " USER_COMMAND_PERNR
Here the total line of selected field you can catch in SY-LISEL.
Thanks.
If this helps you reward with points.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
70 | |
10 | |
10 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.