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: 

ALV Grid Insert

vanessa_blount
Discoverer
0 Kudos

Hello,

I have an ALV grid that I am using to maintain a table. I would like to protect the key fields from update for existing records, but just un-protect them (allow edit) when a new row is inserted. I used LVC_FIELDCATALOG_MERGE to create my catalog. I tried allowing edit on the catalog and on the layout but either way I seem to get 'all or nothing' in that I can always edit the field or I cannot even edit it for new lines. I would have hoped this functionality would have been standard for fieldcatalog merge.

Thanks in advance....

Regards, Vanessa.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi ,

Welcome To SDN community

You would have to control the editablity at cell by cell basis n not based on column.

Use field for LVC_T_STYLE.

you can Enable and disable the new rows and old rows respectively.

Hope that helps..

Regards,

Tanveer.

Please mark helpful answers by clicking on the star

3 REPLIES 3

Former Member
0 Kudos

Hi,

Basically you want to control the EDIT functionality at a CELL level. Here is what you need to do.

1. Add a field call STYLE TYPE LVC_T_STYLE to your data table.

2. This is a nested internal table.

3. For each row, specify the STYLE (MC_STYLE_ENABLED / MC_STYLE_DISABLED - <i> These are attributes of the class CL_GUI_ALV_GRID </i>) for each column in this nested table. That mean this table will 5 rows (assuming 5 columns in the table) for each row in the main table.

4. This will enable edit at a cell level.

<b>

Set the EDIT field of the field catalog to X for all the fields and disable it via the individual cells.

</b>

Regards,

Ravi

Note - Please Mark the helpful answers

Message was edited by: Ravikumar Allampallam

0 Kudos

Hi Ravi,

Thanks very much for the reply. It pointed me in the right direction.

Relevant code changes that I made are below. Problem is now solved.

Best Regards,

Vanessa.

DATA: BEGIN OF outtab OCCURS 0.

INCLUDE STRUCTURE zsdxref.

data: style type lvc_t_styl.

DATA: END OF outtab.

data: style_ln like line of OUTTAB-STYLE.

form build_fieldcat.

      • build the field catalogue

  • Create field catalogue from stucture

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = 'ZSDXREF'

CHANGING

ct_fieldcat = i_catalog[].

  • Change catalog entry for changeable fields.

LOOP AT i_catalog.

IF i_catalog-fieldname = 'ORIG_MFR'

OR i_catalog-fieldname = 'ORIG_IDNLF'

  • all fields enabled for edit...

OR i_catalog-fieldname = 'TECH_DESC'

OR i_catalog-fieldname = 'XREF_TYPE'

OR i_catalog-fieldname = 'LOEVM'.

i_catalog-edit = 'X'.

MODIFY i_catalog.

ENDIF.

ENDLOOP.

endform. " build_fieldcat

MODULE pbo_grid_display OUTPUT.

*tell the layout which outtab field is the style field.

wa_layout-stylefname = 'STYLE'.

  • Key fields of existing rows disabled for edit. In practice new rows will then

  • be available to edit as per the catalog setting.

*NB: field names need to be in alphabetical order.

LOOP AT outtab.

REFRESH outtab-style.

CLEAR STYLE_ln.

style_ln-fieldname = 'ORIG_IDNLF'.

style_ln-style = cl_gui_alv_grid=>mc_style_disabled.

APPEND style_ln TO outtab-style.

CLEAR STYLE_ln.

style_ln-fieldname = 'ORIG_MFR'.

style_ln-style = cl_gui_alv_grid=>mc_style_disabled.

APPEND style_ln TO outtab-style.

MODIFY outtab.

ENDLOOP.

CALL METHOD grid1->set_table_for_first_display

EXPORTING

is_layout = wa_layout

it_toolbar_excluding = i_toolbar_excl

CHANGING

it_outtab = outtab[]

it_fieldcatalog = i_catalog[]

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4

ENDMODULE. " pbo_grid_display OUTPUT

Former Member
0 Kudos

Hi ,

Welcome To SDN community

You would have to control the editablity at cell by cell basis n not based on column.

Use field for LVC_T_STYLE.

you can Enable and disable the new rows and old rows respectively.

Hope that helps..

Regards,

Tanveer.

Please mark helpful answers by clicking on the star