Buy

Buy

List of Posts

Get this widget
To get notifications, Please like our Facebook Page >>>>>>

Use Search box to find a topic in this Blog!!!

Showing posts with label Business Explorer. Show all posts
Showing posts with label Business Explorer. Show all posts

Customer Exit to Restrict a Characteristic with Values Containing Certain Pattern

Ref: SDN Wiki
Author: Ramakrishna Gattikoppula

Scenario
In BW Queries very often there is a requirement to restrict a characteristic with some values to get the correct result. Let us say we have a requirement where we need to restrict the query to only those Departments for which the Department ID starts with D1 or D2. This will be very simple task when there are limited number of Departments IDs starting with D1 or D2, but what if there are many Departments whose ID starts with D1 or D2.

Solution
This Can be achieved using a Customer Exit Variable.

Following are the steps you need to perform to restrict the characteristic with values having certain pattern.

Step1: Create a New Variable(say ZVAR_DEPT) on the Characteristic Department with following properties.

Type of Variable: Characteristic Value.
Processing By: Customer Exit.
Variable Represents: Multiple Single Values.
Variable Entry is: Mandatory, Not Ready for Input and Cannot be changed in Query Navigation

Step 2: Restrict the Characteristic with the variable ZVAR_DEPT.

Step 3: Go to Transaction SE37 and enter "EXIT_SAPLRRS0_001". In the next screen double click on "ZXRSRU01", this will take you to the screen where you can define Customer exit code for Global Variables in Reporting.

Step 4: Include the following code in the Customer Exit code.

WHEN 'ZVAR_DEPT'.
IF I_STEP = 1.
DATA: ITAB1 TYPE STANDARD TABLE OF /BI0/SDEPT_ID WITH HEADER LINE.
SELECT * FROM /BI0/SDEPT_ID INTO TABLE ITAB1 WHERE DEPT_ID LIKE 'D1%' OR DEPT_ID LIKE 'D2%'.
CLEAR: L_S_RANGE.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'EQ'.
LOOP AT ITAB1.
L_S_RANGE-LOW = ITAB1-DEPT_ID.
APPEND L_S_RANGE TO E_T_RANGE.
ENDLOOP.
CLEAR L_S_RANGE.
ENDIF.

Customer specific adjusting of BEx web-based variable screen

Customer specific adjusting of BEx web-based variable screen


1 Introduction

The possibilities of adaptation of a web-based report dialog variables were previously restricted. About parameters of the WebTemplate and using the Web Design API that can be charged affects the behavior of Web Templates in the variables but not the layout and processing logic of the input

Figure 1.1: SAP Standard Variable Dialog

With patch NW730 BI JAVA SP08 Patch 30 (see also Note 1622306),
SAP offers a possibility the layout and processing logic for the following dialogues with respect to variable processing to adapt:
Variables
Dialogue
Filter

For customer-specific adaptation of the variables dialog, two alternative routes are available:
Customized formatting and positioning
Customer-specific layout and processing logic

The principle of implementation is the same for all kinds of adjustment. About a Web item types of Individual expansion of the BEx Web runtime, an HTML and / or JavaScript code segment (Snipplte) is passed. The BEx Web runtime replaces the standard SAP code passed by the code segments. Thus, the BEx Web runtime performs this replacement process, certain conditions must be met. I go even further down into the details of the implementation.

2 Customized formatting and positioning

The first way is to adjust the variable dialog customized, positioning to the individual elements of the variables dialog customized. For determining the positions of the individual elements can be any HTML tags are used. For the individual elements are patterns (pattern) are available which can be placed within a customized HTML text.

The following items are available:
Area variants
Areaersonalize
Eachvariable of the report
OK-Button
Check-Button

The pattern will be placed as a custom XML tags in customized HTML coding. The BEx Web runtime environment recognizes the pattern and replaces them with the necessary coding.

Figure 2.2 shows in (1) a custom dialog variables in the areas of personalization options and were just like the OK button and check positioned similar to the standard variable dialog.

