Unable to Declare a Temporary Variable in Calc Script

We are using Hyperion System 9 BI+ Analytic Administration Services. 9.2.03.0.44
I am trying to declare a temporary variable in a calculation script.
We have found several guides and examples in the support documentation that give us a step by step instruction on how to 1.) declare the variable, then 2.) Assign a value.
Example:
/* Declare the variable */
VAR TotalAllocDept;
/* Baseline Fix */
FIX ("FY10","Jan","BU Version_1", "Actual", "NoProd", "NoCust")
/* Assign a value to the variable */
TotalAllocDept = ("Alloc_HR"+"Alloc_IT"+"Alloc_FIN");
ENDFIX
/* Allocate overhead based on Total Alloc Dept Variable */
FIX ("FY10","Jan","BU Version_1", "Actual", "NoProd", "NoCust")
"Alloc_5xSS" = @ALLOCATE("Alloc_Overhead","Account", TotalAllocDept,, share);
ENDFIX
However, when we try to check the syntax, we are given various error messages such as:
Error parsing FIX STATEMENT "invalid object type" and
"Invalid member name" and
Invalid Calc Script syntax.
Can anyone suggest some techniques that we can try or alternative ways of entering the text to make it possible for us to use temporary variables?

A variable must be declared within a calc member block and can only exist for the scope of that block.
This would work (not that you would necessarily want it)"
/* Allocate overhead based on Total Alloc Dept Variable */
FIX ("FY10","Jan","BU Version_1", "Actual", "NoProd", "NoCust")
"Alloc_5xSS"
TotalAllocDept = ("Alloc_HR""Alloc_IT""Alloc_FIN");
"Alloc_5xSS" = @ALLOCATE("Alloc_Overhead","Account", TotalAllocDept,, share);
ENDFIX
Regards,
Cameron Lackpour

