You are on page 1of 18

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.

com | UAC - uac.sap.com
© 2011 SAP AG 1
Dynamic Dates within a BEx
Universe
Applies to:
SAP BW, BusinessObjects Designer, BusinessObjects Web Intelligence. For more information, visit the
Business Objects homepage.
Summary
This article discusses ways in which dynamic dates can be used in a BEx-based BO universe and
associated Web Intelligence (WEBI) documents.

Author: Eric Siboda
Company: Daugherty Business Solutions
Created on: 5 June, 2011
Author Bio
Eric Siboda has 10 years of experience with SAP and has worked in HR, Logistics, SCM, SRM, CRM, and
BW. Seven of these years have seen an emphasis on SAP BW. Eric is a techincal BW consultant with
Daugherty Business Solutions and is currently consulting as a tech lead with Monsanto.


Dynamic Dates within a BEx Universe
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 2
Table of Contents
Introduction ......................................................................................................................................................... 3
BEx Variables within a BO Universe Overview .................................................................................................. 3
Standard variables .......................................................................................................................................... 3
User Exit Variables .......................................................................................................................................... 3
Data read for prompt list of values .................................................................................................................. 3
Single Dynamic Date Scenario ........................................................................................................................... 3
Dynamic Date Grouping Scenario ...................................................................................................................... 7
Step 1: Base InfoProvider ............................................................................................................................... 7
Step 2: New InfoObject ................................................................................................................................... 8
Step 3: Reporting Layer InfoProvider .............................................................................................................. 9
Step 4: Query ................................................................................................................................................ 10
Step 5: User Exit Coding for Price Date Variable ......................................................................................... 12
Step 6: Create the universe and WEBI report .............................................................................................. 13
Finished Product ............................................................................................................................................... 14
Output:........................................................................................................................................................... 15
Conclusion ........................................................................................................................................................ 16
Further Possibilities .......................................................................................................................................... 16
Related Content ................................................................................................................................................ 17
Disclaimer and Liability Notice .......................................................................................................................... 18

Dynamic Dates within a BEx Universe
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 3
Introduction
This article discusses solutions for overcoming the dynamic date limitations in a universe built on a BEx
query. Due to not having a Now() type function in the generated MDX, utilizing dynamic date functionality in
a BEx based universe is a challenge. This document presents ways in which these challenges can be met.
First, there is a brief review of BEx variables and how they function in the universe (this will not be all
inclusive, but a review sufficient for this article). Then, two scenarios and the associated development to
implement dynamic dates (single dates and date groupings) are reviewed.

BEx Variables within a BO Universe Overview
Standard variables
There isn’t anything limiting really, when it comes to standard variables. They work very similarly to how they
would in a BEx query.
User Exit Variables
With these variables, they cannot be ready for input. Creating a variable of type customer exit, the custom
code will not be invoked if the variable is marked as ready for input. This is what makes dynamic date
functionality difficult. Since the variable cannot be ready for input, in order to invoke the code, the default
values cannot be populated to a variable using ABAP. This is how a variable is typically populated with a
default system date.
Data read for prompt list of values
When the query in which the universe is built from is based on a single DSO or Cube, the list of values is
generated from InfoProvider related values. The universe will not read master data in these cases to
generate the list of values.
If the universe is built on a query based from an InfoSet or MultiProvider, master data will be read to
generate the list of values.

Single Dynamic Date Scenario
The first scenario explores how to dynamically define a single date within a universe. This solution does not
get around the dynamic date populating the BO prompt to a default date. The limitation with not invoking
user exit coding for variables ready for input does not allow writing the dynamic date to the prompt. This
workaround should be suitable and also allows scheduling reports using a dynamic date as well.
Start with a BEx query in which the date characteristic to be implemented dynamically will have two variables
associated with it. Here a month variable is used, but this solution is appropriate for any date variable.


Dynamic Dates within a BEx Universe
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 4
Below are summaries of the variable definitions.

Temp Month for Testing:

 Tech ID – YYMONTH_EXIT
 Processing By: Customer Exit
 Variable represents: Single Value
 Variable is optional
 Variable is not ready for input.

Calendar Year/Month (Single value, Optional)

 Tech ID – YCA_YM1
 Manual Input/Default Value
 Variable represents: Single Value
 Variable is optional
 Variable is ready for input.
 No default value is defined


