cancel
Showing results for 
Search instead for 
Did you mean: 

Script Logic, question Regargind Scope and *FOR statement

former_member182305
Active Participant
0 Kudos

Hello experts,

I am doing a calculation using script Logic.

What I need to do is to calculate Salary 1 based on Salary0 multipied by KPI, the things is that the KPI is captured by building (hotel) and so did the next script:

//SCOPE

*XDIM_MEMBERSET CATEGORIA = Real

*XDIM_MEMBERSET MONEDA = NA_MONEDA

*XDIM_MEMBERSET CUENTAS= 0000611010

*XDIM_MEMBERSET ZRELACIONCTACEBE= NA_ZREL

*XDIM_MEMBERSET ZSTAGL= NA_ES

*XDIM_MEMBERSET SOCIEDAD= %SOCIEDAD_SET%

*XDIM_MEMBERSET OP_SUPUESTOS= NA_SUP

*XDIM_MEMBERSET HOTEL= %HOTEL_SET%

//Select december and year where the KPIs are sotred

*SELECT(%YRS%,"[YEAR]",PERIODO,"[ID]='%PERIODO_SET%'")

*SELECT(%MNTH12%,"[ID]",PERIODO,"[YEAR]='%YRS%' AND [PERIOD]='DEC'")

*SELECT(%YR%,"[YEAR]",PERIODO,"[ID]='%MNTH12%'")

//SCOPE DEC where the KPIs are stored

*XDIM_MEMBERSET PERIODO= 12.%YR%

                *WHEN SUPNOM // CALCULATE  SD1 based on SDI0

                               *IS SDI0

                                               *WHEN MONEDA

                                                               *IS MXN

                                                                              *FOR %T%= 01.%YR%, 02.%YR% ,03.%YR%, 04.%YR%, 05.%YR%, 06.%YR%, 07.%YR%, 08.%YR%, 09.%YR%, 10.%YR%, 11.%YR%, 12.%YR%

                                                                              *FOR %H% = %HOTEL_SET%

                                                                                              *REC(EXPRESSION=%VALUE%*([PERIODO].[%YR%],[SOCIEDAD].[NA_CCC],[CATEGORIA].[Real],[CeBe].[NA_CeBe],[CECO].[NA_CECO],[CUENTAS].[NA_ACC],[MONEDA].[MXN],[OP_RRHH].[NA_RH],[SUPNOM].[NA_SUPRH],[ZSTAGL].[NA_ES],[ZRELACIONCTACEBE].[NA_ZREL],[OP_SUPUESTOS].[SSDI],[HOTEL].[%H%]), MONEDA="MXN",PERIODO=%T%)

                                                                              *NEXT

                                                                              *NEXT

                                               *ENDWHEN

                *ENDWHEN

The problem in the previous script is that it works when the %HOTEL_SET% is just one building, ie BUILDING1, but if the user selects BUILDING1 and BUILDING2 the script gets all messed up this is bc the *FOR is made twice 1 for BUILDING1 and 2 for BUILDING2 which are in the scope,

What can I do to validate that the script do the for just for the BUilding where the info should be stored and (the difference is by Salary and not by buildint).

Any Ideas

Thnaks for the post,

Best regards

Accepted Solutions (1)

Accepted Solutions (1)

former_member186338
Active Contributor
0 Kudos

Sorry, but calculation logic is not 100% clear! Please read

Anyway, why do you need second FOR/NEXT loop at all???

*REC(EXPRESSION=%VALUE%*([PERIODO].[%YR%],[SOCIEDAD].[NA_CCC],[CATEGORIA].[Real],[CeBe].[NA_CeBe],[CECO].[NA_CECO],[CUENTAS].[NA_ACC],[MONEDA].[MXN],[OP_RRHH].[NA_RH],[SUPNOM].[NA_SUPRH],[ZSTAGL].[NA_ES],[ZRELACIONCTACEBE].[NA_ZREL],[OP_SUPUESTOS].[SSDI]), MONEDA="MXN",PERIODO=%T%)

will use hotel from the current record!

former_member182305
Active Participant
0 Kudos

Thank you very much Vadim,

I Didn't know that if you don't include a Dimension in  Tupple expresion it is taken from the scope.

Thanks again.

Best regards.

Answers (0)