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: 

ALV Control: Making some columns editable in a new entry row

0 Kudos
2,246

Hi,

I have an alv grid with some of the columns editable. When I click on New entry button, it brings up an empty row which is editable. But I need only some of the fields in edit mode. The remaining fields I would like to calculate from the other fields.

I tried to take control using the event "after_user_command". When I click on Refresh button I can get the control goes into the event handler but for the new entry button the control will never go into the event handler.

I would also appreciate if someone can tell me how to debug the standard functions on the ALV control.

Thanks,

Kishore.

Message was edited by: Kishore Moosani

Message was edited by: Kishore Moosani

Message was edited by: Kishore Moosani

9 REPLIES 9

ssimsekler
Active Contributor
0 Kudos
1,126

Hi Kishore

You can achieve this by adding a table-type column into your data table and telling ALV Grid control to read style data by entering the name of style-table to the field "stylefname" of the layout structure.

Doing this way you can switch between editable and non-editable modes by changing your data table according to the conditions and refreshing ALV Grid control.

<u>e.g.</u>

FORM adjust_editables USING pt_list LIKE gt_list[] .

  DATA ls_listrow LIKE LINE OF pt_list .
  DATA ls_stylerow TYPE lvc_s_styl .
  DATA lt_styletab TYPE lvc_t_styl .

  LOOP AT pt_list INTO ls_listrow .

    IF ls_listrow-carrid = 'XY' .
      ls_stylerow-fieldname = 'SEATSMAX' .
      ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled .
      APPEND ls_stylerow TO lt_styletab .
    ENDIF .
    IF ls_listrow-connid = '02' .
      ls_stylerow-fieldname = 'PLANETYPE' .
      ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled .
      APPEND ls_stylerow TO lt_styletab .
    ENDIF .

    INSERT LINES OF lt_styletab INTO ls_listrow-cellstyles .
    MODIFY pt_list FROM ls_listrow .
  ENDLOOP .
ENDFORM .

For more information, you can inspect <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/an%20easy%20reference%20for%20alv%20grid%20control.pdf">the ALV Grid Control tutorial</a> published at SDN.

*--Serdar

0 Kudos
1,126

Hi,

Thanks for the reply. But I am passing the style table along with the data table. It only works for the records already in the table. But if I click on new entry, there will be no style record corresponding to that and I am not able to get the control into my program to gray out some of the columns.

Thanks,

Kishore.

0 Kudos
1,126

Will NO_EDIT in field catalog be of any help here ?

Regards,

Subramanian V.

0 Kudos
1,126

Hi Subramanian,

There is no 'NO_EDIT' field in field catalog. There is a field called 'EDIT' but this is not serving the purpose.

Thanks,

Kishore.

0 Kudos
1,126

Hi Kishore

I guess, you may catch it at the event <b>"data_changed"</b> and/or <b>"data_changed_finished"</b>. At the latter one you can fill your style data I think. Try and inform us about the result.

*--Serdar

0 Kudos
1,126

It is not caught in data_changed or data_change_finished events.

Thanks,

Kishore.

0 Kudos
1,126

Hi Kishore

Why don't you make those columns noneditable at all? Then what you need is to make them editable at solidly existing rows.

*--Serdar

0 Kudos
1,126

Hi Serdar,

How can I make the columns non-editable? The only place I can think of is field catalog and the I am not populating the EDIT field anyway.

Thanks,

Kishore.

0 Kudos
1,126

Hi Kishore

While filling your style tab, check whether a key field (or whole line) is filled.

<u><b>e.g.</b></u>

IF NOT <field_1> IS INITIAL .
<style_field_of_data_tab> = cl_gui_alv_grid=>...disabled.
ELSE .
<style_field_of_data_tab> = cl_gui_alv_grid=>...ensabled.
ENDIF .

And at the field catalog pass space to field "edit" for the row of those fields.

Hope I could explain...

*--Serdar