cancel
Showing results for 
Search instead for 
Did you mean: 

SCRIPT LOGIC Error

Former Member
0 Kudos

Dear Experts,

I have a simple requirement as below :

//*XDIM_MEMBERSET P_ACCT = EXPORT_SALE,TOTAL_SALE,DOM_ROYAL,DOM_OTHER,DOM_IMPORT_SALE

//[P_ACCT].[#EXPORT_SALE] = ([P_ACCT].[TOTAL_SALE] - ([P_ACCT].[DOM_ROYAL] + [P_ACCT].[DOM_OTHER] + [P_ACCT].[DOM_IMPORT_SALE]+[P_ACCT].[INTERNAL_SALE]))

//*COMMIT

But there is an exception with a set of cost center , where EXPORT_SALE = ZERO (0)

In order to implement this, we have written below script:

*XDIM_MEMBERSET CATEGORY=PLAN

*XDIM_MEMBERSET FLOW=NA

*XDIM_MEMBERSET P_ASSET=NA

*XDIM_MEMBERSET P_DATASRC=MANUAL

*XDIM_MEMBERSET P_CC=BAS(ABCD)

*XDIM_MEMBERSET P_ACCT = EXPORT_SALE,TOTAL_SALE,DOM_ROYAL,DOM_OTHER,DOM_IMPORT_SALE,INTERNAL_SALE

*XDIM_MEMBERSET P_EMP_TYPE=NA

*XDIM_MEMBERSET P_MATERIAL=NA

*XDIM_MEMBERSET P_PROJECT=NA

*XDIM_MEMBERSET P_SERVICES=NA

*WHEN P_CC

*IS BAS(BC)

*WHEN P_ACCT

*IS TOTAL_SALE,DOM_ROYAL,DOM_OTHER,DOM_IMPORT_SALE,INTERNAL_SALE

*REC(FACTOR=0,P_ACCT=EXPORT_SALE)

*ENDWHEN

*ELSE

*WHEN P_ACCT

*IS TOTAL_SALE

*REC(EXPRESSION=%VALUE%-([P_ACCT].[DOM_ROYAL]+[P_ACCT].[DOM_OTHER]+[P_ACCT].[DOM_IMPORT_SALE]+[P_ACCT].[INTERNAL_SALE]),P_ACCT=EXPORT_SALE)

*IS DOM_ROYAL

*REC(EXPRESSION=[P_ACCT].[TOTAL_SALE]-(%VALUE%+[P_ACCT].[DOM_OTHER]+[P_ACCT].[DOM_IMPORT_SALE]+[P_ACCT].[INTERNAL_SALE]),P_ACCT=EXPORT_SALE)

*IS DOM_OTHER

*REC(EXPRESSION=[P_ACCT].[TOTAL_SALE]-([P_ACCT].[DOM_ROYAL]+%VALUE%+[P_ACCT].[DOM_IMPORT_SALE]+[P_ACCT].[INTERNAL_SALE]),P_ACCT=EXPORT_SALE)

*IS DOM_IMPORT_SALE

*REC(EXPRESSION=[P_ACCT].[TOTAL_SALE]-([P_ACCT].[DOM_ROYAL]+[P_ACCT].[DOM_OTHER]+%VALUE%+[P_ACCT].[INTERNAL_SALE]),P_ACCT=EXPORT_SALE)

*IS INTERNAL_SALE

*REC(EXPRESSION=[P_ACCT].[TOTAL_SALE]-([P_ACCT].[DOM_ROYAL]+[P_ACCT].[DOM_OTHER]+[P_ACCT].[DOM_IMPORT_SALE]+%VALUE%),P_ACCT=EXPORT_SALE)

*ENDWHEN

*ENDWHEN

We have passed this script in default.lgf.

But every time any GL is written, the value is getting added to EXPORT_SALE for other values of P_CC other than BAS(BC)

Will appreciate your inputs.

Regards,

SAP BPC

Accepted Solutions (1)

Accepted Solutions (1)

former_member186338
Active Contributor
0 Kudos

