Header Ads

Code to access component controller in Main window .

 DATA : lt_buttons  TYPE crmt_thtmlb_button_ext_t,
         wa_buttons  LIKE LINE OF lt_buttons ,
         lr_entity   TYPE REF TO cl_crm_bol_entity,
         lr_current  TYPE REF TO cl_crm_bol_entity,
         lr_compctrl TYPE REF TO cl_bt116h_s_bspwdcomponen_impl,
         lv_guid     TYPE crmt_object_guid,
         lr_sq_btorder_header   TYPE REF TO cl_crm_bol_entity,
         ls_sq_btorder_header   TYPE crmst_adminh_btil,
         lv_quotation TYPE crmt_object_id_db,
         lv_process_type  TYPE crmt_process_type_db.

*Call super class to get all the buttons which are to be added.
  CALL METHOD super->if_bsp_wd_toolbar_callback~get_buttons
    RECEIVING
      rt_buttons lt_buttons.

* Get component controller .
    lr_compctrl ?= me->comp_controller.
* Get controller context .
    lr_current ?= lr_compctrl->typed_context->btorder->collection_wrapper->get_current).
    IF lr_current IS BOUND.

*    Get order header to get process type .
      lr_sq_btorder_header lr_current->get_related_entity'BTOrderHeader' ).
      CHECK lr_sq_btorder_header IS BOUND.
      lr_sq_btorder_header->get_propertiesIMPORTING es_attributes ls_sq_btorder_header ).
      lv_quotation   ls_sq_btorder_header-object_id.
      lv_process_type  ls_sq_btorder_header-process_type.

*     Disable buttons for sub quotations .
      IF lv_process_type 'ZQDC' OR lv_process_type 'ZQLM' OR lv_process_type 'ZQPS' OR lv_process_type 'ZQSD'.

*     Disable COPY button .
        READ TABLE lt_buttons INTO wa_buttons WITH KEY  on_click 'COPY'.
        IF sy-subrc EQ 0.
          wa_buttons-enabled ' '.
          MODIFY lt_buttons  FROM wa_buttons INDEX sy-tabix.
        ENDIF.
*      Disable Create button .
        READ TABLE lt_buttons INTO wa_buttons WITH KEY  on_click 'CREATE'.
        IF sy-subrc EQ 0.
          wa_buttons-enabled ' '.
          MODIFY lt_buttons  FROM wa_buttons INDEX sy-tabix.
        ENDIF.
      ENDIF.
    ENDIF.

rt_buttons[] lt_buttons[].
Powered by Blogger.