cancel
Showing results for 
Search instead for 
Did you mean: 

Script Logic multiplies oddly depending on number of members with Tx data

former_member645265
Discoverer
0 Kudos

Hi,

My script is doing something very odd. Given the value from my initial scope (EXPRESSION = %VALUE%), I want to be able to sum / substract / multiply or divide it by another account value that I specify on my *REC statement. My script works perfectly if I multiply or divide, but whenever I use additions or substractions, the account value (or even any hardcoded value) that I specify in my *REC statement is oddly multiplied by the number of members with transactional data that the parent node from my initial scope has.

For example, from the script I'm sharing, imagine this:

* BAS(Z00720) has 18 members from which 14 have transactional data

* The %VALUE% from BAS(Z00720) is =10

* The value from [CUENTA].[Z007629]... is = 2

Sooo...

If I multiply, it does 10 * 2 = 20

If I divide, it does 10 / 2 = 5

but...

If I sum, I would expect 10 + 2 = 12... but it does 10 + (2*14) = 38

If I substract, I would expect 10 - 2 = 8... but it does 10 - (2*14) = -18

The %VALUE% I get is always right, there is no problem there, the problem comes with whatever value I want to sum or substract to it.

The following script is simplified inside the *REC statement just to show my example. Due to the user requirement, the calculation involves substracting, multiplying, summarizing and dividing several accounts in very specific dimensions for every FOR loop with that time offset, which, like I said, works perfectly when I multiply or divide... but not when I sum or substract.

Any idea why is this happening and how to solve it?

*SELECT(%CAT%,"[BASECATEGORY]",VERSION,"[ID] = %VERSION_SET%")
*SELECT(%ACC%, "[PROJECTED]",CUENTA,"[ID] = Z00720") 

*XDIM_MEMBERSET E_GLOBAL = GLOBAL
*XDIM_MEMBERSET MONEDA = MXN
*XDIM_MEMBERSET FLUJO = F00
*XDIM_MEMBERSET FUENTE_P = 00_MCO
*XDIM_MEMBERSET CUENTA = BAS(Z00720) 
*XDIM_MEMBERSET VERSION = %CAT% 
*XDIM_MEMBERSET TIEMPO AS %TIME% = BAS(%TIEMPO_SET%)


*FOR %TIEMPO_SET% = %TIME% 
	*XDIM_ADDMEMBERSET TIEMPO = TMVL(-12,%TIEMPO_SET%)
	*WHEN TIEMPO
		*IS TMVL(-12,%TIEMPO_SET%)
		*BEGIN

                        *REC(EXPRESSION = %VALUE% *
			([CUENTA].[Z007629],[FLUJO].[F99],[FUENTE_P].[00_ECA],[VERSION].[%VERSION_SET%],[TIEMPO].[%TIEMPO_SET%]),  
			CUENTA = %ACC%, VERSION = %VERSION_SET%, TIEMPO = %TIEMPO_SET%, FLUJO = F99, FUENTE_P = 00_ECA)
		*END
	*ENDWHEN
*NEXT
former_member186338
Active Contributor
0 Kudos

Sorry, but the required logic is not clear! Just some incorrect script...

Please read: https://blogs.sap.com/2014/01/31/how-to-ask-questions-about-script-logic-issues/

And provide missing info, especially data sample!

Accepted Solutions (1)

Accepted Solutions (1)

former_member186338
Active Contributor
0 Kudos

Incorrect statement:

"BAS(Z00720) has three child members, two of them have transactional data (the first two on the image), so, %VALUE% = 200; and [CUENTA].[Z007629] = 50."

You have 2 records with %VALUE% = 100

Multiplication:

100*50=5000

100*50=5000

Total 10000

For addition:

100+50=150

100+50=150

Total 300

To add you have to use:

*XDIM_MEMBERSET E_GLOBAL =GLOBAL
*XDIM_MEMBERSET MONEDA = MXN
*XDIM_MEMBERSET FLUJO = F00
*XDIM_MEMBERSET FUENTE_P = 00_MCO
*XDIM_MEMBERSET CUENTA = BAS(Z00720),Z007629 //Scope all members to add
*XDIM_MEMBERSET VERSION = REAL 
*WHEN TIEMPO //TIME
*IS 2020.001
*REC(EXPRESSION = %VALUE%,CUENTA = 21011001,VERSION = 00_PPTO)	   
*ENDWHEN