Please read my document about default.lgf specifics:

You have to split single when/endwhen loop to 5 loops and remove XDIM_MEMBERSET's

Vadim

Former Member
0 Kudos

According to your post , we need to split when/endwhen . Even  after splitting the it , values are getting added.

former_member186338
Active Contributor
0 Kudos

Please, show the code after split and the UJKT result.

Vadim

former_member186338
Active Contributor
0 Kudos

P.S. The final code for default.lgf have to be like:

*WHEN P_CC

*IS BAS(BC)

*WHEN CATEGORY

*IS PLAN

*WHEN FLOW

*IS NA

*WHEN P_ASSET

*IS NA

*WHEN P_DATASRC

*IS MANUAL

*WHEN P_EMP_TYPE

*IS NA

*WHEN P_MATERIAL

*IS NA

*WHEN P_PROJECT

*IS NA

*WHEN P_SERVICES

*IS NA

*WHEN P_ACCT

*IS TOTAL_SALE

*REC(EXPRESSION=[P_ACCT].[TOTAL_SALE]-([P_ACCT].[DOM_ROYAL]+[P_ACCT].[DOM_OTHER]+[P_ACCT].[DOM_IMPORT_SALE]+[P_ACCT].[INTERNAL_SALE]),P_ACCT=EXPORT_SALE)

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*WHEN P_CC

*IS BAS(BC)

*WHEN CATEGORY

*IS PLAN

*WHEN FLOW

*IS NA

*WHEN P_ASSET

*IS NA

*WHEN P_DATASRC

*IS MANUAL

*WHEN P_EMP_TYPE

*IS NA

*WHEN P_MATERIAL

*IS NA

*WHEN P_PROJECT

*IS NA

*WHEN P_SERVICES

*IS NA

*WHEN P_ACCT

*IS DOM_ROYAL

*REC(EXPRESSION=[P_ACCT].[TOTAL_SALE]-([P_ACCT].[DOM_ROYAL]+[P_ACCT].[DOM_OTHER]+[P_ACCT].[DOM_IMPORT_SALE]+[P_ACCT].[INTERNAL_SALE]),P_ACCT=EXPORT_SALE)

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*WHEN P_CC

*IS BAS(BC)

*WHEN CATEGORY

*IS PLAN

*WHEN FLOW

*IS NA

*WHEN P_ASSET

*IS NA

*WHEN P_DATASRC

*IS MANUAL

*WHEN P_EMP_TYPE

*IS NA

*WHEN P_MATERIAL

*IS NA

*WHEN P_PROJECT

*IS NA

*WHEN P_SERVICES

*IS NA

*WHEN P_ACCT

*IS DOM_OTHER

*REC(EXPRESSION=[P_ACCT].[TOTAL_SALE]-([P_ACCT].[DOM_ROYAL]+[P_ACCT].[DOM_OTHER]+[P_ACCT].[DOM_IMPORT_SALE]+[P_ACCT].[INTERNAL_SALE]),P_ACCT=EXPORT_SALE)

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*WHEN P_CC

*IS BAS(BC)

*WHEN CATEGORY

*IS PLAN

*WHEN FLOW

*IS NA

*WHEN P_ASSET

*IS NA

*WHEN P_DATASRC

*IS MANUAL

*WHEN P_EMP_TYPE

*IS NA

*WHEN P_MATERIAL

*IS NA

*WHEN P_PROJECT

*IS NA

*WHEN P_SERVICES

*IS NA

*WHEN P_ACCT

*IS DOM_IMPORT_SALE

*REC(EXPRESSION=[P_ACCT].[TOTAL_SALE]-([P_ACCT].[DOM_ROYAL]+[P_ACCT].[DOM_OTHER]+[P_ACCT].[DOM_IMPORT_SALE]+[P_ACCT].[INTERNAL_SALE]),P_ACCT=EXPORT_SALE)

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*WHEN P_CC

*IS BAS(BC)

*WHEN CATEGORY

*IS PLAN

*WHEN FLOW

*IS NA

*WHEN P_ASSET

