Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to get the values dynamically

Former Member
0 Likes
1,108

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.

6 REPLIES 6
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,037

Hi,

Refer this wiki code ALV Grid Display with checkbox to process selected records at runtime, it will definitely help you:-

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/alv%252bgrid%252bdisplay%252bwith%252bch...

Regards,

Tarun

Read only

Former Member
0 Likes
1,037

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,

Read only

Former Member
0 Likes
1,037

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,

Read only

Former Member
0 Likes
1,037

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

Read only

Former Member
0 Likes
1,037

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

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,037

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