Next, code for the variable processed by customer exit. Here is the user exit code for variable
YYMONTH_EXIT:
If I_STEP = 2.

read table I_T_VAR_RANGE INTO LOC_VAR_RANGE WHERE vnam = 'YCA_M1'.

If SY-SUBRC <> 0.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
concatenate sy-datum+0(4) sy-datum+4(2) into l_s_range-low.
append l_s_range to e_t_range.
ENDIF.

ENDIF.


This code first tries to find the variable which is ready for user input. If the user did not enter a value for the
variable, the read will not find anything in the internal variable table. When this is the case, the month is
defaulted to current month for the customer exit variable. With this coding, one of the month variables will
always be blank. By doing this, neither variable interferes with the other. So if the user simply doesn’t define
a date/month, then it is defaulted to current. This will also work when scheduling the report. If it is scheduled
with no default value in the date field, the customer exit variable then takes over and populates the other
date variable. This is how to schedule the report as well with a single dynamic date.

Below are the WEBI screenshots to show this working. The universe was created directly off the query with
the variables described above and no other modifications were done. The query used shows inventory
quantities.

Dynamic Dates within a BEx Universe
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 5
Prompt screen showing 01/2011 as the selected month:


Related output:

In the above screenshot, the selected month of 01/2011 is what appeared on the report.

Dynamic Dates within a BEx Universe
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 6
Prompt screen showing no calendar month selected:


Related output:


This is the sandbox system and data has not been loaded for material movements in a while. However, this
shows that not entering a month makes it default to current month through the backend ABAP routine.
Again, this will not default a date into the BO prompt screen. There is no conventional method in which to do
that. The prompt variable/filter can simply be created with a description that indicates to the user that leaving
the field blank implies current date will be used. The user can then input a date value if they want something
other than current date to be used.
Dynamic Dates within a BEx Universe
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 7

Dynamic Date Grouping Scenario
The second scenario explores how to create dynamic date groupings in a BEx-based universe. In this
article, dynamic date groupings refers to year-to-date, month-to-date, and anything of the sort. While
creating YTD, MTD, etc… key figures in a BEx query is a trivial concept, the challenge lies in having one key
figure and allowing the user to select at run time if they want YTD, MTD, and so forth. The solution
presented here provides details to the WEBI level, but can be just as useful for stand alone BEx queries/Web
Templates.

The main problem encountered with this scenario is that a BEx variable, unless it is a text variable, is used to
build the data selection based on objects that exist in the DataProvider. So the solution is to develop a
method which gives the user a way to select data groupings in the prompt screen, from a variable built off an
InfoObject which doesn’t actually exist or hold data in the InfoProvider. A very general set of data is used
here to demonstrate the functionality. This is broken into areas of the development/solution from backend to
WEBI.

Step 1: Base InfoProvider
Here a very generic DSO object is used. It contains sales order information and a few key figures. For this
article, the data itself isn’t of much importance. The following are created: YEMSIBTP, Sales Data Temp
DSO for BO Testing.

A quick utility program is written to fill this DSO from the standard sales DSO (move corresponding type of
idea). So as it sits right now, price is the date object in our DSO. All other objects are typical sales related
InfoObjects and do hold data.
Dynamic Dates within a BEx Universe
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 8
Step 2: New InfoObject
Introduce a new InfoObject whose purpose is to hold the reporting periods for the users to be able to select.
This is called YREPPERBO, BO Reporting Period Object.

As is shown, this InfoObject has associated master data and text associated with it. It is in NUMC, length 2
because the object itself will just have numerical values and the text is what the users will select on. This
also makes the backend coding much simpler with having language dependencies on the object.
Next, create some master data for this object.

Dynamic Dates within a BEx Universe
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 9

The base reporting DSO and the new reporting period InfoObject is now created.

Step 3: Reporting Layer InfoProvider
The next step to this solution is creating a reporting layer provider. This will be done using MultiProvider.
Using MultiProviders as the reporting layer solution is common practice. Create a MultiProvider which uses
the sales DSO and the new InfoObject. Obviously, having the data roll into a cube is best practice for
reporting but the DSO is being used to keep this example simple.