Similar Messages

  • Unable to execute the substitution variable in calc scripts in essbase 11.1

    Unable to execute the substitution variable in calc scripts in essbase 11.1.3
    FIX(&CURRVERSION,COLA)
    Unit=units*Listprice;
    dataexport "file" "," "E:\NEW.TXT";
    ENDFIX
    Error: 1200471 Error parsing formula for FIX STATEMENT (line 1): expression expected before [)]
    This is error it throws when executing the calculation script
    I wonder whether its a problem with substitution variable i want to know wat went wrong inside the fix statement
    I have created substitution variable use maxl
    Installed the essbase in custom manner and standlone mode nt register with the shared services ,
    Is this problem with the custom installation of essbase
    Regards
    shenna

    If you remove the substitution variable and replace it with the actual value (whatever that is), does the code work? That will tell you if the issue is around the substitution variable or not.
    John -- First you race Glenn, then you race me -- and you always win. :)
    Regards,
    Cameron Lackpour

  • Using variables in Calc scripts and Business Rules

    I am sure there have been previous discussions about this, but can somebody let me know the benefits of using variables in Calc scripts and BRs?
    Thanks,
    A

    I have never used calc variables and after reading a study guide, which talked about them, I couldn't really understand the benefits.^^^I use variables all the time to make abstract difficult formulas. Below is an example.
    /*     Declare variables     */
    VAR varSalaryCosts ;
    VAR varProdOHLabXXXX ;
    VAR varXXXX ;
    A whole bunch of code here along with very limited FIX statement and then...
    "Salaried Labor"
         varSalaryCosts = "Salary Costs"->"No Department"->"No Category"->"Salaried" -
                             "Wage Bonus"->"No Department"->"No Category"->"Salaried" -
                             "YYYY Retention Bonus 40%"->"No Department"->"No Category"->"Salaried" -
                             "YYYY 60% Ret Bonus Accrual"->"No Department"->"No Category"->"Salaried" ;
         varProdOHLabXXXX = "Number of Employees"->"ZZZZDepartments"->"Codes"->"Salaried" +
                             "Number of Employees"->"Blah Departments"->"Codes"->"Salaried" +
                             "Number of Employees"->"Humph Departments"->"Codes"->"Salaried" +
                             "Number of Employees"->"TTTT"->"Codes"->"Salaried" ;
         "Salaried Labor" = varSalaryCosts * ("Number of Employees"->"Salaried" / varProdOHLabXXXX) ;
    )The last formula is how the formula was described to me by the business owner. I find it to be much easier to read than something like:
    "Salaried Labor" = ("Salary Costs"->"No Department"->"No Category"->"Salaried" -
                             "Wage Bonus"->"No Department"->"No Category"->"Salaried" -
                             "YYYY Retention Bonus 40%"->"No Department"->"No Category"->"Salaried" -
                             "YYYY 60% Ret Bonus Accrual"->"No Department"->"No Category"->"Salaried") *
                             ("Number of Employees"->"Salaried" /
                             ("Number of Employees"->"ZZZZDepartments"->"Codes"->"Salaried" +           
                             "Number of Employees"->"Blah Departments"->"Codes"->"Salaried" +
                             "Number of Employees"->"Humph Departments"->"Codes"->"Salaried" +     
                             "Number of Employees"->"TTTT"->"Codes"->"Salaried")) ;I have used ARRAY in a really-cool-but-alas-not-invented-by-me calc script to do currency conversion in Planning better than Planning does currency conversion. (How's that for a run-on sentence?) It is one of the six blog posts I am working on and I will finish it soon, I hope. I am sort of in thrash mode right now. It does have its uses and I'll try to remember to update this thread when I'm done.
    Regards,
    Cameron Lackpour

  • REP-0118 Unable to create a temporary file in "Windows 7 "

    We are using Report Builder Version 6.0.8.24.0 and Windows7 32 bit operating system, here
    While Running a Report through form i am getting this below
    error.
    REP-0118 Unable to create a temporary file*
    But while running the same report in a windows 98 or windowsXp PC
    i dont get this error.
    What might be the problem.
    pls advice the solution....
    thanks in Advance...
    Stalin...

    try this..
    REP-118: Unable to create a temporary file.
    Case 1: The environment variable that determines in what directory to create temporary files is set to an invalid directory.
    Case 2: There is not enough free space on the disk to create the temporary file.
    Case 3: A temporary file that cannot be modified already exist
    In regedit under branch hkey_local_machine/software/oracle/<oracle home> 
    I have changed the variable REPORTS_TMP. I changed the value for this to c:\reports_tmp
    or you can use something like this where you want Oracle reports to create temp files. Hope this helps

  • Doubt in Decode and Using Temporary variable

    I was facing the following issue,
    For example,
    The column_name if A should be stored with the value B or, with itself for which I included a statement as following,
    Case [1]
    SELECT ....DECODE(column_name,'A','B',column_name) alias_name
         FROM table_name
              WHERE condition;
    But,
    when i used a temporary variable as following i could not get the expected change,
    Case [2]
    SELECT ...column_name
         FROM table_name
              WHERE condition;
    temp VARCHAR(10);
    BEGIN
    IF column_name='A' THEN
         temp:='B';
    ELSE
         temp:=column_name;
    END IF;
    END;
    I was able to get the right output in Case[1],but failed to get in [2]. Please help and Thanks in advance.

    Without seeing your code, whatever I can say might be just an assumption. I can give an example to show that it will work.
    SET SERVEROUTPUT ON
    DECLARE
      var      VARCHAR2(10);
      col_name VARCHAR2(30);
      TEMP     VARCHAR2(20);
    BEGIN
      SELECT column_name
      INTO col_name
      FROM user_tab_columns
      WHERE table_name = 'EMP'
      AND rownum       =1;
      IF (col_name     ='EMPNO') THEN
        temp          := 'X';
      ELSE
        temp := col_name;
      END IF;
      var := 'abc '||temp;
      dbms_output.put_line(var);
    END;
    OUTPUT :
    abc X
    PL/SQL procedure successfully completed.

  • Temporary variables in business rule in essbase

    hi,
    I want to add temporary variable in my business rule. I have declared the variable as below:
    VAR TaxRate;
    "ROA Tax Rate"
    TaxRate = "ROA Tax Rate"->"GLBU_CVD CONSOLIDATED"->"OU_NUTRITIONAL CHEM"->"All DEPTS"->"Working"->"Forecast"->&FcstYear->"USD"->&FcstMths;
    It is validatoing correctly but when I am running the rule it is giving the error as:
    Error executing formula for [ROA Tax Rate] (line 18): Cannot assign [DOUBLE] objects of different length
    A I doing something wrong with the declaration? (ROA Tax Rate is the member name)
    Please suggest.

    Hi,
    Try this,
    VAR TAXRATE = #MISSING;
    "ROA Tax Rate"
         TAXRATE= "GLBU_CVD CONSOLIDATED"->"OU_NUTRITIONAL CHEM"->"All DEPTS"->"Working"->"Forecast"->&FcstYear->"USD"->&FcstMths;
                             //Intersection of your data;  (i.e., A->B->C)
    Regards,
    Avneet

  • Temporary Variables

    I’m sure there’s an easy solution to this and that I must be looking at it the wrong way.In my calc script, I’ve created a temporary variable called BC_uf_wages containing the following members. My actual outline for the “urban fare” has many members. I’ve also setup a province attribute splitting the urban fare locations into BC and Alberta. But how do I bring that attribute into my temporary variable if I just want BC (without creating an alternatie rollup)? BC_uf_wages="bp1-2002"->cod->"WAGES/SALARIES*"->"urban fare";Thanks in advanceRFung

    I’m sure there’s an easy solution to this and that I must be looking at it the wrong way.In my calc script, I’ve created a temporary variable called BC_uf_wages containing the following members. My actual outline for the “urban fare” has many members. I’ve also setup a province attribute splitting the urban fare locations into BC and Alberta. But how do I bring that attribute into my temporary variable if I just want BC (without creating an alternatie rollup)? BC_uf_wages="bp1-2002"->cod->"WAGES/SALARIES*"->"urban fare";Thanks in advanceRFung

  • Unable to create the temporary folder. Error 183 when starting Distiller

    New information discovered - see end of message!
    Full error message is (window title is Acrobat Distiller):
    "Unable to create the temporary folder
    Error: 183 - cannot create a file when that file already exists."
    I have no idea what file or what folder it is referring to. This is on an x86 Vista notebook and the message comes up when starting the notebook and also if you manually start Distiller 8. Updating did not help, nor did turning off the UAC, or running Distiller as Administrator. In the latter case, Distiller will open correctly, but the next time you need to use it, it fails. With the UAC turned off, the behavior is for it to show the Distiller window for a fraction of a second and close immediately. I also gave the user full rights to the C:\Program Files\Adobe folder and lower. Made no difference.
    Coincidental with this is that the PDFMOfficeAddIn.dll add-in will not enable in Word - when it is checked, and I hit OK, I get the message:
    "The connected state of Office Add-Ins registered in HKEY_LOCAL_MACHINE cannot be changed."
    All of this is going on when logged in as an administrator. I have seen folks post about this issue, but no answers that actually fiux the problem, just suggest what I have already tried. Anyone seen this one?
    The user is highly mobile, so I am not going to have a chance to work on her computer again until next week.
    NEW INFO
    I tried removing and reinstalling as administrator and the problem remains. However while trying to troubleshoot, I discovered some more details.
    The message is being thrown when acrotray.exe is started as a process in HKLM\Software\Microsoft\Windows\Current Control Set\Run and then tries to run acrodist.exe (which fails, BTW). If I don't let it run there and run acrotray,exe as administrator, then acrodist.exe runs as a process without an error. Additionally, stopping it from running in the registry, and then starting MS Word, the Acrobat add-in does load and even though there is an error thown, it still creates the PDF! I have other Vista 32 notebooks running various Acrobat versions with no problems.
    Another key thing I found out is that Acrobat started throwing the error after an HP Scanjet 8400 and its software were installed. I tried explicitly giving the user (already an administrator) full rights to the Acrobat, HP and Read IRIS directories. Did not help the problem. I have to think that there is some interaction there, but sure don't know what it is.

    what i did to eliminate that error message, i don't think it eliminated th
    e problem but now i can reboot and log in OK, was 2 things:
    i went into my system registry and unchecked to start at startup and then disavled it.
    i also had to go to each adobe icon, right click, go to properites, and than make all selections set to be administator.

  • Peculiar problem with Essbase (Calc Script) - substitution variable / UDAs

    This is odd but I have a script like :
    VAR iloop=1,break=0;
    FIX(<required POV>)
    Loop (20,break)
    VAR Country_total1,Country_total2,Country_total3;
    FIX (@UDA(Entity,@ALIAS(@CONCATENATE("&Country",iloop)))) // &Country1, &Country2 - are substitution variables with UDAs stored as strings
    Statements;
    /* +<statements for calculating total values.. for that country and stored against variables>+ */
    Country_total1=Country_total1+ +<Calculation>+
    ENDFIX
    /* Second part : Now again the calculations stored in the variables are to be stored against specific entities */
    FIX (@UDA(Entity,@ALIAS(@CONCATENATE("&Country",iloop))))
    FIX(@ISUDA(Entity,<Check1>)
    ..... Assign to relevant account
    ENDFIX
    ENDFIX
    ENDLOOP
    ENDFIX
    Now the problem is that the first fix statement works just fine, but the FIX statement in the 'second part' throws an error
    Error: 1200354 Error parsing formula for [FIX STATEMENT] (line 66): expected type [STRING] found [EXTVAR] ([iloop]) in function [@CONCATENATE]
    If I hard code the 'second part' FIX statement to the substitution variable directly - it works just fine.
    How can the first statement work and not the second one ? They are exactly the same.

    Glenn, thanks - I hadn't thought of that :).
    But it still does not entirely solve my problem (please see my previous post depicting a requirement similar to ours )
    - We have lots of countries (50-60+ might be much more) and each country can have multiple entities (3-4 on an average - can go unto 7-8)
    - so good guess would be around 200 entities
    - So say I have to do it for 2 countries only (two entity types). Then I need 4 variables - 2 for each country ('country 1 ET1 total', 'Country 1 ET2 Total')
    When the list is 20 counties - variables become 40 :(.
    - Still leaving aside the 40 variables for a bit -
    There are subsequent steps of calculations which needs to be done based on these totals (which are exactly the same for all countries) - just that we need the correct totals to begin with and the rest is already stored in the DB
    So since I have a different variable for each country - I cannot write one single calculation block to use the variables sequentially one by one (can I ?)
    I might have to write a separate calculation block for each of these countries. (20 separate blocks)
    That's what I was trying to avoid and simplify with the substitution variable (but is not working)
    - Create substitution variables - which would store the alias of the required countries (2/10/20 as many required)
    - Loop through these substitution variables - using them one by one
    - So I just need one single block of calculation with all the variable in the calc script being reused after each country calculation is done
    - and the user need not go into the script, as the only thing that will change are the countries. And he can change it easily through the substitution variable.
    Edited by: Ankur on Jun 27, 2012 12:53 PM

  • A method for passing in the system date to either a substitution variable or directly into a calc script for use on the fix statement

    Does anyone have an idea of how to pass in the server system date into a calc script or into a substitution variable so that I can fully automate my calc script to only calculate the current day? Thanks very much for any assistance on this.

    unsure why cannot att bat<BR>below is raw code meant to insert into .bat file<BR>================================================<BR><BR>code starts below this line<BR>================================================<BR>:: <BR>:: pls ensure essbase server up and running <BR>:: batch file to upd subs var <BR>:: insert correct values below<BR>:: <BR>:: substitution variables set up in cube: curryr, lastyr <BR>:: substitution variables set up in cube: currmth, prevmth ... <BR>::<BR><BR>:: setting of local env vars<BR>setlocal<BR>::<BR><BR>:: setting of job control vars<BR>set svr=<< insert value here >><BR>set uid=<< insert value here >><BR>set pwd=<< insert value here >><BR>::<BR><BR>:: setting of date and time vars<BR>for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (<BR>set dayofweek=%%i<BR>set day=%%k<BR>set month=%%j<BR>set year=%%l<BR>set datestamp=%%l_%%j_%%k<BR>)<BR>for /F "tokens=1-2 delims=: " %%i in ('time /t') do (<BR>set hour=%%i<BR>set minute=%%j<BR>set timestamp=%%i_%%j<BR>)<BR>::<BR><BR>:: setting year vars<BR>set /a curryr=%year%<BR>set /a lastyr=(%year% - 1)<BR>::<BR><BR>:: setting paths and files<BR>set destpath=<< insert path here >><BR>set errpath=<< insert path here >><BR>set errfiles=%errpath%\*.err<BR>set errfiledir=%errpath%\%datestamp%_%timestamp%_err.dir<BR>set errfile=%destpath%\%datestamp%_%timestamp%_err.err<BR>set logfile=%destpath%\%datestamp%_%timeStamp%_log.log<BR>set upd_var_file=%destpath%\upd_var.txt<BR>::<BR><BR>:: initial housekeeping<BR>if exist %errfile% del %errfile%<BR>if exist %logfile% del %logfile%<BR>if exist %upd_var_file% del %upd_var_file%<BR>if exist %errfiledir% del %errfiledir%<BR>::<BR><BR>:: start all<BR>echo. >> %logfile%<BR>echo rem &0 >> %logfile%<BR>echo. >> %logfile%<BR>echo rem --- start all --- >> %logfile%<BR>date/t >> %logfile%<BR>time/t >> %logfile%<BR><BR>:: dates<BR>echo rem --- dates --- >> %logfile%<BR>echo Curr Year = %curryr% >> %logfile%<BR>echo Last Year = %lastyr% >> %logfile%<BR><BR>:: gen temp txt to upd subs vars<BR>echo rem --- upd subs vars start --- >> %logfile%<BR>echo. >> %upd_var_file%<BR>echo. >> %upd_var_file%<BR>echo login "%svr%" "%uid%" "%pwd%"; >> %upd_var_file%<BR>if %month% == 01 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Dec"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Nov"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q4"; >> %upd_var_file%<BR>)<BR>if %month% == 02 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Jan"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q1"; >> %upd_var_file%<BR> echo updatevariable "CurrYr" "%svr%" "" "" "FY%curryr%"; >> %upd_var_file%<BR> echo updatevariable "NextYr" "%svr%" "" "" "FY%nextyr%"; >> %upd_var_file%<BR> echo updatevariable "NextY2" "%svr%" "" "" "FY%nexty2%"; >> %upd_var_file%<BR> echo updatevariable "LastYr" "%svr%" "" "" "FY%lastyr%"; >> %upd_var_file%<BR> echo updatevariable "LastY2" "%svr%" "" "" "FY%lasty2%"; >> %upd_var_file%<BR> echo updatevariable "LastY3" "%svr%" "" "" "FY%lasty3%"; >> %upd_var_file%<BR> echo updatevariable "PrevYr" "%svr%" "" "" "FY%lastyr%"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Dec"; >> %upd_var_file%<BR>)<BR>if %month% == 03 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Feb"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Jan"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q1"; >> %upd_var_file%<BR> echo updatevariable "PrevYr" "%svr%" "" "" "FY%curryr%"; >> %upd_var_file%<BR>)<BR>if %month% == 04 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Mar"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Feb"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q1"; >> %upd_var_file%<BR>)<BR>if %month% == 05 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Apr"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Mar"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q2"; >> %upd_var_file%<BR>)<BR>if %month% == 06 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "May"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Apr"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q2"; >> %upd_var_file%<BR>)<BR>if %month% == 07 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Jun"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "May"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q2"; >> %upd_var_file%<BR>)<BR>if %month% == 08 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Jul"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Jun"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q3"; >> %upd_var_file%<BR>)<BR>if %month% == 09 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Aug"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Jul"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q3"; >> %upd_var_file%<BR>)<BR>if %month% == 10 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Sep"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Aug"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q3"; >> %upd_var_file%<BR>)<BR>if %month% == 11 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Oct"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Sep"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q4"; >> %upd_var_file%<BR>)<BR>if %month% == 12 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Nov"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Oct"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q4"; >> %upd_var_file%<BR>)<BR>echo. >> %upd_var_file%<BR>echo exit; >> %upd_var_file%<BR><BR>:: run temp txt to upd subs vars <BR>esscmd %upd_var_file%<BR>echo rem --- update subs vars end --- >> %logfile%<BR> date/t >> %logfile%<BR> time/t >> %logfile%<BR><BR>:: end all<BR>echo rem --- end all --- >> %logfile%<BR> date/t >> %logfile%<BR> time/t >> %logfile%<BR><BR>: end_all<BR>endlocal<BR><BR>===============================<BR>

  • Query in SQL 2008R2 error Msg 1087, Level 15, State 2, Line 31 Must declare the table variable

    Hello Experts, 
    Can You help me; I get the follwing error in my query
    Msg 1087, Level 15, State 2, Line 31
    Must declare the table variable "@ASE_SUBART_GROEP".
    the @ASE_SUBART_GROEP is a self-defined table in this SQL environment.
    Maybe you know the error or the missing part
    Thanks in advance, Jos Dielemans

    I'm not familiar with SAP Business One unfortunately, so can only be of limited help here. But I'm going to guess that @ASE_SUBART_GROEP is a table variable passed to a stored procedure and is defined and passed down by the application, so you won't
    be able to copy-paste this code directly into management studio and get it to work.
    You could remove the join to return *all* records. Although the dataset might be very big
    SELECT T0.CardCode AS 'Klantnr'
    ,T0.CardName AS 'Klantnaam'
    ,T4.GroupName AS 'Klantgroep'
    ,T9.Descr AS 'Merknaam'
    ,T5.SlpName AS 'Verkoper'
    ,T3.MailCity AS 'Leverplaats'
    ,T7.NAME AS 'Leverland'
    ,T3.City AS 'Factuurplaats'
    ,T7.NAME AS 'Factuurland'
    ,T0.DocNum AS 'Documentnr'
    ,T0.DocDate AS 'Datum'
    ,Cast((Datepart(Year, T0.DocDate)) AS VARCHAR) AS 'Jaar'
    ,RIGHT('00' + CAST(DATEPART(MONTH, T0.DocDate) AS VARCHAR(2)), 2) AS 'Maand'
    ,(Cast((Datepart(Year, T0.DocDate)) AS VARCHAR) + '-' + RIGHT('00' + CAST(DATEPART(MONTH, T0.DocDate) AS VARCHAR(2)), 2)) AS 'Periode'
    ,T1.ItemCode AS 'Artikelnr'
    ,T2.ItemName AS 'Artikelnaam'
    ,T1.Quantity AS 'Aantal VEH'
    ,T2.SVolume AS 'Aantal EH per VEH'
    ,(T1.Quantity * T2.SVolume) AS 'Aantal EH'
    ,T8.UnitName AS 'EH-Naam'
    ,T6.ItmsGrpNam AS 'Artikelgroep'
    ,T2.U_ItemGrp AS 'Hoofdgroep'
    ,T10.NAME AS 'Subgroep'
    ,T1.CogsAcct AS 'Kostpr.rek.'
    ,T1.AcctCode AS 'Opbrengstrek.'
    ,T1.LineTotal AS 'BrutoOmzet'
    ,T0.DiscPrcnt AS 'Korting'
    ,(+ T1.LineTotal * (100 - T0.DiscPrcnt) / 100) AS 'NettoOmzet'
    FROM dbo.OINV T0
    INNER JOIN dbo.INV1 T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode
    INNER JOIN OCRD T3 ON T0.CardCode = T3.CardCode
    INNER JOIN OCRG T4 ON T3.GroupCode = T4.Groupcode
    INNER JOIN OSLP T5 ON T3.SlpCode = T5.SlpCode
    INNER JOIN OITB T6 ON T2.ItmsGrpCod = T6.ItmsGrpCod
    INNER JOIN OCRY T7 ON T3.Country = T7.Code
    LEFT OUTER JOIN OLGT T8 ON T2.SVolUnit = T8.UnitCode
    LEFT OUTER JOIN UFD1 T9 ON T3.U_ZPgroep = T9.FldValue
    AND TableID = 'OCRD'
    AND FieldID = 2
    --LEFT OUTER JOIN @ASE_SUBART_GROEP T10 ON T2.U_ASE_SUB_ARTGROEP = T10.Code
    WHERE T0.DocDate >= '20120101'
    AND T0.Canceled = 'N'
    UNION ALL
    SELECT T0.CardCode AS 'Klantnr'
    ,T0.CardName AS 'Klantnaam'
    ,T4.GroupName AS 'Klantgroep'
    ,T9.Descr AS 'Merknaam'
    ,T5.SlpName AS 'Verkoper'
    ,T3.MailCity AS 'Leverplaats'
    ,T7.NAME AS 'Leverland'
    ,T3.City AS 'Factuurplaats'
    ,T7.NAME AS 'Factuurland'
    ,T0.DocNum AS 'Documentnr'
    ,T0.DocDate AS 'Datum'
    ,Cast((Datepart(Year, T0.DocDate)) AS VARCHAR) AS 'Jaar'
    ,RIGHT('00' + CAST(DATEPART(MONTH, T0.DocDate) AS VARCHAR(2)), 2) AS 'Maand'
    ,(Cast((Datepart(Year, T0.DocDate)) AS VARCHAR) + '-' + RIGHT('00' + CAST(DATEPART(MONTH, T0.DocDate) AS VARCHAR(2)), 2)) AS 'Periode'
    ,T1.ItemCode AS 'Artikelnr'
    ,T2.ItemName AS 'Artikelnaam'
    ,- T1.Quantity AS 'Aantal VEH'
    ,T2.SVolume AS 'Aantal EH per VEH'
    ,(- T1.Quantity * T2.SVolume) AS 'aantal EH'
    ,T8.UnitName AS 'EH-Naam'
    ,T6.ItmsGrpNam AS 'Artikelgroep'
    ,T2.U_ItemGrp AS 'Hoofdgroep'
    ,T10.NAME AS 'Subgroep'
    ,T1.CogsAcct AS 'Kostpr.rek.'
    ,T1.AcctCode AS 'Opbrengstrek.'
    ,- T1.LineTotal AS 'BrutoOmzet'
    ,T0.DiscPrcnt AS 'Korting'
    ,(+ T1.LineTotal * (100 - T0.DiscPrcnt) / 100) AS 'NettoOmzet'
    FROM dbo.ORIN T0
    INNER JOIN dbo.RIN1 T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode
    INNER JOIN OCRD T3 ON T0.CardCode = T3.CardCode
    INNER JOIN OCRG T4 ON T3.GroupCode = T4.Groupcode
    INNER JOIN OSLP T5 ON T3.SlpCode = T5.SlpCode
    INNER JOIN OITB T6 ON T2.ItmsGrpCod = T6.ItmsGrpCod
    INNER JOIN OCRY T7 ON T3.Country = T7.Code
    LEFT OUTER JOIN OLGT T8 ON T2.SVolUnit = T8.UnitCode
    LEFT OUTER JOIN UFD1 T9 ON T3.U_ZPgroep = T9.FldValue
    AND TableID = 'OCRD'
    AND FieldID = 2
    --LEFT OUTER JOIN @ASE_SUBART_GROEP T10 ON T2.U_ASE_SUB_ARTGROEP = T10.Code
    WHERE T0.DocDate >= '20120101'
    AND T0.Canceled = 'N'
    ORDER BY T0.CardCode
    The join to the table variable has been commented out above, so the code should run. After that you might want to update the WHERE clause to include only particular sub-groups

  • Getting "Must declare the scalar variable" Error

    Hello All,
    I have write following query to block invoice which has Prices not equal to PriceList as below.
    -- To Block Invoices which has Prices not equal to PriceList
    IF (@transaction_type='A' OR @transaction_type = 'U') AND CAST(@OBJECT_TYPE = '18')
    BEGIN
        SELECT T1.ItemCode,
                T1.Price AS PO_Price,
                T2.U_ListPrice AS Listed_Price
            FROM OPCH AS T0 
            INNER JOIN
            PCH1 AS T1 ON
            T0.DocEntry = T1.DocEntry
            LEFT OUTER JOIN    
            [dbo].[@PRICELISTS] AS T2 ON
            T1.ItemCode = T2.U_ItemNo
        WHERE
                    T1.DocEntry = @list_of_cols_val_tab_del) AND
            (T1.Price <> T2.U_ListPrice)   
    BEGIN
    SET @error = 123
    SET @error_message = 'Deviation in price'
    END
    END
    But after Execution got following Errors
    Msg 137, Level 15, State 2, Line 2
    Must declare the scalar variable "@transaction_type".
    Msg 137, Level 15, State 2, Line 19
    Must declare the scalar variable "@list_of_cols_val_tab_del".
    Msg 137, Level 15, State 1, Line 22
    Must declare the scalar variable "@error".
    Msg 137, Level 15, State 1, Line 23
    Must declare the scalar variable "@error_message".
    Please Help
    Regards
    Hitul

    Hi Hitul,
    Please check Snapshot.
    Please see Red Lines for SBO_SP_TransactionNotification Procedure.
    Paste your code below ADD YOUR CODE HERE.
    Hope this help
    Regards::::
    Atul Chakraborty

  • Must declare the Scalar variable *@prompt*.. (IES 10901)".

    Hi,
    I am getting an error: "Database error Must declare the Scalar variable *@prompt*.. (IES 10901)".
    backend: SQLServer
    The dim, Lovs are valid in IDT universe.
    There is a Fiscal Year Month Dim in Universe=SELECT
      cast(convert(varchar(6),DATEADD (YEAR,"COST_SUMMARY_FACT_VR"."FISC_YEAR"-1900,DATEADD(MONTH,"COST_SUMMARY_FACT_VR"."FISC_PERIOD"-1,DATEADD(DAY,0,0 ))),112) as int)
    FROM "COST_SUMMARY_FACT_VR"
    Lov
    There are two LOVs FP_From, FP_To
    1) FP_From= select distinct cast(convert(varchar(6),DATEADD (YEAR,"COST_SUMMARY_FACT_VR"."FISC_YEAR"-1900,DATEADD(MONTH,"COST_SUMMARY_FACT_VR"."FISC_PERIOD"-1,DATEADD(DAY,0,0 ))),112) as int) from COST_SUMMARY_FACT_VR order by 1
    2) FP_To=select distinct cast(convert(varchar(6),DATEADD (YEAR,"COST_SUMMARY_FACT_VR"."FISC_YEAR"-1900,DATEADD(MONTH,"COST_SUMMARY_FACT_VR"."FISC_PERIOD"-1,DATEADD(DAY,0,0 ))),112) as int) from COST_SUMMARY_FACT_VR order by 1
    Prompts
    There are two universe prompts
    1) FP_From is Numeric and LOV FP_From is attached
    2) FP_To is Numeric and LOV FP_To is attached
    Using the universe prompts in webi as
    Fiscal Year Month between FP_From and FP_To
    Qry is executing perfectly in backend.

    In addition to Visakh's solution: the reason you got the error message is because the piece of dynamic SQL is not part of the stored procedure, but constiutes a scope of its own. Thus variables declared in the surrounding procedure are not visible.
    Also, you should the dynamic SQL this way:
    SET @sql = N'
    SELECT @Result=COUNT( Id ) FROM  ' + quotename(@TableName) +
    ' WHERE RunRegisterKey=@ID'
    SET @Params = N'@Result int OUTPUT, @ID int'
    EXEC sys.sp_executesql @sql,@Params,@Result = @Result OUT, @ID = @ID
    That is, use quotename for the table name, in case you have a table named
    sys.objects; SHUTDOWN WITH NOWAIT; --
    Furthermore, pass @ID as a parameter rather than concatenating it to the string. It is both easier and safer.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Must declare the scalar variable

    I Am getting error as Must declare the scalar variable "@Imageid" for the following code,while executing,
    exec spGetPager  ' ' , ' ', ' 3 ', ' '
    In my coding I pass querystring value like 1,2,3 etc
    CREATE PROCEDURE spGetPager
          @PageNo int = 1,  
          @ItemsPerPage int = 1,  
     @Imageid int,
          @TotalRows int out  
    AS  
    BEGIN  
      SET NOCOUNT ON  
      DECLARE  
        @StartIdx int,  
        @SQL nvarchar(max),   
        @SQL_Conditions nvarchar(max),   
        @EndIdx int
          IF @PageNo < 1 SET @PageNo = 1  
          IF @ItemsPerPage < 1 SET @ItemsPerPage = 10  
          SET @StartIdx = (@PageNo -1) * @ItemsPerPage + 1  
          SET @EndIdx = (@StartIdx + @ItemsPerPage) - 1  
          SET @SQL = 'SELECT Imageid,Imagepath,imagename,username  
                    FROM (  
                    SELECT  ROW_NUMBER() OVER(ORDER BY Imageid) AS Row, *  
                          FROM  Imageupload ) AS tbl WHERE Imageid=@Imageid AND Row >= '  
                                        + CONVERT(varchar(9), @StartIdx) + ' AND  
                           Row <=  ' + CONVERT(varchar(9), @EndIdx)  
          EXEC sp_executesql @SQL  
          SET @SQL = 'SELECT @TotalRows=COUNT(*) FROM Imageupload'  
          EXEC sp_executesql  
            @query = @SQL,  
            @params = N'@TotalRows INT OUTPUT',  
            @TotalRows = @TotalRows OUTPUT  
    END
    Thanks in Advance

    you cant use variable directly in concatenation operator as its of type int. you need to cast it first as below
    CREATE PROCEDURE spGetPager
    @PageNo int = 1,
    @ItemsPerPage int = 1,
    @Imageid int,
    @TotalRows int out
    AS
    BEGIN
    SET NOCOUNT ON
    DECLARE
    @StartIdx int,
    @SQL nvarchar(max),
    @SQL_Conditions nvarchar(max),
    @EndIdx int
    IF @PageNo < 1 SET @PageNo = 1
    IF @ItemsPerPage < 1 SET @ItemsPerPage = 10
    SET @StartIdx = (@PageNo -1) * @ItemsPerPage + 1
    SET @EndIdx = (@StartIdx + @ItemsPerPage) - 1
    SET @SQL = 'SELECT Imageid,Imagepath,imagename,username
    FROM (
    SELECT ROW_NUMBER() OVER(ORDER BY Imageid) AS Row, *
    FROM Imageupload ) AS tbl WHERE Imageid=' + CAST(@Imageid AS varchar(50)) + ' AND Row >= '
    + CONVERT(varchar(9), @StartIdx) + ' AND
    Row <= ' + CONVERT(varchar(9), @EndIdx)
    EXEC sp_executesql @SQL
    SET @SQL = 'SELECT @TotalRows=COUNT(*) FROM Imageupload'
    EXEC sp_executesql
    @query = @SQL,
    @params = N'@TotalRows INT OUTPUT',
    @TotalRows = @TotalRows OUTPUT
    END
    That being I didnt understand why you need dynamic sql here. There's no dynamicity involved as i see
     you could simply use a sql like below
    CREATE PROCEDURE spGetPager
    @PageNo int = 1,
    @ItemsPerPage int = 1,
    @Imageid int,
    @TotalRows int out
    AS
    BEGIN
    SET NOCOUNT ON
    DECLARE
    @StartIdx int,
    @EndIdx int
    IF @PageNo < 1 SET @PageNo = 1
    IF @ItemsPerPage < 1 SET @ItemsPerPage = 10
    SET @StartIdx = (@PageNo -1) * @ItemsPerPage + 1
    SET @EndIdx = (@StartIdx + @ItemsPerPage) - 1
    SELECT Imageid,Imagepath,imagename,username
    FROM (
    SELECT ROW_NUMBER() OVER(ORDER BY Imageid) AS Row, *
    FROM Imageupload ) AS tbl WHERE Imageid=@Imageid
    AND Row >= @StartIdx
    AND Row <= @EndIdx
    SELECT @TotalRows=COUNT(*) FROM Imageupload
    END
    to achieve same requirement.
    Make sure you read
    http://www.sommarskog.se/dynamic_sql.html
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Must declare the scalar variable error

    I am getting the error "Must declare the scalar variable "@Result""  when i execute the below query
    declare @sql nvarchar(max),
    @tablename varchar(200),
    @Id int,
    @Result int
    set @tablename='xyz'
    set @id=1
    SET @sql = '
    SELECT @Result=COUNT( Id ) FROM  ' + @TableName+ ' WHERE RunRegisterKey=' +convert(nvarchar(100),@ID)  
    EXEC sys.sp_executesql @sql

    In addition to Visakh's solution: the reason you got the error message is because the piece of dynamic SQL is not part of the stored procedure, but constiutes a scope of its own. Thus variables declared in the surrounding procedure are not visible.
    Also, you should the dynamic SQL this way:
    SET @sql = N'
    SELECT @Result=COUNT( Id ) FROM  ' + quotename(@TableName) +
    ' WHERE RunRegisterKey=@ID'
    SET @Params = N'@Result int OUTPUT, @ID int'
    EXEC sys.sp_executesql @sql,@Params,@Result = @Result OUT, @ID = @ID
    That is, use quotename for the table name, in case you have a table named
    sys.objects; SHUTDOWN WITH NOWAIT; --
    Furthermore, pass @ID as a parameter rather than concatenating it to the string. It is both easier and safer.
    Erland Sommarskog, SQL Server MVP, [email protected]

Maybe you are looking for