Application Development 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: 

How to make a entire column editable in an ALV grid

Former Member
0 Kudos

Hi all,

I am trying to make a column editable in an ALV grid. For that I wrote the following code. In the below code I have set the 'edit' field of ls_fcat to 'X'. But Iam getting Runtime error. Can anyone help in resolving this problem or suggest any method to make a column editable in an ALV grid.

form prepare_fc changing go_fieldcat type lvc_t_fcat.

data: ls_fcat type lvc_s_fcat.

refresh: go_fieldcat.

clear: ls_fcat.

ls_fcat-reptext = ' Safety Stock Figures'.

ls_fcat-coltext = 'Safety Stock Figures'.

ls_fcat-fieldname = 'EISBE'.

ls_fcat-ref_table = 'IMAT'.

ls_fcat-edit = 'X'.

modify go_fieldcat from ls_fcat.

APPEND LS_FCAT TO GO_FIELDCAT.

endform.

Thanks & Regards,

Vishnu Priya.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Indeed you are modifying the internal table go_fieldcat with ls_fcat wherein in the first step you have refreshed the table. so the statement gets failed and raises a dump.

so do change your code to append the same or check before whether it has an entry adn then modify.

Regards,

Jagath

Message was edited by: Jagathguru Chandrasekharan

4 REPLIES 4

Former Member
0 Kudos

ls_fcat-edit = 'X'.

is correct only.

have a look into this code

struct_grid_lset TYPE lvc_s_layo,

i_grid_fcat TYPE lvc_t_fcat

DATA ls_fcat TYPE lvc_s_fcat.

CLEAR ls_fcat.

ls_fcat-fieldname = 'MONTH'.

ls_fcat-ref_table = 'TYPE'.

ls_fcat-ref_field = 'C'.

<b> ls_fcat-edit = 'X'.</b>

ls_fcat-coltext = text-030."Month

ls_fcat-seltext = text-030.

APPEND ls_fcat TO p_i_grid_fcat.

CLEAR ls_fcat.

ls_fcat-fieldname = 'YEAR'.

ls_fcat-ref_table = 'TYPE'.

ls_fcat-ref_field = 'C'.

ls_fcat-coltext = text-031."Year

ls_fcat-seltext = text-031.

APPEND ls_fcat TO p_i_grid_fcat.

CALL METHOD o_grid->set_table_for_first_display

EXPORTING

i_bypassing_buffer = space

is_variant = ws_f_grid_disvar

i_save = ws_c_grid_save

is_layout = struct_grid_lset

CHANGING

it_outtab = i_grid_outs[]

<b>it_fieldcatalog = i_grid_fcat[]</b>

it_sort = i_sort_fcat. " Period

Also Check this code.Another way using field symbols.

i_fieldcat TYPE lvc_t_fcat,

w_layout TYPE lvc_s_layo ,

w_variant TYPE disvariant.

FIELD-SYMBOLS : <lfs_fieldcat> TYPE lvc_s_fcat.

*Default display

LOOP AT p_fieldcat ASSIGNING <lfs_fieldcat>.

CASE <lfs_fieldcat>-fieldname.

WHEN 'GL_ACCT'.

<lfs_fieldcat>-coltext = text-050.

<lfs_fieldcat>-no_out = ' '.

<lfs_fieldcat>-scrtext_l = text-050.

<b> <lfs_fieldcat>-edit = 'X'.</b>

WHEN OTHERS.

ENDCASE.

ENDLOOP.

Hope this helps.

Former Member
0 Kudos

Hi,

Indeed you are modifying the internal table go_fieldcat with ls_fcat wherein in the first step you have refreshed the table. so the statement gets failed and raises a dump.

so do change your code to append the same or check before whether it has an entry adn then modify.

Regards,

Jagath

Message was edited by: Jagathguru Chandrasekharan

0 Kudos

Thanks a lot. My problem is solved

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Try the following.

data i_fieldcat TYPE lvc_t_fcat.

Field-symbols: <lfs_fieldcat> TYPE lvc_s_fcat.

LOOP AT i_fieldcat ASSIGNING <lfs_fieldcat>.

CASE <lfs_fieldcat>-fieldname.

WHEN 'EISBE'.

....

<lfs_fieldcat>-edit = 'X'.

...

ENDCASE.

ENDLOOP.