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

Making a cell editable without selecting the cell using CL_GUI_ALV_GRID

Former Member
0 Likes
909

Hi all,

I am creating an alv grid by using CL_GUI_ALV_GRID. There are five columns and multiple rows in my grid. The whole grid is in disabled mode. My requirement is this that whenever user selects more than one row, only for the selected rows the cells in column 3 will get enabled for editing. For example if the user selects first and second row, then only cell (row1, column3) and cell (row2, column3) should get enabled for editing.

Please reply asap. It's urgent.

Thanks in advance.

Ritu

Hi all,

I am creating an alv grid by using CL_GUI_ALV_GRID. There are five columns and multiple rows in my grid. The whole grid is in disabled mode. My requirement is this that whenever user selects more than one row, only for the selected rows the cells in column 3 will get enabled for editing. For example if the user selects first and second row, then only cell (row1, column3) and cell (row2, column3) should get enabled for editing.

Please reply asap. It's urgent.

Thanks in advance.

Ritu

4 REPLIES 4
Read only

Sm1tje
Active Contributor
0 Likes
808

wel first, you will have to determine which rows are selected using method get_selected_rows and next, make these cells editable.

For setting cells to editable check sample report BCALV_EDIT_02.

Read only

Former Member
0 Likes
808

Hi Micky,

Thanks for replying. I have tried my best and tried every demo program but they are not fulfilling my requirement. I am able to trace rows but unable to trace the cell for selected rows and column2. Can you please help me out?

thanks in advance.

Ritu

Read only

Former Member
0 Likes
808

Hi Ritu,

Try the below stpes.

1. Include the internal table at the end of your internal table.

type: begin of type ty_out,

  • list of fields,

cellstyles TYPE lvc_t_styl,

end of type ty_out.

data: gt_out type standard table of ty_out,

ls_stylerow type lvc_s_style.

2. Select the rows which are to be editable.

3. Create a button in ALV Toolbar (without interact the system we can't get selected rows, so that create the button in the toolbar).

4. Once the user click the button 'Change' , call the method 'GET_SELECTED_CELLS', it will return the row and column number.

5. Read the values from your final internal table based on the row number (step4), add the below style in the style internal table.

ls_stylerow-fieldname = 'COLUMN3'.

ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled.

append ls_stylerow into gt_out-cellstyles.

6. Refresh the ALV grid.

Example Programs,

BCALV_GRID_EDIT.

loop at gt_sflight1.

clear gt_sflight.

clear ls_cell.

move-corresponding gt_sflight1 to gt_sflight.

if p_cedit = 'X'.

if sy-tabix = 7.

ls_cell-style = cl_gui_alv_grid=>mc_style_disabled.

append ls_cell to gt_sflight-cell.

endif.

if sy-tabix = 9.

ls_cell-style = cl_gui_alv_grid=>mc_style_enabled.

ls_cell-maxlen = 4.

ls_cell-fieldname = 'PLANETYPE'.

append ls_cell to gt_sflight-cell.

endif.

if sy-tabix = 11.

ls_cell-style = cl_gui_alv_grid=>mc_style_enabled.

ls_cell-maxlen = 4.

ls_cell-fieldname = 'CARRNAME'.

append ls_cell to gt_sflight-cell.

endif.

endif.

append gt_sflight.

endloop.

Pls reward if it is helpful.

Regards,

Boobalan Suburaj.

Read only

Former Member
0 Likes
808

Try the below program

**********Declarations*******************

TYPE-POOLS: slis.

TYPES: BEGIN OF gty_vbak,

vbeln TYPE vbak-vbeln,

erdat TYPE vbak-erdat,

waerk TYPE vbak-waerk,

netwr TYPE vbak-netwr,

fstyle TYPE lvc_t_styl,

END OF gty_vbak.

DATA: gt_vbak TYPE STANDARD TABLE OF gty_vbak,

gs_vbak TYPE gty_vbak,

gt_fcat TYPE lvc_t_fcat,

gs_fcat TYPE lvc_s_fcat,

gc_container TYPE REF TO cl_gui_custom_container,

gc_alv_grid TYPE REF TO cl_gui_alv_grid,

gs_layout TYPE lvc_s_layo.

  • Defining a macro for field catalogue

DEFINE fcatmac.

gs_fcat-col_pos = &1.

gs_fcat-fieldname = &2.

gs_fcat-tabname = &3.

gs_fcat-coltext = &4.

gs_fcat-outputlen = &5.

gs_fcat-edit = &6.

append gs_fcat to gt_fcat.

clear gs_fcat.

END-OF-DEFINITION.

  • Selection Screen

SELECT-OPTIONS s_erdat FOR gs_vbak-erdat.

START-OF-SELECTION.

PERFORM select_data.

END-OF-SELECTION.

CALL SCREEN 100.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


module STATUS_0100 output.

SET PF-STATUS 'MENU1'.

SET TITLEBAR 'TITLE01'.

IF gc_container IS INITIAL.

CREATE OBJECT gc_container

EXPORTING

container_name = 'CL_CONTAINER'

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

others = 6.

IF sy-subrc <> 0.

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

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

ENDIF.

CREATE OBJECT gc_alv_grid

EXPORTING

i_parent = gc_container

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

others = 5.

IF sy-subrc <> 0.

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

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

ENDIF.

gs_layout-stylefname = 'FSTYLE'.

fcatmac '1' 'VBELN' 'GT_VBAK' text-001 '10' ' '.

fcatmac '2' 'ERDAT' 'GT_VBAK' text-002 '10' ' '.

fcatmac '3' 'WAERK' 'GT_VBAK' text-003 '5' ' '.

fcatmac '4' 'NETWR' 'GT_VBAK' text-004 '15' 'X'.

CALL METHOD gc_alv_grid->set_table_for_first_display

EXPORTING

is_layout = gs_layout

CHANGING

it_outtab = gt_vbak[]

it_fieldcatalog = gt_fcat

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

others = 4.

IF sy-subrc <> 0.

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

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

ENDIF.

ENDIF.

endmodule. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


module USER_COMMAND_0100 input.

CASE sy-ucomm.

WHEN 'BACK' OR 'EXIT'.

LEAVE TO SCREEN 0.

WHEN OTHERS.

ENDCASE.

endmodule. " USER_COMMAND_0100 INPUT

&----


*& Form SELECT_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form SELECT_DATA .

*Data Selection

SELECT vbeln erdat waerk netwr FROM vbak

INTO CORRESPONDING FIELDS OF TABLE gt_vbak

WHERE erdat IN s_erdat.

IF sy-subrc = 0.

SORT gt_vbak BY vbeln.

ENDIF.

DATA: ls_stylerow TYPE lvc_s_styl,

ls_styletab TYPE lvc_t_styl,

lv_index TYPE i.

LOOP AT gt_vbak INTO gs_vbak.

IF gs_vbak-netwr <> 11.

ls_stylerow-fieldname = 'VBELN'.

ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.

ls_stylerow-fieldname = 'ERDAT'.

ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled.

ls_stylerow-fieldname = 'WAERK'.

ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.

ls_stylerow-fieldname = 'NETWR'.

ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.

APPEND ls_stylerow TO gs_vbak-fstyle.

MODIFY gt_vbak FROM gs_vbak.

ENDIF.

ENDLOOP.

endform. " SELECT_DATA

Reward if useful.......