SQL functions in Script Logic

I want to build a script logic but the dimensions that I am testing do not have the fields I want in the format I want. In my case I would like to test the "Start" property in the Employee dimension. The property represents the employee start date but is a var char in the format dd.mm.yyyy rather thna a date field. I want to test whether it is five years prior to the date being processed.
My time dimension has a year property and a monthnum property. Each of these are varchar. I can write SQL that would convert these to a date and compare them with the start property on the employee dimension.
Can I  do iinsert SQL functions in the When statement. An example would be
*When convert(datetime, substring(employee.start,4,2) + '/' + substring(employee.start,1,2) + '/' + substring(employee.start,7,4))
Can I use  SQL functions in the Is statement? An example would be
*Is <DateAdd(YY,-5 , convert(datetime, Time.Monthnum + '/01/'' + time.year)
Finally when I use such techniques and look at the log by using "show log" in the logic debugger I see no reference to the SQL I used. It is as if the generated SQL has not made use of my functions. Instead all I seee are the extract statements from the three fact tables. Is this normal? Is there a way to see what SQL is really being generated and run?
At the moment it seems my only option is to make changes, try running it and hope I get an output. If no records are written I can't be sure whether it is because embedding SQL function is not supported or because I have made some other error.

No, the "BPC SQL" script logic doesn't allow for this extensive use of real SQL within the scripting syntax. As a concept, it's best to think of "BPC SQL" script logic as, "this unique BPC logic syntax will generate real SQL code when it's executed."
There's very little real SQL that you can use within the syntax itself, and definitely not within the WHEN or IF statements.  Nothing like cast, convert, substring, etc. (Except you CAN use these, a little bit, in a *SELECT statement. But I don't see how that will solve your current problem.)
Plus, when you consider how the logic engine processes a set of data, it's helpful to think of it in terms of selects & reading through a recordset. So in that regard, a SQL background can be helpful, in understanding the concepts. (Sort of helpful, except when it confuses you, or frustrates you since you don't have all the power you want.)
Anyway, to solve your problem, you might be able to restate the problem, and then use something like this code, which is valid syntax:
*WHEN TIME.TIMEID
*IS >= VERSION.FirstPlanMonthTimeID
In this case, FirstPlanMonthTimeID is set up in the version dimension as, for example, 20090400 (representing 2009.APR). This timeID is set by BPC automatically when processing the time dimension, and I need to ensure that my Version property value is set to match it.
A key point is that in BPC fact tables, the time dimension is stored as TIMEID (not ID, unlike all the other dimensions), and can be used for comparative evaluation in script logic WHEN/IF. The comparison property needs to be stored as an 8-digit integer value. If your time dimension has days in it (along with months), check the TIMEID after processing, and you should see the pattern for assigning values to TIMEID for days and months, etc.
Normally, TIMEID is assigned pretty sensible and stable values. If it doesn't meet your logic requirements, you can create another property (be careful of USERTIMEID, since that has a specific purpose in the system which I've never fully understood) and assign that whatever (integer) values make sense.

Similar Messages

  • Math power function in script logic

    Hello all!
    Can anybody help me how  I can do math "power" function in BPC 5.1 Script Logic?
    Thanks

    Let's say you have a source account FOO and you want to calculate FOO to the 5th power, posting the result to FOOFIVE.
    In BPC SQL scripting, there are no mathematical functions to play with (powers, roots, sine, cosine, etc.) except for add, subtract, multiply and divide -- plus you can round results in your Factor or Expression. So that means, we must use multiplication.
    You could certainly do this using a bunch of intermediate accounts, one each for foo squared, foo cubed, foo to the 4th, and foo to the 5th. That would require *GO in between each *WHEN/REC block, and could be slow.
    I haven't tried this, but I think this should work, all in one statement:
    *XDIM_ACCOUNT = FOO
    *WHEN *
    *IS *
    REC(Factor=GET(Account="FOO")GET(Account="FOO")GET(Account="FOO")GET(Account="FOO")*GET(Account="FOO"),Account=FOOFIVE)
    *ENDWHEN
    If you want FOO to the 50th power, copy & paste.
    If you want square root of FOO, that could be a real challenge. I think to use straight BPC SQL logic it wouldn't be possible. I would probably write a stored procedure using SQL's SQRT(), and call that from the BPC logic file. Likewise for any other geometric functions, complex algebra, etc.
    There also may be a way to calculate powers in MDX -- that's more mathematically straightforward -- but as a BPC on MS person, I really never ever use MDX due to performance.
    Regards,
    Tim

  • Greater Than Function in Script Logic File

    BPC Experts,
    I've got a pretty simple script logic file to calculate salary amounts, overtime, etc.  The purpose of this logic is for forecasting.  I have two referenced dimensions, TIME and SCENARIO, where TIME.MONTHNUM is equal to its relative month number (eg: Jan monthnum = 1), and SCENARIO.CURRMONTH is equal to the relative amount of actual months data, (eg Jan currmonth = 0, Feb = 1) because if you are completing a February forecast, you have one month of actual.
    The ACTUAL scenario is never touched, but after a month closes, we copy the ACTUAL data to, for example, FEB_FCST.  So, after January closes, its actuals are copied to the FEB_FCST scenario so we can complete an actual/forecast (one month actual, 11 months forecast).
    Currently, the default logic skips anything in the ACTUAL scenario, by stating "*WHEN SCENARIO, *IS <> "ACTUAL" yada yada yada.
    However, when the default logic runs on the forecast scenarios, it takes the same inputs from the months that are copied over from the ACTUAL scenario and adds to the original amount, essentially doubling the value--ultimately causing an incorrect actuals number in the forecast scenario.
    My script right now looks like this:
    *XDIM_MEMBERSET DATASRC=INPUT
    *XDIM_MEMBERSET PRODUCT=NO_PRODUCT
    *XDIM_MEMBERSET SHIFT=NO_SHIFTS
    *XDIM_MEMBERSET MEASURES=PERIODIC
    *WHEN SCENARIO
    *IS <> "ACTUAL"
         *WHEN TIME.MONTHNUM
         *IS > SCENARIO.CURRENTMNTH
              *WHEN ACCOUNT
              *IS "SALARIED_MANPOWER"
                   *REC(EXPRESSION=((([ACCOUNT].[SALARIED_AVG_WAGE] * (1 + [ACCOUNT].[SALARY_TIMEAHALF]))* [ACCOUNT].[SALARIED_MANPOWER])),ACCOUNT="01100")
              *ENDWHEN
    *ENDWHEN
    *ENDWHEN
    *COMMIT
    When it hits line 9 (*IS > SCENARIO.CURRENTMNTH) during validation, it errors.  How can I use a "greater than" function to dictate whether or not a given scenario should run default logic on a specific month?
    If not, is there a different/better way to do it?
    Thank you!
    ABF

    Hi Alex
    Take this sample logic, check the properties in your Time dimension to trouble shoot your issue.
    *SELECT(%CAT_VAR%, "ID", CATEGORY, ID= PLAN_APRIL)
    *XDIM_MEMBERSET CATEGORY = ACTUAL, PLAN, %CAT_VAR%
    *SELECT(%CATMTH%, "STARTMTH", CATEGORY, ID= %CAT_VAR%)
    *SELECT(%ACT_PERIOD%, "ID", TIME, MONTHNUM < %CATMTH% AND  LEVEL = MONTH AND YEAR = 2010)
    *SELECT(%PLAN_PERIOD%, "ID", TIME, MONTHNUM >= %CATMTH% AND LEVEL = MONTH AND YEAR = 2010)
    *XDIM_MEMBERSET TIME= %ACT_PERIOD%
    *XDIM_MEMBERSET CATEGORY=ACTUAL
    *WHEN CATEGORY
    *IS ACTUAL
    *REC(EXPRESSION=%VALUE%, CATEGORY = %CAT_VAR%)
    *ENDWHEN
    *XDIM_MEMBERSET TIME= %PLAN_PERIOD%
    *XDIM_MEMBERSET CATEGORY=PLAN
    *WHEN CATEGORY
    *IS PLAN
    *REC(EXPRESSION=%VALUE%, CATEGORY = %CAT_VAR%)
    *ENDWHEN
    Thanks

  • Need Example for AVG() function in script logics...

    Hi Everyone,
                      I need to calculate average for all the account members ...
    so if anybody worked with this AVG() in Script logics please share with me...................

    What do you mean by calculate average? Average for the period or for some other parent or..? Where do you want to store this average? How do you want to use this average???

  • Using "left" mdx function in script logic

    Hello experts,
    I'm fetching a selection from a package prompt into a logic.
    The dimension name is ENTITYCC, so the variable name is %ENTITYCC_SET%.
    In this prompt user can select members from a hierarchy like that :
    CH20
    --- CH201000
    --- CH202000
    --- CH203000
    FR20
    --- FR201000
    --- FR202000
    --- FR203000
    and so on
    In my logic I need to have the parent node selected, but in case the user select a leave, I need to keep only first four caracters of his selection (to simulate the fact he select the parent)
    left(%ENTITYCC_SET%,4)
    What would be the instruction to get in another variable only the first four caracters of %ENTITYCC_SET% ?
    Thanks for your ideas.
    G.

    Solved by myself, sorry for the useless post.
    (my solution is :
    *SELECT(%ENTITY%,"left([ID],4)","ENTITYCC","[ID] = '%ENTITYCC_SET%'")
    and remember to use lgf file and not lgx when there is mdx in the logic

  • [ASK] Get One Row of Property Value From Dimension in Script Logic

    Hello, i need help about how to get one row of property value from dimension in script logic.
    Let say there is CATEGORY dimension and the members are like this :
    ID                                                  YEAR   Status
    PLAN_2011                                   2011        A
    PLAN_2011_V1                            2011        I
    ACTUAL_2011                              2011        I
    FORECAST_2011                         2011        I
    FORECAST_2011_V1                  2011        A
    PLAN_2012                                  2012        A
    PLAN_2012_V1                           2012        I
    ACTUAL_2012                             2012        I
    FORECAST_2012                         2012        I
    FORECAST_2012_V1                  2012        A
    If i scope CATEGORY like this :
    *XDIM_MEMBERSET CATEGORY = [CATEGORY].PROPERTIES("YEAR") = "2011"
    Then i will get member scope like this :
    PLAN_2011                                   2011        A
    PLAN_2011_V1                            2011        I
    ACTUAL_2011                              2011        I
    FORECAST_2011                         2011        I
    FORECAST_2011_V1                  2011        A
    Question :
    In script logic, how can i read the second record of scope and move it to variable ?
    Ex. : I read second record, so i can get the data of second record (PLAN_2011_V1, 2011, A).
    Is there any function to read all record that had been scope ? So i can read all those 5 records.
    Is there any substring or offset function in script logic ? How to use it ?
    Thank you.

    Hi,
    Firstly, when we scope the logic, it doesnt fetch the entire record from the member sheet. It just fetches the ID.
    Secondly, we dont have the feasibility to read only the second ID and skip the others. However, one alternative is that you use the SELECT statement to store all the IDs in a variable, and then use a FOR loop. But this will loop through all the 5 IDs, as per your example. If you want to skip all the IDs except one, you should maintain some property, so that all the IDs are neglected which doesnt have a particular property value.
    Hope you got the idea.

  • Include within Default.lgf Script Logic does not run

    Dear Gurus,
    I wrote a WHEN function in Script Logic which is supposed to multiply a input % (INP01) value (growth) with the absolute figure of the previous year. I works fine in the Backend Debugger. Then I put it in the default logic because I want it to run everytime somebody sends data. However it doesn't run? Has anybody had a problem like this?
    When running the default formulas out of the data manager it works just fine.
    default:
    *INCLUDE CALCULATE_KPI.LGF
    Calculate KPI:
    *XDIM_MEMBERSET ULOB=D00000
    *XDIM_MEMBERSET UCHANNEL=VD0001
    *XDIM_MEMBERSET RPTCURRENCY=EUR
    *WHEN TIME
    *IS "2008.SUM"
    *WHEN CATEGORY
    *IS "ACTUAL"
        *WHEN P_ACCT
        *IS "I001"
    REC(EXPRESSION=%VALUE%(1+([P_ACCT].[INP01],[ TIME].[2010.INP],[CATEGORY].[PLAN])),CATEGORY=V302,TIME=2010.INP,P_ACCT=I0000001)
    *ENDWHEN
    *ENDWHEN
    *ENDWHEN
    Thank you so much in Advance
    Edited by: Cora Boettger on Oct 19, 2009 3:59 PM

    Hi Cora,
    Are you sure that your default logic isn't running and that the *WHEN just isn't being triggered? This has happened to me when members used in *XDIM_MEMBERSET or *WHEN are not base-level. I'm a bit suspicious about 2008.SUM with regards to this.
    You can test by replacing what you have with something like
    *WHEN CATEGORY
    *IS *
    *REC(FACTOR=1.1)
    *ENDWHEN
    If this results in your written back values being multiplied by 1.1 into the TEST category, then your default logic is running and your issue is that the *WHEN is not getting triggered. At that point your should be able to head into the script logic tester and keep trying different scripts until you find one that works.
    Good luck!
    Ethan

  • Problems with "GET" in a Script Logic

    Hi,
    I created a Script Logic in BPC NW with the following code:
    *WHEN *
    *IS *
       *REC(GET(CONCEPTO=M30121),CONCEPTO=M213)
    *ENDWHEN
    And I click "Validate and Save" and I get this error:
    Validation Error
    Unknown Dimension Name in Keyword: "*:
    What's happening?
    Regards,
    Miguel.

    Thanks, but my problem is with "GET" function in Script Logic. You don't look at what I do with the code because it's an example. The problem is that the GET function doesn't work.
    I created a Script Logic in BPC NW with the following code:
    *WHEN CONCEPTO
    *IS M30121
       *REC(FACTOR=GET(CONCEPTO=M213),CONCEPTO=M30121)
    *ENDWHEN
    And I click "Validate and Save" and I get this error:
    Validation Error
    Unknown Dimension Name in Keyword: "M213):
    And if the code is like this:
    *WHEN CONCEPTO
    *IS "M30121"
       *REC(FACTOR=GET(CONCEPTO="M213"),CONCEPTO=M30121)
    *ENDWHEN
    The error is this:
    Validation Error
    Unknown Dimension Name in Keyword: ""M213"):
    Regards,
    Miguel.

  • 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

  • Catch a value from a pl*sql function in a shell script

    Hi all,
    I have a shell script that simply calls the following pl*sql function.
    echo "execute scott.my_pkg.test('FDLmaster');\n exit;" >./pippo.sql
    sqlplus scott/tiger @/fidcap_ftp/FDL/SCRIPTS/pippo.sql
    What I have to do to catch the value returned from the function test?
    Thanks in advance
    best regards
    Mario

    SQL> create or replace function do_something return varchar2 is
      2  begin
      3      return ('Something');
      4* end;
    SQL> /
    Function created.
    SQL> select do_something from dual;
    DO_SOMETHING
    Something
    SQL> save pippo
    Created file pippo.sql
    SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production
    With the Partitioning, OLAP and Data Mining options
    [linuxas tmp test10]$ echo exit >>pippo.sql
    [linuxas tmp test10]$ VAR=`sqlplus -s scott/tiger @pippo`
    [linuxas tmp test10]$ echo $VAR | cut -f3 -d" "
    Something
    [linuxas tmp test10]$

  • How can I order PL/SQL functions in "Called" a "Caller" order in function script file

    Does anybody know how to create PL/SQL function script file
    in "called" and "caller" (parent/child) order.
    Thanks
    Soheil

    Does anybody know how to create PL/SQL function script file
    in "called" and "caller" (parent/child) order.
    Thanks
    Soheil

  • Evaluation of SignedData in Script Logic v7.5 SQL

    Hello everyone,
    I'm noticing a problem in script logic at a client trying to upgrade to version 7.5 SQL.  This client has used its logic for around 5 years now through versions 4 and 5 but is now having a problem moving to version 7.5 and using this logic.
    It appears that evaluation of signeddata doesn't work in version 7.5 in SQL.  For example, a statement like:
    *WHEN ACCOUNT
    *IS 1000
    *WHEN SIGNEDDATA
    *IS <>0
    *REC...
    *ENDWHEN
    *ENDWHEN
    *COMMIT
    Doesn't appear to be working.  It's also possible that a reference to the TIMEID property is not working in something like:
    *WHEN ACCONT
    *IS 1000
    *WHEN SIGNEDDATA
    *IS >TIME.TIMEID
    *REC...
    *ENDWHEN
    *ENDWHEN
    *COMMIT
    Does anyone have any experience using SIGNEDDATA references in logic in version 7.5?
    Thank you,
    Grant

    Hello everyone,
    I'm noticing a problem in script logic at a client trying to upgrade to version 7.5 SQL.  This client has used its logic for around 5 years now through versions 4 and 5 but is now having a problem moving to version 7.5 and using this logic.
    It appears that evaluation of signeddata doesn't work in version 7.5 in SQL.  For example, a statement like:
    *WHEN ACCOUNT
    *IS 1000
    *WHEN SIGNEDDATA
    *IS <>0
    *REC...
    *ENDWHEN
    *ENDWHEN
    *COMMIT
    Doesn't appear to be working.  It's also possible that a reference to the TIMEID property is not working in something like:
    *WHEN ACCONT
    *IS 1000
    *WHEN SIGNEDDATA
    *IS >TIME.TIMEID
    *REC...
    *ENDWHEN
    *ENDWHEN
    *COMMIT
    Does anyone have any experience using SIGNEDDATA references in logic in version 7.5?
    Thank you,
    Grant

  • 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

  • How to use SQL() function while writing scripts in BODS 4.0

    How to use SQL() function while writing scripts in BODS 4.0

    Hello,
    I think you want to post your question to the [Data Integration and Data Quality Management|Data Services and Data Quality; forum. This forum is for other BusinessObjects SDK development questions.
    Sincerely,
    Dan Kelleher

  • Calc Previous YTD periods in SQL script logic

    Hi, experts!
    I need help in writing SQL script logic. I want to calculate such logic
    (Account = Acc3, TIME = 2009.FEB ) = (Account = Acc1, SUM(TIME = (2009.JAN; 2009.FEB))) - (Account = Acc2, SUM(TIME = (2009.JAN)))
    (Account = Acc3, TIME = 2009.MAR ) = (Account = Acc1, SUM(TIME = (2009.JAN; 2009.FEB; 2009.MAR))) - (Account = Acc2, SUM(TIME = (2009.JAN; 2009.FEB)))
    ..... and so on
    Thanks all for help.

    Hi Petar,
    Thanks for your advice.
    Legalapp in my Apshell do not have any account transformation rules. But looking at the account transformation table, I can see it requires dimension type datasrc and subtable for datasource and flow fields. But currently my application is similar to the Finance application from Apshell and do not have these dimension types.
    Still I created a rule in account transformation table by having these fields blank and the validation was successful. Then I used SPRUNCALCACCOUNT in default.LGL file to trigger this rule but I don't see this working.
    Can you help me on below questions:
    1. Is it necessary to have datasrc and subtable dimensions to create account transformation rule?
    2. Will SPRUNCALCACCOUNT write the values to WB table or should I use COMMIT or any other command along with his to have the values written?
    3. Is there any way/place where I can get the examples of Account Transformation rules ?
    Thanks
    Sharath

Maybe you are looking for

  • Presentation Director for T410?

    Hi all, I just got a new T410 Thinkpad for work and it looks like none of the ThinkVantage software is loaded - the OS is Windows XP SP3.  I already miss the Presentation Director so I can Function-F7 my way to different monitors at home and work.  I

  • Error in EDI Partner or partner profile partner no while notification close

    Hi All, When trying to close notification the system provides error message u201CError in EDI Partner or partner profile partner number".  The Relevant transaction code is QM02. EDI relevant partner profiles are maintained in table EDPVW which has en

  • "Desktop & Screen Saver" settings not saving upon reboot.

    "Desktop & Screen Saver" settings not saving upon reboot. Settings are always set back to factory default upon computer startup. Need help! Please!

  • Bookmarks and FlashHelp

    Hello, This is another newbie question, but I had put this problem to the backburner for a while and now am trying to deal with it again. My company is using FlashHelp (RoboHelp 6.0) for our new product, and I'm trying to figure out how to get bookma

  • Compelete system change log

    Hello Experts, I want to see complete system change log, is there any option through which I can see the complete change log, or any query for viewing the change Log ? Thanks Help Required....