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

Similar Messages

  • 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

  • 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?

  • Having issue using TMVL in script logic

    Hello experts,
    We need to replicate the behaviour of the copy opening Bal through script logic.
    Below is my code:
    where user selects only entity when he runs package,time is derived from property.
    // Year from version property
    *SELECT(%YEAR%,"[YEAR]","Z_VERSION","[ID]='BUD'")
    // Months
    *SELECT(%MONTHS%,"[ID]","Z_TIME","[YEAR]=%YEAR% AND LEVEL='MONTH'")
    *XDIM_MEMBERSET Z_TIME=%MONTHS%   (for ex:My first month is 2009.jan(ope month)
       *WHEN ACCT
               *IS CHC          
            *REC(FACTOR=1, ACCT="CHC",Z_TIME=TMVL(1,%MONTHS%))  ( for ex:2009.feb,nxt month)
        *ENDWHEN
    When i run the above logic in debugger TMVL doesn't show next month.
    If i hardcode time in my xdimmemberset to (*XDIM_MEMBERSET Z_TIME=2009.JAN) and change my TMVL in my REC statement to TMVL(1,2009.JAN)).Logic works fine.
    Please tell me how can we pass dynamic variables to TMVL.
    *REC(FACTOR=1, ACCT="CHC",Z_TIME=TMVL(1,%MONTHS%))
    Thanks

    copying closing bal of prev month to nxt month.
    for ex:
    Account     jan 2009    Feb 2009    Mar 2009
    HC_PLAN     10.00      11.00      21.00
    CHC          10.00      11.00        11
    TI                     1.00                      1.00
    TO                      2.00      1.00          2.00
    AP                      3.00                       3.00
    RT                       4.00                        4.00
    My logic needs to copy values from HC_PLAN (parent) to CHC. I have written ope_bal logic in MS version.
    In NW i cannot use next (i am using TMVL),calc_dummy_org,calc_each_period.
    Please tell me how can i get values from a parent (HC_PLAN).
    Is Calculate_Difference is supported in BPC7.5NW?
    Below is my updated code
    *SELECT(%Year%,"[YEAR]","Z_Version","[ID]='ACTUAL'")
    *SELECT(%Months%,"[ID]","Z_Time","[YEAR]=%Year% AND [LEVEL] = 'MONTH'")
    *XDIM_MEMBERSET Z_TIME=%Months%
    *XDIM_MEMBERSET EB_ACCT = CHC,TI,TO,AP,RT
    *WHEN EB_ACCT
               *IS CHC,TI,TO,AP,RT         
                      *FOR %MonthCopy% = %Months%
                           *REC(FACTOR=1,EB_ACCT="CHC",Z_TIME=TMVL(1,%MonthCopy%))
                        *NEXT
                 *ENDWHEN

  • 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

  • Use Counter in Script Logic

    Hi guys, I have code in default logic which starts its run if one of several accounts data has been sent. However, when I send data for 2 accounts from *WHEN/IS condition, this script logic runs 2 times and result doubles, while I need it to work only once. Here is a code:
    *WHEN P_ACCT
    *IS "PAC10064", "PAC10065", "PAC10066", "PAC10067"
    *REC(EXPRESSION=[P_ACCT].[PAC10064] + [P_ACCT].[PAC10065] + [P_ACCT].[PAC10066] + [P_ACCT].[PAC10067], P_ACCT="PAC10068")
    *ENDWHEN
    *COMMIT
    Is there any option to put Counter in BPC Logic, like in VBA where I can put code like this
    Y=0
    *WHEN P_ACCT
    *IS *
    IF Y=0
    *do calculation
    Y=Y+1
    END IF
    ENDWHEN
    Looking for help. Thank You.

    Nilanjan,
    1. Is there any option to generate intersection within %VALUE% with something else but not with so many *WHEN/ENDWHEN? The reason why I'm asking is that we have 300 calculations to develop and hadle in Script Logic and this will be quite a toughcode to maintain for client afterwards
    2. And another question: with 2 *SELECT statements we get 2 pools of Accounts, which we need divide ( SUM(Pool1)/SUM(Pool2) ). What I need to write in EXPRESSION and is there any chance to avoid FOR/NEXT in this case?
    *SELECT(%ACCOUNT1%, "[ID]", P_ACCT, "[SUBFUNC_ID]='SUB09'" AND "[TYPE]='u0417u0430u0442u0440u0430u0442u044B'" AND "[CALC]='N'")
    *SELECT(%ACCOUNT2%, "[ID]", P_ACCT, "[SUBFUNC_ID]='SUB07'" AND "[TYPE]='u0417u0430u0442u0440u0430u0442u044B'" AND "[CALC]='N'")
    *SELECT(%COSTCENTER%, "[ID]", COSTCENTER, "[TYPE_ID]<>'TP11'" AND "[CALC]='N'")
    *XDIM_MEMBERSET COSTCENTER=%COSTCENTER%
    *WHEN P_ACCT
    *IS *
    *DESTINATION_APP = KPI
    *SKIP_DIM = COSTCENTER_SEND
    *ADD_DIM AGGREGAT = AGR2, WORKSHOP_LINE = WSL2, STOCK_CATEGORY = STC2, PARTNER = PRN2, RESOURCE_TYPE = RTT2, SALE_PROJECT = SLP2
    *REC(EXPRESSION=................, COSTCENTER="CCN2", P_ACCT="PAC30318")
    *ENDWHEN

  • 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.

  • Creating an empty file using variable in script task

    I created an empty file by writing a code in script task. how can i use a variable to do the same job.
    System.IO.File.Create(@"C:\OneEmptyTextFile.txt");

    Hi SyedF,
    Just as you said, we should refer to the code below to create an empty file in the specified path using System.IO.File.Create:
    System.IO.File.Create(Path)
    If we want to use a variable named FilePath to control the path of the created file, please refer to the following code:
    Dim Path As String
    Path = Dts.Variables("FilePath").Value
    System.IO.File.Create(Path)
    Reference:
    https://msdn.microsoft.com/en-IN/library/ms135941.aspx
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • 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.

  • Referring to SQL comment table in Script Logic

    Dear all,
      If i have the following combination of dimensions, i.e. "DimA, DimB and DimC", and they will point to a comment in the comment table in SQL, how do i grab the [Comment] from the comment table to be used in my script logic.
      I was adviced to use *select statement, but i can't seem to get it to work.
      Any help is much appreciated.
    Cheers,
    Lip Chean

    Hi,
    *Select allows you to retrieve a list of elements from a dimension or table and save it in a user-defined variable for later use anywhere else in the logic.
    For example, with this instruction:
    *SELECT(%REPORTING_CURRENCIES%, u201CIDu201D, u201CCURRENCYu201D, u201C[GROUP] = 'REP'u201D)
    In this case, you retrieve the ID of all members in the CURRENCY dimension where the property GROUP has the value REP. Running this example fills the variable %REPORTING_CURRENCIES% with the list of reporting currencies defined in the current application.
    Important information
    xxx The SELECT statement generates a SQL query, and NOT an MDX query. This implies that it can be executed against any SQL table existing in the application set database, and not just against the properties of a dimension in the cube. The prefix "mbr" is automatically added to any name entered in the table parameter. Otherwise, the name of the table is taken as is. If
    you want to select a list of elements from a dimension using an MDX query use *MEMBERSET statement.
    xxx In case any parameter contains embedded commas the entire parameter must be enclosed in an extra set of double quotes.
    xxx The *SELECT statement is executed at the time the logic is validated, and the expanded result is written in the LGX file. This means that if the related dimension is modified, it may be necessary to re-validate the logic.
    xxx Statements returning no members do not necessarily cause the validation of the logic to fail. In this case a warning is entered in the validation log.
    xxx These instructions are not specific to a given logic section, but they can be written once anywhere in the logic and used across multiple commit sections.
    Hope this helps.
    Badrish

  • Line numbers in Script Logic editor

    Hi everybody,
    when using the default Script Logic editor in BPC NW I can not see any Line Numbers (or Column Numbers) in the edited script.
    When an error is detected by the system after validating the script, the error message sometimes refers to a certain Line Number where the error occured.
    Is there a better way than manually counting the lines from the top (which can be quite a task when editing, say 500 lines) ?
    Do I miss something here or are you all using alternative editors ?
    Please give me some input.
    Regards.
    Wolfgang

    Hi Nilanjan,
    thanks for the quick answer.
    That would mean that I always need to switch from BPC frontend Script Editor into BW and start a transacion and program there. I would have hoped, that simole line numbers would be a standard feature in the BPC frontend editor itself. Nevertheless...
    Best regards.
    Wolfgang

  • Script Logic choice SQL or MDX in NW release?

    Hi experts,
    I have encountered some opposite arguments in forum. Please can you clarify NW release script logic choice should be as MS release?
    In [Script Logic BPC MS (SQL) vs. NW (ABAP); Tim Klem states
    - "Write the logic using BPC SQL script logic syntax (not MDX) for performance reasons" but this opinion based on MS version. How about NW release is it really smarter to select SQL Script rather than MDX.
    There is another statement in [Re: BPC 7 NW; Deppak mentions that:
    - "In BPC 5.1 the script formula approach suggests to use SQL based logic instead of MDX.
    Whereas in Teched,08, I learnt that MDX & ABAP (using BADIs) would be used for it. Thats why I am slightly confused...."
    But second statement is far beyond NW relase date and I am sure this is not true but I would like you to confirm that.
    If you were a project responsible and want that all scripts will be held in one language, what would you choose??
    Thanks in advance,
    ergin ozturk

    Hi Ergin,
    I can understand your approach not to use ABAP hence you miss the skills witin your project team.
    However, you (or you client) has chosen the NetWeaver version for whatever reason. I'm sure a thorough decisions process has lead to this decision. In choosing the NetWeaver version with SAP BI you will sooner or later come to the point that you will have to use ABAP if you like it or not. Especially when you start using further capabilities within NetWeaver and the BI solutions. So from my point of view ABAP knowledge is an essential skill you need in a project based on SAP NetWeaver anyway.
    Additionally I heared some statements that MDX is causing some performance issues on the NetWeaver version. This may have been fixed in the meantime with some SPs.
    As the SQL within the NetWeaver verison does not have the full functionality than it has in MS Version SQL is not an option for me.
    I do also not see the cost impact hence someone need to do the support anyway. In case of MDX you need an MDX developer, in case of ABAP and ABAP developer. Or a technical BPC consultant able to do the development (which I would recommend you should have in your project team anyway).
    So coming back to your original question, I would recommend to do as much as possible using ABAP BADIs.
    Cheers,
    Steffen

  • Can we calculate difference of  dimension properties values in script logic

    HI
    I have 3 products, whose manufacturing process starting perod and end periods are different for three products. Now I want
    to distribute total  manufactuing cost to those periods only for each product.  how will write script logic  for this senario.
    My system is BPC nw7.5
    Mahi

    Hi,
    So, you want to find the difference between the dates and distribute the cost among them. I dont think this will be feasible using script logic. My suggestion would be use BADI. Script logic cannot do manipulation on the properties. BADI will be much easier. In addition to this, you need to think what should be the destination of the result. Every record is going to generate few records (depending on the number of months).
    Hope this helps.

  • Question on script logic

    Have a property for the category dimension, u201CFX_SOURCE_CATEGORYu201D.  The values for this property is another category dimension member.  For example FCST01_P_FR have property value as FCST01 and FCST02_P_FR have property value as FCST02 and so on.
    Using a dynamic script logic, want to copy the data in FCST01 to FCST01_P_FR if I choose FCST01_P_R in the selection while running the script.  Simiarly FCST02 to FCST02_P_FR if I choose FCST01_P_R in the selection while running the script. 
    Again the script should dynamic to get the data from category property value member and write to the category member that is chosen during the script run.
    I tried the following scripts and it is not working
    Script 1:
    *WHEN RPTCURRENCY
    *IS LC
    *WHEN ACCOUNT
    *IS BAS(EXPENSES)
    *WHEN CATEGORY
    *IS CATEGORY.FX_SOURCE_CATEGORY
         *REC(FACTOR=1)
         *ENDWHEN
    *ENDWHEN
    *ENDWHEN
    *COMMIT
    Script 2:
    *WHEN RPTCURRENCY
    *IS LC
    *WHEN ACCOUNT
    *IS BAS(EXPENSES)
         *REC(EXPRESSION = ([CATEGORY].[CATEGORY.FX_SOURCE_CATEGORY]))
         *ENDWHEN
    *ENDWHEN
    *ENDWHEN
    *COMMIT
    Edited by: Al Sathappan on Oct 11, 2011 9:03 PM
    Edited by: Al Sathappan on Oct 11, 2011 9:04 PM
    Edited by: Al Sathappan on Oct 11, 2011 9:04 PM
    Edited by: Al Sathappan on Oct 11, 2011 9:07 PM

    You have data in FCST01. It means that this member will appear in WHEN-ENWHEN loop. You have to define property of THIS member like "FX_TARGET_CATEGORY" and assign this property value FCST01_P_FR.
    Then you will have simple REC:
    *REC(EXPRESSION=%VALUE%, CATEGORY=[CATEGORY].[FX_TARGET_CATEGORY])

  • How to use the current view in script logic - %DIMENSIONNAME_SET% not work

    Hello,
    I have the requirement to use the values from the current view in the script logic. User would like to use the members which were selected from the current view in the calculation.
    We are using SAP BPC 7.0 SP06
    I have prepared the following scrpit:
    *XDIM_MEMBERSET TIME=$YEARS001$.NA
    *XDIM_MEMBERSET ACCOUNT=BAS(PLVEH_EXP)
    *SELECT(%CBU%,ID,BUSINESSAREA,[ID]='%BUSINESSAREA_SET%'")
    *SELECT(%CIO%,ID,INTERNALORDER,[ID]='%INTERNALORDER_SET%'")
    *RUNALLOCATION
    *FACTOR=USING
    *DIM BUSINESSAREA WHAT=BANA;WHERE=%CBU%;USING=<<<
    *DIM INTERNALORDER WHAT=IONA;WHERE=%CIO%;USING=<<<
    *DIM INDICATORS WHAT=INVEHPRI;WHERE=INPXQ;USING=INVEHQUA
    *ENDALLOCATION
    I have read in the sdn that it is possible to get the current values using %DIMENSIONNAME_SET% variable and use it but it returns all the members that were selected in the datapackage.
    I would like to know if there is any special consideration regarging the use of variable or if there is another way to solve it.
    Thanks in advance.

    Hi,
    If you want the code to be executed for the current view selected, you can place the code in Default logic which executes the logic for what ever current view values you send the data through Input schedule.
    The key word you have mentined is for script running through Data Manager which gets the value selected through user promt.
    Hope this helps,
    Regards,
    G.Vijaya Kumar.

Maybe you are looking for