cancel
Showing results for 
Search instead for 
Did you mean: 

REC using property in a ternary expression

0 Kudos

Dear Experts,

I get a syntax problem and I don't know how to write the correct syntax for one expression on our BPC 10.1 (SP10).

The purpose is that we get values on a FLOW (Correction) and we want to add the value of this one to another flow using a property in our ACCOUNT dimension (Pos_Flow if the value is positive and Neg_Flow if the value is negative).

I try writing the formula with some syntax like :

*REC(EXPRESSION = %VALUE% > 0 ? %VALUE% + [FLOW].([ACCOUNT].properties.POS_FLOW) : 0 , FLOW=ACCOUNT.POS_FLOW) 
*REC(EXPRESSION = %VALUE% > 0 ? %VALUE% + [FLOW].[ACCOUNT].[POS_FLOW] : 0 , FLOW=ACCOUNT.POS_FLOW)

And I try using a SELECT statement with the same issue (RUN_LOGIC: syntax error: " missing name after . operator")

When I only try to write data on the property it works properly like you see below :

*REC(EXPRESSION = %VALUE% , FLOW=ACCOUNT.POS_FLOW)

but I can't find the good syntax to perform the ternary expression.

Could you help me ?

Many thanks for your help.

Stéphane

Accepted Solutions (1)

Accepted Solutions (1)

former_member186338
Active Contributor
0 Kudos

Sorry, but not clear what you are doing!

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

In this particular case data sample is required to make question clear.

My guess: in REC you want to read value from the FLOW member defined in the property of current ACCOUNT member

Solution: define LOOKUP by property - read help: https://help.sap.com/viewer/a2049170bfeb4178ace32222842c3ec1/10.1/en-US/f02a3d4897254042be24ebea3ba5...

Last example:

*DIM RATE:INPUTCURRENCY=ENTITY.CURRENCY

In your case:

*DIM PFLOW:FLOW=ACCOUNT.POS_FLOW

And then use this LOOKUP in you REC ternary operator.

0 Kudos

Hi Vadim,

Many thanks for your answer, I try to explain with an example below, I hope it is more clear to understand the situation :

In summary we get values on an initial flow but we can get positive or negative value that we want to move tyo different flows using the POS_FLOW or NEG_FLOW property of the account.

I am going to see the Lookup to try if it is possible in this case, I think that is the good way to answer this case.

former_member186338
Active Contributor
0 Kudos

Sorry, but the image is not attached! Please correct!

former_member186338
Active Contributor
0 Kudos

P.S. Please read my old blog: https://blogs.sap.com/2014/06/09/how-to-write-defaultlgf/

starting from: "Using LOOKUP to the same model to get expression argument member"


0 Kudos

Sorry for the image, normaly it is now better. I am going to see your link, many thanks

former_member186338
Active Contributor

OK, now it's clear! Then I do not understand why do you need LOOKUP. Please read my new answer.

Answers (1)

Answers (1)

former_member186338
Active Contributor
0 Kudos

Script based on your requirements ("we want to move tyo different flows"):

*XDIM_MEMBERSET FLOW=Initial //Scope Initial
*WHEN FLOW
*IS *
*REC(EXPRESSION=%VALUE%>0 ? %VALUE% : 0,FLOW=ACCOUNT.POS_FLOW) //move if positive
*REC(EXPRESSION=%VALUE%<0 ? %VALUE% : 0,FLOW=ACCOUNT.NEG_FLOW) //move if negative
*REC(EXPRESSION=0) //Clear Initial value
*ENDWHEN

May be instead of "move" you are talking about "add"? But "add" is dangerous in general - repeating will duplicate value.

0 Kudos

You are right, I want to add value but as expected it is really dangerous in our case so I try with a lookup like the code below and it works fine, many thanks for your help !!!

*LOOKUP PNL
*DIM PFLOW:FLOW=ACCOUNT.POS_FLOW
*DIM NFLOW:FLOW=ACCOUNT.NEG_FLOW
*ENDLOOKUP

*XDIM_MEMBERSET TIME = %TIME_SET%
*XDIM_MEMBERSET ENTITY = %ENTITY_SET%
*XDIM_MEMBERSET ACCOUNT = BAS(PL)
*XDIM_MEMBERSET AUDIT_TRAIL = INIT
*XDIM_MEMBERSET FLOW = CORR

*REC(EXPRESSION = %VALUE% > 0 ? %VALUE% + LOOKUP(PFLOW) : LOOKUP(PFLOW) , FLOW=ACCOUNT.POS_FLOW)
*REC(EXPRESSION = %VALUE% < 0 ? %VALUE% + LOOKUP(NFLOW) : LOOKUP(NFLOW) , FLOW=ACCOUNT.NEG_FLOW)
former_member186338
Active Contributor
0 Kudos

P.S. How do you want to run this script? As default.lgf or as DM package?

0 Kudos

It is loaded as a DM package, I just forgot on my script to clear the initial value of the flow.

former_member186338
Active Contributor

Yes, clearing initial will prevent data duplication if the script will run second time:

After clearing with *REC(EXPRESSION=0) the initial value will be zero:

%VALUE%=0

*REC(EXPRESSION = %VALUE% > 0 ? %VALUE% + LOOKUP(PFLOW) : LOOKUP(PFLOW) , FLOW=ACCOUNT.POS_FLOW)
*REC(EXPRESSION = %VALUE% < 0 ? %VALUE% + LOOKUP(NFLOW) : LOOKUP(NFLOW) , FLOW=ACCOUNT.NEG_FLOW)

Both lines will write the target value to target:

LOOKUP(PFLOW) to FLOW=ACCOUNT.POS_FLOW
LOOKUP(NFLOW) to FLOW=ACCOUNT.NEG_FLOW