The variables were divided into time-related variables, and not time-related variables. To better highlight this structure for each type, a separate group was formed.


Figure 2.1: Customer-specific formatting and positioning
Adjustment in (2) illustrates the use of more complex HTML components. Here, only the time-related variables shown directly and all other variables are hidden on a tray. This allows the variable dialog for reports with a lot of variables to be made ​​clearer and thus the ease of use increased.

The implementation of the component tray used here is purely on HTML and JavaScript, and needs no round-trip.

This representation could be achieved through a personalization that could not be controlled centrally.

3 Customer Individual Variable dialog
Another option is to adjust the variable dialog to make the layout and processing logic for each variable individually customized.

In this variant is not the SAP standard HTML coding of the entire variables dialogue replaced by customer-specific HTML coding but only the ranges for the input variable values. In the Variables dialog in Figure 3.1, the SAP standard HTML coding for the two variables CURRENT PREVIOUS YEAR PERIOD
YERA PERIOD and was replaced by customized HMTL code.


Figure 3.1: Individual customer's variables dialog

For the example implementation shown in Figure 3.1 has been deposited adjacent to the surface for the input of a very specific period still additional JavaScript code, through which a function of the two variables and PREVIOUS YEAR CURRENT PERIOD YEAR PERIOD was implemented.

Validation and adjustment of variable values

When entering a value for a period of two variables is automatically checked whether the variable value of the other period, according to custom rules, is still
valid. This is not the case; the value is adjusted according to the rules directly.

Such validation and adjustment is not possible without this extension, since it is in the customer exit in I_STEP 3 is not possible to override the values of the user.

Analogous to the implementation of a customized variables dialogue must also be replaced by a Web item types from individual extension of the SAP standard HTML code. In this variant, for each variable of a Web item types must Individual expansion in WebTemplate be deposited.

For the implementation of custom HTML code for some HTML elements are also patterns provided. For these HTML elements are patterns available:
Input Feld
Dropdown-Box
Label

The pattern is used to facilitate the creation of a portal layout compliant HTML code, but they are not to use it. Some properties of the extension can be customized via parameters from the Web item type Individual expansion in WebTemplate.

For each extension the BEx Web runtime environment add a standard variable input field automatically into the layout. About the Web item parameters, you can control whether the input field should be displayed above or below the user-defined layouts.

Standard input field
Using JavaScript, it is also possible to hide the standard input field. Important is that it is available within the HTML page. Also, the button for the F4 help can be hidden using JavaScript if it is not needed.

The aim of the implementation is to fill this field with the variable value.

Layout
In the current version you some adjustments at the layout of are necessary. This applies, for example, the width of the dialog variables; the height of the row in a customer-specific adaptation is embedded. Positioning of the standard input field for the variable value.

4 Customized F4 and filter dialogs
Another way of displaying variables is the customer-specific adaptation of the F4 and filter dialogs. Figure 4.1 shows two different implementations of an F4 input help dialog for the variable ZTK_0I0DAYS. In the above example, the values ​​are displayed with a reference period.

Dependencies between variables
The F4 help dialog is used explicitly for a variable. In this variant, it is not possible to influence the values of another with. Technically, the dialogue contains
an extra field that contains the value of the variable. This field is closely associated with the variable. The value of this field is passed when you close the dialog via the OK button of the dialog variables for exactly that variable. The extension replaces only the HTML code within the F4 help dialog.


Figure 4.1: Individual customers F4 and filter dialog

For each dialogue has its own Web item types of Individual expansion in WebTemplate provided. Here it is possible to reuse the implementation. You want an individual F4 help dialog for variable 0I_CALMONTH (based on 0CALMONTH) Implement. At the same time you want, however, that if the user in the report a filter to the feature 0CALMONTH applying the filter dialog has the analogous behavior as the F4 help dialog. You can do this in the Web item you both use the same implementation class. It is equally possible to implement different dialogues.

