Query Designer - Variables - Replacement Path

I need a help.
In one query I need to select some data from the current Period until yesterday.
In another query I need to select the same data, but from the current Month until yesterday.
I created 2 restricted key figures:
SEL_PERIOD restricts 0FISCPER by the variable 0FPER, wich is an exit SAP for current Period.
SEL_MONTH restricts OCALMONTH by the variable 0CMONTH, wich is an exit SAP for current Month.
Now in both RKFs I want to restrict 0CALDAY from the beginning of the Period or Month until yesterday.
I found this variable 0DAT, wich is an exit SAP for current day.
I'm trying to create an interval variable, type replacement path, with From Value not filled and To Value filled with 0DAT - 1.
But it doesn't work, Query Designer points that 0DAT is not an allowed source for the target variable.
And the documents that I searched state that "the target variable must represent a single value" and "the source variable must be input-ready".
Does anyone have a suggestion on how I can restrict 0CALDAY, for this specification ???
Thanks in advance.
César Menezes
Edited by: César Menezes on Jun 25, 2011 11:51 PM
I forgot an important point:
Sometimes I need current Period or Month, in other cases I need the same Period or Month from last Fiscal Year or Calendar Year.
No problem with 0FISCPER and 0CALMONTH, I can off-set the variables by -12.
But I would like a help on how to do it with 0CALDAY.
Example: today is 25.06.2011. In some cases I need to restrict until 24.06.2011, in other cases I need to restrict until 24.06.2010.

