cancel
Showing results for 
Search instead for 
Did you mean: 

script logic lookup and rec expression

michele_medaglia5
Active Participant
0 Kudos

Hi BPC Friend

I am in trouble to understand the meaning of the three rows in bold

*SELECT(%MYTIME%,ID,TIME,BUD_FCST_DRS=IN_BPF)

*LOOKUP Reporting

*DIM FLAG1000:ACCOUNT="FL1000"

*DIM FLAG1000:FLOW="F_CLO"

*DIM PGIND1000:ACCOUNT="ROY_005"

*DIM PGIND1000:FLOW="PUB_GROUP"

*DIM PGDEP1000:ACCOUNT="ROY_005"

*DIM PGDEP1000:PRODUCTGRP="ALL_PRODGRPS"

*DIM PGDEP1000:FLOW="PUB_GROUP"

*DIM FLAG1005:ACCOUNT="FL1005"

*DIM FLAG1005:FLOW="F_CLO"

*DIM PGIND1005:ACCOUNT="ROY_001"

*DIM PGIND1005:FLOW="PUB_GROUP"

*DIM PGDEP1005:ACCOUNT="ROY_001"

*DIM PGDEP1005:PRODUCTGRP="ALL_PRODGRPS"

*DIM PGDEP1005:FLOW="PUB_GROUP"

*ENDLOOKUP

*XDIM_MEMBERSET CATEGORY=NYBUDGET

*XDIM_MEMBERSET CHANNEL=NO_CHANNEL

*XDIM_MEMBERSET COSTCATEGORY=NO_COSTCAT

*XDIM_MEMBERSET DATASRC=IN_BPF

*XDIM_MEMBERSET ENTITY=%ENTITY_SET%

*XDIM_MEMBERSET FLOW=BAS(PUB_GROUP),PUB_GROUP,F_CLO

*XDIM_MEMBERSET GROUPS=G_NONE

*XDIM_MEMBERSET INTCO=I_NONE

*XDIM_MEMBERSET PRODUCTGRP=BAS(ALL_PRODGRPS)

*XDIM_MEMBERSET RPTCURRENCY=LC

*XDIM_MEMBERSET TIME=%MYTIME%

*WHEN_REF_DATA=MASTER_DATA

*WHEN ACCOUNT

*IS FL1000

*WHEN FLOW

*IS F_CLO

*WHEN PRODUCTGRP

*IS<>PG_8001

*REC(EXPRESSION=(LOOKUP(FLAG1000)==1&&LOOKUP(PGIND1000)==0)?1:2,ACCOUNT=CL1000)

*REC(EXPRESSION=(LOOKUP(FLAG1000)==2&&LOOKUP(PGIND1000)!=0)?1:2,ACCOUNT=CL1000)

*REC(EXPRESSION=-2,ACCOUNT=CL1000)

*ELSE

*REC(EXPRESSION=(LOOKUP(FLAG1000)==1&&LOOKUP(PGDEP1000)==0)?1:2,ACCOUNT=CL1000)

*ENDWHEN

*ENDWHEN

*ENDWHEN

*COMMIT

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member186338
Active Contributor
0 Kudos

WHEN/ENDWHEN always aggregate values written to the same destination.

And commit has absolutely no relation to when/endwhen loop (used only with MDX calculations, not with when/endwhen).

You have to spend some time working with some test code in UJKT to understand basic things...

michele_medaglia5
Active Participant
0 Kudos

thanks a lot Vadim

former_member186338
Active Contributor
0 Kudos

I am not a cryptanalyst to explain what was the idea of the code author 🙂 I don't even know if it's a working code or not!

You have to explain the logic to be achieved and I will help with the code.

Just about syntax:

*DIM FLAG1000:ACCOUNT="FL1000"
*DIM FLAG1000:FLOW="F_CLO"

means that LOOKUP label FLAG1000 has the mentioned dimensions scoped.

*REC(EXPRESSION=(LOOKUP(FLAG1000)==1&&LOOKUP(PGIND1000)==0)?1:2,ACCOUNT=CL1000)

If (LOOKUP(FLAG1000)=1 AND LOOKUP(PGIND1000)=0) then result=1 else result=2

And result will be stored in ACCOUNT=CL1000

michele_medaglia5
Active Participant
0 Kudos

perfect Vadmin, I understood very well your answer.

I found this code, I haven't written it.

I didn't know that the variable Flag1000 could have more dimension-member.

What about the other dimensions? which member the lookup will check? for which other member the rec will write the value 1 or 2?

If (LOOKUP(FLAG1000)=1 AND LOOKUP(PGIND1000)=0) then result=1 else result=2

former_member186338
Active Contributor

"What about the other dimensions? which member the lookup will check?" - if member is not provided in the lookup label then it will be from the current record of when/endwhen loop.

Is it clear?

P.S. The code itself is not very professional -for example:

*XDIM_MEMBERSET FLOW=BAS(PUB_GROUP),PUB_GROUP,F_CLO

...

*WHEN FLOW

*IS F_CLO

What for to scope BAS(PUB_GROUP),PUB_GROUP??????

former_member186338
Active Contributor

P.S. Flag1000 is not a variable, it's a lookup label with some scope related to it.

michele_medaglia5
Active Participant
0 Kudos

thanks Vadim

you said:

"What about the other dimensions? which member the lookup will check?" - if member is not provided in the lookup label then it will be from the current record of when/endwhen loop. Is it clear?

so it means that (tell me if I am right), according the code below BPC will create a new record writing 1 or 2 for the account CL1000 F_CLO and the other member like the record that is being analysed by when

*WHEN ACCOUNT

*IS FL1000

*WHEN FLOW

*IS F_CLO

*WHEN PRODUCTGRP

*IS<>PG_8001

*REC(EXPRESSION=(LOOKUP(FLAG1000)==1&&LOOKUP(PGIND1000)==0)?1:2,ACCOUNT=CL1000)

former_member186338
Active Contributor

Yes, something like...

You have also special statement:

*WHEN_REF_DATA=MASTER_DATA

it will loop all scope master data independent on existing records...

michele_medaglia5
Active Participant
0 Kudos

thanks Vadim.

I have another two questions:

what does the following mean?

*WHEN_REF_DATA=MASTER_DATA

the second question, according the below code, my record could fall as true in the first expression writing 1 or 2 and surely will be true the last expression writing -2.

How does it work?

*WHEN ACCOUNT

*IS FL1000

*WHEN FLOW

*IS F_CLO

*WHEN PRODUCTGRP

*IS<>PG_8001

*REC(EXPRESSION=(LOOKUP(FLAG1000)==1&&LOOKUP(PGIND1000)==0)?1:2,ACCOUNT=CL1000)

*REC(EXPRESSION=(LOOKUP(FLAG1000)==2&&LOOKUP(PGIND1000)!=0)?1:2,ACCOUNT=CL1000)

*REC(EXPRESSION=-2,ACCOUNT=CL1000)

*ELSE

former_member186338
Active Contributor
0 Kudos

what does the following mean?

*WHEN_REF_DATA=MASTER_DATA

WHY NOT TO SEARCH YOURSELF?????????????????????????????????

former_member186338
Active Contributor

The result of 3 expressions will be written to the same intersection ACCOUNT=CL1000

There result will be aggregated = result1 + result2 +result3

michele_medaglia5
Active Participant
0 Kudos

thanks Vadim. why BPC aggregate? There isn't the commit in the middle so I thought that was the last value to be written