Thursday, October 27, 2011

Calculations with key date

A bit of follow up to the previous post ... we'd like to have the key date at hand for performing some calculations, unfortunately we didn't find an easy way so with some micro abap we managed to get that variable into another variable (??) that can be used.
Coding for variables (CMOD on BW side, EXIT_SAPLRRS0_001, include ZXRSRU01 etc.) follows:
Wish there was a simpler way ...
case i_vnam.
 when 'YV_DAY_2_VAR'.
    if i_step = 2.
      loop at i_t_var_range into loc_var_range where vnam = 'YV_DAY'.
 clear: l_s_range. 
       l_s_range-low = loc_var_range-low.
       l_s_range-sign = 'I'.
       l_s_range-opt = 'EQ'.
 append l_s_range to e_t_range.

Monday, August 22, 2011

Prompts in SAP BO OLAP universe (query key date)

Having recently struggled with a key date prompt in a BO universe built on a BEx query ... I'm posting here some samples and screenshots of the outcome as I didn't find/couldn't understand documentation on this ....

The universe wizard in my case didn't generate something usable out of the box, so I had to tweak it a bit

First one, how to show it as a datepicker (sounds strange ...)

The corresponding code for the prompt is:

<filter key="[YV_DAY]"><condition operatorcondition="Equal"><constant tech_name=" @Prompt('Data Cardine (formato YYYYMMDD)','D',,mono,free)"></condition></filter>

Then if you want it to be a simple, no frills, single value prompt

<filter key="[YV_DAY]"><condition operatorcondition="Equal"><constant tech_name="@Prompt('Data Cardine (formato YYYYMMDD)','A',,mono,free)"></condition></filter>

And if you want the prompt to “forget” the previous value when the query is refreshed:

<filter key="[YV_DAY]"><condition operatorcondition="Equal"><constant tech_name="@Prompt('Data Cardine (formato YYYYMMDD)','A','Data\LovData CardineBase',mono,free, not_persistent)"></condition></filter>
Also see note 1407631 and keep up with the updates on BW and BO side, IMHO it’s not a mature solution yet.

Note 1142664 - MDX: Composite SAP note about performance improvements

Note 838800 - Composite SAP Note for consulting notes about MDX/OLAP BAPIs

Note 1156101 - MDX: Composite SAP note for incorrect data

Another useful one

Note 1567394 - MDX: Consulting note for sort sequence

Wednesday, July 20, 2011

Filtering on hierarchy values in DTP

Having spent some time unsuccessfully googleing for a way to use a hierarchy as filter in a DTP I've come up with a (rather inelegant) solution myself.
Posting it here in hope it's helpful.

DATA: l_idx like sy-tabix.

DATA: lw_hier_id TYPE rshi_s_rshiedirkey.
DATA: lt_nodes_a_leaves TYPE rshi_t_hienode.
DATA: lw_nodes_a_leaves LIKE LINE OF lt_nodes_a_leaves.

DATA: l_hier_name TYPE rshienm.
DATA: lw_hier_type TYPE rshiedir.

read table l_t_range with key
fieldname = '/BIC/ZFIELD_NAME'.
l_idx = sy-tabix.

l_hier_name = 'ZH_HIER_NAME'.

SELECT SINGLE * FROM rshiedir INTO lw_hier_type
WHERE hienm = l_hier_name
AND objvers = 'A'.

IF sy-subrc = 0.
lw_hier_id-hieid = lw_hier_type-hieid.
lw_hier_id-objvers = 'A'.

i_rshiedirkey = lw_hier_id
e_t_rsnodes = lt_nodes_a_leaves
invalid_hierarchy = 1
name_error = 2
iobj_not_found = 3
IF sy-subrc <> 0.

DELETE lt_nodes_a_leaves WHERE iobjnm = '0HIER_NODE'.

Loop at lt_nodes_a_leaves INTO lw_nodes_a_leaves.

l_t_range-fieldname = '/BIC/ZFIELD_NAME'.
l_t_range-sign = 'I'.
l_t_range-option = 'EQ'.
* substring is due to compounding, generally unneeded
l_t_range-low = lw_nodes_a_leaves-nodename+2(4).

append l_t_range.




* if l_idx <> 0.
* modify l_t_range index l_idx.
* else.
* append l_t_range.
* endif.
p_subrc = 0.
OK, this is all SAP BW jargon ;-)