Hi Ceaser,
This is a generic explanation to your scenario. Please make some changes as per your requirement. Just to give you some idea......................
We  need to manipulate u201CKey Dateu201D values to achieve required analytics.
Step 1: As a first step, create a variable on u201CSales Dateu201D (or whichever date is used for Sales Date) field (ZPDATE) with user input. It was meant to capture u201CKey Dateu201D through user entry.
Step 2: Create a restricted key figure on Sales & restrict it on u201CKey Dateu201D value to get first analytics need i.e. u201CSales on Dayu201D.
Step 3:Next step was to manipulate the value of u201CKey Dateu201D on which I could restrict u201CSalesu201D (Key Figure) again and again to get other values.
Step 4: Create a new variable (e.g. ZPUTMNTH) and assigned it to be filled up by Customer Exit. (For simplicity purposes only u201CMonth to Dateu201D value is explained below. Same procedure can be repeated to fulfill other needs. Though in code section, ABAP code is available for almost all the variables)
Create Variable
Step 5:  Create one variable (ZPUTMNTH) for u201CMonth to Dateu201D with processing by u201CCustomer Exitu201D. This variable was created on u201CDateu201D characteristics.
Sample ABAP Code
*& Include ZXRSRU01
DATA: L_S_RANGE TYPE RSR_S_RANGESID.
DATA: LOC_VAR_RANGE LIKE RRRANGEEXIT.
Data: v_loc_date type d.
Data: v_loc_date1 type d.
Data: v_loc(4) type c.
CASE I_VNAM.
to calculate "month to date" user input is "Calday" Key Date
WHEN 'ZPUTMNTH'.
IF I_STEP = 2. "after the popup
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
WHERE VNAM = 'ZPDATE'.
CLEAR L_S_RANGE.
L_S_RANGE-LOW = LOC_VAR_RANGE-LOW(6). "low value, e.g.YYYYMM (200606) part of key date (20060625)
L_S_RANGE-LOW+6(2) = '01'. u201C low value e..g. YYYYMM01 (20060601)
L_S_RANGE-HIGH = LOC_VAR_RANGE-LOW. "high value = input
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'BT'.
APPEND L_S_RANGE TO E_T_RANGE.
EXIT.
ENDLOOP.
ENDIF.
to Calculate no of days up to "month to date" (user input Calday Key date)
WHEN 'ZDAYMTH'.
IF I_STEP = 2. "after the popup
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
WHERE VNAM = 'ZPDATE'.
CLEAR L_S_RANGE.
L_S_RANGE-LOW = LOC_VAR_RANGE-LOW+6(2). "YYYYMMDD - DD will indicate the no of days
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'EQ'.
APPEND L_S_RANGE TO E_T_RANGE.
EXIT.
ENDLOOP.
ENDIF.
to calculate Previous year "month to date" (User input Calday u2013 Key date)
WHEN 'ZDAYPMTH'.
IF I_STEP = 2. "after the popup
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
WHERE VNAM = 'ZPDATE'.
CLEAR L_S_RANGE.
L_S_RANGE-LOW = LOC_VAR_RANGE-LOW.
L_S_RANGE-LOW(4) = L_S_RANGE-LOW(4) - 1. "low value previos year
v_loc_date = L_S_RANGE-LOW. "take input value in another variable
L_S_RANGE-LOW+6(2) = '01'.
L_S_RANGE-HIGH = v_loc_date. "high value = input, taken into another variable
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'BT'.
APPEND L_S_RANGE TO E_T_RANGE.
EXIT.
ENDLOOP.
ENDIF.
to calculate "year to date" (User input Calday u2013 key date)
WHEN 'ZPUTYEAR'.
IF I_STEP = 2. "after the popup
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
WHERE VNAM = 'ZPDATE'.
CLEAR L_S_RANGE.
L_S_RANGE-LOW = LOC_VAR_RANGE-LOW(4)."low value, e.g.200001
L_S_RANGE-LOW+4(4) = '0101'.
L_S_RANGE-HIGH = LOC_VAR_RANGE-LOW. "high value = input
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'BT'.
APPEND L_S_RANGE TO E_T_RANGE.
EXIT.
ENDLOOP.
ENDIF.
to calculate "Previous year to date" (User input Calday u2013 key date)
WHEN 'ZDAYPYR'.
IF I_STEP = 2. "after the popup
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
WHERE VNAM = 'ZPDATE'.
CLEAR L_S_RANGE.
L_S_RANGE-LOW = LOC_VAR_RANGE-LOW.
L_S_RANGE-LOW(4) = L_S_RANGE-LOW(4) - 1. "low value previos year
v_loc_date = L_S_RANGE-LOW. "take input value in another variable
L_S_RANGE-LOW+4(4) = '0101'.
L_S_RANGE-HIGH = v_loc_date. "high value = input, taken into another variable
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'BT'.
APPEND L_S_RANGE TO E_T_RANGE.
EXIT.
ENDLOOP.
ENDIF.
to calculate "Previous year" User input Calday u2013 key date
WHEN 'ZPYEAR'.
IF I_STEP = 2. "after the popup
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
WHERE VNAM = 'ZPDATE'.
CLEAR L_S_RANGE.
v_loc = LOC_VAR_RANGE-LOW(4) - 1.
L_S_RANGE-LOW = v_loc. "low value previos year
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'EQ'.
APPEND L_S_RANGE TO E_T_RANGE.
EXIT.
ENDLOOP.
ENDIF.
to calculate No of Days - "year to date"
WHEN 'ZYRDAY'.
IF I_STEP = 2. "after the popup
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
WHERE VNAM = 'ZPDATE'.
CLEAR L_S_RANGE.
v_loc_date1 = LOC_VAR_RANGE-LOW.
v_loc_date = LOC_VAR_RANGE-LOW(4). "low value, e.g.200001
v_loc_date+4(4) = '0101'.
L_S_RANGE-LOW = v_loc_date1 - v_loc_date. "get the difference between current date & first date of year
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'EQ'.
APPEND L_S_RANGE TO E_T_RANGE.
EXIT.
ENDLOOP.
ENDIF.
Save and Activate the Include.
Go back to Exit and activate again.
Go back to Project and activate again.
Variable (ZPUTMNTH) is ready (its values filled up with the manipulation of u201CKey Dateu201D) to be used in query to restrict Key Figure u201CSalesu201D on it and get u201CMonth to Dateu201D (MTD) Sales Value.
Regards,
Suman

