2008 Aug 28 9:50 PM
Hi,
I did the same thing, what you mentioned here except method name -
i have used - mc_style_disabled since i need to disable in alv for certain field values and others should be enable.
I am not sure where exactly i am doing wrong. As you said i did everything... apart from that do i need to do anything else...please suggest me.
( gw_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.)
Thanks
-
Orrginal messge -
It is possible in Class ALV (OOPS).
Sample code:
LOOP AT itab INTO wa.
IF wa-field1 = 'X'. "condition
wa_stylerow-fieldname = 'FIELD1'.
wa_stylerow-style = cl_gui_alv_grid=>mc_style_enabled.
APPEND wa_stylerow TO wa-it_styletab.
CLEAR wa_stylerow.
ENDIF.
MODIFY itab FROM wa
TRANSPORTING it_styletab.
ENDLOOP.
ITAB is the output internal table. Along with the output fields, declare additional field it_styletab of type lvc_t_styl.
after calling the method SET_TABLE_FOR_FIRST_DISPLAY, call another method,
CALL METHOD tt_gr_alvgrid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
Again refresh the grid using REFRESH_TABLE_DISPLAY method.
set layout attribute gs_layout-stylefname = 'IT_STYLETAB'.
Regards,
Lakshmi.
Edited by: Santhanalakshmi V on Jun 18, 2008 6:15 PM
-
2008 Aug 28 9:54 PM
Hi,
remove the following code..this will enable all the columns open for input..
CALL METHOD tt_gr_alvgrid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
Thanks
Naren
Hi,
remove the following code..this will enable all the columns open for input..
CALL METHOD tt_gr_alvgrid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
Thanks
Naren
2008 Aug 28 9:54 PM
Hi,
remove the following code..this will enable all the columns open for input..
CALL METHOD tt_gr_alvgrid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
Thanks
Naren
2008 Aug 28 9:58 PM
Thanks Naren,
I have commented out but no use... even no change in the layout.
2008 Aug 28 10:12 PM
Hi,
Sorry for the confusion...
Check this sample code..in that first row I have disabled the werks column..second row it will be enabled..it is working fine for me..
DATA: g_container TYPE scrfname VALUE 'CONTAINER1',
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.
DATA: BEGIN OF wa,
matnr TYPE matnr,
werks TYPE werks,
t_style TYPE lvc_t_styl,
END OF wa,
gt_outtab LIKE TABLE OF wa,
t_style TYPE lvc_t_styl,
s_style TYPE lvc_s_styl.
*---------------------------------------------------------------------*
* MAIN *
*---------------------------------------------------------------------*
* Prepare dummy data. row 1 disable WERKS.
wa-matnr = 'test'.
wa-werks = '1000'.
s_style-style = cl_gui_alv_grid=>mc_style_disabled.
s_style-fieldname = 'WERKS'.
APPEND s_style TO t_style.
wa-t_style = t_style.
APPEND wa TO gt_outtab.
CLEAR: t_style.
* Prepare dummy data. row 2 enable werks.
wa-matnr = 'test'.
wa-werks = '1000'.
wa-t_style = t_style.
APPEND wa TO gt_outtab.
CLEAR: t_style.
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 g_grid
EXPORTING
i_parent = g_custom_container.
gs_layout-stylefname = 'T_STYLE'.
gs_layout-edit = 'X'.
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'WFCS_MARC_KEY'
is_layout = gs_layout
CHANGING
it_outtab = gt_outtab.
ENDIF.
ENDMODULE. "pbo OUTPUTThanks
Naren
2008 Aug 29 5:00 AM
Check the below code, in this i am disabling the sixth row , you can conditionally disable enable the columns. just take the Disable/enable logic from this code. i am using the LVC function , the same works in case of Class.
REPORT ztest_edit.
TYPE-POOLS: slis.
*- Fieldcatalog
DATA: it_fieldcat TYPE lvc_t_fcat.
DATA: x_fieldcat TYPE lvc_s_fcat.
DATA: x_layout TYPE lvc_s_layo.
"{ FOR DISABLE
DATA: ls_edit TYPE lvc_s_styl,
lt_edit TYPE lvc_t_styl.
"} FOR DISABLE
DATA: BEGIN OF it_vbap OCCURS 0,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
check(1),
style TYPE lvc_t_styl, "FOR DISABLE
END OF it_vbap.
DATA: ls_outtab LIKE LINE OF it_vbap.
SELECT vbeln
posnr
UP TO 10 ROWS
INTO CORRESPONDING FIELDS OF TABLE it_vbap
FROM vbap.
DATA:l_pos TYPE i VALUE 1.
CLEAR: l_pos.
l_pos = l_pos + 1.
x_fieldcat-coltext = 'CHECK'.
x_fieldcat-fieldname = 'CHECK'.
x_fieldcat-tabname = 'IT_VBAP'.
x_fieldcat-col_pos = l_pos.
x_fieldcat-checkbox = 'X'.
x_fieldcat-edit = 'X'.
x_fieldcat-outputlen = '10'.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
l_pos = l_pos + 1.
x_fieldcat-coltext = 'VBELN'.
x_fieldcat-fieldname = 'VBELN'.
x_fieldcat-tabname = 'IT_VBAP'.
x_fieldcat-col_pos = l_pos.
x_fieldcat-edit = 'X'.
x_fieldcat-outputlen = '10'.
x_fieldcat-ref_field = 'VBELN'.
x_fieldcat-ref_table = 'VBAK'.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
l_pos = l_pos + 1.
x_fieldcat-coltext = 'POSNR'.
x_fieldcat-fieldname = 'POSNR'.
x_fieldcat-tabname = 'IT_VBAP'.
x_fieldcat-col_pos = l_pos.
x_fieldcat-edit = 'X'.
x_fieldcat-outputlen = '5'.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
l_pos = l_pos + 1.
"{FOR DISABLE HERE 6ROW IS DISABLED
LOOP AT it_vbap.
CLEAR : lt_edit, ls_edit.
IF sy-tabix NE 6.
ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
ELSE.
ls_edit-style = cl_gui_alv_grid=>mc_style_disabled.
ENDIF.
ls_edit-fieldname = 'VBELN'.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 10.
INSERT ls_edit INTO TABLE lt_edit.
ls_edit-fieldname = 'CHECK'.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 5.
INSERT ls_edit INTO TABLE lt_edit.
ls_edit-fieldname = 'POSNR'.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 6.
INSERT ls_edit INTO TABLE lt_edit.
INSERT lines of lt_edit INTO TABLE ls_outtab-style.
MODIFY it_vbap INDEX sy-tabix FROM ls_outtab TRANSPORTING
style .
CLEAR ls_outtab.
ENDLOOP.
x_layout-stylefname = 'STYLE'.
x_layout-no_rowmark = 'X'.
"} UP TO HERE
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
is_layout_lvc = x_layout
it_fieldcat_lvc = it_fieldcat
TABLES
t_outtab = it_vbap[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |