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

Similar Messages

  • Problems when using RUNLOGIC Keyword in Script Logic

    Hello experts,
    I have a problem using RUNLOGIC keyword within Script logic. Both scripts are mentioned below.
    Following scenario:
    - combination of DESTINATION_APP and LOOKUP to multiply values from two source applications in order to to write results in target application
    - data volume in source application VALCHAIN are approx 187.000 records; source app SALES = 500 records
    - created data records in target application QUANTITIES are approx 204.000 records
    Running LOGIC01_QUANTITIES.LGF without "RUNLOGIC" keyword:
    - time to execute logic and write records: 10-12 minutes
    - created records 204.000
    Running LOGIC01_QUANTITIES.LGF via CALL_RUNLOGIC.LGF
    - script does not finish; system produces dumps
    - Tcode ST22 shows error messages called "TSV_TNEW_PAGE_ALLOC_FAILED" as well as "SYSTEM_NO_ROLL" as well as "CALL_FUNCTION_SEND_ERROR"
    Does anybody have a guess for that? Any answer appreciated.
    Thanks a lot!
    ==================================================
    CALL_RUNLOGIC.LGF
    *START_BADI RUNLOGIC
    QUERY=OFF
    WRITE=ON
    LOGIC=LOGIC01_QUANTITIES.LGF
    APPSET=FINPLAN_PERFORM
    APP=VALCHAIN
    CHANGED=PRODUCT
    DEBUG=OFF
    *END_BADI
    ===========================================
    LOGIC01_QUANTITIES.LGF
    *XDIM_MEMBERSET DATASRC=ITEMIZED
    *XDIM_MEMBERSET VERSION=%VERSION_SET%
    *XDIM_MEMBERSET TIME=%TIME_SET%
    *LOOKUP SALES
    *DIM DATASRC="OUTPUT"
    *DIM ITEM="IM_M02"
    *DIM QUANTU="QU_TO"
    *DIM MEASURES="PERIODIC"
    *FOR %LOOP_CENTER%=PC_1000,PC_2000,PC_3000,PC_4000,PC_5000,PC_6000
    *DIM C_%LOOP_CENTER%:PCENTER=%LOOP_CENTER%
    *NEXT
    *ENDLOOKUP
    *DESTINATION_APP=QUANTITIES
    *ADD_DIM COSELE=CE_NONE
    *WHEN PRODUCT.LG
    *IS "1"
      *WHEN MATERIAL
      *IS "MA_NONE"
        *FOR %LOOP_CENTER%=PC_1000,PC_2000,PC_3000,PC_4000,PC_5000,PC_6000
        REC(EXPRESSION=%VALUE%LOOKUP(C_%LOOP_CENTER%), PCENTER=%LOOP_CENTER%, ITEM="IM_M08", DATASRC="CALCULATED")
        *NEXT
      *ELSE
        *FOR %LOOP_CENTER%=PC_1000,PC_2000,PC_3000,PC_4000,PC_5000,PC_6000
        REC(EXPRESSION=%VALUE%LOOKUP(C_%LOOP_CENTER%), PCENTER=%LOOP_CENTER%, ITEM="IM_M05", DATASRC="CALCULATED")
        *NEXT
      *ENDWHEN
    *IS "1000"
      *WHEN MATERIAL
      *IS "MA_NONE"
        *FOR %LOOP_CENTER%=PC_1000,PC_2000,PC_3000,PC_4000,PC_5000,PC_6000
        REC(EXPRESSION=%VALUE%LOOKUP(C_%LOOP_CENTER%)/1000, PCENTER=%LOOP_CENTER%, ITEM="IM_M08", DATASRC="CALCULATED")
        *NEXT
      *ELSE
        *FOR %LOOP_CENTER%=PC_1000,PC_2000,PC_3000,PC_4000,PC_5000,PC_6000
        REC(EXPRESSION=%VALUE%LOOKUP(C_%LOOP_CENTER%)/1000, PCENTER=%LOOP_CENTER%, ITEM="IM_M05", DATASRC="CALCULATED")
        *NEXT
      *ENDWHEN
    *ENDWHEN
    *COMMIT

    Hello,
    This error comes up when there is no enough memory.
    How many members do you have in PRODUCT and how many parallel processes did you set up in PARALLELSCRIPT?
    Also, I'd suggest to put *XDIM_MEMBERSET PRODUCT = %PRODUCT_SET% in your LOGIC01_QUANTITIES.LGF script.
    Did you get anything in RUNLOGIC log? In UJFS you can find logs for every parallel process ran, name if it is just it's time stamp.
    Can you see from those what scripts ran and with what parameters?
    This should simplify resolution of your issue.
    Regards,
    Gersh

  • 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

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

  • 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 BADI or LGF script logic? Which is good in performance

    Hello,
    I have a situation wherein a choice is to be made among the "BADI" or "script logic" having DESTINATION_APP which is along with WHEN clause.
    Below is the code in which WHEN clause is used:
    Code Starts****
    XDIM_MEMBERSET CATEGORY=FC_CUR
    *DESTINATION_APP=GROSSMARGIN
    *SKIP_DIM =WEEK
    *ADD_DIM PLAN_PARTNER = PP_NA, RPTCURRENCY = LC
    *WHEN CATEGORY     
        *IS "FC_CUR"     
                  *REC(EXPRESSION=%VALUE%)
    *ENDWHEN
    *****Code Ends****
    The business requirement could be changing as we are at initial stage, wherein i may have to incorporate some data mapping logic which can also be handled through scripts instead of using BADI.
    The major concern is if BADI would be most prefferable over script logic having WHEN clause to acheive the optimal performance considering large no. of records that needs to be written to the target APPLICATION
    from the source application?
    OR
    The script with WHEN statement is fine if the data mapping is pretty simple and would not have much impact on performance compared to using of BADI even if the records to be moved is huge.

    If data mapping is simple you can opt for script logic . If requirement is complex then you can go for BADI . You can check this [How-to|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/70187b3e-d5ce-2d10-d780-bb8b1a5b0bdc?QuickLink=index&overridelayout=true] 6 th page on performance considerations of BADI .
    A well designed BADI implementation is faster than script logic

  • Changing Work Status using data package or script logic

    Is it possible to set Work Status using Script logic, or an SSIS package.
    I know status is kept is an SQL table, is it possible to just update the locking table with a new record, or is there more to changing the work status.
    Thanks for you help

    Thanks for your reply. This would be a nice enhancement.
    Although the work status does help with the audit trail of who and what locks the data, doing it automatically will allow the system to automatically unlock the period when it is opened before auto-loading the current closing balances. It will need to be carefully used in order to maintain proper audit trail of the data. When done automatically, the system userid would be used in the lock table witha  timestamp.
    I am needing to know if there are anyother steps involved in locking data other than writing to the SQL lock table. Is usppose this is especailly relevant when locking a parent and pushing the status to the children.

  • Use of LEFT in Script Logic

    I am having one doubt reagrding usage of excel function like LEFT, MID, RIGHT in script logic of SELECT Statement.
    Let me know with example if its possible.
    I tried the below statement:
    *SELECT(%EQACC%,"ID","ACCOUNT","LEFT(ID,6)='BE9001' AND CALC='N' AND ID<>'BE9001010'")
    But it throw the error as "invalid select statement"
    Anurodh

    Anurodh,
    what you are trying to do is not supported. As a workaround you can try to create a new property in the dimension (for example IDSHORT), putting in this filed just the first 6 characters of the ID and you can filter on it like in the following example:
    *SELECT(%EQACC%,"ID","P_ACCT","IDSHORT='CE0004' AND CALC='N'")
    Regards,
    Simmaco

  • Use of comments in script logic / BADI

    Hi,
    Does anyone knows whether one can read the comments entered in an input schedule in a script logic or BADI? Depending on the text entered in a comment, a certain planfunction has to be executed during save ...
    the user should be able to easily change a dimension value in an input schedule:
    Product    Product group    Key figure 1     Key figure 2
    A             A1                     10                       30
    -> the user easily needs to change the product group from A1 into B1 . When doing so the values of key figure 1 and 2 need to be copied to the new product group and the original values on A1 have to be removed. we cannot set up the product group as a propoerty since one should be able to compare multiple versions with different assignments ... So we were thinking to add an additional comment column in which the new value can be assigned to. When save, it should read the comment and perform the planfunction ... Would this be possible?
    D

    HI D-
    Possible, but you would probably need to create a Badi to accomplish all the logic...
    For a start, you would need to be able to find the comments...the naming convention for the dynamic comment table is:
    /1CPMB/application_set_prefixapplication_prefixCMT
    The two character application_set_prefix can be identified from the table UJA_APPSET_INFO, and the two character application_prefix can be identified from the UJA_APPL table.   
    Once the comment table is identified you could create a custom Badi to look up comment information to direct processing of specific records.   
    Regards,
    Sheldon Edelstein

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

  • Custom Measure in Script logic

    Hi,
    We have a custom measure created which is more or less the same as the YTD, but it starts not at the beginning of the year, but instead it starts at a given month.
    The measure creation was ok and we can use it perfectly well in reports and input shedules and the cumulation of data is ok.
    However, if we want to use this measure in a script logic it does not work.
    - Validating the script in the admin console goes fine
    - Executing the script gives the error:
             - Root element is missing
    - validating in UJKT gives the erro:
            - UJK_VALIDATION_EXCEPTION:Invalid Measures value: "T_232"
    The script we try to use is below. If we change the LTD (our custom measure) by YTD it works perfectly fine:
    *XDIM_MEMBERSET BUILDSTATE=NABS
    *XDIM_MEMBERSET BUSAREA=V1
    *XDIM_MEMBERSET CATEGORY=FCSTCUR
    *XDIM_MEMBERSET DATASRC=INPUT
    *XDIM_MEMBERSET ENTITY=201
    *XDIM_MEMBERSET MARKSEGM=NAMS
    *XDIM_MEMBERSET ORIGIN=OBOOK
    *XDIM_MEMBERSET PRODUCT=ELEVATORS
    *XDIM_MEMBERSET PROFCENT=201251
    *XDIM_MEMBERSET RPTCURRENCY=LC
    *XDIM_MEMBERSET SALESORG=SO_201
    *XDIM_MEMBERSET TECHPLATF=NATP
    *XDIM_MEMBERSET TIME=2010.OCT
    *XDIM_MEMBERSET TYPE=T_PLAN0
    *XDIM_MEMBERSET NEBACCOUNT =BAS(T_232)
    *XDIM_MEMBERSET MEASURES=PERIODIC
    [NEBACCOUNT].[#A232]=([MEASURES].[LTD],[NEBACCOUNT].[T_232])
    *COMMIT
    Thanks for any input on this. We want to avoid going via a BADI!
    Kind regards,
    Christophe Posson

    Hi Christophe,
    I'm in a similar position to you and wish to avoid use of a BAdI if we can - despite the MDX parser engine being pretty pathetic at handling YTD or custom measures.
    Did you get a resolution to this? If so, could you please share it with everyone?
    As much information as possible would be apprecaited. Our next move is to contact SAP for confirmation that there is no possibility of using custom measures in Script Logic.
    Many thanks,
    Nick

  • MEASURES in script logic

    Hi All!
    How can I use YTD measures in script logic? My aplication is PERIODIC ( YTDInput set to No) and I need in my script logic to use YTD values for some calculation. I tried following syntax
    *REC(EXPRESSION=([C_ACCT].[PLM],[MEASURES].[YTD]))
    but after validation error appears
    http://screencast.com/t/q2gChPrqbVXy.
    Please help, how to use measures dim in script logic??
    Regards,
    Justyna

    Full script not it is working fine after change *XDIM_MEMBERSET MEASURES=YTD to *XDIM_MEMBERSET MEASURES=PERIODIC
    *XDIM_MEMBERSET C_ACCT = VALCON_EN020
    *XDIM_MEMBERSET MEASURES=PERIODIC
    *WHEN_REF_DATA = MASTER_DATA
    *WHEN C_ACCT
    *IS VALCON_EN020
    *REC(EXPRESSION=([C_ACCT].[PLM],[MEASURES].[YTD]))
    *ENDWHEN
    *COMMIT

  • Multiple Script Logics in Default Logic.. order of execution... Commit

    Hi,
    I have a situation where I need to perform two activities...
    i) Perform a multiplication operation on the data input by the user - Script Logic A
    ii) Send the data at a summary level to another application. - Script Logic B
    Both Script logics are in the Default Logic
    User opens an input template and makes changes to a few Products (more than 1). I want the script logicA to execute completely (i.e. for all the models) and THEN Script Logic B to execute since Script Logic B summarises the data
    It seems like this is not how the system works.. Rather it goes thru Script Logic A and Script LogicB for the 1st Product, then the 2nd Product and so on...
    I tried using a commit after Script Logic A / before Script logic B and a few other options but to no avail... Any suggestions ???
    The other option is not to put Script Logic B in the Default Logic but to execute it separately... Worse case situation I'll use that option..
    thanks

    Hi,
    Have you defined the scope of the product for the two logics independently.
    Try that by including commit after the first logic. This should work.
    *XDIM_MEMBERSET PRODUCT=BAS(ALL)
    Script 1
    *COMMIT
    *XDIM_MEMBERSET PRODUCT=BAS(ALL)
    Script 2
    *COMMIT
    Hope this helps,
    Regards,
    G.Vijaya Kumar

  • Dimension Formula versus Script Logic that runs on default

    Hi Experts,
    Which is better to use dimension formula or script logic that runs on default? We have a lot of dimension formulas and when noticed that it has a huge impact in the performance of our AppSet. When we try to remove them, the performance seems better. We we're thinking of transforming these dimension formulas into script logic which will run by default instead. Right now I'm hesitant with two things, 1.) Will there be improvement in performance if I all these formulas are run at default via script logic? 2.) The maintenance seems to be much more complex for the user if we use script logic.
    Thanks,
    Marvin

    Hi Marvin,
    Actually you pointed very well the advantage and disantavage regarding dimension formula.
    Dimension formula are executed into run time which means that value are not calculated. Of course this will have an impact regarding performances.
    Usually our recommendation is to use dimension formula just when yoiu have KPI's to calculate which will be very difficult to be implemented into SQL scrip logic or when you have very simple calculation like Account A = Account B+ Account C.
    For other calculation we advice our customer to use script logic.
    But attention:
    Default formula should not become very heavy because you will arrive into other issue with performances.
    When you will send data if default formula script will be heavy you will arrive into situation to wait may be minutes just to send one figure and of course this will be not acceptable for users.
    So you have to use script logic but you have to run into batch mode (schedule package) that script logic.
    Into default formula you have to keep just minimum (you have to calculate just figures which have importance for user imediat, real time).
    Also you have to be aware that moving dimension formula into scrip logic actually your fact table will grow a lot because the number of records generated will be probably 3-4 times bigger than number of records from fact table with dimension formula.
    Maintenance of script logic is more complex than dimension formula and you pointed very well this.
    So it is a balance and I tried o provide you suggestions or best practice when you have to use dimesnion formula and you have to avoid dimension formula.
    I hope this will help you to arrive to best combination for your application.
    Kind Regards
    Sorin Radulescu

Maybe you are looking for

  • Sample Response File for Oracle Database 12c Standard Edition on Oracle Linux 6.4 -- working

    oracle@styles-and-artists-development-oracle database]$ cat response/db_install.rsp ## Copyright(c) Oracle Corporation 1998,2013. All rights reserved.## ## Specify values for the variables listed below to customize     ## ## your installation.       

  • ITunes 11.0.2.26 freezes when adding folder to library

    iTunes 11.0.2.26 freezes when adding folder to library. This did not occur with any previous version and is taking place with several different folders. Adding files as a batch wrks fine.

  • BEx QUERY DESIGNER AND QUERY ANALYZER

    HI!!! I want to learn to use the BEx Query Designer and the Query Analyzer, someone can help me with link, manuals, tutorials, cookbooks, everything about this? Thanks and regards

  • Integrating Oracle forms in Portals- URGENT

    Hi, How to integrate the Oracle forms/ reports (From an existing application) in Oracle portals?

  • Html Form

    Hellow to everybody, i got this problem. I will like to know, how to create an html form, to put on a unix server that dosent suport cgis, or asp. Is a simple html form, the one includes: name, phone, email and coments, and two butons, one for clear