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

Editable ALV

Former Member
0 Likes
698

Hi all,

I am using editable alv control.

I want to fetch the customer description, when a user enters a customer code in next field.

How to do this at runtime?

Please help me out.

Regards,

Sunny

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
667

Hello,

You mean to say when ever in ALV if find a customer field then user will give the input in the alv and press enter then the value should be updated if you u r using ALV oops try this because i have used alv opps only so i dont now it will work for normal grid dispaly.

You try this example program you will get BCALV_EDIT_03.

I have use same program to get the edit field and change the value and it should get updated after pressing enter key.

Hi all,

I am using editable alv control.

I want to fetch the customer description, when a user enters a customer code in next field.

How to do this at runtime?

Please help me out.

Regards,

Sunny

4 REPLIES 4
Read only

Former Member
0 Likes
668

Hello,

You mean to say when ever in ALV if find a customer field then user will give the input in the alv and press enter then the value should be updated if you u r using ALV oops try this because i have used alv opps only so i dont now it will work for normal grid dispaly.

You try this example program you will get BCALV_EDIT_03.

I have use same program to get the edit field and change the value and it should get updated after pressing enter key.

Read only

0 Likes
667

Hi Santosh,

Thanks for ur reply.

I reffered your code, but It is too complex for me.

Could you just give me the example?

I want customer name field to be fetched from std table into alv when a user enters or changes cutomer code field in alv.

Regards,

Sunny

Read only

Former Member
0 Likes
667

Use Method modify_cell of class cl_alv_changed_data_protocol to change cell values

Refer program BCALV_EDIT_04

Hope this helps....

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
667

Hi Sunny,

Use this code at any user command.

This code will reflect all the changes into the internal table that is being displayed.


* to reflect the data changed into internal table
      DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new

      IF ref_grid IS INITIAL.
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
          IMPORTING
            e_grid = ref_grid.
      ENDIF.

      IF NOT ref_grid IS INITIAL.
        CALL METHOD ref_grid->check_changed_data.
      ENDIF.

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 solves your problem.

Thanks & Regards,

Tarun Gambhir