If you have different combinations of members (for example FLUJO is different) then:

*XDIM_MEMBERSET E_GLOBAL =GLOBAL
*XDIM_MEMBERSET MONEDA = MXN
*XDIM_MEMBERSET FLUJO = F00,F99 //Scope both
*XDIM_MEMBERSET FUENTE_P = 00_MCO
*XDIM_MEMBERSET CUENTA = BAS(Z00720),Z007629 //Scope all members to add
*XDIM_MEMBERSET VERSION = REAL 
*WHEN TIEMPO //TIME
*IS 2020.001
*WHEN CUENTA
*IS BAS(Z00720)
*WHEN FLUJO
*IS F00
*REC(EXPRESSION = %VALUE%,CUENTA = 21011001,VERSION = 00_PPTO)	   
*ENDWHEN
*ENDWHEN
*WHEN CUENTA
*IS Z007629
*WHEN FLUJO
*IS F99
*REC(EXPRESSION = %VALUE%,CUENTA = 21011001,VERSION = 00_PPTO,FLUJO = F00)	   
*ENDWHEN
*ENDWHEN
*ENDWHEN

Answers (2)

Answers (2)

former_member645265
Discoverer
0 Kudos

Thank you Vadim, I wasn't aware the way %VALUE% was calculated, so it'll be a matter of rethinking my logic using the scopes and *WHEN statements.

former_member186338
Active Contributor
0 Kudos

%VALUE% is not calculated! It's a value coming from current record of WHEN/ENDWHEN loop. Each record is processed separately!

former_member645265
Discoverer
0 Kudos

Sorry, here I'm providing additional info after reading the suggested link, I hope this helps. I will also provide a shorter version of my script in order to go directly to the point (the script does the same anyway)

BPC version: NetWeaver 10.1, SP level 0016.

I get the same issue either I run this script with UJKT or with a package.

The account dimension y called "CUENTA".

The purpose is that I want to be able to make operations (+,-,*,/) between the %VALUE% gotten from my initial scope and a given account at the right side of the operation symbol.

I can do this without any problem if I use * or / (like in my script below), but when using + or - it behaves in a way that I can't understand:


*XDIM_MEMBERSET E_GLOBAL = GLOBAL
*XDIM_MEMBERSET MONEDA = MXN
*XDIM_MEMBERSET FLUJO = F00
*XDIM_MEMBERSET FUENTE_P = 00_MCO
*XDIM_MEMBERSET CUENTA = BAS(Z00720) 
*XDIM_MEMBERSET VERSION = REAL 

*WHEN TIEMPO //TIME
*IS 2020.001
*REC(EXPRESSION = %VALUE%*([CUENTA].[Z007629]),CUENTA = 21011001,VERSION = 00_PPTO)	   
*ENDWHEN

Here is how I have my data:

BAS(Z00720) has three child members, two of them have transactional data (the first two on the image), so, %VALUE% = 200; and [CUENTA].[Z007629] = 50.

Given the above script, this is translated to 200*50 = 10000, which is right. If I wanted to divide it, then it would be 200/50=4, which is also right.

But, here comes the issue: what if I want to sum (%VALUE%+[CUENTA].[Z007629]), I would expect 200+50=250, but I get 300:

From what I can see is that due to BAS(Z00720) having two child members with transactional data then it looks like the value 50 is being multiplied by 2 (interpreted as 200+[50*2] = 300). If I write transactional data on the third child member, then what happens is 200+[50*3] = 350.

This also happens when I want to substract (%VALUE%-[CUENTA].[Z007629]): I would expect 200-50=150, but instead I get 100 (following the same logic it's being interpreted as 200-[50*2] = 100.

I neet to be able to use *,/,+ and -, this is because I need to make a variety of operations, for example EXPRESSION = %VALUE% - (accountB - accountA)/accountC*(accountD + accountE) and so on, but whenever I use + or - I get these odd results.

Thanks for your time Vadim.