-
Notifications
You must be signed in to change notification settings - Fork 10
Switch
Jaime Rodriguez Capote edited this page Mar 10, 2023
·
3 revisions
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

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
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:

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
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.
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.