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

Help with WHEN Loops in in Logic Script

Former Member
0 Likes
556

Hi Gurus,

I am attempting to write a Logic script for Eliminations with minimum WHEN loops as possible.

I have attempted the below, but the requirement has too many specific accounts, and the logic will continue to have multiple WHEN loops if i continue this way

1) Is there any way i can write the script with minimum loops?

Attached is the requirement in .txt format, pls copy and paste in excel, the columns will be clear.

script1-to-create-actual-category.txt

Please let me know if you need more info

*XDIM_MEMBERSET AUDITTRAIL = BAS(AT_TOTAL), ADJ_AutoELIM //Elim Interco Sales against Manuf Cost
*XDIM_MEMBERSET ACCOUNT = 40050, 40060, 51000
*XDIM_MEMBERSET FLOW = F_TOTAL
*XDIM_MEMBERSET TIME = %TIME_SET%
*XDIM_MEMBERSET ENTITY = DOMXELIM, INTLXELIM
*XDIM_MEMBERSET CATEGORY = ACTUAL
*XDIM_MEMBERSET CHANNEL = CH_TOTAL
*XDIM_MEMBERSET DEPT = D_TOTAL
*XDIM_MEMBERSET INTERCO = I_SME
*XDIM_MEMBERSET PRODUCTLINE = PR_TOTAL
*XDIM_MEMBERSET MEASURES = YTD
*XDIM_MEMBERSET RPTCURRENCY = USD
*WHEN ENTITY
*IS DOMXELIM
*WHEN ACCOUNT.ACCTYPE
*IS INC,LEQ
*REC(EXPRESSION = %VALUE%*-1, AUDITTRAIL = ADJ_AutoELIM, CHANNEL = CH_PHY, DEPT = D_NONE, FLOW = F_NONE, INTERCO = I_OOELMEU, PRODUCTLINE = PR_21, ENTITY = OOOELMA1, RPTCURRENCY = LC)
*ELSE
*REC(EXPRESSION = %VALUE%*, AUDITTRAIL = ADJ_AutoELIM, CHANNEL = CH_PHY, DEPT = D_NONE, FLOW = F_NONE, INTERCO = I_OOELMEU, PRODUCTLINE = PR_21, ENTITY = OOOELMA1, RPTCURRENCY = LC)
*ENDWHEN
*ENDWHEN
*COMMIT

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Likes

Hi Vadim,

As the requirement doc is very lengthy, i will try to explain my it as clearly as possible.

We are attempting to perform Eliminations and Adjustments from one entity to another.

Below is a sample of the requirement.

Set1: (ACTUAL Cat)

Set2: (ACTUAL Cat)

Set1 and Set 2 belong to an excel where there are about 18 such sets just for CATEGORY = ACTUAL, where we calculate the sum and differences in Local currency, in the manner above.

We also have another excel sheet where all these values once calculated as above, will be FX translated, stored in another Category (ACTUAL_BR) and will have Similar sets of calculations as above (about 18 more sets).

Now, we are not clear if Logic Script is the way to go for such calculations. I attempted writing a script for Set 1 (see below), but looking at the requirement, it could be extremely lengthy and complex.

I have 2 questions -

1) Is Logic script the correct way to go for such a scenario? If so, my script will be extremely lengthy and complex with multiple loops and scoping. Is there any way i could simplify this?

2) Can we attempt business rules? I don't know much on this, but when i tried creating a rule of type - "Eliminations and Adjustments", we did not have Entity and other dimensions we require.

Please let me know if you have any suggestions on this.

I will be happy to provide any more information you need on this.

Thank you