5 Implementation
The implementation of all the extensions described above is always the same principle. Figure 5.1 shows the architecture of the individual extensions.


Figure 5.1: Architecture – SAP Standard

The number of implementations of the Web item types of Individual expansion may increase due to the many possible combinations quickly. To every implementation of a Web item types of Individual expansion ever heard an implementing ABAP OO class.

Using a BAdI, the different implementations to be better organized and structured. It also provides the advanced architecture of the BAdI framework
the ability to create templates that simplify the implementation costs of new implementations and greatly shorten. Additionally, a fallback implementation is stored in the event that an implementation is not available.

Figure 5.2: Architecture - SAP standard with BAdI

SAP BEX Toolbar

SAP BEX Toolbar

 

How to use OpenDocument with BEx variables

How to use OpenDocument with BEx variables

While the official OpenDocument guide is a great resource and explains in detail how to use OpenDocument syntax, We have not seen a good documentation explaining how to use OpenDocument in conjunction with SAP BW BEx variables, and yes, there are syntax differences depending on the different BEx variable types. 
What is the OpenDocument interface?
The OpenDocument interface allows you to open reports that are saved in the BI LaunchPad by using URL hyperlinks. You can take advantage of the OpenDocument syntax and parameterize the report to be opened.
How to pass values to BEx variables in general?
As everything in SAP BW, there is always a Text and a Key for every record in your report. The text is clearly not unique though, it depends for example on the language of the user that is currently viewing the report. On the other side most of the users are not very comfortable seeing and working only with technical keys, you should always pass both: Key and Text.
How do I construct an OpenDocument URL in general? 
While you can construct your own URL manually by carefully reading the manual, there is much fancier way: Use the hyperlink wizard! The hyperlink wizard is available only in Web Intelligence Web Mode (DHTML), it is not available in RIA mode (Java) nor in the Rich Client. You can open the hyperlink wizard by right-clicking on a field > Linking > Add Document Link:


After you select a target document in the hyperlink wizard, you will be presented with all the prompts of the target report. In this example I have a prompt (from a BEx variable) on a dimension object named "Material", an example of a material is a material named "Ten" with key "010". The following would be a correct way of passing a single material by using the dimension objects in a table:

In the first box you should provide a Text (Dimension Object), and in the second its corresponding key. In the screenshot above "Z_SINGLE_OPT_TEXT" corresponds to the description of the BEx variable, on the other side, the generated hyperlink will use the technical name of the variable.
How do I pass Single Values?
If you use the hyperlink wizard to pass a single value variable, you will notice that the wizard will use two parameters lsS for the Text and lsI for the key. If for example you click on a material "Ten" with key "010" using a variable "Z_SINGLE_OPT" (technical name):
You will get a syntax like this: 
"…lsSZ_SINGLE_OPT=Ten&lsIZ_SINGLE_OPT=010"
Notice that code is hard coded with the values for a better understanding, but of course you can use dimensions here.
How do I pass Multiple Single Values?
By separating individual values with a semicolon (;), you can pass multiple single values at a time. For example:
The corresponding syntax equates to: 
"…&lsMZ_MSV_OPT=Ten;Fourty&lsIZ_MSV_OPT=010;040"
Notice that lsM is used to pass multiple single values.
How do I pass Ranges?
When passing ranges you must separate the minimum and maximum value with two consecutive dots (..). The start and end of the range must have square brackets that you have to create manually:

Generated syntax: 
"…lsRZ_RANGE_OPT=[Ten..Thirty]&lsIZ_RANGE_OPT=[010..030]"
Notice that lsR will be used to pass ranges.
How do I pass nodes of a Hierarchy?
Passing a hierarchy node with standard text and key objects works fine most of the times, however I use following syntax (according to note 1677950) to avoid potential issues: [Hierarchy].key
In this case you will notice that a "0HIER_NODE/" will be inserted to all non-leaves in the hierarchy.

