FUNCTION Variable within Data Template

Hi Im calling a function within my sql and i want to use the result as a bind variable.... here goes...
Data Template...... XML
<sqlStatement name="Q1">
<![CDATA[select function_name(ppp.id) the_main_one,
:the_main_one + 10 new_value
from per_ppp]]>
</sqlStatement>
I get null value .... but from the_main_one i get a value..... any ideas... i checked for number and nvl(,0) and all that no luck
is there a grouping thing involved here... where as i need to call the function from within another sql statement...

It can be done.
Step 1: Setup package.
Step 2: Create a global variable for your function value
Step 3: Before the calling function returns the value, set a global variable (placeholder)
Step 4: Create a new function that returns the global variable, make sure it's after the first function call. Returning the value you might want to reset the global variable to null....
Your good to go.
Ike Wiggins
http://bipublisher.blogspot.com

Similar Messages

  • Calling a package function in the data template

    Hello All,
    I am not able to understand the concept of calling a function from the data template.
    In my data template, I put the sql statement as
    <sqlStatement name="Q_SEL">
    <![CDATA[  Select l_period_name PERIOD_NAME
                             from xla_tb_ap_report_pvt.get_period_name(1) ]]>
    </sqlStatement>
    Is it possible to call a specific package function as shown above in a select statement?
    I am getting the message "ORA-00933: SQL command not properly ended" when I tried with the above. Could you pls. point out what the error is in the above sqlStatement?
    1) My instance is R12.1.3
    2) The base pkg function 'xla_tb_ap_report_pvt.get_period_name' expects a number to be passed in as 'IN' parameter.
    Thanks,
    Monkey

    I tried another version of the sql statement (after going through some older posts) like:
    <sqlStatement name="Q_SEL">
    <![CDATA[  Select xla_tb_ap_report_pvt.get_period_name(1) PERIOD_NAME
                            from  dual]]>
    </sqlStatement>
    My group is :
    <group name="G_PERIOD_NAME" source="Q_SEL">
    <element name="PERIOD_NAME" value="PERIOD_NAME"/>
    </group>
    Now getting the error message:
    ORA-00904: xla_tb_ap_report_pvt.get_period_name : invaild identifier
    What is it that i am doing wrong?
    Thanks,
    Monkey
    Edited by: OAF_Monkey on Mar 26, 2012 11:52 AM

  • Functions needed in Data Template for XML output

    Hi ,
    Are there any oracle functions like abs() available
    in data_template to be used as follows
    group name="listItem" source="Q2">
    <element name="amount" value="abs(amount)"/>
    <element name="serialNumber" value="TXN_SERIAL_NO"/>
    I want the absolute value of the amount .
    OR
    Can I HIDE the xml Element like
    <element name="amount" value="amount"/> (i want to hide this tag in output?)
    Please do not suggest to do the same in the SQL query as I am using the SQL query to do something else and resolve another issue.
    rdgs
    xyz

    You can do this abs in Template.
    use xdoxslt:abs or abs from xsl.
    if you want the data in the xml to habe absolute value , then write pl/sql package to this .
    <element name="amount" value="yourpcakage.yourabs(amount)"/>
    or do it in sql query, which you dont want to.

  • BeforeReportTrigger , Data Template and Parameters

    Hi
    I'm new to XML publisher. Things has been going quite smoothly until I started to introduce BeforeReportTriggers and Parameters in my Data Template.
    When I go to view the report, I get
    "The report cannot be rendered because of an error, please contact the administrator"
    Unfortunately, I don't know if there is any log file for further information. I know the package works when I was debugging it.
    Please help.
    Below is my XML Data Template, the package header and body
    XML data template
    <dataTemplate name="SCH_A_dt1" description="schedule A database template1" defaultPackage="sch_a_dt1" dataSourceRef="nbdot_zsvm1">
    <parameters>
    <parameter name="p_COUNTY" dataType="character" defaultValue="GLOUCESTER"/>
    </parameters>
    <dataQuery>
    <sqlStatement name="Q1">
    <!-- insert sql statement here-->
    <![CDATA[select COUNTY, NETWORK_COMP,SECT_ID,CS_REF,RD_LOC,TYPE_MEANING,TOTAL_KM from sch_A_byCounty_det
    where &P_WHERE_CLAUSE]]>
    </sqlStatement>
    </dataQuery>
    <!-- BEFOREREPORT TRIGGER -->
    <dataTrigger name="beforeReportTrigger" source="sch_a_dt1.BEFOREREPORTTRIGGER(p_COUNTY)"/>
    <!-- DataStructure -->
    <dataStructure>
    <group name="G_COUNTY" source="Q1">
    <element name="COUNTY_NAME" value="COUNTY"/>
    <group name="G_NETWORK" source="Q1">
    <element name="NETWORK" value="NETWORK_COMP"/>
    <element name="SECT_ID" value="SECT_ID"/>
    <element name="ROAD_LOCATION" value="RD_LOC"/>
    <element name="TYPE_MEANING" value="TYPE_MEANING"/>
    <element name="LENGTH" value="TOTAL_KM"/>
    </group>
    </group>
    </dataStructure>
    </dataTemplate>
    Package header
    create or replace package sch_a_dt1
    as
    p_county varchar2(50);
    P_WHERE_CLAUSE VARCHAR2(100);
    procedure beforereportTrigger(p_county varchar2);
    end;
    Package body
    CREATE or replace PACKAGE BODY sch_a_dt1
    as
    procedure beforereportTrigger (p_county varchar2) is
    begin
    if (p_county) is null then
    p_where_clause := '1=1';
    elsif (p_county = '*') then
    p_where_clause := '1=1';
    else
    p_where_clause := 'COUNTY in (' ||p_county||')';
    end if;
    end;
    end;
    Thanks Zubran

    Thanks Daniel..
    You were right! The weird thing is that the XML user guide used a procedure as an example.
    Anyway. I wonder if you assist me further. Although I don't get an error, when I try to query on a paramter, I get no data return {ie. only the parameter is shown in result}. However, when I pass in '*' or null as per my function then this return the entire database.
    Please can you have a quick at the function and xml data template again.
    XML Data Template
    <dataTemplate name="SCH_A_dt1" description="schedule A database template1" defaultPackage="sch_a_dt1" dataSourceRef="nbdot_zsvm1">
    <parameters>
    <parameter name="p_COUNTY" dataType="character" defaultValue="GLOUCESTER"/>
    </parameters>
    <dataQuery>
    <sqlStatement name="Q1">
    <!-- insert sql statement here-->
    <![CDATA[select COUNTY, NETWORK_COMP,SECT_ID,CS_REF,RD_LOC,TYPE_MEANING,TOTAL_KM from sch_A_byCounty_det
    where &amp;P_WHERE_CLAUSE]]>
    </sqlStatement>
    </dataQuery>
    <!-- BEFOREREPORT TRIGGER -->
    <dataTrigger name="beforeReportTrigger" source="sch_a_dt1.beforerep(:p_COUNTY)"/>
    <!-- DataStructure -->
    <dataStructure>
    <group name="G_COUNTY" source="Q1">
    <element name="COUNTY_NAME" value="COUNTY"/>
    <group name="G_NETWORK" source="Q1">
    <element name="NETWORK" value="NETWORK_COMP"/>
    <element name="SECT_ID" value="SECT_ID"/>
    <element name="ROAD_LOCATION" value="RD_LOC"/>
    <element name="TYPE_MEANING" value="TYPE_MEANING"/>
    <element name="LENGTH" value="TOTAL_KM"/>
    </group>
    </group>
    </dataStructure>
    </dataTemplate>
    Procedure body
    CREATE or replace PACKAGE BODY sch_a_dt1
    as
    function beforerep (p_county in varchar2) return boolean is
    begin
    if (p_county) is null then
    p_where_clause := '1=1';
    return true;
    elsif (p_county = '*') then
    p_where_clause := '1=1';
    return true;
    else
    p_where_clause := 'COUNTY in (' ||p_county||')';
    return true;
    end if;
    exception
    when others then
    return false;
    end ;
    end ;
    Header
    create or replace package sch_a_dt1
    as
    p_county varchar2(50);
    P_WHERE_CLAUSE VARCHAR2(100);
    function beforerep (p_county in varchar2) return boolean;
    end;
    /

  • How do I code relative links as function parameters within Templates?

    I am a newcomer looking for best practices for a "How Do I?" properly code relative links as function parameters within an Adobe template (DWT) which accomodates page creation at 2 different level of folders. Dreamweaver doesn't appear to handle auto-correction of relative links as function parameters as far as I can see.  It's not clear to me what the best practice I should be following.  While this is not exactly a SPRY question, I am hoping that someone using the Spry.Data.XMLDataSet had already found the best practice to use.
    My Site
    -- Multiple pages at this level    and the parameter needs to be "_includes/UnitSideNavigation.xml"
    SubFolder
    -- Other pages at this level.       and the parameter needs to be "../_includes/UnitSideNavigation.xml"
    And this is the particular code snippet within a non edtable template area I would like to work for 2 levels of pages created from the template.
    <script type="text/javascript">
    var dsItems1 = new Spry.Data.XMLDataSet("_includes/UnitSideNavigation.xml", "/links/firstlevel");
    var dslinks = new Spry.Data.NestedXMLDataSet(dsItems1, "secondlevels/secondlevel");
    </script>
    My environment is Windows/Vista using latest CS4 dreamweaver.
    Any pointers appreciated. This is learn time for me. Hope I have made myself clear. Andy

    I use serverside includes instead of DWT for exactly that reason. Not only that, if you change anything within the template you must re-upload all of the files affected by the change; only the modified include file needs to be uploaded.

  • How to call oracle Function which has If else condition in Data Template

    Hi,
    currently I am working on creating Data Template which uses a Oracle Function which I need to make use in my data template. But I have some confusions on using the same. Could anybody please help me in this regard.
    I have a function like this,
    function invoice_query (p_facility_id facility.facility_id%TYPE,
    p_wave_nbr pick_directive.wave_nbr%TYPE,
    p_container_id unit_pick_group_detail.container_id%TYPE,
    p_distro_nbr unit_pick_group_detail.distro_nbr%TYPE) return invoice_refcur IS
    refcur invoice_refcur;
    begin
    IF p_wave_nbr IS NOT NULL THEN
    OPEN refcur FOR SELECT t1.distro_nbr,
    t1.cust_order_nbr,
    t1.pick_not_before_date,
    SYSDATE,
    t1.ship_address_description,
    t1.ship_address1,
    t1.ship_address2,
    t1.ship_address3,
    t1.ship_address4,
    t1.ship_address5,
    t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip,
    t1.ship_country_code,
    t1.bill_address_description,
    t1.bill_address1,
    t1.bill_address2,
    t1.bill_address3,
    t1.bill_address4,
    t1.bill_address5,
    t1.bill_city || ', ' || t1.bill_state || ' ' || t1.bill_zip,
    t1.bill_country_code,
    min(t2.pick_order),
    NULL,
    t2.wave_nbr
    FROM stock_order t1,
    pick_directive t2,
    unit_pick_group_detail t3
    WHERE t1.facility_id = t2.facility_id
    AND t1.facility_id = t3.facility_id
    AND t2.facility_id = t3.facility_id
    AND t1.distro_nbr = t2.distro_nbr
    AND t1.distro_nbr = t3.distro_nbr
    AND t2.distro_nbr = t3.distro_nbr
    AND t1.facility_id = p_facility_id
    AND t2.wave_nbr = p_wave_nbr
    AND g_scp(p_facility_id, 'interface_tcp_flag') = 'N'
    AND t2.pick_type = 'U'
    AND t3.group_id in (SELECT t4.group_id
    FROM unit_pick_group t4
    WHERE t4.facility_id = p_facility_id
    AND t4.wave_nbr = p_wave_nbr)
    GROUP BY t1.distro_nbr,
    t1.cust_order_nbr,
    t1.pick_not_before_date,
    t1.ship_address_description,
    t1.ship_address1,
    t1.ship_address2,
    t1.ship_address3,
    t1.ship_address4,
    t1.ship_address5,
    t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip,
    t1.ship_country_code,
    t1.bill_address_description,
    t1.bill_address1,
    t1.bill_address2,
    t1.bill_address3,
    t1.bill_address4,
    t1.bill_address5,
    t1.bill_city || ', ' || t1.bill_state || ' ' || t1.bill_zip,
    t1.bill_country_code,
    t2.wave_nbr
    ORDER BY MIN(t3.group_id), MAX(t3.slot);
    elsif p_container_id is not null then
    OPEN refcur FOR SELECT distinct t1.distro_nbr,
    t1.cust_order_nbr,
    t1.pick_not_before_date,
    SYSDATE,
    t1.ship_address_description,
    t1.ship_address1,
    t1.ship_address2,
    t1.ship_address3,
    t1.ship_address4,
    t1.ship_address5,
    t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip,
    t1.ship_country_code,
    t1.bill_address_description,
    t1.bill_address1,
    t1.bill_address2,
    t1.bill_address3,
    t1.bill_address4,
    t1.bill_address5,
    t1.bill_city || ', ' || t1.bill_state || ' ' || t1.bill_zip,
    t1.bill_country_code,
    NULL,
    t2.dest_id,
    null
    FROM stock_order t1,
    unit_pick_group_detail t2
    WHERE t1.facility_id = t2.facility_id
    and t1.distro_nbr = t2.distro_nbr
    and t1.facility_id = p_facility_id
    AND g_scp(p_facility_id, 'interface_tcp_flag') = 'N'
    AND t2.container_id = p_container_id;
    else
    open refcur for SELECT distinct t1.distro_nbr,
    t1.cust_order_nbr,
    t1.pick_not_before_date,
    SYSDATE,
    t1.ship_address_description,
    t1.ship_address1,
    t1.ship_address2,
    t1.ship_address3,
    t1.ship_address4,
    t1.ship_address5,
    t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip,
    t1.ship_country_code,
    t1.bill_address_description,
    t1.bill_address1,
    t1.bill_address2,
    t1.bill_address3,
    t1.bill_address4,
    t1.bill_address5,
    t1.bill_city || ', ' || t1.bill_state || ' ' || t1.bill_zip,
    t1.bill_country_code,
    NULL,
    NULL,
    t3.wave_nbr
    FROM stock_order t1,
    unit_pick_group_detail t2,
    unit_pick_group t3
    WHERE t1.facility_id = t2.facility_id
    and t2.facility_id = t3.facility_id
    and t1.distro_nbr = t2.distro_nbr
    and t2.group_id = t3.group_id
    and t1.facility_id = p_facility_id
    AND g_scp(p_facility_id, 'interface_tcp_flag') = 'N'
    AND t2.distro_nbr = p_distro_nbr;
    END IF;
    return refcur;
    end;
    I have created data template like following,
    <sqlStatement name="Q_INVOICE">
                   <![CDATA[
              SELECT Pack_Slip_R.invoice_query(:P_FACILITY_ID,:P_WAVE_NBR,:P_CONTAINER_ID,:P_DISTRO_NBR) from dual
                                                     ]]>
    </sqlStatement>
    But how does I create a element for the "t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip" column in the oracle function. I normally create an element like following,
    <group name="G_INVOICE" source="Q_INVOICE">
                   <element name="CUST_ORDER_NBR" value="cust_order_nbr"/>
                   <element name=":dest_id" value="dest_id"/>
    </Group>
    But how do i create element if a column name is kind of dynamic. Please help. I cannot Rename/change the Column in SQL Query. Please let me know If I could handle this whole logic in BI Publsiher.
    Regards,
    Ashoka BL

    try useing alias
    t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip as <COLUMN_ALIAS>

  • Using Variable in the Data Template

    Hi All,
    I am on BIP 10.1.3.4.1 and DB is SQL Server. My Data Model is a Data Template wherein I have written multiple SQL Statements. I want to use a variable in my Data Template, assign it a value and use that variable to limit one of the SQL statements in the where clause like
    declare @cnt int;
    set @cnt = select count(asset_id) from asset
    How do I use in the data template. I tried using it in a separate SQL statement but it throws me an error when i run the report like
    "Need to declare the scalar variable '@cnt'
    Can we have a variable section like parameter section we have in the data template to declare the parameters?
    Any help would be highly appreciated.
    Thanks,
    Ronny

    Sorry for the shot follow up, can anybody please reply on this?

  • Calling Oracle Functions in Data Template

    Hi,
    I have a package and 2 functions inside that, I need to use those 2 functions inside my BI Publisher Data Template,
    Package1
    Function1(Param1 varchar2,param2 varchar2) return Refcursor
    Open Refcursor for
    Select Fun1Col1,Fun1Col2,Fun1Col3 from ABCD;
    Function2(Param1 varchar2 , Fun1Col1 varchar2,Fun1Col2 varchar2 ) return Refcursor
    Open Refcursor for
    Select Fun2Col1,Fun2Col2,Fun2Col3 from XYZ where XXX=Fun1Col1 and YYY=Fun1Col2 and ZZZ=Param1;
    Here the Second Function is using the Output Columns of First Function as Input Parameters.
    The above functions are created for Oracle Reports which is working fine, Now I am converting them from Oracle Reports to BI Publisher and I am not able to proceed.
    I have designed my Data Template as follows.
    <dataTemplate name="XYZ " description="XYZ" defaultPackage="">
         <!-- Property to make XML Output tags UPPERCASE -->
         <properties>
              <property name="scalable_mode" value="off"/>
              <property name="debug_mode" value="off"/>
         </properties>
         <!-- Parameters -->
         <parameters>
              <parameter name="Param1" dataType="varchar2"/>
              <parameter name="Param2" dataType="varchar2"/>
         </parameters>
         <!-- Lexicals -->
         <lexicals/>
         <!-- SQL Queries -->
         <dataQuery>
              <sqlStatement name="Q_Container_Query">
                   <![CDATA[
    Select Package1.Function1(:param1,:param2) from dual;
    ]]>
              </sqlStatement>
              <sqlStatement name="Q_Container_Item_Query">
                   <![CDATA[
    Select Package1.Function2(:param1,:Fun1Col1,:FunCol2) from dual
    ]]>
              </sqlStatement>
         </dataQuery>
         <!-- Grouping -->
         <dataStructure>
              <group name="G_Container_Query" source="Q_Container_Query">
                   <element name="Fun1Col1" value="Fun1Col1"/>
    <element name="Fun1Col2" value="Fun1Col2"/>
    <element name="Fun1Col3" value="Fun1Col3"/>
                   <group name="G_Container_Item_Query" source="Q_Container_Item_Query">
                   <element name="Fun2Col1" value="Fun2Col1"/>
    <element name="Fun2Col2" value="Fun2Col2"/>
    <element name="Fun2Col3" value="Fun2Col3"/>
                   </group>
              </group>
         </dataStructure>
    </dataTemplate>
    The point of concern is whether
    Select Package1.Function2(:param1,:Fun1Col1,:FunCol2) from dual
    is valid or not, because its accepting Function1's output values as Input Parameters.
    Regards,
    Ashoka BL

    Could anyone please reply....

  • I cant call a procedure within a data template

    Hi,
    I m working in a data template because i want to call a prcedure befor running the report.
    My procedure is under the folder of procedure. it is not under a package.
    So i left the defaultpackage empty in the data model.
    *<dataTemplate name="Extraction_Template" dataSourceRef="mydatasource" defaultPackage="">*
    But it didsn't work.
    Help.
    SAAD

    The default package attribute is required if your data template contains any other calls to PL/SQL. For the source attribute for the data trigger definition, you need to have the source in the form of <package name>.<function name>
    Check out the report designer's guide for details.
    Thanks,
    BIPuser

  • Function Module to Compare Date within date Range

    Hi All,
            Does anyone know Function Module to Compare Date within date Range...For example i need to find whether 08/02/2006 falls in between 07/15/2006 and 09/15/2006......

    data: datum type sy-datum value '20070802',
          datum_low type sy-datum  value '20070730',
          datum_high type sy-datum value '20070930'.
    If datum between datum_low and datum_high.
    Endif.
    Regards,
    Rich Heilman

  • Show date variable in WAD Template.

    HI,
    I want to be able to show the date variable in WAD template. To do this I used the info field web item. This web item  has the option to show variables which is great, but unfortunatly for me it also shows all the other variables I am using. I can not see anywhere where I can restrict it to only show the date variable.
    Does anyone know how I can do this or is it something I would have to do query side.
    Regards
    Forhad

    Hi Forhad,
    Yes you can show the date var alone, for this you would have to choose the specific date var under Data Binding -> List of Text Elements to display -> Text Element Type =  Variable Value, Variable = (select the date var from the available list).
    You may also turn off the Static Variables & Dynamic Variables if required.
    --Priya

  • XML Data template. Using the SUM() function

    Hi there,
    I have a data template where I want to create a summary column based on the child group.
    *<group name="G_RO_ESTIMATES" source="Q_RO_ESTIMATES">
    <element name="ESTIMATE_TOTAL" value="G_RO_ESTIMATE_LINES.CHARGE" function="SUM()" />
    <group name="G_RO_ESTIMATE_LINES" source="Q_RO_ESTIMATE_LINES">
    <element name="CHARGE" value="CHARGE" />
    </group>
    </group>*
    ESTIMATE_TOTAL returns 0
    even though the value of the CHARGE column is 760.
    I got the SUM() function to work on another group further down in my data template but for some reason this will not work.
    Does anyone have a clue on what's wrong?
    Thank you in advance.
    BR Kenneth

    give the name of the element diff as CHARGE_TEST
    *<group name="G_RO_ESTIMATES" source="Q_RO_ESTIMATES">
    <element name="ESTIMATE_TOTAL_TEST" value="G_RO_ESTIMATE_LINES_GRP.CHARGE_TEST" function="SUM()" />
    <group name="G_RO_ESTIMATE_LINES_GRP" source="Q_RO_ESTIMATE_LINES">
    <element name="CHARGE_TEST" value="CHARGE" />
    </group>
    </group>*
    sometimes the name get overlapped which results in zero.. keep the names unique
    (i guess , i already logged a bug for this sometime back)

  • HOWTO: Declare a variable within a function.

    I'm having a hard time declaring a variable within a function. This is my code:
    CREATE OR REPLACE FUNCTION schemaName.functionName (inParam VARCHAR2(20))
    RETURN VARCHAR2 IS VARCHAR2(10)
    BEGIN
    DECLARE paramLength NUMBER; --This is not working. The docs do not state what the size of the number returned by LENGTH is.
    SELECT LENGTH(inParam) INTO paramLength FROM DUAL;
    IF paramLength < 10 THEN
    RETURN '';
    ELSE
    /* Clean up the value */
    RETURN inParam
    END IF;
    END;

    In relation to your own code...
    CREATE OR REPLACE FUNCTION schemaName.functionName (inParam VARCHAR2(20)) RETURN VARCHAR2 IS
    paramLength NUMBER;
    BEGIN
      /* Clean up the value */
      paramLength = LENGTH(inParam);
      IF paramLength < 10 THEN
        RETURN NULL;
      ELSE
        RETURN inParam
      END IF;
    END; You don't need to use SQL to determine the length of a string.

  • How Can I apply a RTF Function on a variable in RTF Template in XML Publisher Report

    Hi Everyone,
    I am developing a RTF Template of XML Publisher Report, I have a variable lv_counter which I can declare using below syntax
    <?xdoxslt: set_variable($_XDOCTX, 'lv_counter',0)?>
    I can access this variable in the template as <?xdoxslt: get_variable($_XDOCTX,'lv_counter')?>
    My need is to print the variable in words in the RTF Template. I am using <?xdofx: to_check_number(xdoxslt: get_variable($_XDOCTX,'lv_counter'))?>
    But this is not working. any help will be appreciated thanks in advance
    The XML Publisher Desktop version which I am using is 10.1.3.3.0
    Please let me know where I can post this question, if this is not the appropriate discussion forum.
    Thanks in Advance.

    Hi,
    Can you elaborate your requirement little bit clear with some example like what is your expected output.
    And you can post you BI related question in the BI publisher forum
    https://forums.oracle.com/community/developer/english/business_intelligence/business_intelligence_foundation/bi_publisher/content?filterID=contentstatus[published]~objecttype~objecttype[thread]
    Regards
    Sri

  • Using a global variable within a function

    Hi all,
    I'm trying to learn how to use global variables, but can't quite get it right:
    Im trying to use two buttons, named UpButton and DownButton to control one global variable, p1
    A text field, named "Value" displays p1.
    Here's my code:
    p1 = 0;
    ButtonClick("UpButton", p1, 100,"Value");
    ButtonClick("DownButton", p1,(-100),"Value");
    function ButtonClick(ButtonName,Var,Increment,TextToChange){
                        sym.$(ButtonName).click(function(){
                        Var = Var + Increment;
                        sym.$(TextToChange).html(Var);
    However, it seems to be treating p1 as two different variables.
    Here's a link to the page to show you what I mean, apologies but this link wont work in google chrome because I'm using dropbox as a server temporarily
    In other browsers you may need to click "Show all content" or similar to any security warnings...
    https://dl.dropboxusercontent.com/u/83693404/ButtonTest/buttons.html
    Here are the project files:
    https://app.box.com/s/0shocivto8fl295h62uq
    Any help greatly appreciated, sorry if this is a stupid question,
    Katherine

    Hi Katherine,
    However, it seems to be treating p1 as two different variables.
    Indeed, your code created two different variables in two different scopes (I guess it as to do with JavaScript closures, but do  not ask me more, I am still a bit foggy about that idiosyncrasy ).
    In JavaScript, a primitive parameter – this is the case here with p1, a Number value –, is passed by value. In other words, a copy of the value is made. Your code handles two copies of the value stored in p1.
    This contrasts with an object parameter, which is passed by reference (address in memory), without copy. Your code would work if Numbers were passed by reference : the two Var (p1) would then point to the same address.
    The intent behind your trial is a global variable.
    1) Let us be as simple as possible :
    Stage : document.compositionReady event handler
    p1 = 0;
    buttonClick = function( Increment)
      p1 += Increment;
      sym.$( "Value").html( p1);
    Stage : DownButton.click event handler
    buttonClick(-100);
    Stage : UpButton.click event handler
    buttonClick(100);
    Without being preceded by the var keyword the variables are global.
    So the Number variable p1 can be accessed inside function buttonClick.
    And the Function variable buttonClick as well, is accessible inside click event handlers, everything (function definition +function calls) being inside the same symbol (Stage).
    2) Now, suppose this is no longer the case : you want to access a variable from another symbol.
    We create a new GraySquare symbol, instantiated both in the DownButton symbol (instance name DownSquare) and in the UpButton symbol (instance name DownSquare).
    Stage : document.compositionReady event handler
    p1 = 0;
    sym.buttonClick = function( Increment)
      p1 += Increment;
      sym.$( "Value").html( p1);
    The sym. prefix is now necessary to make the variable (here a Function, but you would proceed exactly the same with a String, Number or Boolean) accessible in other symbols.
    DownButton symbol : DownSquare.click event handler
    sym.getComposition().getStage().buttonClick( -100);
    UpButton symbol : UpSquare.click event handler
    sym.getComposition().getStage().buttonClick( 100);
    From these other symbols, the sym.getComposition().getStage(). prefix is necessary to acces to our global variable (function).
    The two examples are downloadable here : https://app.box.com/s/6vkyiqk7i8zwlw0j1wk1
    Gil

Maybe you are looking for

  • Update Routine with Return table

    Hello All: I'm trying to populate the cube by splitting 1 record into many records. I have following ABAP code in the routine which is failing at the LOOP keyword $$ begin of routine - insert your code only below this line        - fill the internal

  • How to Restore deleted records in other table in oracle database 10g...

    Hi All, i want to restore deleted records of a particular table in other table suppose: i perform a query delete from emp where deptno =30; now i wont to restore deptno=30 records in other table, let say in emp1 table can any one let me know how to d

  • URGNET - Electronic Bank Statement - Master Account not ends with zero.

    Hi I have a peculiar situation.  I have a House bank which we would like to use for EBS.  The GL account assigned for this house bank ends with 6.  As per the EBS design, the master account must end with zero (0) and all other clearing account can en

  • Regarding Active directory configuration

    We have one PDC and one backup PDC and 272 ADC in our Organization .all server will communicate to PDC for replication as per the design. we are facing the the issue in replication domain dns zone and forest dns zone is not replicating getting 1722 e

  • ADOPT THE PR PRICE INTO PO

    Dear All, I would like to fix the price for a material and whenever i create PR that fixed prce of the material should automaticaly into PR and the same PR i would like to adopt in the PO with the fixed material price. Thx