*IS NA

*WHEN P_DATASRC

*IS MANUAL

*WHEN P_EMP_TYPE

*IS NA

*WHEN P_MATERIAL

*IS NA

*WHEN P_PROJECT

*IS NA

*WHEN P_SERVICES

*IS NA

*WHEN P_ACCT

*IS INTERNAL_SALE

*REC(EXPRESSION=[P_ACCT].[TOTAL_SALE]-([P_ACCT].[DOM_ROYAL]+[P_ACCT].[DOM_OTHER]+[P_ACCT].[DOM_IMPORT_SALE]+[P_ACCT].[INTERNAL_SALE]),P_ACCT=EXPORT_SALE)

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

Vadim

former_member186338
Active Contributor
0 Kudos

And for sure, you can use FOR next to have more compact code:

*FOR %AC%=TOTAL_SALE,DOM_ROYAL,DOM_OTHER,DOM_IMPORT_SALE,INTERNAL_SALE

*WHEN P_CC

*IS BAS(BC)

*WHEN CATEGORY

*IS PLAN

*WHEN FLOW

*IS NA

*WHEN P_ASSET

*IS NA

*WHEN P_DATASRC

*IS MANUAL

*WHEN P_EMP_TYPE

*IS NA

*WHEN P_MATERIAL

*IS NA

*WHEN P_PROJECT

*IS NA

*WHEN P_SERVICES

*IS NA

*WHEN P_ACCT

*IS %AC%

*REC(EXPRESSION=[P_ACCT].[TOTAL_SALE]-([P_ACCT].[DOM_ROYAL]+[P_ACCT].[DOM_OTHER]+[P_ACCT].[DOM_IMPORT_SALE]+[P_ACCT].[INTERNAL_SALE]),P_ACCT=EXPORT_SALE)

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*NEXT

Former Member
0 Kudos

Both the codes are not working , now infact the EXPORT_SALE is not even getting calculated , its blank.

former_member186338
Active Contributor
0 Kudos

Sorry, but if you put this code as a default.lgf and enter some value in the input form with the combination of members matching:

*WHEN P_CC

*IS BAS(BC)

*WHEN CATEGORY

*IS PLAN

*WHEN FLOW

*IS NA

*WHEN P_ASSET

*IS NA

*WHEN P_DATASRC

*IS MANUAL

*WHEN P_EMP_TYPE

*IS NA

*WHEN P_MATERIAL

*IS NA

*WHEN P_PROJECT

*IS NA

*WHEN P_SERVICES

*IS NA

*WHEN P_ACCT

*IS %AC% //list of accounts


Then it will work!


In our system we have a lot of code like this and it works for years. Please show your input form with all members visible.


Vadim

Former Member
0 Kudos

Dear Vadim,

Kindly find the attachment , which will show the various calculations engaged in the Input schedule

As discussed earlier, there are some exception where Export_Sale is zero when Costcenter is  BC and hence the value of Energy Revenue - Export Sales will be Energy available for sale *  Export Rate (value 11 * value 20)

In order to test the script you provided for Export_Sale, we have taken a single Costcenter group KHP.

All the scripts in Scripts Implemented column in excel sheet have been written separately  and called in default.lgf.

Will appreciate your inputs.

Thanks and Regards,

SAP BPC

former_member186338
Active Contributor
0 Kudos

Sorry, I have no idea why you attached the file with different scripts...

Please, test my script as a single default.lgf file with a correct input form and you will see that it's working.

Vadim

Former Member
0 Kudos

Your given code is working Sir.

I attached that sheet since the value TOTAL_SALE is derived from some other calculation  and not entered directly in input template.

*XDIM_MEMBERSET P_ACCT = NET_GEN,TOTAL_SALE,IMPORT,INTERNAL_PURCHASE