Generated syntax:
„…&lsSZ_HIER_OPT=Even&lsIZ_HIER_OPT=0HIER_NODE/EVEN"

How do I pass compounded objects?
In this case you need to make sure that the key that you are passing is not compounded (more Information in this blog post). You can achieve this by using formulas in the front-end e.g. "=right()" or by selecting the non-compounded key available since BI4 SP05:

Hope you enjoyed this introduction into using OpenDocument with BEx variables

By Victor Gabriel Saiz Castillo

BEx-Userexits reloaded

BEx-Userexits reloaded


After the initial release of the BI-Tools framework for BEx-Exitvariables in Easy implementation of BEx-Userexit-Variables I got a lot of useful comments and suggestions. And finally, I realized, that I omit a detailed discussion and implementation of the I_STEP 3 ( check after variable-screen ).
Please read first my first blog, because there are a lot more informations about the process and the variable implemenation. This blog talks mostly about experiences and refactoring.
Existing experiences 
I have talked to some people, which are using this framework and I have seen some other implementations based on BADI or function modules.

When introducing the object-oriented approach, you can obtain some advantages:
  • Traceability: Every Variable is clearly defined and can be relocated very fast ( without scanning a lot of ABAP coding)
  • Self-documenting Implementation: The variable-interface has been defined for an easy use and not for encapsulating the technical customer-exit interface
  • Reusablitiy: Reduce variable code by inheritance and specify only the necessary code within your concrete variable
  • Stability: If one of the variables has a failure, just this coding is not usable. If you have another approach like includes or big function-groups, this is not guaranteed by default.
  • Testability: Using ABAPUnit with ABAP OO-Bex-Variables is very easy and efficient.
The usage of the BEx-Variables framework has also shown, that an object-oriented approach is easier than plain function modules, if a clear interface is used. I found one example, where even young developers without a lot of development knowledge implemented BEx-Variables.
Why reloaded?
The original implementation has two problems: 
The I_STEP = 3 has been implemented as "normal" variable instance and so it has not been very much possiblities to configure and implement this for special queries/infoproviders. This leads to the situation, that all coding has been implemented in one variable-class which handled a lot of different use-cases (and this has not been the original idea of "Separations of concerns").
A spelling mistaked has been slipped into the naming of the methods - so this could lead into a misunderstanded usage when implementing authority-variables.
So, I enhanced the existing solution and perform a small but effective refactoring. The actual code is checked into code-exchange and can be installed via SAPLink.
Refactoring
Instead of having one interface, which implement all steps, I decided to split the existing variable-interface into two interfaces:
The existing variable interface - without step 3 ( and renaming method for i_step = 0)
A new check-interface handling I_STEP = 3
A short look into the UML-structure:
As you may notice there is another new class called "ZCL_BIU001_CHECK_COLLECTION". This has been necessary, because a check can be resolved through a infoprovider assignment or a special query. Within the new customizing it is possible, to define checks based upon those two criterias. Not enough: these parameters could be configured as pattern-based parameters, so you can specify a special check for a class of queries / infoproviders.
Details
In the following, I will show the main changes.
Variable-Interface
Check-Interface
Additional, the variable-include has been enhanced (a little bit ;-) ):
Customizing
The customizing has been changed, so that there are two customizing tables: One for the variables and one for the checks.
I would suggest to use them together in one view-cluster. And if you defined the views, think about the DDIC capabilities like search-helps, maintenance-views, foreign-keys. Through the usage of ABAP Interfaces, it is possible, to check at customizing time, if a class implements the correct interface!
Conclusion
Author use the described framework intensively and like the simple usage and the fact, that the original very technical calling has been hidden by two suitable interfaces.

Author : Hendrik Brandes

Note

This blog is solely for the purpose of getting educated in SAP. This blog does not encourage distribution of SAP hold copyright and any other publication and/or materials bearing SAP mark. If you find any copyright materials, please mail me so I can remove them. This blog is not in association with SAP.

ALL Posts

Get this widget