Similar Messages

  • Query Variable - Replacement Path

    Hi all,
    I would need to fill a query variable (based on calendar week characteristic) with specific list of values. I need all calendar weeks that are present in infocube, but only if key-figure > 0. So I've created a query with cal. weeks in rows and with suppressed zero rows. Output values from query contains exactly what I need.
    Than I created a variable (replacement path) with reference to mentioned query. But it seems to me that the variable does not contain all values displayed in the query, but only filtered values (if I use some restriction of cal. week).
    Is it possible to achieve this using replacement path at all?
    If not I would appreciate any idea or experiences how to accomplish this requirement.
    Many thanks,
    regards,
    Pavel

    Hi Pavel, I didn't get your requirement 100% . Still, I would like to tell How Replacement path works.
    First of all for the Source query you have given condition to restict the output of the query on particular keyfigure value > 0 ......  Right.
    Now on second query, you have created the Characteristic variable with Replacement path....here some important things to look at.
                    while creating the variable, select Processing Type as REPLACEMENT PATH, then in the "Replacement path" Tab,  give Replaced variable with.. "Query" ...and at bottom, For QUERY give the query name.
    If u want RRI facility from Source Query to Target Query, then u give RRI Connection in T-Code : RSBBS....
    ...and now when u execute the Second Query, First the first Query will be executed and those filtered values > 0 will be passed to the Second Query's variable input...then the second query will be executed...
    But, in your case check once again all settings in Variable in Second Query..and Conditions block in First Query..
    It should definitely work...
    ---Intros.
    Edited by: Intros on Apr 25, 2008 1:31 PM

  • Query View in Replacement Path variable

    When selecting the query for a replacement path variable there is an option 'Use View for Query Start'.
    Does anyone know what this is (supposed) to do?
    Whatever setting I use during testing, the result is always the same.
    Thanks,
    József.

    I, too, have this same question.  I have looked for an explanation of the "Use View for Query Start" checkbox and its usage, and while I would expect that to be explained in one of the following links, it is not...
    http://help.sap.com/saphelp_nw70ehp1/helpdata/EN/bd/589b3c494d8e15e10000000a114084/content.htm
    http://help.sap.com/saphelp_nw70ehp1/helpdata/EN/ee/1e9b3c334d8c15e10000000a114084/content.htm
    http://help.sap.com/saphelp_nw70ehp1/helpdata/EN/2c/78a03c1178ad2ce10000000a114084/content.htm

  • Preselection-variable (replacment-path: replacement with query)

    Hello Expert's
    Can you explain me, how we can set up a pre-query with characteristics and key figures.
    e.g.
    Due the performace reason in the olap process, we have the calculate a range of values before
    in query 1. This query contains characteristics and key figures.
    In the query 2 we've preselection-variable (replacment-path: replacement with query) to query 1.
    My question is, how we can get also the key figures-values from query 1, to continue to use the values for query 2?
    Thanks for feedbacks,
    Regards

    Hi,
    As this is the variable restriction and variable restrictions are not put on key figure values (except RKF). As I know you will not be able to get key figure values using replacemtn path with query.
    Regards,
    Durgesh.

  • Crystal Report using BW Query that contains replacement path (control query

    I have a Crystal report built on a BW query.  The BW query contains a replacement path on a characteristic (as a control query).  The control query has additional variables that the main query is not using.  The crystal report is not recognizing any of the variables that the control query includes.  How do I get the crystal report to recognize the control query variables?

    Post your question BEX and B1 and/or classic SAP data source issues to the Integration Kit forum

  • Behaviour of a query with a replacement path variable on the web

    Hi,
    We have BW 7.0 at support pack 17. We have a query which has a replacement path variable whose values get replaced from a pre-query. This query runs fine and returns quickly when run in the Bex Analyzer. The same query when run on the web hangs. It never returns. Have any of you experienced such a behaviour?
    Thanks and Regards
    Subray Hegde

    Hi there,
    solution I found is to create new Replacement Path variables, based on the InfoSet objects. 
    Although they are technically the same infoobjects the Query Designer treats them as different objects.
    cheers,
    F.

  • Using Variable Replacement Path with Hierarchies

    Hi,
    I have a requirement where I have two product hierarchies.
    In my report I want the user to be able to select which hierarchy they view at run time.
    I want them to be able to see this hierarchy as a tree,in order for me to do this I first must inlcude one variable to specify which hierarchy i am going to use, then the next Variable2 is populated by Variable1 and allows the users to expand on that hierarchy tree.
    E.g
    At Run Time
    Selection 1: User selects Product Hierarchy1
    Selection 2: Gets automatically populated based on selection 1 to show the product hierarchy tree for this variable.
    I have tried using replacement paths to do this but it does not allow this.
    Any ideaS?
    Thanks

    It finally worked, looks like the reason it was not working was a Query Designer exception issue whihc went with a re-start of Query Designer.
    All good

  • Query Design (Variable & Dummy-Ouput)

    Hello everyone,
    i have two questions, its Analysis for Office 1.4.11.3353.
    a) Is it possible to pass a variable (forced by a prompt) from one query to a second query?
    Example: User starts Analysis for Office and is forced to enter a variable (e.g year 2012). Afterwards (after some macros and calculations) the user triggers a second query via a macro. And here, the query takes the variable of the first query (year 2012). So, if the user would have been entered the year 2018 at the very beginning, the second query would have taken the year 2018 too. I tried to use the replacement path option of the query designer, but it didn't work out.
    b) How do I load a dummy structure (rows and colums) to AO ?
    Example: I created a query with different query elements. Atm no transactional data are being loaded into the BW. Logically no data are loaded into my report and the workbook stays empty. But i need the basis structure of the report (coums, rows) in my workbook. Is is it possibly to fill the report (or query) with zeros or dump values by changing the query?
    Thanks all,
    Matthias

    Thank you so much Cornelia.
    1) I guess I wasn't sure if some of the settings could be applied in AO. It seems that it is not the case.
    2)  Just to clarify: There are two queries within the workbook. The first query get triggered by macro. By triggering the query a prompt will show up and force the user to enter a certain year.
    Thereby, the prompt could be used next year again because its kind of dynamic. That's the goal.
    At a later step the user has to trigger another query. This query should use exactly the same year (or entered variable) as the first query. But without forcing a (visible) prompt (variable selection) again. So it should be dynamic regarding the time too.
    For that reason I looking for a way to transfer the entered variable from the first query to the second query automatically.
    3 & 4) Thanks, worked fine!
    5) Another question concerning formulas and selctions came up:
    Actually I'm mapping certain movement types to different accounts. I simply used a "New Selection" to combine the needed account and the movement type.
    Right now,I need to combine several movement types with ONE account. In fact I need to calculate the balance of the desired account. From my point of view I need to make a "New Selection" for every movement type.
    Exampe:
    Selection 1: Account A, Movement Type A
    Selection 2: Account A, Movement Type B
    Selection 3: Account A, Movement Type C
    Formula 1 (for the account balance): Selection 1 + Selection 2 + Selection 3
    This seems to be very complicated, especially if you use more than 3 movement types because you need to create a lot of selections.
    Is there a smarter way like doing the calculation/summation within a selection?
    Thank you
    Matthias

  • Exception color with formula variable(replacement path)

    Hello,
    I tried to define exceptions in a query which "from" and "to" values
    are determined by formula variables with replacement path. I checked
    the values of the formula variables and they are right. <b>But <b>the cells
    are not colored</b></b>. When I set the same values in the field "from" and "to" without variables : the colors appear.
    Could help me to resolve this problem please ?
    Catherine Bellec

    Hi Alec,
    You are right, the user exit permits to color the lines.
    But the value of my variable needs to change for each line of the infocube so I can't do this with the user exit RSR00001 because it concerns global variables.
    That's why I used a replacement path on a virtual characteristic.

  • Variable replacement path with another variable

    Hi Guru's
    I'd like to use the functionnality of replacement path from a variable.
    Well, i have variable V_1 which is a basic manual entry variable based on a date infoobject. this variable is not mandatory and accessible.
    And i have the variable V_2 which should be based on V_1 so i created V_2 with a process replacement path and in the replacement tab i put V_1 (i try with the list but i didn't find my V_1)
    But the result is that V_2 is always empty but i have no problem when i check the query
    So do you have any idea ?
    Why i can not see the V_1 in the list of variable from the replacement ?
    I don't want to use by exit. i know that it is possible but i want to use the main simple functionnality for flexibility is maintenance by users.
    Thanks for help
    Cyril

    thanks for your answer,
    svu123, my V_1 variable is of course in a correct status to be used. i made test in first without V_2.
    And when i create V_2 in the first tab i activated correctly the replacement in processing type. if not i can not choose
    the query or variable source and i can not see the list of variables.
    Rakesh, i tried what you answered without results. i check different variables that are available in the list and i have
    lots of different variables (all in ready for input) but i have interval, multiple single values, SAP standard variables my own variable on other fields.
    any other ideas ?
    many thanks
    Cyril

  • Offset in Variable Replacement Path

    Hi gurus,
    I have a 7.0 BI System.
    I can't able to set an offset in a variable replace from query.
    It's normal? Or I must to set some parameters to make it?
    Thanks in advance.

    Hi,
    What you exactly mean by variable replace - is it
    Formula variable with processing by replacement path  -If yes, then you can set the offset in the replacement path variable. when we create a replacement path variable then we do get the option for setting the offset. Please check that while creating a replacement path variable.
    Thanks
    Dipika

  • Formula variable / Replacement path issue

    Hi Experts,
    I have a Field which has different status description.
    I want to bring the count of only one preferred description.
    Model Status
    A1     New
    A2     Open
    A3     New
    B1     Closed
    B2      Pending
    B3     New
    I want to view only the closed count of models
    Model Count of Closed
    A1     0
    A2     0
    A3     0
    B1     1
    B2      0
    B3     0
    I tried doing this using the formula variable and Replacement path with Status Field.
    But I'm unsuccessful in selection the desired status.
    Please help me to over come this.
    Thanks

    Hi Dear Prasad,
    I can't restrict the characterstic to Closed. If I do so the output will be only for Closed.
    But here I want to bring every model with value as 0 and 1 for model with closed status.
    Hi Dear Raju,
    The requirement what I have here is more complex. like, the result will be for 6 month displaying every single cal/day.
    and also I have to find out percentage of closed for every cal/day based on number of model we got.
    i have only asked a small portion of it, with this input i will manage to build the percentage etc....
    I  cannot bring counter inside. My report is already too wide to be displayed.
    I have tried similar kind of thing, using CKF, Formula Variable and Replacement path with the Char - InfoObj.
    http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/009819ab-c96e-2910-bbb2-c85f7bdec04a&overridelayout=true
    But I'm not very sure how do I get only count of the my desired status.
    Please help.
    Thanks

  • Derive YYYYMM from YYYYMMDD with formula variable replacement path

    Dear All
    For deriving month from date I tried the replacement path variable with the offset 0, length 6 (for YYYYMM). But the YYYYMM displayed as a number i.e. 200502 as 200,502. Tried to divided by 100. It still displayed as 2,005.02. Any idea how to let it as 200502?
    Thanks, Jessica
    Message was edited by:
            jessica sheng

    Actually, here's a quick example of a customer exit that I think does what you want (I did it here in this text, so you might need to debug):
            WHEN 'ZDAT_MTH'.
    DATA: l_curdate  like sy-datum.
    *           Initialization
                CLEAR: l_calmonth, l_curdate.
    *           Get calmonth from curdate
                CALL METHOD cl_rsar_function=>date_month
                  EXPORTING
                    i_curdate  = l_curdate
                  IMPORTING
                    e_calmonth = l_calmonth.
    *           Return calendar month
                CLEAR l_s_range.
                l_s_range-sign = 'I'.
                l_s_range-opt  = 'EQ'.
                l_s_range-low  = l_calmonth .
                APPEND l_s_range TO e_t_range.

  • BI 7 - BEX Query Designer variable question

    Hi all,
    If I have an Entry Variable in the selection screen of a query,  is it possible to populate another variable based on the user input.
    e.g.
    If I have a Report Date with a mandatory input, and I want a CalMonth variable to be populated based on this.
    Is the only way of achieving this through customer exits???
    Many thanks,
    Shane.

    Hi Shane,
    You would need to write a code in the CMOD for the variable, something like below:
    Declare internal table IT_RANGE with type same as I_T_VAR_RANGE.
    Also declare work area WA_RANGE like line of IT_RANGE
    when 'variable_name'.
         IF i_step = 2.
         REFRESH e_t_range.
         data: v_date type sy-datum.
         data: v_date1 type sy-datum.
         data: v_month type I length 2.
         data: v_year type I length 4.
         read I_T_VAR_RANGE into WA_RANGE where VNAM = 'variable_name' and IOBJNM = '0cal_day'.
         if sy-subrc = 0.
              v_date = WA_RANGE-LOW. "Date Entered by user     
         endif.
         WA_RANGE-SIGN = 'I'.
         WA_RANGE-OPT = 'EQ'.
         * here we will write our logic to populate the 7 dates as required.
         * and populate the date into v_date1.
            WA_RANGE-LOW = v_date1. "Similar procedure to derive all 7 dates
         append wa_range to e_t_range. "We append all the 7 derived dates to e_t_range
            "(i.e. 7 append statements)
         You should be careful while writing the logic for previous month to handle year ends.
         you can use sample code like below for that:
         v_month = v_date4(2). "month
         v_year = v_date+0(4). "Year
         if v_month = '01'.
              v_month = '12'.
              v_year = v_year - 1.
         endif.
    You will probably need an ABAPers help to write the logic for deriving the dates as required.
    Here your logic will be like finding end date of previous months which can be done using function module LAST_DAY_OF_MONTHS
    similarly you will have to get last dates of 3 quarters, which can be done by determining which quarter the input date falls in.
    and same for the year end date.
    Hope this helps
    Regards,
    Joe
    Edited by: lazarus_joey on Feb 15, 2012 6:45 PM

  • Query Designer - Variables with exclusion: is it possible?

    could be possible to create in BEx a Variable that exclude a Manual entry Value?
    thank you
    Massimiliano
    Edited by: Massimiliano Indrio on Mar 11, 2010 11:32 AM

    Hi Massimiliano,
    You can code it in the Customer Exit - I_STEP =2.
    Where you can read the value entered by the user , and in the assign the sign as :l_s_range-sign = 'E'. which will exclude the values from selecetion.
    Hope this helps,
    Regards,
    Umesh.

Maybe you are looking for