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

Setting one grid column editable

Former Member
0 Likes
630

Hi there. Could You tell me how can I set only one/few grid columns editable whilst others not editable?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
564

Hi,

you can do tat.

while creating fieldcat u just give fcat-edit = 'X'. for that perticular column.

rgds,

bharat.

3 REPLIES 3
Read only

Former Member
0 Likes
565

Hi,

you can do tat.

while creating fieldcat u just give fcat-edit = 'X'. for that perticular column.

rgds,

bharat.

Read only

Former Member
0 Likes
564

Hi,

chk this program...

report zalv_color_display_edit.

type-pools: slis.

tables : zcust_master2.

*----


  • INTERNAL TABLE DECLARATION

*----


types : begin of wi_zcust_master2,

zcustid like zcust_master2-zcustid,

zcustname like zcust_master2-zcustname,

zaddr like zcust_master2-zaddr,

zcity like zcust_master2-zcity,

zstate like zcust_master2-zstate,

zcountry like zcust_master2-zcountry,

zphone like zcust_master2-zphone,

zemail like zcust_master2-zemail,

zfax like zcust_master2-zfax,

zstat like zcust_master2-zstat,

field_style type lvc_t_styl,

end of wi_zcust_master2.

data: it_wi_zcust_master2 type standard table of wi_zcust_master2

initial size 0,

wa_zcust_master2 type wi_zcust_master2.

*----


*ALV data declarations

*----


data: fieldcatalog type slis_t_fieldcat_alv with header line.

data: it_fieldcat type lvc_t_fcat, "slis_t_fieldcat_alv WITH HEADER

line,

wa_fieldcat type lvc_s_fcat,

gd_tab_group type slis_t_sp_group_alv,

gd_layout type lvc_s_layo, "slis_layout_alv,

gd_repid like sy-repid.

************************************************************************

start-of-selection.

perform data_retrieval.

perform set_specific_field_attributes.

perform build_fieldcatalog.

perform build_layout.

perform display_alv_report.

&----


*& Form BUILD_FIELDCATALOG

&----


  • Build Fieldcatalog for ALV Report

----


form build_fieldcatalog.

wa_fieldcat-fieldname = 'ZCUSTID'.

wa_fieldcat-scrtext_m = 'CUSTOMER ID'.

wa_fieldcat-col_pos = 0.

wa_fieldcat-outputlen = 10.

append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'ZCUSTNAME'.

wa_fieldcat-scrtext_m = 'CUSTOMER NAME'.

wa_fieldcat-col_pos = 1.

append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'ZADDR'.

wa_fieldcat-scrtext_m = 'ADDRESS'.

wa_fieldcat-col_pos = 2.

append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'ZCITY'.

wa_fieldcat-scrtext_m = 'CITY'.

wa_fieldcat-col_pos = 3.

append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'ZSTATE'.

wa_fieldcat-scrtext_m = 'STATE'.

wa_fieldcat-col_pos = 4.

append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'ZCOUNTRY'.

wa_fieldcat-scrtext_m = 'COUNTRY'.

wa_fieldcat-col_pos = 5.

append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'ZPHONE'.

wa_fieldcat-scrtext_m = 'PHONE NUMBER'.

wa_fieldcat-col_pos = 6.

  • wa_fieldcat-edit = 'X'. "sets whole column to be editable

append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'ZEMAIL'.

wa_fieldcat-scrtext_m = 'EMAIL'.

wa_fieldcat-edit = 'X'. "sets whole column to be editable wa_fieldcat-col_pos = 7.

wa_fieldcat-outputlen = 15.

wa_fieldcat-datatype = 'CURR'.

append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'ZFAX'.

wa_fieldcat-scrtext_m = 'FAX'.

wa_fieldcat-col_pos = 8.

wa_fieldcat-edit = 'X'. "sets whole column to be editable

append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'ZSTAT'.

wa_fieldcat-scrtext_m = 'STATUS'.

wa_fieldcat-col_pos = 9.

append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.

endform. " BUILD_FIELDCATALOG

&----


*& Form BUILD_LAYOUT

&----


  • Build layout for ALV grid report

----


form build_layout.

  • Set layout field for field attributes(i.e. input/output)

gd_layout-stylefname = 'FIELD_STYLE'.

gd_layout-zebra = 'X'.

endform. " BUILD_LAYOUT

&----


*& Form DISPLAY_ALV_REPORT

&----


  • Display report using ALV grid

----


form display_alv_report.

gd_repid = sy-repid.

*----


  • call function 'REUSE_ALV_GRID_DISPLAY'

*----


call function 'REUSE_ALV_GRID_DISPLAY_LVC'

exporting

i_callback_program = gd_repid

is_layout_lvc = gd_layout

it_fieldcat_lvc = it_fieldcat

i_save = 'X'

tables

t_outtab = it_wi_zcust_master2

exceptions

program_error = 1

others = 2.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

endform. " DISPLAY_ALV_REPORT

*&----


*

*& Form DATA_RETRIEVAL

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

form data_retrieval .

data: ld_color(1) type c.

select zcustid zcustname zaddr zcity zstate zcountry zphone zemail

zfax zstat up to 10 rows from zcust_master2 into corresponding fields of

table it_wi_zcust_master2.

endform. "data_retrieval

&----


*& Form set_specific_field_attributes

&----


  • populate FIELD_STYLE table with specific field attributes

----


form set_specific_field_attributes .

data ls_stylerow type lvc_s_styl .

data lt_styletab type lvc_t_styl .

  • Populate style variable (FIELD_STYLE) with style properties

  • The following code sets it to be disabled(display only) if 'ZFAX'

  • is NOT INITIAL.

loop at it_wi_zcust_master2 into wa_zcust_master2.

if wa_zcust_master2-zfax is not initial.

ls_stylerow-fieldname = 'ZFAX' .

ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.

"set field to disabled

append ls_stylerow to wa_zcust_master2-field_style.

modify it_wi_zcust_master2 from wa_zcust_master2.

endif.

endloop.

endform. "set_specific_field_attributes

REagrds,

Arunsri

Read only

Former Member
0 Likes
564

Hi,

BCALV_TEST_GRID_EDITABLE.

Thanks,

Sriram Ponna.