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

Toggle edit functionality of ALV Grid

Former Member
0 Likes
2,979

Hello there,

I have an ALV Grid on my Dynpro with a self-defined button and event handling. Now I want to change the "display<->edit" mode of the ALV with this button.

Can anybody help me, please?

Kind regards,

Daniel

1 ACCEPTED SOLUTION
Read only

Former Member
1,472

Hi ,

Check this Program .

ata: ok_code like sy-ucomm,
      save_ok like sy-ucomm,
      g_container type scrfname value 'BCALV_GRID_DEMO_0100_CONT1',
      g_grid  type ref to cl_gui_alv_grid,
      g_custom_container type ref to cl_gui_custom_container,
      gs_layout type lvc_s_layo,
      g_max type i value 100.

data: gt_outtab type table of sflight.

*---------------------------------------------------------------------*
*       MAIN                                                          *
*---------------------------------------------------------------------*
call screen 100 starting at 1 1..

*---------------------------------------------------------------------*
*       MODULE PBO OUTPUT                                             *
*---------------------------------------------------------------------*
module pbo output.
  set pf-status 'MAIN100'.
  set titlebar 'MAIN100'.
  if g_custom_container is initial.
    create object g_custom_container
           exporting container_name = g_container.
    create object g_grid
           exporting i_parent = g_custom_container.
*§1.Set status of all cells to editable using the layout structure.
    gs_layout-edit = 'X'.

    select * from sflight into table gt_outtab up to g_max rows.

    call method g_grid->set_table_for_first_display
         exporting i_structure_name = 'SFLIGHT'
                   is_layout        = gs_layout
         changing  it_outtab        = gt_outtab.
*§2.Use SET_READY_FOR_INPUT to allow editing initially.
*   (state "editable and ready for input").
    call method g_grid->set_ready_for_input
          exporting i_ready_for_input = 1.

  endif.
endmodule.
*---------------------------------------------------------------------*
*       MODULE PAI INPUT                                              *
*---------------------------------------------------------------------*
module pai input.
  save_ok = ok_code.
  clear ok_code.
  case save_ok.
    when 'EXIT'.
      perform exit_program.
    when 'SWITCH'.
      perform switch_edit_mode.
    when others.
*     do nothing
  endcase.
endmodule.
*---------------------------------------------------------------------*
*       FORM EXIT_PROGRAM                                             *
*---------------------------------------------------------------------*
form exit_program.
  leave program.
endform.
*&---------------------------------------------------------------------*
*&      Form  SWITCH_EDIT_MODE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form switch_edit_mode.
*§3.Use IS_READY_FOR_INPUT to fetch current substate of editable cells.
  if g_grid->is_ready_for_input( ) eq 0.
*§4.Use SET_READY_FOR_INPUT to switch between the substates.
    call method g_grid->set_ready_for_input
                     exporting i_ready_for_input = 1.
  else.
    call method g_grid->set_ready_for_input
                     exporting i_ready_for_input = 0.
  endif.
endform.                               " SWITCH_EDIT_MODE

For more information check the standard programs :BCALV_EDIT_*

Regards,

Raghav

3 REPLIES 3
Read only

Former Member
1,473

Hi ,

Check this Program .

ata: ok_code like sy-ucomm,
      save_ok like sy-ucomm,
      g_container type scrfname value 'BCALV_GRID_DEMO_0100_CONT1',
      g_grid  type ref to cl_gui_alv_grid,
      g_custom_container type ref to cl_gui_custom_container,
      gs_layout type lvc_s_layo,
      g_max type i value 100.

data: gt_outtab type table of sflight.

*---------------------------------------------------------------------*
*       MAIN                                                          *
*---------------------------------------------------------------------*
call screen 100 starting at 1 1..

*---------------------------------------------------------------------*
*       MODULE PBO OUTPUT                                             *
*---------------------------------------------------------------------*
module pbo output.
  set pf-status 'MAIN100'.
  set titlebar 'MAIN100'.
  if g_custom_container is initial.
    create object g_custom_container
           exporting container_name = g_container.
    create object g_grid
           exporting i_parent = g_custom_container.
*§1.Set status of all cells to editable using the layout structure.
    gs_layout-edit = 'X'.

    select * from sflight into table gt_outtab up to g_max rows.

    call method g_grid->set_table_for_first_display
         exporting i_structure_name = 'SFLIGHT'
                   is_layout        = gs_layout
         changing  it_outtab        = gt_outtab.
*§2.Use SET_READY_FOR_INPUT to allow editing initially.
*   (state "editable and ready for input").
    call method g_grid->set_ready_for_input
          exporting i_ready_for_input = 1.

  endif.
endmodule.
*---------------------------------------------------------------------*
*       MODULE PAI INPUT                                              *
*---------------------------------------------------------------------*
module pai input.
  save_ok = ok_code.
  clear ok_code.
  case save_ok.
    when 'EXIT'.
      perform exit_program.
    when 'SWITCH'.
      perform switch_edit_mode.
    when others.
*     do nothing
  endcase.
endmodule.
*---------------------------------------------------------------------*
*       FORM EXIT_PROGRAM                                             *
*---------------------------------------------------------------------*
form exit_program.
  leave program.
endform.
*&---------------------------------------------------------------------*
*&      Form  SWITCH_EDIT_MODE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form switch_edit_mode.
*§3.Use IS_READY_FOR_INPUT to fetch current substate of editable cells.
  if g_grid->is_ready_for_input( ) eq 0.
*§4.Use SET_READY_FOR_INPUT to switch between the substates.
    call method g_grid->set_ready_for_input
                     exporting i_ready_for_input = 1.
  else.
    call method g_grid->set_ready_for_input
                     exporting i_ready_for_input = 0.
  endif.
endform.                               " SWITCH_EDIT_MODE

For more information check the standard programs :BCALV_EDIT_*

Regards,

Raghav

Read only

Former Member
1,472

Hi,

check this demo program <b>BCALV_EDIT_02</b>

Regards

vijay

Read only

0 Likes
1,472

Thx a lot for your helpful answers!

Regards,

Daniel