SAP Tech Pro

SAP Technical Blog
Topprice Price Comparison

How to hide/display buttons in FPM

How to hide/display buttons in FPM



    DATA: lo_fpm    TYPE REF TO if_fpm,
          lo_cnroif TYPE REF TO if_fpm_cnr_oif,
          ls_button  TYPE if_fpm_cnr_oif=>s_button,
          lt_button  TYPE if_fpm_cnr_oif=>t_button.

    lo_fpm = cl_fpm_factory=>get_instance( ).

* example for OIF based component
    TRY.
        lo_cnroif ?= l_o_fpm->get_service( cl_fpm_service_manager=>gc_key_cnr_oif ).
      CATCH cx_sy_move_cast_error.
        RETURN.
    ENDTRY.

* Get menu reference
    IF ( lo_cnroif IS NOT BOUND ).
      RETURN.
    ENDIF.

    lo_cnroif->get_buttons( IMPORTING et_buttons = lt_button ).

* Button to be checked
    READ TABLE lt_button INTO ls_button WITH KEY element_id = 'CUSTOM_BUTTON_1'.
    IF sy-subrc = 0.
* Change the properties as required
      ls_button-enabled    = abap_true.                              
      ls_button-visibility = cl_wd_uielement=>e_visible-visible.   

* Set properties of the Button
    CALL METHOD lo_cnroif->define_button(
      EXPORTING
        iv_function   = if_fpm_constants=>gc_button-other_function
        iv_element_id = ls_button-element_id
        iv_on_action  = ls_button-on_action
        iv_enabled    = ls_button-enabled
        iv_visibility = ls_button-visibility ).
   ENDIF.

Add comment

Before Buying, Compare Prices at Topprice.in

Topprice.in