2014 Jan 22 5:20 AM
HI,
I have an issue in OOALV.I want to disable a push button in OOALV when the user clicks on the push button.IAM able to disable an input field using following code
ls_STYLE-FIELDNAME = 'COMMENTS'.
ls_STYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
APPEND ls_STYLE TO LS_FINAL-FLD_STYL.
but the same code is not working for push button (name = OPEN).
ls_STYLE-FIELDNAME = 'OPEN'.
ls_STYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
APPEND ls_STYLE TO LS_FINAL-FLD_STYL.
Is it possible to disable a push button in a row or disable a row completely including push button in that row.Kindly do the needful.
2014 Jan 22 8:01 AM
Hi noufal ,
ls_STYLE-FIELDNAME = 'OPEN'.
ls_STYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
APPEND ls_STYLE TO LS_FINAL-FLD_STYL.
i think here you tried disable button but you want to disable comment right ?
IF sy-ucomm eq 'OPEN'.
ls_STYLE-FIELDNAME = 'COMMENTS'.
ls_STYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
APPEND ls_STYLE TO LS_FINAL-FLD_STYL.
ENDIF.
2014 Jan 22 8:35 AM
Hi Noufal,
Its not possible to Grey out the button, But you can instead handle the "is_col_id" and "is_row_id" parameters that it sends out on clicking it and clear it somehow or Even try to call REFRESH_TABLE_DISPLAY on clicking.
Hope this Helps,
Santhosh Yadav
2014 Jan 23 9:48 AM
HI,
I removed the push button and make it as radio button.
thanks
2014 Jan 23 10:22 AM
Hi Noufal,
Its possible.
Suppose Open is your Push Button field.
Before displaying the ALV first time, set the attributes for push button like this. (this should be called before display_alv.
form set_specific_field_attributes .
DATA ls_stylerow TYPE lvc_s_styl .
LOOP AT i_final INTO wa_final.
clear ls_stylerow.
ls_stylerow-fieldname = 'OPEN' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_button.
APPEND ls_stylerow TO wa_final-FLD_STYL.
MODIFY i_final FROM wa_final.
clear wa_final.
ENDLOOP.
endform.
Also dont forget to add field style FLD_STYL to the layout. I assume you have already added in your code as you are using disable field too.
Now in the user command module, when you click the button, while disabling the comment field, delete the above line in ls_style also.
ls_STYLE-FIELDNAME = 'COMMENTS'.
ls_STYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
APPEND ls_STYLE TO LS_FINAL-FLD_STYL.
delete ls_final-FLD_STYL where fieldname = 'OPEN'.
MODIFY i_final FROM ls_Final.
ALong with disabling the comment field, the above code will disable the button field also.
2014 Jan 23 11:30 AM
Hi noufal,
Try the below code it may help u
*&---------------------------------------------------------------------*
*& Report ZALV_CUSTOM_TOOLBAR
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZALV_CUSTOM_TOOLBAR.
CLASS lcl_event_receiver DEFINITION DEFERRED.
*type pool declarations
TYPE-POOLS : icon.
*Internal table and work area declarations for dd02l
DATA: it_dd02l TYPE TABLE OF dd02l,
wa_dd02l TYPE dd02l.
*Data declaration for alv.
DATA :it_layout TYPE lvc_s_layo,
it_toolbar TYPE stb_button,
c_alv TYPE REF TO cl_gui_alv_grid,
custom_container TYPE REF TO cl_gui_custom_container,
event_receiver TYPE REF TO lcl_event_receiver.
DATA : v_fname TYPE string,
v_file TYPE RLGRAP-FILENAME.
*Select options multiple values no ranges
SELECT-OPTIONS : s_table FOR wa_dd02l-tabname NO INTERVALS.
PARAMETERS p_fname TYPE RLGRAP-FILENAME.
*Initialization event
INITIALIZATION.
*Start of selection event
START-OF-SELECTION.
*sUBROUTINE FOR ALV DISPLAY
PERFORM alvdisplay.
AT SELECTION-SCREEN on VALUE-REQUEST FOR p_fname.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FNAME'
CHANGING
file_name = p_fname.
v_fname = p_fname.
*Class definition
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
*handling toolbar for interactive
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
*handling menu button
handle_menu_button
FOR EVENT menu_button OF cl_gui_alv_grid
IMPORTING e_object e_ucomm,
*On click of the menu button
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
PRIVATE SECTION.
ENDCLASS. "lcl_event_receiver DEFINITION
*Class implementation
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
* handle toolbar
CLEAR it_toolbar.
MOVE 'DETAIL' TO it_toolbar-function.
MOVE icon_detail TO it_toolbar-icon.
MOVE 2 TO it_toolbar-butn_type.
move 'X' to it_toolbar-disabled.
APPEND it_toolbar TO e_object->mt_toolbar.
ENDMETHOD. "handle_toolbar
METHOD handle_menu_button.
* handle own menubuttons
IF e_ucomm = 'DETAIL'.
CALL METHOD e_object->add_function
EXPORTING
fcode = 'DLOAD'
text = 'DLOAD'.
ENDIF.
ENDMETHOD. "handle_menu_button
METHOD handle_user_command.
*On click
CASE e_ucomm.
WHEN 'DLOAD'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = v_fname
FILETYPE = 'ASC'
* APPEND = ' '
WRITE_FIELD_SEPARATOR = 'X'
tables
data_tab = it_dd02l.
ENDCASE.
ENDMETHOD. "handle_user_command
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
*&-----------------------------------------------------------------*
*& Module PBO OUTPUT
*&-----------------------------------------------------------------*
* text
*------------------------------------------------------------------*
MODULE pbo OUTPUT.
SET PF-STATUS 'MENU'.
IF custom_container IS INITIAL.
* select data from table dd02l
PERFORM fetch_dd02l.
* create a custom container control for our ALV Control
CREATE OBJECT custom_container
EXPORTING
container_name = 'CCONT'.
* create an instance of alv control
CREATE OBJECT c_alv
EXPORTING i_parent = custom_container.
* Set a titlebar for the grid control
it_layout-grid_title = 'TABLE DETAILS'.
*ALV display
CALL METHOD c_alv->set_table_for_first_display
EXPORTING
i_structure_name = 'dd02l'
is_layout = it_layout
CHANGING
it_outtab = it_dd02l.
*Handlers for the events
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_user_command
event_receiver->handle_menu_button
event_receiver->handle_toolbar FOR ALL INSTANCES.
*Calling the interactive toolbar method of ALV
CALL METHOD c_alv->set_toolbar_interactive.
ENDIF.
ENDMODULE. " PBO OUTPUT
*&-----------------------------------------------------------------*
*& Module PAI INPUT
*&-----------------------------------------------------------------*
* text
*-----------------------------------------------------------------*
MODULE pai INPUT.
IF sy-ucomm = 'BACK'.
LEAVE TO SCREEN 0.
ENDIF.
ENDMODULE. " PAI INPUT
*&----------------------------------------------------------------*
*& form fetch_dd02l
*&----------------------------------------------------------------*
* text
*-----------------------------------------------------------------*
*Subroutine to fetch data
FORM fetch_dd02l.
SELECT * FROM dd02l INTO CORRESPONDING FIELDS OF TABLE it_dd02l
WHERE tabname IN s_table.
ENDFORM. " SELECT_TABLE_dd02l
*&-----------------------------------------------------------------*
*& Form ALVDISPLAY
*&-----------------------------------------------------------------*
* text
*------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*------------------------------------------------------------------*
FORM alvdisplay .
* ALV output
CALL SCREEN 600.
ENDFORM. " ALVDISPLAY
Thanks,
Ashritha.
2014 Jan 23 12:58 PM
Hi Noufal,
Happy that you have solved that issue by giving a radio button as I suggested.
Njoy