Exit Characteristics relationship with AMDP – Fallback scenario
Discover new possibilities of using ABAP Managed Database Procedure in characteristics relationship.
Exit Characteristics relationship with AMDP – Fallback scenario
To have synchronized and valid planned data SAP provides the functionality of defining characteristics relationship on planning cube or on planning aDSO. Let’s check new possibilities of using ABAP Managed Database Procedure in characteristics relationship.
Before getting into details of the new approach, we need to understand the main concept for characteristics relationship. There are two main types of the functionality – “Derivation” and “Check” based on the checkbox “with derivation” in the transaction RSPLAN. The type “Derivation” uses source and target characteristics. The target characteristics of selected source characteristics are filled in the moment when new records in the info provider are created. The type “Check” only executes check for valid combinations of characteristic values as illustrated in Picture 1.
Picture 1 - Settings for Characteristics Relationship in RSPLAN
There are four different methods of defining characteristics relationship: Attribute, Hierarchy, DSO, and Exit, in which “Derivation” or “Check” is used. Exit relationships apply for special cases, where relationships cannot be modeled in attributes, hierarchies and DSO’s. The Exit relationship uses user ABAP classes, which have to implement the interface IF_RSPLS_CR_EXIT. Also, the specific business logic for characteristics relationship should be implemented into methods “CHECK”, “DERIVE” and “CREATE” in the user class. The methods are executed in the following cases:
- DERIVE method is executed when the type “Derivation” is set, selected source characteristics are in the aggregation level, and one or more target characteristics are not in the aggregation level. The method call occurs when the system writes data into the delta or after-image buffer. Furthermore, DERIVE might be called in an input-ready query, in new lines.
- CHECK method is executed when all characteristics of the relation are known. This normally occurs in planning functions and in input-ready queries, depending on the query view.
- CREATE method is executed in input-ready queries, e.g. F4 help - 'access mode for result values' based on characteristic relationships in new lines and in some planning functions such as 'COPY'
With the introduction of BW on HANA, BW4HANA and Planning Applications KIT, BW-IP standard functions as well as characteristics relationship can be executed directly in HANA (see Picture 2). The second functionality requires enhancement of the existing Exit-classes with implementation for execution in HANA.
Picture 2 - Characteristics relationship execution from Input-ready Query and Planning function
SAP has provided a quick solution by introducing the interface IF_RSPLS_CR_EXIT_HDB. It is used as a marker for full processing in HANA. It has two methods:
If these two methods are left empty without implementation, “ABAP Fallback scenario” will be called. It means that corresponding ABAP-implementation is executed. This allows HANA execution without any SQL-programming and characteristics relationship validation in ABAP.
Let’s have a look at the three main parameters of the method IF_RSPLS_CR_EXIT_HDB~GET_SQLSCRIPT_INFO. The parameter E_PROCEDURE_NAME_CHECK defines the SQL Script name for the Check method of the characteristic relationship, while the parameter E_PROCEDURE_NAME_DERIVE is the corresponding one for the Derive method, and parameter E_PROCEDURE_NAME_CREATE is for the Create method, this is illustrated in Picture 3.
Picture 3 – EXIT-class with new Interfaces for HANA and their methods
For example, let’s have a relationship defined in aDSO between the characteristics Brand and Channel, where the characteristic Product has an attribute Brand. Our aggregation level has only the characteristics Product and Channel, which don't have a direct relationship. So, an EXIT characteristics relationship has to be created for Product and Channel as shown in Picture 4.
Picture 4 – Relationship between Product, Brand and Channel
Our EXIT class will have both ABAP & SQL via AMDP implementations. Firstly, we are declaring the needed HANA types for the creation of a relationship between Product and Channel, and the methods for CREATE, CHECK and DERIVE in the public section of the class, please see Picture 5.
Picture 5 – HANA types and methods in public section in EXIT class
In our example, we are focusing on the new AMDP methods for characteristics relationship. Take a look at the Create method (see Picture 6). The returning table E_T_CHAS has to be populated with a select statement, insert statements are not allowed here. The Create method should return a list of all possible combinations. The main difference between ABAP and HANA implementation is that in ABAP it’s not possible to return combinations that lie outside the selection, whilst in HANA it can be done.
Picture 6 – AMDP Create Method
Next method is our Check method, which reads data from import table I_T_CHAS. The table I_T_CHAS contains all combinations, which should be checked. The Check method returns valid combinations into table E_T_CHAS (see Picture 7). The HANA method is called once and makes check for all records, while ABAP method is called on every single combination and verifying if the record is valid or not. The HANA method allows better performance as the whole Check is done at once.
Picture 7 – AMDP Check Method
In the Derive method, we observe the same behaviour as in the Check method. The ABAP Derive method is called for each single combination and returns values for target characteristics. While the HANA method receives a list of all incoming combinations and returns a list with filled target characteristics. Our Derive method populates the target characteristic Channel based on the incoming list of selected Products. The method is demonstrated in Picture 8.
Picture 8 – AMDP Derive Method
Considering all the mentioned above, “ABAP Fallback scenario” provides a quick solution for EXIT characteristics allowing PAK deep HANA integration. For better performance, it is recommended to have also SQL implementation via AMDP. Our example has shown how SQL script could be used in user EXIT class for characteristics relationship.
DAHLBEER ensures your business objectives are achieved. Our vast experience and technical expertise in SAP planning tools enables efficient implementation in short cycles. Dynamic and Reliable – It’s how we are known to our clients.
Phone: +49 (0) 1515 629 66 08
Impressum & Datenschutz
Dahlbeer Unternehmensberatung GmbH
Landshuter Allee 8-10
Tel: +49 (0) 1515 629 66 08
Geschäftsführer: Christoph Dahl
Sitz der Gesellschaft: München
Registergericht: AG München HRB 201525
Umsatzsteueridentifikationsnummer (UID): DE285620916
Inhaltlich verantwortlich gemäß § 55 Abs. 2 RStV: Christoph Dahl