When defining the MultiProvider associations, there are just 1-1 mappings to make. This would change if
there are multiple DSOs or Cubes in the MultiProvider, but the main idea is that there is the new InfoObject
and the following association shown below.
Dynamic Dates within a BEx Universe
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 10


Step 4: Query
A BO Prompt Testing query has been created based on the MultiProvder from the previous step. It is a very
simple query, bringing in just a few characteristics, key figures, and variables. The following focuses on the
main parts of the query.
Date variable – Earlier it was mentioned that pricing date is what is used as the date characteristic in this
example. There is a variable on pricing date of type user exit and not ready for input. Note that there is a
variable on sales organization as well, and that was just to add something else to the prompt screen.



Dynamic Dates within a BEx Universe
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 11
Local key figure selection – Here a local key figure selection is built that includes the new InfoObject
previously created.


Notice the new InfoObject has a variable on it. This variable is single entry and mandatory. It would not
have to be mandatory, but is for this article. Also, making the key figure global would be ideal for something
that is going to production so it could be reused.
Note that this variable is within a key figure selection so that it does not influence any true data in the report.
It will mainly apply to just that key figure and that figure will never be used/shown.

Three variables remain:
 Price date – User exit, not ready for input
 Sales org – Doesn’t really serve a purpose but just used to add to the selection screen
 BO reporting period – Single entry, mandatory.

Dynamic Dates within a BEx Universe
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 12
Step 5: User Exit Coding for Price Date Variable
This article assumes the reader understands how to create and code user exit variables. For those new to
this area, a link in the related content is provided.
The coding idea is simple. In I_STEP 2, look to see if the BO reporting period variable is populated. If so,
then invoke the code to populate the pricing date based on the reporting period selected:


Notice that based on the numeric value of the users selection, the pricing date is being populated
accordingly. For this article the dates have been hard coded into this ABAP, but in a real life scenario have
them generated/determined in the code.

Dynamic Dates within a BEx Universe
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 13
Step 6: Create the universe and WEBI report
This article assumes a working knowledge of universe building and WEBI report building. See related
content for links to information on those areas.
The universe used was simply created directly from the query and not modified in any way.


Note that the universe has imported the sales org and BO reporting period variables. Since the pricing date
is user exit and not ready for input, it is not recognized.


The next step is to build a simple WEBI off this universe. Here there is a query with outputs as date and
quantity. This is merely a way to show that the selections are working.

Dynamic Dates within a BEx Universe
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 14


Finished Product
Development is complete. Here is the finished product with output examples.
The selection screen is shown below.

Note: Since the BEx query is on a MultiProvider, the universe goes after the InfoObjects master data for selection
criteria.

Dynamic Dates within a BEx Universe
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 15
Output:


Another example is shown below using different selection.


Dynamic Dates within a BEx Universe
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 16
Output with the new selection:


Conclusion
Hopefully through this paper it is evident that using dynamic dates with a BEx based BO universe is not only
possible, but not difficult to do. The first time it may take a little extra effort, but after that, everything is
reusable for other reports.
It is also important to note that the date groupings idea works very well on just a BEx Query or BW Web
Template query as well. This article addressed the needs of dynamic BO reporting, but it would be just as
suitable for those solutions as well.

Further Possibilities
Some ideas on how to further extend this:
 Have a “configuration” table for each reporting period ID. In the program, look up the ID (01, 02, 03)
and the table will have all the information needed for variable population. A process of updating that
table could also be built either manually or using ABAP. By doing this, new values can actually be
added in production and anywhere this functionality is used. It will reference to table and use all like
values for consistency.
 This solution is not only applicable to dates. Use this for user selection in many ways. Any place
where it would be ideal for the user to make selections which are readable via backend ABAP, but
not actually part of the data provider, would be a scenario for this type of development.

Dynamic Dates within a BEx Universe
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 17
Related Content
SAP NetWeaver 7.0
How to Create BO Universe using SAP BW
Using User Exit for Variables in BEx Reporting
For more information, visit the Business Objects homepage.


Dynamic Dates within a BEx Universe
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 18
Disclaimer and Liability Notice
This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not
supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.
SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document,
and anyone using these methods does so at his/her own risk.
SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or
code sample, including any liability resulting from incompatibility between the content within this document and the materials and
services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this
document.