on β2018 Oct 23 3:59 PM
Hi Experts,
We have logic that rounds β depending on greater than or less than 0 and then inner logic <.5 and >.5, Script is below.
The logic works most of the time except in some circumstances β tried isolating to multiple dimension members within the scoped dimensions but itβs not consistent.
Working example
3.25 results in (.25) so that 3.25-.25 = 3
3.60 results in .4 = 4.0
(2.40) results in +.40 = (2.0)
Error Example
3.3 results in .7 = (3.3+.7)
Again canβt determine why this occurs - some dimensions are the breakout of the rounding e.g. ENTITY,ACCOUNT,INTERCO, CURRENCY,FLOW, while most are summarized β total of COUNTRY = CO_ALL.
Caps in the script are correct as per the dimension parents.
Any ideas?
Here is the script.
Also tried splitting the REC statements to 2 statements with separate scoping and commit. Same result. The logic is getting tied up in the inner loop of the first REC statement as an example
//2B_ROUND_RND23N.LGF
*XDIM_MEMBERSET TIME = %TIME_SET%
*XDIM_MEMBERSET ENTITY = %ENTITY_SET%
*XDIM_MEMBERSET CURRENCY = %CURRENCY_SET%
*XDIM_MEMBERSET CATEGORY = %CATEGORY_SET%
*XDIM_MEMBERSET AUDITID = BAS(AD3005) // Other dimensions *XDIM_MEMBERSET ACTIVE_INGREDIEN=AI_All
*XDIM_MEMBERSET ACTIVITY=AC_All
*XDIM_MEMBERSET BANK=BA_All
*XDIM_MEMBERSET COST_CENTER=CC_ALL
*XDIM_MEMBERSET COUNTRY=CO_All
*XDIM_MEMBERSET INTERCO=BAS(I_ALL)
*XDIM_MEMBERSET PRODUCTION_LINE=PL_ALL
*XDIM_MEMBERSET SUBGLOBALRGN=GR_All
*XDIM_MEMBERSET TC=TC_ALL
*XDIM_MEMBERSET FLOW =BAS(END),F99
*WHEN SCOPE *IS S_NONE
// SPLIT POSITIVE AND NEGATIVE
// greater than 0
*REC(EXPRESSION=(%VALUE% >0)?((%VALUE%%1 < 0.5 )? -%VALUE%%1:1-%VALUE%%1):0, AUDITID=ADRND2,ACTIVE_INGREDIEN=AI_NONE,ACTIVITY=AC_NONE,BANK=BA_NONE,COST_CENTER=CC_NONE,COUNTRY=CO_NONE,PRODUCTION_LINE=PL_NONE,SUBGLOBALRGN=GR_NONE,TC=TC_NONE)
// Less than 0
*REC(EXPRESSION=(%VALUE% <0)?((-%VALUE%%1 < 0.5 )? -%VALUE%%1:-1-%VALUE%%1):0, AUDITID=ADRND3,ACTIVE_INGREDIEN=AI_NONE,ACTIVITY=AC_NONE,BANK=BA_NONE,COST_CENTER=CC_NONE,COUNTRY=CO_NONE,PRODUCTION_LINE=PL_NONE,SUBGLOBALRGN= GR_NONE,TC=TC_NONE)
*ENDWHEN
*COMMIT
This was a long posting with guidance on ternary β where I tried to create in one shot but ended up splitting the ternary logic.
Thanks in advance.
Regards,
Eyal
Request clarification before answering.
Hi Vadim,
Found the problem with a little help....
Issue was the scoping of the AUDITID - I was using BAS(PARENT) instead of
*XDIMMEMBERSET AUDITID = PARENT
Now it's working as we want!
Thanks for your help.
Regards
Eyal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In general - where you can see rounding errors? Rounding errors are results of multiplication/division:
- Currency translation
- Consolidation
- Allocation
- Script logic with multiplication/division
Can be solved using write back badi performing rounding
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vadim,
Yes we tried that but what happens is this β on a detail level.
ACCT_1234 BANK_1:10.3 rounded to 10
ACCT_1234 BANK_2: 10.14 rounded to 10
ACCT_1234 BANK_3: 10.16 rounded to 10
Total30.6 rounded to 30
If we summarize without a bank then the total is 30.6 rounded to 31.This is what we are trying to accomplish
Regards,
Eyal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
"Thinking is that I donβt want the rounding to occur on every single row of BANK dimensions and others β too detailed" - Sorry, but this is the wrong idea to my mind. You have to perform rounding on the individual records, not totals. It's incorrect from finance point of wiew...
Sample:
You have invoice with 5 product lines and VAT 18%
Total VAT for invoice is not equal to TotalInvoice*0.18, but has to be calculated for each line due to rounding.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vadim,
We are using BPC NW 10.1 SP11 - Using K2CalcEngline=JS (Javascript)
TC_All is a parent member as are the dimensions below (except Interco of course).
Thinking is that I donβt want the rounding to occur on every single row of BANK dimensions and others β too detailed.Intent is to summarize on these dimensions.
In my sample test I used multiple banks, multiple Sublglobalrgn etc. and it worked.
In the data set of 2000 there are multiple values of these dimension members TC, Bank etc.
// Other dimensions *XDIM_MEMBERSET ACTIVE_INGREDIEN=AI_All
*XDIM_MEMBERSET ACTIVITY=AC_All
*XDIM_MEMBERSET BANK=BA_All
*XDIM_MEMBERSET COST_CENTER=CC_ALL
*XDIM_MEMBERSET COUNTRY=CO_All
*XDIM_MEMBERSET INTERCO=BAS(I_ALL)
*XDIM_MEMBERSET PRODUCTION_LINE=PL_ALL
*XDIM_MEMBERSET SUBGLOBALRGN=GR_All
*XDIM_MEMBERSET TC=TC_ALL
Regards,
Eyal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vadim,
Thanks for the response.
So the script runs successfully.
Ran with selecting TC_ALL, CO_ALL etc as well as specific dimension scoping.
An example of an error: Rows had multiple dimension values within the all e.g. 25 rows for same Account with 2 country dimension members (CO_USA, CO_UK) and several TC dimension members (TC_EUR, TC_USD, TC_NONE). However, other rows in the set with similar data did work.
The logic works (thanks to your help in a prior post!).
Any ideas?
Regards,
Eyal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please read: https://blogs.sap.com/2014/01/31/how-to-ask-questions-about-script-logic-issues/
Even version info is not provided!
Just tested:
*XDIM_MEMBERSET TIME=2007.01,2007.02,2007.03,2007.04
*XDIM_MEMBERSET AUDITTRAIL=Input
*XDIM_MEMBERSET CATEGORY=Budget
*XDIM_MEMBERSET ENTITY=DE
*XDIM_MEMBERSET PRODUCT=ProductA
*XDIM_MEMBERSET INTERCO=ThirdParty
*XDIM_MEMBERSET RPTCURRENCY=LC
*XDIM_MEMBERSET ACCOUNT=PL110 //ACCTYPE=EXP
*WHEN ACCOUNT
*IS *
*REC(EXPRESSION=(%VALUE% >0)?((%VALUE%%1 < 0.5 )? -%VALUE%%1:1-%VALUE%%1):0, ACCOUNT=PL120)
*REC(EXPRESSION=(%VALUE% <0)?((-%VALUE%%1 < 0.5 )? -%VALUE%%1:-1-%VALUE%%1):0, ACCOUNT=PL120)
*ENDWHENInitial data:

Script result:
...
DATA TO WRITE BACK:
ACCOUNT AUDITTRAIL CATEGORY ENTITY INTERCO PRODUCT RPTCURRENCY TIME SIGNEDDATA
PL120 Input Budget DE ThirdParty ProductA LC 2007.01 0.25-
PL120 Input Budget DE ThirdParty ProductA LC 2007.02 0.40
PL120 Input Budget DE ThirdParty ProductA LC 2007.03 0.40
PL120 Input Budget DE ThirdParty ProductA LC 2007.04 0.30-
4 RECORDS HAVE BEEN WRITTEN BACK.
...Report result:

Use simple models to test logic!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please read: https://blogs.sap.com/2014/01/31/how-to-ask-questions-about-script-logic-issues/
And provide missing info!
3.3 results in .7 = (3.3+.7)
May be 3.3 is for INC/LEQ account? Then it will be (3.3)...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 15 | |
| 11 | |
| 11 | |
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 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.