‎2006 Jun 08 8:44 AM
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
‎2006 Jun 08 8:49 AM
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
‎2006 Jun 08 8:49 AM
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
‎2006 Jun 08 8:49 AM
‎2006 Jun 08 8:56 AM