[P_ACCT].[#TOTAL_SALE] = [P_ACCT].[NET_GEN] + [P_ACCT].[IMPORT] + [P_ACCT].[INTERNAL_PURCHASE]

*COMMIT

So whenever  the value of  TOTAL_SALE is  changed, the code given by you is not getting triggered and hence the value of EXPORT_SALE remains unchanged.

former_member186338
Active Contributor
0 Kudos

It's better to rewrite all logic to WHEN/ENDWHEN and without XDIM_MEMBERSET. For Example:

First you need to calculate TOTAL_SALE:

//Calculate TOTAL_SALE if any of NET_GEN,IMPORT,INTERNAL_PURCHASE sent by user

*FOR %AC1%=NET_GEN,IMPORT,INTERNAL_PURCHASE

//Conditions to be tested

*WHEN P_CC

*IS BAS(KHP)

*WHEN CATEGORY

*IS PLAN

*WHEN FLOW

*IS NA

*WHEN P_ASSET

*IS NA

*WHEN P_DATASRC

*IS MANUAL

*WHEN P_EMP_TYPE

*IS NA

*WHEN P_MATERIAL

*IS NA

*WHEN P_PROJECT

*IS NA

*WHEN P_SERVICES

*IS NA

*WHEN RPTCURRENCY

*IS LC

*WHEN P_ACCT

*IS %AC%

*REC(EXPRESSION=[NET_GEN].[DOM_ROYAL]+[P_ACCT].[DOM_OTHER]+[P_ACCT].[IMPORT]+[P_ACCT].[INTERNAL_PURCHASE],P_ACCT=TOTAL_SALE)

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*NEXT

//Calculate EXPORT_SALE if any of NET_GEN,IMPORT,INTERNAL_PURCHASE,DOM_ROYAL,DOM_OTHER,DOM_IMPORT_SALE,INTERNAL_SALE are sent by user (NET_GEN,IMPORT,INTERNAL_PURCHASE - affect TOTAL_SALE calculated on the previous step)

*FOR %AC2%=NET_GEN,IMPORT,INTERNAL_PURCHASE,DOM_ROYAL,DOM_OTHER,DOM_IMPORT_SALE,INTERNAL_SALE

*WHEN P_CC

*IS BAS(KHP)

*WHEN CATEGORY

*IS PLAN

*WHEN FLOW

*IS NA

*WHEN P_ASSET

*IS NA

*WHEN P_DATASRC

*IS MANUAL

*WHEN P_EMP_TYPE

*IS NA

*WHEN P_MATERIAL

*IS NA

*WHEN P_PROJECT

*IS NA

*WHEN P_SERVICES

*IS NA

*WHEN RPTCURRENCY

*IS LC

*WHEN P_ACCT

*IS %AC%

*REC(EXPRESSION=[P_ACCT].[TOTAL_SALE]-([P_ACCT].[DOM_ROYAL]+[P_ACCT].[DOM_OTHER]+[P_ACCT].[DOM_IMPORT_SALE]+[P_ACCT].[INTERNAL_SALE]),P_ACCT=EXPORT_SALE)

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*ENDWHEN

*NEXT

Same can be done with other formulas, just check dependency.

Vadim

Former Member
0 Kudos

Ohk., so we need to declare the dependent objects in all FOR , wherever that object has the impact, irrespective of the object being used in formula or not.

One more query, can we write all these FOR  which are interdependent in a single script or we have to write in separate logic and call these logics in default.lgf.

former_member186338
Active Contributor
0 Kudos

"call these logics in default.lgf" - incorrect term, actually the statement:

*INCLUDE something.lgf

will simply put text of something.lgf in the compiled default.lgx. It's not a real call.

You can have all logic in a single default.lgf or you can use include - no difference.

The idea of calculation is like this:

You have 2 calculated values: X and Y, calculated by formulas:

X=F(A,B,C)

Y=F(X,D,E,F)

Actually it means, that:

Y=F(A,B,C,D,E,F)

For each value sent to A,B,C,D,E,F you have to recalculate Y. But because X is already calculated you can use it in REC formula instead of A,B,C.

The idea of not using XDIM_MEMBERSET is to deal with only members sent by user.

Vadim

Answers (1)

Answers (1)

Former Member
0 Kudos

Thank you for your inputs!!