Pass package variable to script logic

Hi expert,
I have creted a variable in a Package with the statement
PROMPT(TEXT,%PERCE%,"Revaluation rate",,"")
the variable appears and properly stores a value.
However, what statement can be used to pass it to the sript logic?
I tried 'TASK(Execute formulas,REPLACEPARAM,PERCE%EQU%%PERCE%) but it's somehow wrong.
Please..any help?
Thanks,
Alberto Sabate

Jeffrey,
Thanks for your answer.
I am aware that within the script logic I have to use a variable between $ signs. So $PERCE$ is exactly what I had in my script logic.
However in order to get a value there we have to enter a command into the dstx file to actually send the value enter by the user into the script logic.
In the Package I have:
PROMPT(TEXT,%PERCE%,"Revaluation rate",,"")
TASK(RUNLOGIC,FORMULASCRIPT,"*FUNCTION PER=%PERCE%")
In the script I have
*WHEN *
IS
*REC(FACTOR=PER.INPUT)
*ENDWHEN
I have also tried $PERCE$ instead of PER.INPUT, but no luck either.
Still I'm not able to get the variable %PERCE% into the formula. Why?
Thanks
Alberto

Similar Messages

  • Variable in  script logic

    Follow is the script code from previous post
    *XDIM_MEMBERSET ACCOUNT = ACC1
    *FOR %My_Var% = %ENTITY_DIM%
    *WHEN ENTITY
    *IS *
    *REC(EXPRESSION = (GET (ENTITY = %My_Var%.PROP1)), ENTITY = %My_Var%)
    *ENDWHEN
    *NEXT
    I understand that  both %My_Var% and %ENTITY_DIM% are variables, my question is how %My_Var% and %ENTITY_DIM% get the value during the process of the code, do we neeed to define the variable some where else before we use them? I remeber in FOX, we need to define the variable before we can use it.
    also is there a difference if I use $My_Var$ to replace %My_Var%?

    nilanjan,
    Thanks for the explanation,I have another question regarding to the variables.
    I need to get the YTD salary. in BPS the pseudocode code is as following:
    data YTD_salary type amount
    loop at each_month,
       YTD-Salary =  YTD-Salary  + current_month.
       if the  YTD-Salary  > FICA CAP.
       exit.
    Endloop
    How can we archive the same in BPC script logic with a variable to capture the YTD-Salary and pass it to next month?

  • Use of Variable in Script Logic

    Dear All,
    We are working on a BPC Script Logic involving depreciation calculation, which calls an implementation of the BAdI BADI_UJ_CUSTOM_LOGIC. We are passing some parameters from the script logic to the BAdI. There are two parameters to be passed: an account number (Account in which the posting will happen), and the rate (rate with which depreciation will be affected). The parameters are stored in the Dimension member of the account dimension and need to be fetched from there. We are using the following piece of code to achieve this:
    *INCLUDE FUNCTIONS.LGF
    [#PERC] = PRO([%ACCOUNT_DIM%].CURRENTMEMBER,DEP_PERCENTAGE)
    [#DEPACCOUNT] = PRO([%ACCOUNT_DIM%].CURRENTMEMBER,DEP_ACCT)
    *START_BADI DEPR
    QUERY = ON
    WRITE = ON
    DEPACCT = [#DEPACCOUNT]
    PERCENTAGE = [#PERC]
    *END_BADI
    Here, FUCNTIONS.LGF contains the PRO function, which fetches the account and percentage properties from the account dimension member. Problem is, when we refer to the temporary variables within our code using the variables [#DEPACCOUNT] and [#PERC], we encounter a short dump for CX_SY_CONVERSION_NO_NUMBER. We suspect that instead of passing the parameter values, the logic is passing the variable name as the value. How do we rectify this? What is the correct syntax for passing such a parameter to the BAdI? Any ideas?
    Thanks in Advance,
    Sid

    Hi Ethan,
    Thanks for the answer. Unfortunately, even after trying out your solution with K2 variables, we are getting the same dump, this time the log says:
    An exception with the type CX_SY_CONVERSION_NO_NUMBER occurred, but was neither handled locally, nor declared in a raising clause
    The argument '%PERC%' cannot be interpreted as a number
    We are starting to think that maybe only substitution variables can be passed as parameter to the BAdI call, because whenever we use a local variable, we end up in passing the variable name to the BAdI, and not the variable value. We digged through the SAP Help, following is the excerpt from there:
    Run the following instruction to call custom ABAP programs: where filter_value_of_your_BADI_implementation is the name of the filter you provided during the BADI implementation of UJ_CUSTOM_LOGIC BADI.
    *START_BADI <filter_value_of_your_BADI_implementation>
    <key1> = <value1>
    <key2> = <value2>
    *END_BADI
    where filter_value_of_your_BADI_implementation is the name of the filter you provided during the BADI implementation of UJ_CUSTOM_LOGIC BADI.
    Does this mean we can only pass <key>:<value> pairs, and not <key>:<variable> pairs? Is there any instance / documentation which points to this (or the contrary)?
    Awaiting answers.
    Thanks and Regards,
    Sid

  • Parameter passing in BADI in script logic

    inside BADI when I tried to pass variables, I got error 'incorrect parameter format in "DIMENSION =" .
    //local variable
    *SELECT(%VERSION%, ID, VERSION, "GROUP <>'ACTUAL')
    *XDIM_MEMBERSET VERSION = %VERSION%
    *START_BADI RUNLOGIC
    LOGIC = TEST1.LGF
    DIMENSION = %VERSION1%
    *END_BADI
    When I changed it to DIMENSION = PLAN, where "PLAN" is an actual dimension member, it works.
    when I changed it to DIMENSION = $VER$, it works. however $VER$ is for DM input parameter, not for my local variable.
    So how do I pass the variable to TEST1.LGF? simply the "*XDIM_MEMBERSET VERSION = %VERSION%" will do this, right?
    anyway I can pass variable from inside BADI?
    my plan is to have a sructure like the following
    *XDIM XXXXXX
    BADI to call test1.lgf
    BADI to call test2.lgf
    BADI to call test3.lgf
    so it will be great if I can pass different parameters into each BADI.
    now %VERSION% does not work. that's my issue.
    George

    Gersh,
    yeah, that's a typo.
    I see your point. for *XDIM_MEMBERSET, I will define it for each badi.
    for the DIMENSION = %VARIABLE%, I found it behaves weird, sometimes it works, sometimes it complains about incorrect parameter format. this happened like in one minute. I double checked my spelling, and could not figure out.
    I will proceed now.
    I will post one new question in another thread.thanks Gersh.
    George

  • Using variables in script logic.

    Hi,
    I still haven't figured out how to assign a userdefined variable in a script.
    My case is that I in my script commits data several times, after every commit I need to do a new *XDIM_MEMBERSET. Every time the *xdim_memberset is exactly the same.
    Example - what I do now.
    *XDIM_MEMBERSET ACCOUNT="REVENUE"
    *XDIM_MEMBERSET VERSION="90"
    *rec
    *commit
    *XDIM_MEMBERSET ACCOUNT="REVENUE"
    *XDIM_MEMBERSET VERSION="90"
    *rec
    *commit
    Etc.
    It would be much easier, if I the beginning of each script for Account and Version defined a variable, and then having every *xdim_memberset use the variable. Then I only need to change the definition of the variable in the beginning of each script.
    Example - what I want to achieve.
    //Definition of constant variables.
    %ACCOUNT_VARIABLE%= "ACCOUNT = REVENUE"
    %VERSION__VARIABLE% = "VERSION=90"
    *XDIM_MEMBERSET %ACCOUNT_VARIABLE%
    *XDIM_MEMBERSET VERSION=%VERSION__VARIABLE%
    *rec
    *commit
    *XDIM_MEMBERSET %ACCOUNT_VARIABLE%
    +*XDIM_MEMBERSET VERSION=%VERSION__VARIABLE%
    *rec
    *commit
    I've looked at the *SELECT and *MEMBERSET - but can't really get the syntax to work.....
    Thank you,
    Joergen
    Edited by: Jørgen Dalby Andersen on Dec 30, 2011 7:58 AM

    Hi,
    when I use *XDIM_MEMBERSET ACCOUNT AS %TEST% = BAS(REVENUE) - it work fine.
    BUT ! after my first commit, it seems like the variable value is lost. And the *Xdim_memberset takes all.....
    Fortunately enough, *select still contains the variable value after *commit.
    Thanks,
    Joergen
    *Correction !
    It actually works, it still contains the variable value after commit !!
    Edited by: Jørgen Dalby Andersen on Dec 30, 2011 1:33 PM

  • Declaring a Variable in Script Logic

    Hi Folks,
    Following is my Allocation Scenario:
    Source :
    Cost Elements
    A1, A2,A3,A4
    Cost Center = STORE1
    Destination:
    Cost Elements
    Same
    Cost Center = STORE11,STORE12,STORE13
    But in the Destination Cost Elements, we have some values which are overwritten after I run the Allocation Logic.
    Can anyone let me know how to proceed with this scenario, with retaining the existing values @destination.
    Thanks in Advance !

    Hi,
    For this, you need to use the select statement. Please refer to the below link:
    http://help.sap.com/saphelp_bpc75/helpdata/en/12/bddcd3f6ba42f1aeb0b500fca1b876/content.htm
    The variables declared in the select statement can be used later in the code also.
    Hope this helps.

  • Declare a variable in script logic

    I want to declare variable in the beginning of the code , that i could use later on.
    something like.
    %fiscalYear% = "2010.INP"
    Bu i'm able to do that, and BPC documentation is not really helping.
    I'd appreciate any insight.
    Leandro Brasil

    Hi,
    For this, you need to use the select statement. Please refer to the below link:
    http://help.sap.com/saphelp_bpc75/helpdata/en/12/bddcd3f6ba42f1aeb0b500fca1b876/content.htm
    The variables declared in the select statement can be used later in the code also.
    Hope this helps.

  • Error trying to run SSIS Package via SQL Server Agent: DTExec: Could not set \Package.Variables[User::VarObjectDataSet].Properties[Value] value to System.Object

    Situation:
    SSIS Package designed in SQL Server 2012 - SQL Server Data Tools
    Windows 7 - 64 bit.
    The package (32 bit) extracts data from a SQL Server db to an Excel Output file, via an OLE DB connection.
    It uses 3 package variables:
    *) SQLCommand (String) to specify the SQL Statement to be executed by the package
    Property path: \Package.Variables[User::ExcelOutputFile].Properties[Value]
    Value: f:\Output Data.xls
    *) EXCELOutputFIle (String) to specify path and filename of the Excel output file
    Property path: \Package.Variables[User::SQLCommand].Properties[Value]
    Value: select * from CartOrder
    *) VarObjectDataSet (Object) to hold the data returned by SQL Server)
    Property path: \Package.Variables[User::VarObjectDataSet].Properties[Value]
    Value: System.Object
    It consists out of 2 components:
    *) Execute SQL Task: executes the SQL Statement passed on via a package variable. The resultng rows are stored in the package variable VarObjectDataSet
    *) Script Task: creates the physical output file and iterates VarObjectDataSet to populate the Excel file.
    Outcome and issue:The package runs perfectly fine both in SQL Server Data Tools itself and in DTEXECUI.
    However, whenever I run it via SQL Server Agent (with 32 bit runtime option set), it returns the errror message below.
    This package contains 3 package variables but the error stating that a package variable can not be set, pops up for the VarObjectDataSet only.  This makes me wonder if it is uberhaupt possible to set the value of a package variable
    of type Object.
    Can anybody help me on this please ?
    Message
    Executed as user: NT Service\SQLSERVERAGENT. Microsoft (R) SQL Server Execute Package Utility  Version 11.0.2100.60 for 32-bit  Copyright (C) Microsoft Corporation. All rights reserved.    Started:  6:40:20 PM  DTExec: Could
    not set \Package.Variables[User::VarObjectDataSet].Properties[Value] value to System.Object.  Started:  6:40:20 PM  Finished: 6:40:21 PM  Elapsed:  0.281 seconds.  The package execution failed.  The step failed.
    Thank you very much in advance
    Jurgen

    Hi Visakh,
    thank you for your reply.
    So, judging by your reply, not all package variables used inside a package need to be set a value for when run in DTEXEC ?
    I already tried that but my package ended up in error (something to do with "... invocation ...." and that error is anything but clearly documented. Judging by the error message itself, it looks like it could be just about anything. that is why I asked my
    first question about the object type package variable.
    Now, I will remove it from the 'set values' list and try another go cracking the unclear error-message " ... invocation ...". Does an error message about " ... invocation ..." ring any bells, now that we are talking about it here ?
    Thx in advance
    Jurgen
    Yes exactly
    You need to set values only forthem which needs to be controlled from outside the package
    Any variable which gets its value through expression set inside package or through a query inside execute sql task/script task can be ignored from DTExec
    Ok I've seen the invocation error mostly inside script task. This may be because some error inside script written in script task. If it appeared after you removed the variable then it may because some reference of variable existing within script task.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Package variables

    Hi, 
    VS2008 
    SQL 2008 R2 
    Bit of a newbie with SSIS and script tasks.  I have a simple package that defines two package variables. 
    I'm trying to read these in the Main() method of the C# script task. 
    However this gives the following error. 
    System.Runtime.InteropServices.COMException (0xC0010009): The element cannot be found in a collection.
    This would imply that the variable does not exist in the variables collection, however it does.  I've tried both Package:: and User::, same result. 
    Googling this seems to show that square brackets are correct for C#. 
    Any ideas? 

    Why are you assigning a single string value to object variable? you should be assigning it to a string variable.
    Trial and error really.  I started with String and when it didn't work I changed to object. 
    Did you pass the variable in Script Task properties? If you want to read the value alone include it within ReadOnly variables. If you want to modify value make it ReadWrite
    If not you wont be able to use it in script body and will get element not found error.
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Passing Presentation variblae to the logical column in the rpd

    Hi,
    Can some one please tell me how to pass presentation variable to RPD logical column
    i am capturing a date from prompt and defining a status column based on the date user selects in the prompt,
    can some please tell me how to achieve this..
    Thanks in advance

    You can pass request variable to RPD.
    Create a session variable called PRESENTATION_VARIABLE. Write some SQL in initialization block like select 'something' from dual.
    Now you can use this session variable in logical column as VALUEOF(NQ_SESSION.PRESENTATION_VARIABLE).
    Now go to dashboard prompt , edit the column using which you wanted to set presentation variable. Select Request Variable in Set a variable dropdown.
    Type the name of the Request variable as PRESENTATION_VARIABLE.
    Now in your dashboard report you can use the logical column which is using this request variable.
    Let me know whether it worked or not.
    Thanks

  • Script Logic examples

    Are any script logic examples available anywhere which I can refer to? (like Fox Formula examples in BPS).
    Is there any book that I can refer to?
    Please let me know.
    Thanks.

    The central notes for each of the BPCNW Support Pack releases contain helpful information on a variety of topics, as well as information on specific script logic functionality. Please review notes: 1306898, 1349538, 1349538, and 1366582.
    http://help.sap.com/saphelp_bpc70sp02/helpdata/en/a1/532226947C49A5B2E2BD32450CB2D1/frameset.htm
    Business Planning and Consolidations (BPC) Tips -3 u2013 Sheldon Edelstein
    /people/sheldon.edelstein/blog/2008/04/21/business-planning-and-consolidations-bpc-tips-3
    /people/sheldon.edelstein/blog
    /people/sheldon.edelstein/blog/2008/04/23/business-planning-and-consolidations-bpc-tips-4
    SAP Library BPC Administration Guide
    https://websmp108.sap-ag.de/~form/sapnet?_SHORTKEY=01200252310000085368&_SCENARIO=01100035870000000112&_OBJECT=011000358700001123512008E
    ****How to Use BPC Scripting Logic
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/80ffae4b-99d5-2a10-4e9f-96149969aabb?quicklink=index&overridelayout=true
    SAP BUSINESS PLANNING AND CONSOLIDATION SCRIPT LOGIC, PART 2
    http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/a066c75e-3077-2b10-c6a6-b8af14b91775
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a066c75e-3077-2b10-c6a6-b8af14b91775?quicklink=index&overridelayout=true
    SAP BUSINESS PLANNING AND CONSOLIDATION SCRIPT LOGIC, PART 3
    http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/50c75047-3077-2b10-61b2-9a1b9373b0ee
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/50c75047-3077-2b10-61b2-9a1b9373b0ee?quicklink=index&overridelayout=true
    HOW TO... PASS DYNAMIC PARAMETERS TO SCRIPT LOGIC
    http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/d01ce779-f1b2-2b10-07ba-da3734013245
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d01ce779-f1b2-2b10-07ba-da3734013245?quicklink=index&overridelayout=true
    You can go to and check under "article library"
    http://www.sdn.sap.com/irj/scn/advancedsearch?query=bpc+nw

  • Reference a value of previous year in a Script Logic

    Hi,
    I need to reference a value of previous year to that I have in a Script Logic.
    I've tried it with "%YEAR% (-1)", but "%YEAR%" refers to the current year and doesn't refer to the year that I have in the Script Logic, that is, if I pass "2006.DEC " to Script Logic, the system returns me in "%YEAR%" the value "2010".
    What syntax should I use?
    Regards,
    Miguel.

    Hi
    The  Damien's suggestion is the correct one for BPC 7.0 NW to get the offset of the passed-in Time's member.
    So you have properties in your Time dimension that store the prior year of current member or the next year of current member or next 2 years of current member and etc.
    Then reference them in you logic something right this
    ID : 2008.JAN
    NEXT: 2009.JAN
    PRIOR: 2007.JAN
    *WHEN TIME
    *IS %TIME_SET%
    *REC(FACTOR=1, TIME=TIME.PRIOR)
    *ENDWHEN
    Additional information,
    %YEAR% in BPC NW reflects the time on the server which is different from the BPC MS.
    BPC 7.5 NW has a better function to handle this: TVML.
    Halomoan

  • Passing Script variable to Package variable, ultimately used as fileName

    Following an excellent post by Geplaatst door Joost, I put together a script which SHOULD populate a package variable, then use that variable as a file name.
    The Script code is as follows:
    public class ScriptMain : UserComponent
    string iScriptVar;
    public override void PreExecute()
    base.PreExecute();
    public override void PostExecute()
    base.PostExecute();
    Variables.ExtractName = iScriptVar.ToString();
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    if (!Row.CUSIP_IsNull)
    iScriptVar = Row.CUSIP.ToString();
    A Windows message box (put in as debug, but removed for brevity here) shows the correct value is being set to iScriptVar at all points it was inserted.
    The "ExtractName" variable is checked as a ReadWriteVariables for the Script properties.
    But, the "ExtractName" package variable is not being passed to the Expressions for the FlatFile Connection properties, which is set to:  @[User::ExtractName].
    Where have I gone wrong?

    Why not to provide the link to the post already?
    iScriptVar
    is a local to script variable this explains why it did not you need the full wiring
    e.g.
    Dts.Variables["User::iScriptVar"].Value = iScriptVar
    Arthur
    MyBlog
    Twitter

  • Script logic : determine the content of a variable according to a IF test

    Hello experts,
    I have the following need in a script logic
    determine the content of a variable according to a IF test
    For example I tried :
    *WHEN %ENTITY%
    *IS "CH20","CH30","ES10"
    *SELECT(%ENTITYPBPD%, "[ID]", "ENTITYCC", "[ID] = '%ENTITYCC_SET%_PBPD'")
    *ENDWHEN
    Syntax is correct but I get a query execution error (Error in WHEN/ENDWHEN structure)
    I guess it's because this when don't have any REC instructions.
    In other words, if the user selection at the package prompt step are CH20, CH30 or ES10
    the variable has to be selection_PBPD
    if another member is selected
    the variable has to take other value
    Hope I've made my need clear, and thanks in advance.
    G.

    Hi G,
    Will the *TEST_WHEN() statement work for this case?
    The way that it works is that if the condition evaluates to TRUE, then the subsequent WHEN...ENDWHEN is processed, else it is not.
    Have a look at Page 66 of "How To Use BPC Scripting Logic, Version 1.00, April 21, 2006" (It's a bit old but I use it a lot on our MS7.0 SP9 installation).
    Hope this helps.
    Regards
    Nick

  • Calling  multiple  script  logics from  a  single  package

    Team- How  do i  call multiple  script  logics  from a   single  DM  package...?
    I   know  its  possible  and  have seen  a  prototype  but  cant  recollect  or  find  it on sdn...
    Thanks  for  your  time.
    Vishal.

    Hi,
    You can create a master script logic which will include all the other script logics using the *INCLUDE command and call this master script through your DM package.
    Another way is to have multiple tasks in the process chain which is calling a script logic. You can pass separate script logics to each of the tasks.
    I would prefer the first option
    Hope this helps.

Maybe you are looking for