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?

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

  • 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

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

  • 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

  • Reg: Script Logic - REC Statement Variable usage

    hi friends
    Pl find enclosed the following code:
    *WHEN TIME               
    *IS TMVL(-1,2011.04)               
    *WHEN ACCOUNT               
    *IS "EXP01"               
    *REC(EXPRESSION = [TIME].[2011.04]-%VALUE%,TIME = 2011.04,ACCOUNT = EXP01A)               
    *ENDWHEN               
    *ENDWHEN               
    The above code is working fine and result is extracted but i have hardcoded , ACCOUNT=EXP01A;
    My Query is follows:
    I have used
    *WHEN ACCOUNT               
    *IS "EXP01"
    In REC i want to use concatenation of "A" To account like EXP01&"A"
    i know accunt & i want to concatenate "A" and use in REC statement like assign to variable
    var1="EXP01" & "A" and use var1 in REC
    *REC(EXPRESSION = [TIME].[2011.04]-%VALUE%,TIME = 2011.04,ACCOUNT = var1)
    i am not sure the syntax (Whether we need to put in strings)
    Also if EXP02 then var1="EXP02"&"A" and so on
    In fact i want to make this for all members in Account Dimenstion as generalised.
    Pl. verify and suggest best possibility
    Thanx & Rgds
    Srinath

    Hi Krishna
    *XDIM_MEMBERSET ACCOUNT AS %ACC% = EXP01
    *WHEN ACCOUNT
    *IS %ACC%
    REC(EXPRESSION = %VALUE%2,TIME = 2011.04,ACCOUNT = %ACC%A)
    *ENDWHEN
    Is it required to add EXP01A as below?
    XDIM_MEMBERSET ACCOUNT AS %ACC% = EXP01, EXP01A
    Also In Generalized code you have mentioned:
    Instead of Hard Coding EXP01, EXP02 can i have hierarchy of all EXP , so that if any new account added in dimension, there will be no change in script logic. Pl. can you share how to use the same.
    If above code needs to be generalised, *FOR *NEXT can be used .
    *XDIM_MEMBERSET ACCOUNT AS %ACC_LIST% = EXP01,EXP02,EXP03,EXP04
    *FOR %ACC_MBR% = %ACC_LIST%
    *WHEN ACCOUNT
    *IS %ACC_MBR%
    REC(EXPRESSION = %VALUE%2,TIME = 2011.04,ACCOUNT = %ACC_MBR%A)
    *ENDWHEN
    *NEXT
    Rgds
    Srinath

  • Local variable in script/MDX logic

    Is it possible to define a local variable which will hold a calculated value temporarily to be used later in the program?

    Hello,
    no, it's not possible to use such kind of variables in BPC for NW script logic.
    Hope this info will help u,
    Dzmitry

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

  • FOR loop in script logic

    Dear Gurus,
    This is the logic I am working with:
    *FOR %MONTH% = 2008.FEB,2008.MAR,2008.APR,2008.MAY,2008.JUN,2008.JUL,2008.AUG,2008.SEP
    //CHECK IF THE VALUE OF THE ACCUMULATED DEPRECIATION IS GREATER THAN THE CAPITALIZED ASSET VALUE//
    [ACCOUNT].[#AccumDepr] = (([ACCOUNT].[AccumDepr]+[ACCOUNT].[Depreciation])>[ACCOUNT].[EQUIPMENT1]? [ACCOUNT].[EQUIPMENT1] : ([ACCOUNT].[AccumDepr]+[ACCOUNT].[Depreciation]))
    *NEXT
    I am trying to execute the above script logic, but the system is throwing an error that says 
    "Duplicate formula found:  [ACCOUNT].[#AccumDepr] = (([ACCOUNT].[AccumDepr]+......."
    Any idea why this is happening?
    Also, could you please suggest a better way of writing the above code?
    Thanks,
    Vijay.

    As a testing scenario, I have calculated the depreciation in a different part of the same logic.  Here it is:
    //This logic calculates the accumulated depreciation amount for the time period specified in the logic
    //NOTE:  This logic is not very dynamic and is only valid for the accounts specified in the logic
    //A FUTURE ENHANCEMENT TO THIS LOGIC WOULD BE TO MAKE THE "LIFE" OF THE ASSET A $DATAMANAGER VARIABLE$
    //AND WRITE A CUSTOM SCRIPT LOGIC
    //BEGIN SCRIPT LOGIC FILE//
    //CONSTANTS
    *XDIM_MEMBERSET CATEGORY=ACTUAL
    *XDIM_MEMBERSET ACCOUNT=Depreciation,AccumDepr,NBV_EQUIPMENT1,EQUIPMENT1
    *XDIM_MEMBERSET ENTITY=STORE1
    *XDIM_MEMBERSET TIME=2008.JAN,2008.FEB,2008.MAR,2008.APR,2008.MAY,2008.JUN,2008.JUL,2008.AUG,2008.SEP
    //BEGIN: POPULATE NET BOOK VALUE FROM CAPITALIZED ASSET VALUE //
    *WHEN ACCOUNT
    *IS EQUIPMENT1
         *WHEN TIME
         *IS 2008.JAN
              *REC(FACTOR=1,ACCOUNT="NBV_EQUIPMENT1")
         *ENDWHEN
    *ENDWHEN
    *COMMIT
    //END: POPULATE NET BOOK VALUE FROM CAPITALIZED ASSET VALUE   //
    //BEGIN: CALCULATE DEPRECIATION //
    *WHEN ACCOUNT
    *IS EQUIPMENT1
         *REC(EXPRESSION=(%VALUE%/6),ACCOUNT="Depreciation")
    *ENDWHEN
    *COMMIT
    //END: CALCULATE DEPRECIATION   //
    //BEGIN: CALCULATE ACCUMULATED DEPRECIATION AND NET BOOK VALUE //
    *FOR %MONTH% = 2008.FEB,2008.MAR,2008.APR,2008.MAY,2008.JUN,2008.JUL,2008.AUG,2008.SEP
    //CHECK IF THE VALUE OF THE ACCUMULATED DEPRECIATION IS GREATER THAN THE CAPITALIZED ASSET VALUE//
    *WHEN CATEGORY
    *IS ACTUAL
    *REC(EXPRESSION=IIF((([ACCOUNT].[AccumDepr] + [ACCOUNT].[Depreciation])>[ACCOUNT].[EQUIPMENT1]), [ACCOUNT].[EQUIPMENT1], [ACCOUNT].[AccumDepr]+[ACCOUNT].[Depreciation]))
    *ENDWHEN
    *NEXT
    //*FOR %MONTH% = 2008.FEB,2008.MAR,2008.APR,2008.MAY,2008.JUN,2008.JUL,2008.AUG,2008.SEP
    //CHECK IF THE NET BOOK VALUE OF THE ASSET IS LESS THAN ZERO//
    //*[ACCOUNT].[#NBV_EQUIPMENT1] = (([ACCOUNT].[NBV_EQUIPMENT1]-[ACCOUNT].[Depreciation])>0? ([ACCOUNT].[NBV_EQUIPMENT1]-[ACCOUNT].[Depreciation]) : 0)
    //*NEXT
    *COMMIT
    //END: CALCULATE ACCUMULATED DEPRECIATION AND NET BOOK VALUE   //
    //END SCRIPT LOGIC FILE//
    Please let me know if there is a better way to write this code.
    Thanks for all your help.

  • Error with Script logic

    Hello friends,
    I am getting an error with running currency conversion in an app, the error says Invalid dimension "C_Category". Here is the script logic, I dont see C_Category anywhere. For the record, the name of dimension is category.
    *RUN_PROGRAM CURR_CONVERSION
          CATEGORY     = %C_CATEGORY_SET% 
          GROUP = %GROUPS_SET% 
          TID_RA = %TIME_SET%
          RATEENTITY = GLOBAL
          OTHER = [ENTITY=%ENTITY_SET%]//For More than one other scope parameters: OTHER = [ENTITY=%ENTITY_SET%;INTCO=%INTCO_SET%...]
    *ENDRUN_PROGRAM

    Hello,
    Variable %C_CATEGORY_SET% means set of members selected for Dimension C_CATEGORY. So, if you want to use CATEGORY instead replace it with %CATEGORY_SET%, but if are running Consolidations I think you need C_CATEGORY Dimension.
    Regards,
    Gersh

  • [ASK] Error in Script Logic Using WHEN

    Hello guys.
    Script logic :
    *XDIM_MEMBERSET CATEGORY = %CGY_PLAN%, %CGY_FORECAST%
    *XDIM_MEMBERSET ACCOUNT = <ALL>
    *XDIM_MEMBERSET ENTITY = <ALL>
    *XDIM_MEMBERSET TIME = %YEAR_TTL%
    *XDIM_MEMBERSET VEHICLE = <ALL>
    *XDIM_MEMBERSET BUDGET_ACT = <ALL>
    *WHEN CATEGORY
    *IS %CGY_PLAN%  // Error
      *WHEN TIME
      *IS %YEAR_TTL%
        *REC(CATEGORY = %CGY_FORECAST%, TIME = %YEAR_TTL%)
      *ENDWHEN
    *ENDWHEN
    *COMMIT
    When i validate, it is error for statement : *IS %CGY_PLAN%.
    But if that statement i change into : *IS %YEAR_TTL%; it isn't error.
    Why is this happen ? How to correct it ?
    Thank you.

    Hi,
    You have 3 variables in your script - CGY_PLAN, CGY_FORECAST, and YEAR_TTL.
    Are you passing the values to these variables through DM package?

  • Deduction maths in script logic

    Hi,
      i have a business process that goes as follow:
    total variable overhead + fixed overhead = total overhead
    total overhead - depreciation = factory overhead
      in my script logic, i have the following (please don't mind the spaces in the account dimension)
    *xdim_memberset account = total variable overhead, fixed overhead, depreciation
    *when account
    *is total variable overhead, fixed overhead
      *rec (account = "total overhead")
      *rec (account = "factory overhead", expression = (get(account="variable overhead") + get(account="fixedoverhead") - get(account="depreciation")))
    *endwhen
      the second *rec doesn't work, any idea on how to rectify this deduction situation?
    cheers

    Your *IS statement already references two accounts, so you can't reference either of these in your GET(). You need to flip things around a bit.
    This should work. You may not even need the factor=-1 in the lsat *REC. It depends on the AccType for each account.
    *xdim_memberset account = total variable overhead, fixed overhead, depreciation
    *when account
    *is total variable overhead
    *rec (account = "total overhead")
    *rec (account = "factory overhead")
    *is total fixed overhead
    *rec (account = "total overhead")
    *rec (account = "factory overhead")
    *is depreciation
    *rec (factor= -1, account = "factory overhead")
    *endwhen

  • Use of prompted hierarchy's base members in Script Logic

    Hello all,
    I have a data manager package which prompts the user for a dimension called P_BUDGET_MODEL. The prompt is SELECT hence the user selects a hierarchy node on this dimension.
    In the relevant Script Logic I have a variable %P_BUDGET_MODEL_SET%, which is automatically created by the system. I would like to run the logic for the basemembers of the hierarchy node.
    Please note - the basemembers are not direct children of the selected hierarchy node (i.e. the selected node is the "grandparent" of the basemembers).
    I tried the following simple logic command:
    *XDIM_MEMBERSET P_BUDGET_MODEL = BAS(%P_BUDGET_MODEL_SET%)
    It yielded a message that "Member BAS() does not exist".
    I have also noticed the following thread:
    [BPC 7.5 NW - HIER NODE in PROMPT using Formule in Package ?;
    If I understood properly it is not relevant to my case because the hierarchy is more that 2 levels deep.
    Any ideas?
    TIA
    Avihay

    Hi,
    As it seems after further investigation the problem is that I use "_" in the dimension names and variable names. This creates a problem to BPC in some cases.
    For example here there is no problem:
    *SELECT(%MODEL%,ID,P_BUDGET_MODEL,ID="%P_BUDGET_MODEL_SET%")
    Here there is a problem hence the use of [ ]
    *XDIM_MEMBERSET P_MONTH = BAS([%P_VERSION_SET%.YEAR].TOTAL)
    Here there is not "_" so the code is fine:
    *XDIM_MEMBERSET P_BUDGET_MODEL = BAS(%MODEL%)
    Strange yet seems that this was the problem...
    Avihay

Maybe you are looking for

  • Headset controller not working on iPhone 4 with ios7.04

    Trying to connect a new headset with in-line controller/mic to iPhone 4/ios7.04. Music plays fine but no controls, i.e pause, play, skip etc. Same headset works on my daughter's iPhone 4.  Is this a simple fix, i.e. change settings,  or is there some

  • Symbol in browser: delete and change

    Hello, could you help me please ? I want to change or delete the symbol to my folder but when I do a right clic, I can't delete the symbol or change it by an other symbol (that I want). Do you know how change or delete the symbol please ? Thanks in a

  • T500 series ATI 3650 subtle wavy lines

    When I switch to the Intel 4 series graphics the problem I'm experiencing goes away completely.  I'm not sure how to describe the problem with the ATI card selected, but it seems an awful lot like LCD pixel walking that's only locally focused to brig

  • It worked, but now loads only halfway and then stucks..

    Hi, I have a shiny new 27" iMac (OS 10.8.2) and a iPhone 4 (iOS 6.1.2). I've already connected them successfully via Home Sharing, but out of a sudden, it doesen't work anymore. It loads halfway and then stucks Restarted all devices and the modem. At

  • How do i call these functions without an error? Python

    Hi, I'm confused on how to call these functions I'm continuously getting error can you please help me. I am also unsure on how parameters work and don't know what I need to write in them, i'm a bit of noob so will need you to explain thoroughly thank