SAP ABAP - Custom Enhancement Switch Framework

Enhancement implementation process

The execution of every enhancement will be controlled based on entries in tables, for module-specific parameters (Sales Org, Company Code, etc.). Each enhancement will check if a flag is active or not for the module parameters in the table, for that specific enhancement. Only if the flag is active, the enhancement is executed.

Features  

1) Custom BADIs:

We may come across requirements for which our custom logic can be implemented in a user exit or customer exit. However, so as to create multiple implementations and provide flexibility for country-specific logic, no code will be written directly in the exit. Instead, custom BADIs will be used. 

2) Enhancement points inside custom programs:

Custom programs for which country-specific logic is expected in the future roll-outs, enhancement points will be created and embedded in required sections of the program. This will ensure that the original program logic will not be changed for each country. 

3) Control tables, Exclusion tables, Reusable Class and methods:

  • Every enhancement point, section, and BADI (SAP provided or custom, as above), will be maintained in control tables, along with module-specific parameters (Sales Org, Company Code). This means that all enhancements will read this table, based on the relevant module parameters, and only if the entry is present, will the enhancement be executed. 
  • This allows us to switch the enhancement on and off by just adding/deleting an entry in the control table, without actually activating/deactivating the enhancement, and without a code change.
  • Entries in the control table can be maintained either as a wildcard (*), which indicates enhancement is applicable for all countries/organizational units, or with module-specific parameters so that the enhancement is active or inactive uniformly for all combinations of the module-specific parameters. 
  • However, it is possible that there are specific combinations for which the behavior should be different. Such cases are maintained in the exclusion table (e.g. A certain enhancement is active for all Sales Orgs except for country ‘ABC’. In this case, ‘ABC’ will be maintained in the exclusion table for the specific enhancement. ) This means that the exclusion table is first checked for a specific combination, if this is present, then the enhancement is not executed. Only if the entry is not present in the exclusion table is it then checked for in the control table.
  • Partial maintenance of wildcard (*) values in the table key fields should be avoided, both in control and exclusion tables. Eg:- In SD enhancement control table, Sales Org/Distribution channel/division combination can be maintained as *, which indicates enhancement is applicable for all countries. But an entry such as Sales Org = ABC/ Distribution channel = */ division = XYZ should not be maintained. 
  • The control and exclusion tables will be read by reusable class methods. Every enhancement will have a call to this method, and based on the return value, the remaining logic in the enhancement will be executed or skipped.
  • The reusable class method will first check for the entry in the exclusion table. If present, the enhancement will not be executed. If not, the method then checks for the entry in the control table. If present in this, the enhancement is executed, if not, it is skipped.
  • The method will first check for the specific combination of module parameters, if not present, it then checks for entries with * values.

Advantages


Country specific enhancement implementation:

The enhancement strategy has been designed such that it is easy to accommodate additional countries for each rollout. During a country-specific rollout, additional records will be added in the control and exclusion tables, so that enhancement gets triggered for the new organizational units (Sales Org, Company Code, etc). If different logic is needed for the new country, then another implementation can be created for the same BADI, and a new entry can be added to the table.
  
Switching on/Switching off enhancements using a flag:

Each enhancement can be executed or omitted as per the requirement, by simply marking a flag in a table entry, without actually activating or deactivating the BADI. 

Code Segregation:

Enhancement implementation using the above-mentioned approach ensures that country-specific logic is separated as a different unit, which can be selectively activated/deactivated.

Central repository for all enhancements in the system:

A list of all enhancements implemented in the system, for each module/country/Organizational unit, can be tracked from the enhancement control tables. Therefore, these control tables act as a central repository of P58 enhancements.

Details of control tables, exclusion tables, and reusable class

  • List of module-specific enhancement control tables 

Control table

Description

Z_SD_CNTR            

Enhancement control table for SD Module

Z_FI_CNTR       

Enhancement control table for Finance Module

Z_MM_CNTR       

Enhancement control table for MM Module


  • List of module-specific exclusion tables

Exclusion table

Description

Z_SD_EXCL       

Enhancement exclusion table for SD Module

Z_FI_EXCL       

Enhancement exclusion table for Finance Module

Z_MM_EXCL      

Enhancement exclusion table for MM Module


  • Reusable class ZCL_ENH_CHECKS method IS_ENH_IMPL_ACTIVE need to be used in all the enhancement implementation to read the values maintained in control and exclusion tables & to identify whether an enhancement is active or not. Based on the return flag value from this method, relevant logic in the enhancement will be executed/skipped.

Usage of control tables and exclusion tables


Control Table for SD Enhancements (an Example):






Exclusion Table for SD Enhancements (an Example):






Example 1 – Entry present in Control Table

Implementation ZSD_COND_MAINT_IMPL1, Sales Org DE10, Distribution Channel 10, Division 10.

  • Step1: Exclusion table for the Sales Org., Distribution Channel, Division, Enh Def Name, and Enh Imp Name is read by the reusable class method.          
  • Step2: Since entry is not present, the control table for the Sales Org., Distribution Channel, Division, Enh Def Name, and Enh Imp Name is read.
  • Step3: Since the Activation Flag is ‘X’ for this entry, business logic in the enhancement is executed.

Example 2 – Entry present in Exclusion Table

Implementation ZBADI_DEF1_IMPL1, Sales Org CN10, Distribution Channel 10, Division 10.

  • Step1: Exclusion table for the Sales Org., Distribution Channel, Division, Enh Def Name, and Enh Imp Name.          
  • Step2: Since the entry is present, do not check the control table, EXIT the enhancement implementation. 

Example 3 – New entry in control table during a country rollout

For the US specific rollout, if different business logic is needed, another implementation ZSD_COND_MAINT_IMPL2 is created for the same BADI definition SD_COND_MAINT, and this entry is added in the control table:








Now, within ZSD_COND_MAINT_IMPL2, for Sales Org US12, Distribution Channel 12, Division 12:

  • Step1: Exclusion table for the Sales Org., Distribution Channel, Division, Enh Def Name and Enh Imp Name is read by the reusable class method.                    
  • Step2: Since entry is not present, control table for the Sales Org., Distribution Channel, Division, Enh Def Name and Enh Imp Name is read.
  • Step3: Since entry is present in the control table, for US specific Sales are, business logic in the enhancement implementation ZSD_COND_MAINT_IMPL2 is executed


Comments

Popular posts from this blog

SAP ABAP - Generating Excel file for downloading or sending over email

Get your signature from a paper to word document