‎2009 Feb 27 9:18 AM
Hi ,
I am displaying the grid output. If i select a row is there any way to pick the values depends on that row.
Can you please let me know.
Thanks in advance,
Sreekala.
‎2009 Feb 27 9:53 AM
Hi,
Refer this wiki code ALV Grid Display with checkbox to process selected records at runtime, it will definitely help you:-
Regards,
Tarun
‎2009 Feb 27 10:30 AM
Hi Tarun,
Thanks for u r reply. I called the method get_selected_rows. thorugh that index i am reading the data fro internal table. Again i came back and i sorted the output depends on field then my output gets changed. Now if i select one row and press display button, through the index it is reading from the internal table because of that it is showing wrong data. can u please suggest me how to follow?
Thanks for u r reply,
‎2009 Feb 27 10:44 AM
Hi Tarun,
Thanks for u r reply. I called the method get_selected_rows. thorugh that index i am reading the data fro internal table. Again i came back and i sorted the output depends on field then my output gets changed. Now if i select one row and press display button, through the index it is reading from the internal table because of that it is showing wrong data. can u please suggest me how to follow?
Thanks for u r reply,
‎2009 Mar 02 10:21 AM
Hi Sreekala,
Can u please elaborate the question more so that I can help u out because I am not able to understand it properly paste the code also.
Thanks & Regards,
Ruchi Tiwari
‎2009 Mar 03 12:19 PM
Hi.
Actually when you update any values then it changes in your internal table also
that why u will always get changed values
For handling it first get the original data from db table and then compare it with internal table which holds changed data
In this way you can handle both kind of value and do the functionality you want.
Then because you are sortin data its index get changed again need to call get_selected_rows.
Thanks,
Smita
Edited by: Smita Gupta on Mar 3, 2009 1:20 PM
Edited by: Smita Gupta on Mar 3, 2009 1:24 PM
‎2009 Mar 03 12:32 PM
Hi,
If you double-click on a line to select and then wish to pick the value for field name and field value, the follow the below steps:-
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.
Hope this helps you.
Regards,
Tarun