cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Ternary operator in script logic

Former Member
0 Likes
1,294

Hi,

I have a requirement to use the ternary operator A>B ? C : D in a *REC statement. The new part is, that I want D to not be written. In other words, if A>B I want BPC to write C but in all other cases I want BPC to not write anything. Is that possible?

Thanks,

Arnold

Accepted Solutions (1)

Accepted Solutions (1)

former_member186338
Active Contributor
0 Likes

Writing nothing is equivalent to writing destination over destination. This is the only way to write nothing.

johannes_knaub4
Explorer
0 Likes

HI Vadim,

I am working with Arnold on this script.

The reason for our request is as follows:

we are planning on one Member of Dimension call Project, let us call this member P_1000.

This Member can be planned per Plant, lets assume we plan on Plant PL_ABC.

As one moment of time, the project is approved and also existing in SAP ERP with a different - automatically by SAP - allocated number, let call it P_9000.

Our requirement is now to transfer all Data from P_1000 to P_9000.

Therefore we wrote a Logic which is doing it, by reading PROJECT.[Property.PL_ABC] (which is P_9000).

But once we did the transfer, it should not be done again as the pforecasting continues on P_9000.

Therefore we posting a flag per "dumm"-project/ plant combination, and reding it with a ternary operator.

The part we are failing on is the statement where the transfer from P_1000 to P_9000 is done.

*IS MY_NEXT

*REC(EXPRESSION = (LOOKUP(AD13)<1) ? -%VALUE%: LOOKUP(AD12),AUDITID = AD_12)

*REC(EXPRESSION = (LOOKUP(AD13)<1) ? %VALUE%:NULL,PROJECT = PROJECT.MY_NEXT,AUDITID = AD_11)

*REC(EXPRESSION = (LOOKUP(AD13D)<1) ? 1:(LOOKUP(AD13D))/(LOOKUP(AD13D)),AUDITID = AD_13,TIME = 0000.TOTAL,ACCOUNT=OECC10999,PRO_TYPE = PT_NON)

*ENDWHEN

*ENDWHEN

*NEXT

The aim is to remain the existing records as they are in the destination once they have been written.

Do you have any idea if there are other possibilites?

I though about a Lookup for the AD_11 posting, but did not find a solution for it yet.

Thanks

Johannes

former_member186338
Active Contributor
0 Likes

Hi, Johannes,

Please read:

And compare it with your message!

Also read again my previous post - do you understand it?

Former Member
0 Likes

Hi Vadim,

I will try that.

Thanks

former_member186338
Active Contributor
0 Likes

If the destination member is defined by property like:

PROJECT.MY_NEXT

then you will need to define LOOKUP...

P.S. Like:

*LOOKUP SAME_MODEL

*DIM TARGET1:AUDITID = "AD_11"

*DIM TARGET1:PROJECT = PROJECT.MY_NEXT

*ENDLOOKUP

...? ... : LOOKUP(TARGET1), PROJECT = PROJECT.MY_NEXT,AUDITID = AD_11)

johannes_knaub4
Explorer
0 Likes

HI Vadim,

thanks for your reply.

Although I found a solution, I would like to share that in a correct way.

We are on BPC 10.0 (SP 20) on BW 730 (SP 14).

We have following dimension in the model

ACCOUNT (A), AUDITID (D), CATEGORY (C), INITIATIVE (U-3), PLANT (E), PRODUCT (U-1), PROJECT (U-2), PRO_STATUS (S), PRO_TYPE (U-4), RPTCURRENCY (R), TIME (T)

What we try to achive is described in the previous post, we try to run it as a package.

No Selections are applied for the Datamanager Package, Selection is done by Masterdata and reading the flag.

The problem was that in case that the flag is set, the original value should be kept,

but there is no possibility to do nothing if the flag is set, thus the value have been overwritten by a "0".

Due to a complex setup (PLANT ID's are Properties in Project, some are filled, some are empty) it seems not to be possbile to have a correct lookup.

My solution was as follows:

*FOR MY_NEXT = %MY_PLANTS%

*WHEN PROJECT.MY_NEXT

*REC(EXPRESSION = (LOOKUP(AD13)<1) ? -%VALUE%: LOOKUP(AD12),AUDITID = AD_12)

*REC(EXPRESSION = (LOOKUP(AD13)<1) ? %VALUE%:0,PROJECT = PROJECT.MY_NEXT,AUDITID = AD_11)

*REC(EXPRESSION = (LOOKUP(AD13D)<1) ? 1:(LOOKUP(AD13D))/(LOOKUP(AD13D)),AUDITID = AD_13,TIME = 0000.TOTAL,ACCOUNT=OECC10999,PRO_TYPE = PT_NON)

*ENDWHEN

*ENDWHEN

*NEXT

*WHEN PROJECT

*IS <SELECT for my Destination Projects>

*REC(FACTOR=1)

*ENDWHEN

So as a result:

If the flag is empty, there is no data on the Project, so the second Rec-Statement is writing the Values (correctly) on the destination project. The last Rec Statement is adding "0" to the project.

The flag is set after first run, thus the second Rec Statement is setting the project to "0", but the last rec Statement is writing the current value to the project.

I tested it several times and think the logic is doing what it should.

Thanks!

Johannes

former_member186338
Active Contributor
0 Likes

Sorry, but I am unable to understand what flag you are talking about?

"The problem was that in case that the flag is set, the original value should be kept,

but there is no possibility to do nothing if the flag is set, thus the value have been overwritten by a "0"." - absolutely unclear!

And if you read

You will see that FULL script text is required in the discussion!

Also - incorrect statement:

*FOR MY_NEXT = %MY_PLANTS%???

Please spend some time to provide a clear picture!

Answers (1)

Answers (1)

Former Member
0 Likes

Hi Arnold,

Have you referred this Ternary Operator syntax error in BPC NW Script ... | SCN

We can write 0 instead of D!

Regards,

JP