07-22-2005 12:59 PM
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.
07-22-2005 1:07 PM
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
07-22-2005 1:05 PM
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.
07-22-2005 1:07 PM
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
07-22-2005 1:14 PM
07-22-2005 1:08 PM
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.