on 10-11-2005 2:52 AM
Hi,
I wanna to have certain cells in my ALV grid display are ready for input.
I am using FM 'REUSE_ALV_GRID_DISPLAY'.
Appreciate for any help.
Many thanks
Alia
HI,
i am sending you a complete woking code ..you just run it and see the option in the output screen..select any of the check box and hit F8..and there it is.. you can modify the code to meet yur need
Reward point if it satisfy your needs..
REPORT ZOBJK1 .
*****************************************************************
Use of colours in ALV grid (cell, line and column) *
*****************************************************************
Table
tables : mara.
Type
types : begin of ty_mara,
matnr like mara-matnr,
matkl like mara-matkl,
counter(4) type n,
free_text(15) type c,
color_line(4) type c, " Line color
color_cell type lvc_t_scol, " Cell color
end of ty_mara.
Structures
data : wa_mara type ty_mara,
wa_fieldcat type lvc_s_fcat,
is_layout type lvc_s_layo,
wa_color type lvc_s_scol.
Internal table
data : it_mara type standard table of ty_mara,
it_fieldcat type standard table of lvc_s_fcat,
it_color type table of lvc_s_scol.
Variables
data : okcode like sy-ucomm,
w_alv_grid type ref to cl_gui_alv_grid,
w_docking_container type ref to cl_gui_docking_container.
parameters : p_column as checkbox,
p_line as checkbox,
p_cell as checkbox.
at selection-screen output.
perform get_data.
perform fill_catalog.
if w_docking_container is initial.
perform create_objects.
endif.
&----
*& Form create_objects
&----
form create_objects.
create object w_docking_container
exporting
ratio = 40
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
create object w_alv_grid
exporting
i_parent = w_docking_container.
Field that identify color line in internal table
move 'COLOR_LINE' to is_layout-info_fname.
Field that identify cell color in inetrnal table
move 'COLOR_CELL' to is_layout-ctab_fname.
call method w_alv_grid->set_table_for_first_display
exporting
is_layout = is_layout
changing
it_outtab = it_mara
it_fieldcatalog = it_fieldcat
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4.
endform.
&----
*& Form get_data
&----
form get_data.
select * from mara up to 5 rows.
clear : wa_mara-color_line, wa_mara-color_cell.
move-corresponding mara to wa_mara.
add 1 to wa_mara-counter.
move 'Blabla' to wa_mara-free_text.
if wa_mara-counter = '0002'
and p_line = 'X'.
Color line
move 'C410' to wa_mara-color_line.
elseif wa_mara-counter = '0004'
and p_cell = 'X'.
Color cell
move 'FREE_TEXT' to wa_color-fname.
move '6' to wa_color-color-col.
move '1' to wa_color-color-int.
move '1' to wa_color-color-inv.
append wa_color to it_color.
wa_mara-color_cell[] = it_color[].
endif.
append wa_mara to it_mara.
endselect.
endform.
&----
*& Form fill_catalog
&----
form fill_catalog.
*****************************************************************
Colour code : *
Colour is a 4-char field where : *
- 1st char = C (color property) *
- 2nd char = color code (from 0 to 7) *
0 = background color *
1 = blue *
2 = gray *
3 = yellow *
4 = blue/gray *
5 = green *
6 = red *
7 = orange *
- 3rd char = intensified (0=off, 1=on) *
- 4th char = inverse display (0=off, 1=on) *
*
Colour overwriting priority : *
1. Line *
2. Cell *
3. Column *
*****************************************************************
data : w_position type i value '1'.
clear wa_fieldcat.
move w_position to wa_fieldcat-col_pos.
move 'MATNR' to wa_fieldcat-fieldname.
move 'MARA' to wa_fieldcat-ref_table.
move 'MATNR' to wa_fieldcat-ref_field.
append wa_fieldcat to it_fieldcat.
add 1 to w_position.
clear wa_fieldcat.
move w_position to wa_fieldcat-col_pos.
move 'MATKL' to wa_fieldcat-fieldname.
move 'MARA' to wa_fieldcat-ref_table.
move 'MATKL' to wa_fieldcat-ref_field.
Color column
if p_column = 'X'.
move 'C610' to wa_fieldcat-emphasize.
endif.
append wa_fieldcat to it_fieldcat.
add 1 to w_position.
clear wa_fieldcat.
move w_position to wa_fieldcat-col_pos.
move 'COUNTER' to wa_fieldcat-fieldname.
move 'N' to wa_fieldcat-inttype.
move '4' to wa_fieldcat-intlen.
move 'Counter' to wa_fieldcat-coltext.
append wa_fieldcat to it_fieldcat.
add 1 to w_position.
clear wa_fieldcat.
move w_position to wa_fieldcat-col_pos.
move 'FREE_TEXT' to wa_fieldcat-fieldname.
move 'C' to wa_fieldcat-inttype.
move '20' to wa_fieldcat-intlen.
move 'Text' to wa_fieldcat-coltext.
append wa_fieldcat to it_fieldcat.
endform.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi alia,
this may help you.
PROGRAM BCALV_EDIT_02.
*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
* Purpose:
* ~~~~~~~~
* This report illustrates how to set chosen cells of an
* ALV Grid Control editable. (See BCALV_EDIT_01 for an overview
* of possible states).
* Remark: You may set the states for chosen columns using field
* EDIT of the fieldcatalog, see BCALV_EDIT_03.
*-----------------------------------------------------------------
* To check program behavior
* ~~~~~~~~~~~~~~~~~~~~~~~~~
* Switch to the state editable activated. You may then change the
* price of flights where the capacity of a plane is greater or equal
* than 300 seats.
*-----------------------------------------------------------------
* Essential steps (search for '§')
* ~~~~~~~~~~~~~~~
* 1.Extend your output table for a field, e.g., CELLTAB, that holds
* information about the edit status of each cell for the
* corresponding row (the table type is SORTED!).
* 2.After selecting data, set edit status for each row in a loop
* according to field SEATSMAX.
* 2a.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_ENABLED to set a cell
* to status "editable".
* 2b.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_DISABLED to set a cell
* to status "non-editable".
* 2c.Copy your celltab to the celltab of the current row of gt_outtab.
* 3.Provide the fieldname of the celltab field by using field
* STYLEFNAME of the layout structure.
*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
DATA: ok_code LIKE sy-ucomm,
save_ok like sy-ucomm,
g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
grid1 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.
*§1.Extend your output table for a field, e.g., CELLTAB, that holds
* information about the edit status of each cell for the
* corresponding row (the table type is SORTED!).
DATA: BEGIN OF gt_outtab occurs 0. "with header line
include structure sflight.
DATA: celltab type LVC_T_STYL.
DATA: END OF gt_outtab.
*---------------------------------------------------------------------*
* MAIN *
*---------------------------------------------------------------------*
CALL SCREEN 100.
*---------------------------------------------------------------------*
* 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 grid1
EXPORTING i_parent = g_custom_container.
PERFORM select_data_and_init_style.
*§3.Provide the fieldname of the celltab field by using field
* STYLEFNAME of the layout structure.
gs_layout-stylefname = 'CELLTAB'.
* set substate of editable cells to deactivated
CALL METHOD grid1->set_ready_for_input
EXPORTING i_ready_for_input = 0.
CALL METHOD grid1->set_table_for_first_display
EXPORTING i_structure_name = 'SFLIGHT'
is_layout = gs_layout
CHANGING it_outtab = gt_outtab[].
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 SELECT_DATA_AND_INIT_STYLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM select_data_and_init_style.
DATA: lt_sflight TYPE TABLE OF sflight WITH HEADER LINE,
lt_celltab TYPE lvc_t_styl,
l_index TYPE i.
SELECT * FROM sflight INTO TABLE lt_sflight UP TO g_max ROWS.
* move corresponding fields from lt_sflight to gt_outtab
LOOP AT lt_sflight.
MOVE-CORRESPONDING lt_sflight TO gt_outtab.
APPEND gt_outtab.
ENDLOOP.
*§2.After selecting data, set edit status for each row in a loop
* according to field SEATSMAX.
LOOP AT gt_outtab.
l_index = sy-tabix.
refresh lt_celltab.
if gt_outtab-seatsmax ge 300.
perform fill_celltab using 'RW'
changing lt_celltab.
else.
perform fill_celltab using 'RO'
changing lt_celltab.
endif.
*§2c.Copy your celltab to the celltab of the current row of gt_outtab.
INSERT LINES OF lt_celltab INTO TABLE gt_outtab-celltab.
MODIFY gt_outtab INDEX l_index.
ENDLOOP.
ENDFORM. " SELECT_DATA_AND_INIT_STYLE
*&---------------------------------------------------------------------*
*& Form FILL_CELLTAB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_PT_CELLTAB text
*----------------------------------------------------------------------*
FORM fill_celltab using value(p_mode)
CHANGING pt_celltab TYPE lvc_t_styl.
DATA: ls_celltab TYPE lvc_s_styl,
l_mode type raw4.
* This forms sets the style of column 'PRICE' editable
* according to 'p_mode' and the rest to read only either way.
IF p_mode EQ 'RW'.
*§2a.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_ENABLED to set a cell
* to status "editable".
l_mode = cl_gui_alv_grid=>mc_style_enabled.
ELSE. "p_mode eq 'RO'
*§2b.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_DISABLED to set a cell
* to status "non-editable".
l_mode = cl_gui_alv_grid=>mc_style_disabled.
ENDIF.
ls_celltab-fieldname = 'CARRID'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'CONNID'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'FLDATE'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'PRICE'.
ls_celltab-style = l_mode.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'CURRENCY'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'PLANETYPE'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'SEATSMAX'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'SEATSOCC'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'PAYMENTSUM'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ENDFORM. " FILL_CELLTAB
*&---------------------------------------------------------------------*
*& Form SWITCH_EDIT_MODE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM switch_edit_mode.
IF grid1->is_ready_for_input( ) eq 0.
* set edit enabled cells ready for input
CALL METHOD grid1->set_ready_for_input
EXPORTING i_ready_for_input = 1.
ELSE.
* lock edit enabled cells against input
CALL METHOD grid1->set_ready_for_input
EXPORTING i_ready_for_input = 0.
ENDIF.
ENDFORM. " SWITCH_EDIT_MODE
regards,
venu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
in the field catalog set edit = 'X' for the particular field
like fieldcat-edit = 'X'
cheers,
sasi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
U can make the changes in fieldcatalog
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
<b> fieldcatalog-edit = 'X'.</b>
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
Similarly u can do for the needed column.
Kindly reward and close the thread if ur problem got solved.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.