*XDIM_MEMBERSET AUDITTRAIL = BAS(AT_TOTAL) //Elim Interco Sales against Manuf Cost
*XDIM_MEMBERSET ACCOUNT = 40050, 40060, 51000
*XDIM_MEMBERSET FLOW = F_TOTAL
*XDIM_MEMBERSET TIME = %TIME_SET%
*XDIM_MEMBERSET ENTITY = DOMXELIM, INTLXELIM
*XDIM_MEMBERSET CATEGORY = ACTUAL
*XDIM_MEMBERSET CHANNEL = CH_TOTAL
*XDIM_MEMBERSET DEPT = D_TOTAL
*XDIM_MEMBERSET INTERCO = I_SME
*XDIM_MEMBERSET PRODUCTLINE = PR_TOTAL
*XDIM_MEMBERSET MEASURES = YTD
*XDIM_MEMBERSET RPTCURRENCY = USD
*WHEN ENTITY
*IS DOMXELIM
*WHEN ACCOUNT 
*IS 40050
*REC(EXPRESSION = %VALUE%*-1, AUDITTRAIL = ADJ_AutoELIM, CHANNEL = CH_PHY, DEPT = D_NONE, FLOW = F_NONE, INTERCO = I_OOELMEU, PRODUCTLINE = PR_21, ENTITY = OOOELMA1, RPTCURRENCY = LC)
*REC(EXPRESSION=%VALUE%, ACCOUNT = 51000, INTERCO = I_3RD,AUDITTRAIL = ADJ_AutoELIM,CHANNEL = CH_PHY,FLOW = F_NONE,DEPT = D_NONE,PRODUCTLINE = PR_21,ENTITY = OOOELMA1, RPTCURRENCY = LC)
*IS 40060
*REC(EXPRESSION = %VALUE%*-1, AUDITTRAIL = ADJ_AutoELIM, CHANNEL = CH_37, DEPT = D_NONE, FLOW = F_NONE, INTERCO = I_OOELMEU, PRODUCTLINE = PR_21, ENTITY = OOOELMA1, RPTCURRENCY = LC)
*REC(EXPRESSION=%VALUE%, ACCOUNT = 51000, INTERCO = I_3RD,AUDITTRAIL = ADJ_AutoELIM,CHANNEL = CH_PHY,FLOW = F_NONE,DEPT = D_NONE,PRODUCTLINE = PR_21,ENTITY = OOOELMA1, RPTCURRENCY = LC)
*ENDWHEN
*IS INTLXELIM
*WHEN ACCOUNT 
*IS 40050
*REC(EXPRESSION = %VALUE%*-1, AUDITTRAIL = ADJ_AutoELIM, CHANNEL = CH_PHY, DEPT = D_NONE, FLOW = F_NONE, INTERCO = I_OOELMEU, PRODUCTLINE = PR_21, ENTITY = OOELMFD1, RPTCURRENCY = LC)
*REC(EXPRESSION=%VALUE%, ACCOUNT = 51000, INTERCO = I_3RD,AUDITTRAIL = ADJ_AutoELIM,CHANNEL = CH_PHY,FLOW = F_NONE,DEPT = D_NONE,PRODUCTLINE = PR_21,ENTITY = OOELMFD1, RPTCURRENCY = LC)
*IS 40060
*REC(EXPRESSION = %VALUE%*-1, AUDITTRAIL = ADJ_AutoELIM, CHANNEL = CH_37, DEPT = D_NONE, FLOW = F_NONE, INTERCO = I_OOELMEU, PRODUCTLINE = PR_21, ENTITY = OOELMFD1, RPTCURRENCY = LC)
*REC(EXPRESSION=%VALUE%, ACCOUNT = 51000, INTERCO = I_3RD,AUDITTRAIL = ADJ_AutoELIM,CHANNEL = CH_PHY,FLOW = F_NONE,DEPT = D_NONE,PRODUCTLINE = PR_21,ENTITY = OOELMFD1, RPTCURRENCY = LC)
*ENDWHEN
*ENDWHEN
*COMMIT

former_member186338
Active Contributor
0 Likes

Unable to understand the required business logic!

"Can we attempt business rules? I don't know much on this, but when i tried creating a rule of type - "Eliminations and Adjustments", we did not have Entity and other dimensions we require."

You have to understand the whole process! And look on the standard setup of eliminations using rules. To my mind you are doing something strange with your scripts.

former_member186338
Active Contributor
0 Likes

If you want to sum data in general you have to specify same target for a number of REC statements.

For example:

WHEN ACCOUNT
*IS PL110
*REC(EXPRESSION=%VALUE%,ACCOUNT=PL310)
*IS PL120
*REC(EXPRESSION=%VALUE%,ACCOUNT=PL310)
*ENDWHEN

PL310=PL110+PL120

Former Member
0 Likes

Ok Vadim,

Thank you for your suggestion. I was thinking that the perfromance may get compramised.

Also, can you please help me with the addition of the result? I am struggling with it.

For Ex: I am able to post the data with reverse sign, but I am not sure how to sum the result (Line highlighted in screenshot.) can you please assist?

Above is the code i have written for the same.

former_member186338
Active Contributor
0 Likes

Sorry, but looks like you don't want to read my blog! If you want an answer you have to clearly post your question!

former_member186338
Active Contributor
0 Likes

There is nothing bad in multiple WHEN/ENDWHEN loops in general.

Instead of complex WHEN/ENDWHEN script you may try to use multiple account calculation rules but it depends on the purpose of your script (not described in the question).

Former Member
0 Likes

Thank you Vadim. I will get back to you on the requirement shortly and post it as clearly as possible.