Description: This blog describes about an ABAP utility for updating BRFplus decision tables in Production systems without logging into BRFplus UI. As well as describes how the governance on decision table maintenance can be achieved.
- Basic knowledge on OO ABAP concepts
- Basic knowledge on BRF+ framework
What is BRF Plus?
No matter how much one tries to minimize customization in a SAP system, some volume of custom business logic is usually unavoidable. Historically, this meant introducing custom ABAP syntax in various user-exists, enhancements, BADI’s and custom programs. Given the complex and interdependent nature of an SAP system, it becomes imperative to carefully manage such ABAP based customization in order to ensure that business logic is in sync across various functional areas, and is not duplicated. That’s where SAP Business Rules Framework Plus (BRF Plus) comes into play – a functionality that makes it possible to manage all of the custom business logic at a single place and in a re-usable way.
In general, BRF Plus functionality is available on any SAP NetWeaver based system at the appropriate enhancement pack level.
BRF Plus offers a unified modeling and run time environment for business rules that addresses both technical users (programmers, system administrators) as well as business users who take care of operational business processes (like procurement, bidding, tax form validation, etc.).
Why BRF Plus?
BRF plus Decision Table Maintenance in Production Environment:
BRF plus Decision tables contain rules or values configured and according to those rules the decisions are taken.
“Decisions are high change components” – may be because of policy changes/regulatory changes/market’s changes/customer’s changes/etc. And they may lead to regular data maintenance in decision tables.
In current BRF Plus version, to maintain values in decision table, transport request has to be created and imported till production box. With current BRF Plus version, there is no way to maintain decision tables directly in production system. To achieve decision table maintenance functionality in PROD system, the only solution is via DSM tool (i.e. Decision Service Management).
Alternative way would be to achieve this functionality is via Application Exit but has few drawbacks such as no change log history, no backup of existing contents are taken, no version comparison for decision table contents, no proper governance on who can maintain rules, etc.
Here we will see the how can we develop ABAP utility which will help us to achieve decision table maintenance in production systems while overcoming the drawbacks of Application Exit.
This utility will also provide some exclusive features which are not available in standard BRFplus solution today:
- Delta records upload functionality:
With Extra Selection Criteria Option on Selection Screen, it is possible to filter Decision Table Data for the value provided on screen for specific primary key of the decision table. This will enable fetching only specific rules from BRFplus decision tables and updating them with particular order back to decision table.
Current standard BRFplus solution does not offer delta records upload feature. Whenever excel with records is imported to the decision table it overwrites the contents in the decision table with the excel contents. This BRFplus mass upload utility have capability of uploading only new records to the decision table with the filtered data displayed on ALV Grid Display using Extra Selection Option.
This feature of delta records upload will be additional advantage and will reduce the risk of overwriting all the existing records of the decision table.
The records displayed on screen will be saved back to BRFplus without affecting other records which does not match selection criteria and are not displayed on screen. (Note: Excel Upload functionality is not available for delta upload functionality, this can be done only via Editable ALV grid).
- Sorting & Sequencing :
This feature will allow to maintain rules in specific sorting order either ascending or descending , also sequencing can be done based on the columns. Priorities of the fields for sorting can be set in configuration table one time and based on it data will be always stored in sorted manner in decision table.
- Sorting of rules from Specific to Generic criteria:
If we import records in decision table using “Import from Excel” button in BRFplus API, standard BRFplus will not sort the contents of decision table based on specific –> generic rule criteria.
Below is the example: In the example below if decision table is not sorted from specific to generic rule, it will satisfy the first rule itself in the decision table. We have two rules if customer is ABC and Sales org. is ABCD, discount is 5% and another rule is if customer is ABC and for any Sales Org. discount will 10%. In this case if input to decision table is Cust_no=‘ABC’ and SalesOrg = ‘ABCD’, first generic rule will be satisfied and o/p will be 10%.This is happening because rules are not sorted from specific to generic criteria. But same case will be handled properly if decision table is sorted. It will search most specific rule first instead of generic one. This can be handled with this tool by maintaining required Sorting Sequence for fields and keeping Sorting Order as Descending.
- UNIX file backup of Decision Table Contents:
New feature of UNIX file backup is added in this utility. Whenever user will try to change existing records or add new records in the decision table, backup of existing decision table contents will be taken on UNIX file path on application server as a separate file. This backup can be used in case decision table data gets corrupted in future.
- Change Log History for Decision Table Content Changes:
ABAP custom table is designed which will keep track of changes to the decision table. This table will capture the details as – 1. BRFplus decision table name, 2. User ID (user who made changes to the decision table), 3. Date (system date on which change was made) and 4. Timestamp (Time stamp at which changes were made) and 5. Unix File Path where Back up of Decision Table Data is saved.
- Dynamic Design of the Utility:
This utility to upload data can be used for any decision table. Everything will be configured in custom table and after maintaining few configurations utility can be used for any decision table. We need not make any changes to the ABAP code to use this utility for other decision tables. This tool is based on dynamic design and code is written in dynamic fashion.
- Editable ALV Grid Display:
The Utility Tool is provided with Editable ALV Grid Display, where, Existing Rows can be modified/deleted, New Rows can be inserted, Rows can be duplicated and changed as per requirement.
- Version comparison feature:
With version compare feature any two back up files of decision table contents can be compared or any backup version can be compared with current version. This version comparison will be based on primary key field values and will denote inserted/changed or deleted rows based upon primary key values.
Key Features of the utility:
Working of the Utility:
Decision table maintenance utility will simplify the process of maintaining rules in BRFplus decision tables. We will see step by step working of the tool:
Information Help: Help is provided on click of ‘i’ Button on Selection Screen describing Purpose and Features of the Tool and what are pre-requisites to use the Tool.
User Manual: The User Guide can be downloaded at specified path on clicking User Manual Button.
Fetch Data: Decision Table Data can be displayed using Fetch Data button with Extra Selection Criteria as Filtering Option.
2. Output screen :
Editable ALV Grid Display with Append, Insert, Delete and Duplicate Row Options.Data Upload with Excel File, User Manual Download and Information Help. Differentiation of Input and Output Columns with different colors.
With Extra Selection Criteria Option on Selection Screen, it is possible to filter Decision Table Data for the value provided on screen for one of the columns.
Only one value can be provided at one time as below:
3.Decision table update : Whole / Delta
This for whole data update, similar way for specific condition value decision table can be updated.
On click of SAVE, once save is successful:
Excel download/ upload functionality:
4.Version Compare functionality:
With Decision Table Version Compare Tool, Decision Table Data changed using Decision Table Maintenance Tool can be compared i.e. tool will be used to compare different versions available for Decision Table data in back up files.
Using Decision Table Version Compare Tool:
- Any two Backup Files of Decision Table can be compared with each other.
- Backup File can be compared with Current Version of Decision Table.
- Backup File Contents can be displayed on screen in ALV Grid Display.
After clicking on Display Versions button, change log history with back up files will be displayed.
When user clicks on Compare version button comparison will be shown as below:
Based key fields comparison will happen and will indicate inserted / deleted or changed rows.
Similarly, display back up file display contents in Grid ALV and backup versions can be compared with the current version.
1.Design a custom table to hold all the necessary configurations for decision tables.
For example decision table name, free entry for variable name , variable values, decision table fields data types , flag to identify whether the field is input or output column , sorting sequence to sort fields priority wise also sorting order either ascending or descending , key flag to indicate whether the field is part of primary key or composite primary key.
2.Using this custom table, ABAP dynamic code can be written to fetch data from any decision table, update rules into decision table or perform version comparison.
3.Read the configuration from custom table and develop dynamic logic as per the requirement.
4.To fetch data from decision table faster way is to implement enhancement inside GET_FORMATTED_DT_DATA method of class CL_FDT_DT_EXCEL.
We can put some restrictions such as this custom code inside enhancement will run only for specific decision tables which are configured in configuration table. We can export Decision table name to memory id via ABAP calling program and later import it from memory ID inside enhancement and check if it exists in configuration table then only execute custom code to read or to take backup of decision table data.
5.Call method as shown below
6.After calling this method decision table current content should be stored on application in the UNIX file as per the custom code we have written inside the enhancement.
7.This UNIX file can be read into the internal table and then can be used for further modifications such as display DT data on ALV, display delta records (filtration based on specific condition), updating, deleting and inserting records into the DT.
8.Now only part remaining is how to save the updated data back to BRFplus. SET_TABLE_DATA method can be used to store records back to the decision table.
9.Define an object of type CL_FDT_DECISION_TABLE.
10.Call method to set data to decision table.
11.Perform Deep activation and save decision table data. After the activation is successfully, user id , decision table name and date time stamp can be stored in custom table to maintain change log history.
Version comparison between decision table versions:
- Every time before calling set_table_data, we can call method create_excel_from_dec_tab and it will call enhancement to take a backup of DT data into the UNIX file.
- So whenever user change the data, we will have earlier version present on the application server.
- Using these versions of UNIX files, version comparison functionality can be implemented.
- For the comparison logic Key Fields should be maintained in configuration table in key flag column.
- At first all non-matching rows from two version will be found out.
- If combination of key field from new version is found in old version but row is modified it will be considered as MODIFY.
- If combination of key fields from new version is not found in old version but row is in non-matching list derived earlier then it will be shown as INSERT in new version.
- If combination of key fields from old version is not found in new version but row is in non-matching list derived earlier then it will be shown as DELETE in old version.
Benefits of this utility:
- Decision table data can be viewed and updated in any environment development, quality or production without logging into BRFplus API.
- Effort saving in creating transport for new rule updation and moving it till production.
- Few features such UNIX file backup will always help in recovering older versions in case DT data gets corrupted due to some reason.
- Version comparison feature will provide overview on what changes have been done to rule.
- Control on access to BRFplus decision tables can be implemented via specific authority checks and roles.
- Change log history will be present for reference.
- We will also need to implement Application Exit to have this tool working in production environment.
- While implementing the enhancement, we need to take extra care to have this working only for decision tables which are configured in configuration table and should work for the specific calling ABAP program.
I hope this blog gave helpful insight on how the Decision table mass upload utility can be implemented.