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
971

hi all,

i am using editable alv and i want that the output that comes in the editable alv should be in a way that none of the fields are editable but when i add a new row to this alv the all the fields become editable except 1 field . how can i do ?this please help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
861

Hi Arpit,

See since you want the new added row to be editable the fieldcatalog for all the columns except the one which should be non-editable must be set to editable that is wa_fieldcat-edit = 'X'

Next,

In the structure of your internal table put a field for Celltab as follows,

celltab type lvc_t_styl,

and in the build catalog write the following,

form build_fieldcat changing IT_fieldcat type lvc_t_fcat.

fs_layout-stylefname = 'CELLTAB'. "----> this is very important

perform set_data_change changing it_data[]. Now in this form set the property(disable) of all the rows which are in the internal table

So in the output you will get all the rows in non-editable mode

CALL METHOD grid1->set_table_for_first_display

EXPORTING

is_layout = fs_layout we have passed the above layout to ALV

is_variant = ls_variant

i_save = 'A'

i_default = 'X'

it_toolbar_excluding = lt_exclude

CHANGING

it_outtab = it_data

it_fieldcatalog = it_fieldcat.

endform.

form SET_DATA_CHANGE changing p_it_data LIKE IT_DATA.

loop at p_it_data into ls_outtab.

l_mode = cl_gui_alv_grid=>mc_style_disabled.

ls_celltab-fieldname = 'MATNR'.

ls_celltab-style = l_mode.

INSERT ls_celltab into table p_lt_celltab.

endloop.

endform.

so the row in your internal table becomes un-editable

and when you add a new row since you fieldcatalog are in edit mode and the new entry is not in the internal table the new row become editable.

Let me know if you want further help.

Hope it helps you,

Regards,

Abhijit G. Bokar

5 REPLIES 5
Read only

Sm1tje
Active Contributor
0 Likes
861

Have a look at demo report BCALV_EDIT_04.

Read only

former_member404244
Active Contributor
0 Likes
861

Hi,

While preparing fieldcatalog don't sepcify the parameter (FILEDCATLOG-EXIT = 'X') for the field you don't want to be editable...For rest of the fields pass it as FILEDCATLOG-EXIT = 'X'.

Regards,

Nagaraj

Read only

Former Member
0 Likes
861

Hello Arpit ,

use layout to achieve it ..

*--- Layout structure

DATA gs_layout TYPE lvc_s_layo .

  • set the layout

gs_layout-stylefname = 'CELLTAB'.

inyour internal tbale put column with name CELLTAB .

TYPES: BEGIN OF it_list,

f1 type char,

f2 type char ,

celltab TYPE LVC_T_STYL,

END OF it_list.

DATA: gt_list TYPE STANDARD TABLE OF it_list,

DATA LS_CELLTAB TYPE LVC_S_STYL.

DESCRIBE TABLE gt_list LINES lines.

pass filed name ...

ls_CELLTAB-FIELDNAME = 'f1' .

pass the style (Disable)

ls_CELLTAB-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.

APPEND ls_CELLTAB TO WA_LIST-CELLTAB.

pass filed name ...

ls_CELLTAB-FIELDNAME = 'f2' .

pass the style (Enable)

ls_CELLTAB-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.

APPEND ls_CELLTAB TO WA_LIST-CELLTAB.

modify internal table from WA_LIST index lines TRANSPORTING celltab.

Read only

Former Member
0 Likes
861

hello Arpit ,

the above code can make your as many desired coloumn as you want of last row editable editable or non edittable...

thanks and Regards...

Priyank

Read only

Former Member
0 Likes
862

Hi Arpit,

See since you want the new added row to be editable the fieldcatalog for all the columns except the one which should be non-editable must be set to editable that is wa_fieldcat-edit = 'X'

Next,

In the structure of your internal table put a field for Celltab as follows,

celltab type lvc_t_styl,

and in the build catalog write the following,

form build_fieldcat changing IT_fieldcat type lvc_t_fcat.

fs_layout-stylefname = 'CELLTAB'. "----> this is very important

perform set_data_change changing it_data[]. Now in this form set the property(disable) of all the rows which are in the internal table

So in the output you will get all the rows in non-editable mode

CALL METHOD grid1->set_table_for_first_display

EXPORTING

is_layout = fs_layout we have passed the above layout to ALV

is_variant = ls_variant

i_save = 'A'

i_default = 'X'

it_toolbar_excluding = lt_exclude

CHANGING

it_outtab = it_data

it_fieldcatalog = it_fieldcat.

endform.

form SET_DATA_CHANGE changing p_it_data LIKE IT_DATA.

loop at p_it_data into ls_outtab.

l_mode = cl_gui_alv_grid=>mc_style_disabled.

ls_celltab-fieldname = 'MATNR'.

ls_celltab-style = l_mode.

INSERT ls_celltab into table p_lt_celltab.

endloop.

endform.

so the row in your internal table becomes un-editable

and when you add a new row since you fieldcatalog are in edit mode and the new entry is not in the internal table the new row become editable.

Let me know if you want further help.

Hope it helps you,

Regards,

Abhijit G. Bokar