Set variable value from a query - is it possible?

Hi all,
I need to use a 'precalculated' value in my report measures' calculations.
Is it possible to set a variable value as a result of a query?
Thanks in advance,
Alex

Hi,
In my report, I need to calculate one of the columns as a [certain measure] / [result of another query]
I didn't succeed to include the [result of another query] as a column in my report's request, but it would be very easy to calculate this [result of another query] separately.
The [result of another query] value is same for all the rows of my report.
What I'm trying to do is to run a query before my report (e.q. in the Prefix section), set a variable = [result of another query] and then use this variable in the column calculation of the report.
Is this possible?
Thanks,
Alex

Similar Messages

  • How to transfer variable value from one query to another query?

    I create two queries which contain the same variable "Year" and "Month".
    In the wad,Query1 is used to be a table and Query2 is used to show the chart in the condition with the same variable value of Query1
    So I want to transfer the variable  value from query1 to query2.
    Can anyone help me ?

    Let me explain the issue in detail.
    In Query Designer, both the year and  month variables are defined by user exit function to read current year and month and can be modified  during the query runtime.
    In WAD, Query1 is  used  to be a table with a table interface to hyperlink a chart which is defined by Query2 with the same variable value of Query1.
    During the runtime of template, if I change the variable value of Query1 , I want the variable of Query2 to be changed automatically with the same new value.
    So in the table interface of Query1 , I write the ABAP code in "SE24" and related source code to the variable is following:
    concatenate
    'function fire_urlJGSP_Col(filter) {'
    Cl_rsr_www_renderer=>c_lf
    'chart_url="' url '" + "&CMD=LDOC'
    '&TEMPLATE_ID=GCCHART_9' "WEB ID of the work book
    '&PAGEID=Graphics'       "Name of the view
    '&CMD=PROCESS_VARIABLES&SUBCMD=VAR_SUBMIT&VAR_NAME=Z2MYEAR&VAR_VALUE_EXT=" + filter'
    Cl_rsr_www_renderer=>c_lf
    'openWindow(chart_url,"chart_window","dependent=yes","600",'
    '"450","true")'
    Cl_rsr_www_renderer=>c_lf
    into l_coding.
    In this way , I can only transfer the year variable value from Query1 to Query2 and not two variables .
    So , how  shall I do to transer the two variable value in the same?

  • Looping and setting cfset values (from a query)

    Stuck on how to get this to work.
    How would I go about looping and setting these values instead
    of doing them individually?
    The query this <cfset> references works fine and will
    work but repeats...
    <cfset ans1 = (qryGetPcts1.q1Ct / qryGetCounts.qID2) *
    100>
    <cfset ans2 = (qryGetPcts2.q2Ct / qryGetCounts.qID2) *
    100>
    <cfset ans3 = (qryGetPcts3.q3Ct / qryGetCounts.qID2) *
    100>
    <cfset ans4 = (qryGetPcts4.q4Ct / qryGetCounts.qID2) *
    100>
    <cfset ans5 = (qryGetPcts5.q5Ct / qryGetCounts.qID2) *
    100>
    So I'd like to loop and set them all instead...
    <cfloop index="i" from="1" to="27">
    <cfset ans#i# = (qryGetPcts#i#.q#i#Ct /
    qryGetCounts.qID2) * 100>
    </cfloop>
    But it's responding with this...
    Invalid CFML construct found on line 196 at column 19.
    ColdFusion was looking at the following text:
    I'm sure I'm missing something simple b/c this must be
    possible? Can I use a cfset in a loop?
    Help is appreciated

    In the main everything is in CF is in a struct. Armed with
    this information you use array notation to help you.
    <cfloop index="iCount" from="1" to="27">
    <cfset variables["ans" & iCount] =
    (variables["qryGetPcts" & iCount]["q" & iCount & "Ct"]
    / qryGetCounts.qID2) * 100>
    </cfloop>

  • Passing a variable value from one query to another within a web template

    Hi All,
    I have a web template with two queries.  Both queries have the same select option variable called ZSELCUST on the characteristic ZCUSTOMER but because they are different info providors (both infocubes) the customer has to be entered once for each query, even with the 'Display same variable only once' flag checked.
    I want the user to select the customer once and then that value be passed to the other query within the resulting web template output.
    Am I right in that the same variable is used more than oncee because of the different info providors?
    I'm struggling, can anyone help out there....???
    Best Regards,
    Stuart Humphrey

    Hi
    A way of doing this is by "linking" the queries: in transaction RSBBS you define the sender and receiver queries. In query navigation you can jump to the dependent query (blue arrow icon in the BEx tool bar). This transfers the navigational state to the called query: filters over characteristics and variable values.
    Hope this help
    German

  • How to set variables values via VBA.

    Anybody please help.
    How to set variables values via VBA in workbook. SAP Netweaver 2004s.

    Pass variable values with VBA and BI 7.0 funtions to Query
    At first a remark u2013 Iu2019ve read a lot of threads saying that passing values to a query can be done by using VBA code only. Iu2019ve tested it but Iu2019m not sufficient with the new BEX 7.0 API and therefore I use a mixture of BEX 7.0 funtionality and VBA. I create a BEX 7.0 design item button passing the values to a query u2013 I hide this button somewhere on the sheet or on a hidden sheet and I then raise the event to click the button from VBA code. Works fine and the maintenance is easier if something changes in the API in the future again.
    How to start:
    Switch to design mode in BEX Analyzer:
    Implement a BEX 7.0 design item u201Cbuttonu201D
    Click on the button to implement the properties
    Make the input for the commands
    data_provider = dataprovider_1
    cmd = process_variables
    subcmd = var_submit
    No comes the part with the variables u2013 Letu2019s assume a query has 4 variables but you only want to change 1 with the button u2013 an organizational unit for instance.
    Make a range somewhere in the excel with the following structure:
    Name    Index   Value
    VAR_NAME_1      1       Variablename
    VAR_VALUE_EXT_1 1       variablevalue
    Value should contain the name of your variable of course and u201Cvalueu201D the value of your variable
    Set a name for this range with EXCEL functionality but without the header:
    Back to the properties of the button: Insert the name of the range with the variables in the field Command Range:
    If you have more variables to process you can of course enhance your Filterrange!
    In the left upper Corner you have a name for your button:
    Now you can raise the button-click in vba like this:
    Application.Run "'" & ThisWorkbook.Name & "'!Sheet2.BUTTON_35_Click"
    regards, Lars

  • Setting Page Items from SQL Query

    Hi, </br></br>
    I am using "SQL Query (PL/SQL function body returning SQL query)" for a report. In the body of the sql query, after calling a function, I have the following statement: </br></br>
    APEX_UTIL.SET_SESSION_STATE( p_name => 'P13_MESSAGE', p_value => 'Contact Tech Support' ); </br></br>
    and I find that I cannot save the query. I get an error message: </br></br>
    <b>Unexpected error, unable to find item name at application or page level.
    ERR-1002 Unable to find item ID for item "P13_MESSAGE" in application "4000". </b>
    </br></br>
    I do have the field 'P13_MESSAGE' on my page. </br></br>
    Can't this API call be used within such a query type? Is there an alternative to this? </br></br>
    Thanks in advance </br></br>
    Vasan

    Scott,</br></br>
    I have given the source of the region, below. Its type is 'SQL Query (PL/SQL Function body Returning SQL Query'). </br></br>
    "Get_State_Hit" is a procedure in a package. I have not shown the name of the package here.</br></br>
    Please give me your suggestion. </br></br> Thanks </br></br> Vasan </br></br>
    ========= </br></br>
    DECLARE </br>
    l_sql varchar2(100); </br>
    BEGIN <br>  
    IF(:P13_MATCH_TYPE = 'ALL') THEN</br>
        Get_State_Hit ( one set of values from user-interface );</br>
        apex_util.set_session_state( p_name => 'P13_MESSAGE', p_value => ' MsgString 1' );</br>
    ELSE</br>
        Get_State_Hit ( another set of values from user-interface );</br>
        apex_util.set_session_state( p_name => 'P13_MESSAGE', p_value => ' MsgString 2' );</br>
    END IF; </br>
    l_sql := 'Select Col 1, Col 2, ..., Col 9 from ABC_Vw'; </br>
    RETURN l_sql;</br>
    EXCEPTION</br>
    WHEN OTHERS THEN</br>
    l_sql := 'Select * from Default_Vw' ;</br>
    apex_util.set_session_state(p_name => 'P13_MESSAGE', p_value => 'Contact Tech Support');</br>
    RETURN l_sql; </br>
    END;</br></br>
    ==========</br></br>
    Message was edited by:
    Vasan

  • Passing variable values from WAD to BEx

    Hi Experts,
    I am working with a query which is included in a web template. At the top of this template, I have several variables included in drop down boxes for the user to navigate through the data.
    With clicking at "open in Excel" a BEx-Query is started.
    My question: How can I pass the variable values from those drop down boxes to my Query in BEx?
    The current HTML code for starting the Excel BEx-Query looks like this:
    http://sapserver:port/x/x/x/rsr_bex_launch/bexanalyzerportalwrapper.htm?QUERY=Queryname
    Thanks in advance
    Marco

    If you export your report after selecting required drop down values, your report will be saved to Excel as it was filtered. You do not need any HTML code for this.
    My question: How can I pass the variable values from those drop down boxes to my Query in BEx?
    Why do you want to re-execute your query when you have already ouptut in the first screen shot?

  • How to derive a variable value from another variable of a different IO?

    Hi Gurus,
    I am aware that using BEx variables and Customer Exit you are able to derive a variable value from another variable of the same infoobject (for example, Fiscal Year/Period (0FISCPER) and Calendar Day (0CALDAY)).
    However, is is possible, using the same approach to derive a variable value from another variable that is in a different InfoObject? (for example, Input Fiscal Year/Period (0FISCPER) but derive Output of Required Start Date (0REQSTDAT))?
    There are 2 BEx variables involved,
    1) A user entry variable that is restricted in 0FISCPER
    2) A customer exit variable that is restricted in ZREQSTDAT
    In CMOD under EXIT_SAPLRRS0_001, Include ZXRSRU01, the code (I assume, correct me if I'm wrong) should perform 3 functions in I_STEP = 2,
    1) After the pop up, capture user entry of Fiscal Year/Period
    2) Identify or convert Fiscal Year/Period to Calendar Day range (unsure on how to code this portion)
    3) Use the Calendar Day to lookup on matching Required Start Date and display all Required Start Date that matches. (unsure on how to code on this portion)
    Hope to hear your thoughts soon.
    Regards,
    Eric

    Hi Shanthi,
    I've made the necessary adjustments. The only difference in my code is,
    Instead of,
    If I_VNAM = 'ZREQSTDAT'
    I use,
    CASE I_VNAM.
    Instead of,
    PARAMETERS: ZFISCPER TYPE /BI0/OIFISCPER.
    ZYEAR = ZFISCPER(4).
    ZMM = ZFISCPER+4(3).
    I use ,
    This is the Customer Exit Variable in ZREQSTDAT
    WHEN 'ZRSD_CX'.
    The loop I use for the User Entry Variable in 0FISCPER-ZFYP_IN
      LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
          WHERE VNAM = 'ZFYP_IN'.
        IF SY-SUBRC = 0.
            CLEAR L_S_RANGE.
    ZYEAR = LOC_VAR_RANGE(4).
    ZMM = LOC_VAR_RANGE+4(3).
    The codes were checked with no errors.
    However, when I input the Fiscal Year/Periods and hit 'Execute'. The report went blank, not sure what is the cause. I've tried it several times. No error message appeared.
    Regards,
    Eric

  • How to Sort by the length of the returned value from a query.

    Hi,
    I was wondering if it is possible to sort by the length of the returned value from a query?
    For example if I want to get a list of people with the name 'Samuel', I would like to short by how short the length of the whole name is.
    Sort by length of the name in SQL
    Samuel Syda
    Samuel Indranaka
    Samuel Johnsons
    Samuel Longhenderson
    Thank you.

    Hi,
    Sorting is done by an ORDER BY clause at the end of the main query.
    In most cases, you can ORDER BY any expression, even f it is not in the SELECT clause.  In this case, it sounds like you just need:
    ORDER BY  LENGTH (name_column)
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    Post your query, using an ORDER BY clause like the one above, and point out where that query is producing the wrong results, and explain, using specific examples, how you get the right results from the given data in those places.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • Passing global variable values from databse to forms

    I am using forms 6i and database is oracle 9i.
    I am trying to run a form stand alone ( by pressing CTRL-R) without putting it in the application.
    since when this form is placed in the application menu it works fine as it has been passed global variables values from the database .
    now i am trying to run the form without menu and thus i want to pass the values of global variables .please let me know where should i pass these values in form .is it be WHEN-NEW-FORM-Instance trigger or in Pre-form trigger.
    i know what are the global variable values passing into the form from database.
    i can hard code any values to check if the form runs well or not.

    If you intend to do this sort of testing regularly you might want to consider creating a seperate form with a control block which allows entry of the name of the form you want to run, the names of the globals and their values, and do a CALL_FORM.

  • RRI - Jump query, unable to pass the variable value from source to target

    Hi,
        I've a source query which has a variable on 0vendor, from this query i jump to another query for which i want to pass the this variable value, in the target query i've vendor in free characteristics (no filter or variable in there), and in RSBBS i tried the assignment details options keeping vendor as generic, tried variable and the variable name but nothing seem to work.
    But when query is run i can jump into target query but the vendor variable value doesnt get passed thru the values i get in target query is for all rather than for the variable entered vendor value in the source.
    btw we're in NW2004s.
    any help appreciated with points.
    thanks
    Mayil

    Anyways, I read somewhere that a variable with replacement path in target query would work, tried it seem to work.
    let me know if there other way to do it without creating a variable in target query.
    thanks
    mayil

  • Visual Composer - Variable values from VC to Query

    Hello,
    I am determining the URL dynamically using Function Module in VC, generate the necessary URL and execute the query... This part is working perfectly.
    Now I want to pass a variable value to it  as well.. Any ideas...
    Thanks,
    Om

    Hi,
    Try to use some function module which will convert query data into flat tables. (eg., RS_VC_GET_QUERY_VIEW_DATA_FLAT).
    Hope this solves your issue.
    Regards,
    Vinay

  • Filling up a variable value from another variable

    Hi,
    I have two date fields, one calmonth characteristic ZCALMON (as char) and other calmonth charactaeristic 0CALMON as time dimension (standard bw).
    But at query level, I would like to user enter only one variable value 0PCALMON for 0CALMON (say only for date characteristic as time dimension). This date variable value should get copied to other date characteristic ZCALMON (as char).
    I can do this by using the customer exit varibale (without writing any abap code) and using the copy variable from other variable options. But I am not able to use the offset on ZCALMON.
    How can i Use offset using customer exit variable on ZCALMON.
    cheers
    raj

    Hi,
    you can use customer exit variable which will read the value of the 0calmonth variable and pass it to the zcalmonth.
    While populating the value, do the calculation or the off-set and send the value to zvcalmonth (Variable).
    WHEN 'ZVCALMON'.
       IF i_step = '2'.
      Loop at i_t_var_range into i_s_var_range where vnam = '0PCALMON' .
        zdat = i_s_var_range-low.
      endloop.
          CALL FUNCTION 'GO_BACK_MONTHS' *Sample Function
            EXPORTING
              currdate   = zdat
              backmonths = '012'
            IMPORTING
              newdate    = from_period.
          CALL FUNCTION 'GO_BACK_MONTHS' *Sample Function
            EXPORTING
              currdate   = zdat
              backmonths = '000'
            IMPORTING
              newdate    = to_period.
          CLEAR l_s_range.
          lyear  = from_period+0(4).
          lmon   = from_period+4(2).
          lday   = from_period+6(2).
          CONCATENATE lyear lmon lday INTO l_s_range-low.
    Hope you got it
    Regards
    Happy Tony

  • WAD drop-down box and commands on Set Variable values/ Set Filter Values

    Hello to all
    I am confused in WAD and Help online couldn't clarify my concerns. Thus here following issue:
    I am using a WAD, where the data provider (query)  is set dynamically. I would like that
    1 user selects company in  drop-down-box 1
    2 I use commands on drop-down-box 1 to manage the next drop-down-box 2 ( like it becomes input ready)
    3 user selects plant in drop-down-box 2
    4 User selects a tab strip A, where report A of multiple reports is placed. Now in this moment I assign the query A to the data provider A.
    Now my questions:
    - I am not clear how to use the bex-variables required for the query ( like company and plan). If I use in drop-down variables, then I can't set anymore commands
    - What means and makes the command set_variable_state
    - What means and makes the command set_selection_state
    Thanks a lot for your clarification and help
    Christian

    Hi Christian,
    I will try and answer your Qs
    - I am not clear how to use the bex-variables required for the query ( like company and plan). If I use in drop-down variables, then I can't set anymore commands
    >> Can you explain how exactly are you trying to populate the DropDown webitems for Company / Plant data for user-selection.
    - What means and makes the command set_variable_state
    >> SET_VARIABLE_STATE is used to assign input values to your query variables. Here, the command gives you a range of input options to select from such as Characteristic/Text/Formula/Hierarchy Variables & Binding Type Selection. Binding Type Selection in addition gives you more options such as assigning manual input from a Text webitem [ITEM_INPUT], assigning value from another Variable [VARIABLE], or simply assigning the selected value from an underlying Data Provider such as one mapped to a DropDown webitem [DATA_PROVIDER_CHARACTERISTIC].
    - What means and makes the command set_selection_state
    >> SET_SELECTION_STATE is used to assign input values to Characteristics in your query. It serves as a Filter option.
    I think in your case using SET_VARIABLE_STATE makes more sense. You can use Binding Type Selection with [DATA_PROVIDER_CHARACTERISTIC] on both the DropDown webitems to assign the values of Company / Plant to the query on runtime.
    --Priya

  • Get variable values from a stored procedure

    I am using SQL 2008R2 and I want to replace a view inside a stored procedure with a new stored procedure to return multiple variable values. Currently I am using the code below to get values for 4 different variables.  I would rather get the 4 variables
    from a stored procedure (which returns all of these 4 values and more) but not sure how to do so.  Below is the code for getting the 4 variable values in my current sp.
    DECLARE @TotalCarb real;
    DECLARE @TotalPro real;
    DECLARE @TotalFat real;
    DECLARE @TotalLiquid real;
    SELECT @TotalCarb = ISNULL(TotCarb,0),
    @TotalPro = ISNULL(TotPro,0),
    @TotalFat = ISNULL(TotFat,0),
    @TotalLiquid = ISNULL(TotLiq,0)
    FROM dbo.vw_ActualFoodTotals
    WHERE (MealID = @MealID);

    You can replace the view with inline table valued user-defined function:
    http://www.sqlusa.com/bestpractices/training/scripts/userdefinedfunction/
    See example: SQL create  INLINE table-valued function like a parametrized view
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

Maybe you are looking for