on 07-10-2014 2:18 PM
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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
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
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.
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
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.
"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
Thank you for your inputs!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
3 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.