Skip to content
Jaime Rodriguez Capote edited this page Mar 10, 2023 · 3 revisions

Summary

This functionality allows you to enable/disable by customizing developed features.

To create a switch just create an entry in view cluster (SM34) ZADU_SWITCH

image

Use

To use the switch just need to instantiate zcl_adu_switch using method get to get the specific switch, then call to method is_active

    IF zcl_adu_switch=>get( 'TEST' )->is_active( ).
      write( 'Switch TEST is enabled' ).
    ELSE.
      write( 'Switch TEST is disabled' ).
    ENDIF.

Activation status

You can create a new switch and set the activation status:

  • Disabled → The switch is disabled
  • Enabled → The switch is enabled
  • By user → The switch is enabled just for specified users
  • Custom condition → This enabled status allows you to specify a custom class (with interface ZIF_ADU_SWITCH_CONDITION) to specify a custom activation condition

Enabled by user

To activate the switch for users you need to set the activation status "Enabled by user" and include the usernames in the Users view cluster node:

image

Enabled by custom condition

To activate the switch with your own custom logic you need to set the activation status "Enabled by custom condition" and specify a class with the interface ZIF_ADU_SWITCH_CONDITION

image

The method zif_adu_switch_condition->is_active will receive any data to help you with your own validations

INTERFACE zif_adu_switch_condition
  PUBLIC.

  METHODS is_active
    IMPORTING
      is_data_check TYPE any OPTIONAL
    RETURNING
      VALUE(result) TYPE abap_bool.

ENDINTERFACE.

Example

An example could be a switch enabled only for purchase orders for a specific purchasing organization

CLASS zcl_switch_condition_test DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.
    INTERFACES zif_adu_switch_condition.

  PROTECTED SECTION.

  PRIVATE SECTION.

ENDCLASS.



CLASS zcl_switch_condition_test IMPLEMENTATION.


  METHOD zif_adu_switch_condition~is_active.

    DATA(purchase_order) = CORRESPONDING ekko( is_data_check ).

    result = xsdbool( purchase_order-ekorg = 'TEST' ).

  ENDMETHOD.


ENDCLASS.
Clone this wiki locally