6 Replies Latest reply: Jun 19, 2006 4:42 PM by Reson Reddy RSS

Disable a button from ALV Grid control  toolbar

Josie Nascimento
Currently Being Moderated

I need to disable a button from ALV toolbar. It's print button. I tried to :

 

       if ls_toolbar-function EQ '&PRINT_BACK'.

 

        move 'X' to ls_toolbar-disabled.

        modify e_object->mt_toolbar index v_tabix.

 

      endif.

 

But ls_toolbar is and structure type stb_button, so I can't modify it just append.

 

Best Regards

Josie

  • Re: Disable a button from ALV Grid control  toolbar
    Rich Heilman
    Currently Being Moderated

    You will need to exclude the functions. Here's how.

     

     

     

    
    * You need to add the functions to this table which
    * are to be excluded.
    * Then send this table thru the method.
    
    <b>  DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
    
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_PRINT.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.</b>
    
    
      CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
          EXPORTING
               IS_LAYOUT              = LAYOUT
    <b>           IT_TOOLBAR_EXCLUDING   = LT_EXCLUDE</b>
               IS_VARIANT             = VARIANT
               I_SAVE                 = 'A'
               I_STRUCTURE_NAME       = 'IALV'
          CHANGING
               IT_OUTTAB       = IALV[]
               IT_FIELDCATALOG = FIELDCAT[].
    

     

    Regards,

    Rich Heilman

    • Re: Disable a button from ALV Grid control  toolbar
      Josie Nascimento
      Currently Being Moderated

      Dear Rich

       

       

         Thanks so for your help, I just had to ajust it to my program. Here is my code.

       

      ******************************************************

       

      DATA: lt_exclude TYPE ui_functions,

            <b>ls_exclude TYPE ui_func.</b>

       

      ls_exclude = cl_gui_alv_grid=>mc_fc_print.

      <b>APPEND ls_exclude TO lt_exclude.</b>

       

       

      CALL METHOD grid1->set_table_for_first_display

           EXPORTING i_structure_name = 'YSE_EKKO'

                     is_layout        = gs_layout

                    <b> it_toolbar_excluding   = lt_exclude</b>

            CHANGING  it_outtab        = ys_ekko.

       

       

      ********************************************************

       

      Once more thanks so!

       

      Josie

      • Re: Disable a button from ALV Grid control  toolbar
        Judith Jessie Selvi
        Currently Being Moderated

        Can try this out

        In PBO,

         

        • Excludeing some of the standard toolbar functions

          perform f9200_exclude_functions

                                    using : i_exclude1[]  '&GRAPH',

                                            i_exclude1[]  '&MAXIMUM',

                                            i_exclude1[]  '&FIND',

         

                                            i_exclude2[]  '&PRINT',

                                            i_exclude2[]  '&MAINTAIN',

                                            i_exclude2[]  '&FILTER',

                                            i_exclude2[]  '&INFO'.

        *&----


        *

        *&      Form  f9200_exclude_functions

        *&----


        *

        • This form append the passed function to the list of those to exclude

        • from the toolbar. The following functions exist for the toolbar class

        • The list below contains a super set of the available options not all

        • of these are included in the toolbar as standard.

        *Drilldown Totals Level     '&AUF'

        *Calculate Average     '&AVERAGE'

        *Back         '&F03'

        *ABC Analysis     '&ABC'

        *Call Sequence     '&BEBN'

        *Seagate Info Batch Processing     '&CRBATCH'

        *Seagate Info Web Processing     '&CRWEB'

        *Line Items     '&BEB1'

        *Master Data     '&BEB2'

        *More Calls       '&BEB3'

        *Call Report       '&BEB9'

        *Extended Storage of SAPQuery     '&XINT'

        *XXL                 '&XXL'

        *Check Entries     '&CHECK'

        *Columns Invisible     '&COL_INV'

        *Optimize columns     '&OPTIMIZE'

        *Current Variant     '&COL0'

        *Save Data            '&DATA_SAVE'

        *Delete Filter     '&DELETE_FILTER'

        *Deselect All Rows     '&SAL'

        *Choose Detail     '&DETAIL'

        *Exclude all Grid Functions                   '&EXCLALLFC'

        *CrystalReportsTM (Export with Data)     '&CRDATA'

        *Crystal Reports (TM) ( Start Designer)     '&CRDESIG'

        *Crystal ( Templ ).         '&CRTEMPL'

        *MicrosoftTM Database File     '&MDB'

        *Additional Query Functions     '&EXT'

        *F4                         '&F4'

        *Filters                   '&FILTER'

        *Find                     '&FIND'

        *Freeze to Column           '&CFI'

        *Graphic                   '&GRAPH'

        *Help                     '&HELP'

        *HTML download            '&HTML'

        *Information               '&INFO'

        *Read Variant             '&LOAD'

        *Local: Append Row           '&LOCAL&APPEND'

        *Local: Copy                   '&LOCAL©'

        *Local: Copy Row             '&LOCAL©_ROW'

        *Local: Cut                   '&LOCAL&CUT'

        *Local: Delete Row            '&LOCAL&DELETE_ROW'

        *Local: Insert Row            '&LOCAL&INSERT_ROW'

        *Local: Move Row            '&LOCAL&MOVE_ROW'

        *Local: Paste                   '&LOCAL&PASTE'

        *Locally: Paste new Row     '&LOCAL&PASTE_NEW_ROW'

        *Undo                          '&LOCAL&UNDO'

        *Maintain Variants            '&MAINTAIN'

        *Maximum                   '&MAXIMUM'

        *Minimum                   '&MINIMUM'

        *Export Local File             '&PC'

        *Print                           '&PRINT'

        *Print Backend             '&PRINT_BACK'

        *Print Preview             '&PRINT_BACK_PREVIEW'

        *Refresh                    '&REFRESH'

        *Report/Report Interface      '&REPREP'

        *Save Variant                    '&SAVE'

        *Select All Rows             '&ALL'

        *Send                           '&SEND'

        *Separator                    '&&SEP'

        *Sort                           '&SORT'

        *Sort in ascending order      '&SORT_ASC'

        *Sort in descending order      '&SORT_DSC'

        *Subtotals                    '&SUBTOT'

        *Total                           '&SUMC'

        *Export Office             '&ML'

        *Export Reporting Tree     '&SERP'

        *Unfreeze Columns            '&CDF'

        *View Change                   '&VIEW'

        *Crystal Preview Inplace     '&VCRYSTAL'

        *Excel Inplace            '&VEXCEL'

        *Grid Control                   '&VGRID'

        *Word processing             '&AQW'

        *----


        *

        •      -->P_IEXCLUDE  text

        •      -->P_1150   text

        *----


        *

        form f9200_exclude_functions using   pexclude like i_exclude1

                                       value(pfunction).

         

          data: l_exclude type ui_func.

         

        l_exclude = pfunction.


        append l_exclude to pexclude.


        endform. " f9200_exclude_functions


        i_exclude1 type ui_functions,

        method handle_user_command.

        * In event handler method for event USER_COMMAND: Query your

        •   function codes defined in step 2 and react accordingly.

         

            case e_ucomm.

         

              when 'MATRL'.

        •       generate the grid1 data.

                perform f9600_display_data_grid1 tables  i_output1

                                                         i_groups

                                                        

        i_exclude1


        i_fieldcat1
        using w_layout1.
        form f9600_display_data_grid1 tables p_output
        p_groups

        p_exclude


        p_fieldcat
        using value(p_layout).

        call method o_alvgrid->set_table_for_first_display

             exporting

        •    I_BYPASSING_BUFFER            =

        •    I_BUFFER_ACTIVE               =

        •    I_CONSISTENCY_CHECK           =

        •    I_STRUCTURE_NAME              =

        •       is_variant                    = w_variant

               i_save                        = c_a

        •    I_DEFAULT                     = 'X'

               is_layout                     = p_layout

        •    IS_PRINT                      =

               it_special_groups             = p_groups[]

              

        it_toolbar_excluding = p_exclude[]

        •    IT_HYPERLINK                  =

        •    IT_ALV_GRAPHICS               =

        •    IT_EXCEPT_QINFO               =

            changing

               it_outtab                     = p_output[]

               it_fieldcatalog               = p_fieldcat[]

            exceptions

               invalid_parameter_combination = 1

               program_error                 = 2

               too_many_lines                = 3

               others                        = 4

                  .

         

          if sy-subrc <> 0.

            MESSAGE i278.

            LEAVE LIST-PROCESSING.

          endif.

         

        endform.                    " f9600_display_data_grid1

         

        Please close this thread if ur problem got solved.

         

    • Re: Disable a button from ALV Grid control  toolbar
      Reson Reddy
      Currently Being Moderated

      Hello Rich,

                 If incase the buttons were self defined, i mean if i added them myself and if i would want to disable them after i pass certain condition, what attribute should i pass.

      Thnks.

  • Re: Disable a button from ALV Grid control  toolbar
    Ramanibai Thyagarajan
    Currently Being Moderated

    In a self defined button, you can disable the button with option DISABLED = 'X'

     

    DATA:wl_toolbar  TYPE stb_button.

     

          wl_toolbar-function  = 'DEL'.

          wl_toolbar-butn_type = 0.

          wl_toolbar-icon = icon_delete.

          wl_toolbar-quickinfo = 'delete'.

          wl_toolbar-disabled  = 'X'.

          INSERT wl_toolbar INTO pw_object->mt_toolbar

           INDEX 1.

          CLEAR wl_toolbar.

  • Re: Disable a button from ALV Grid control  toolbar
    Reson Reddy
    Currently Being Moderated

    Hi Frnds,

             If i need to disable the 'Prv' that is self defined button, how do i go about it. I want to enter the code in the <<<<< CODE HERE >>>>>  part. I will have the button up initially and then after an if cond i want to disable it.

    Please help.

     

    Thnks.

     

    CLASS lcl_event_receiver IMPLEMENTATION.

     

      METHOD handle_toolbar.

        DATA: ls_toolbar  TYPE stb_button.

     

        CLEAR ls_toolbar.

        MOVE 3 TO ls_toolbar-butn_type.

        APPEND ls_toolbar TO e_object->mt_toolbar.

     

        CLEAR ls_toolbar.

        MOVE 'Prv' TO ls_toolbar-function.

        MOVE icon_allow TO ls_toolbar-icon.

        MOVE 'Approve'(100) TO ls_toolbar-quickinfo.

        MOVE 'Appr'(112) TO ls_toolbar-text.

        MOVE ' ' TO ls_toolbar-disabled.

        APPEND ls_toolbar TO e_object->mt_toolbar.

     

          ENDMETHOD.                    "handle_toolbar

     

      METHOD handle_user_command.

        DATA: lt_row TYPE lvc_t_row.

     

        CASE e_ucomm.

          WHEN 'Prv'.

            CALL METHOD grid1->get_selected_rows

              IMPORTING

                et_index_rows = lt_row.

            CALL METHOD cl_gui_cfw=>flush.

            IF sy-subrc EQ 0.

              MESSAGE 'You hit the Approve button' TYPE 'S'.

            ELSE.

    • add your handling, for example

            ENDIF.

        ENDCASE.

      ENDMETHOD.                           "handle_user_command

     

      METHOD handle_double_click.

        CLEAR  lt_row_line.

    •   Get selected row

        CALL METHOD grid1->get_selected_rows

          IMPORTING

            et_index_rows = lt_row_line.

        CALL METHOD cl_gui_cfw=>flush.

        LOOP AT lt_row_line INTO wa_row_line.

          CLEAR wa_tab.

          READ TABLE itab1 INTO wa_tab INDEX wa_row_line-index.

        ENDLOOP.

     

        IF sy-subrc IS INITIAL.

          CONCATENATE sy-mandt wa_tab-matnr INTO garg.

          CALL FUNCTION 'ENQUEUE_READ'

                  EXPORTING

                    gclient = gclient

                    guname  = guname

                    gname   = gname

                    garg    = garg

                  IMPORTING

                    number  = number

                  TABLES

                    enq     = enq

                  EXCEPTIONS

                    OTHERS  = 1.

          IF number  = 0.

            MESSAGE 'not loc' TYPE 'S'.

    <<<< CODE HERE >>>>>>

          ELSE.

            MESSAGE 'loc' TYPE 'S'.

          ENDIF.

     

          MESSAGE 'you clicked on a row' TYPE 'S'.

        ENDIF.

      ENDMETHOD.                    "handle_double_click

    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION

Actions