on 11-22-2020 4:50 PM
Hello experts! I am new to BPC and encountered a 1x hours run time when executing the script logic. Please take a look at the details and any help will be really appreciated! Thank you very much for your time and help in advance!
Purpose & Issue encountered:
As we are working on the cost allocation exercise, the purpose of the logic script is to retrieve the ratio from the ratio table (RATIO_ALC) to the transaction table (TRANS_ALC), to calculate the cost allocated to the subsequent flows and writes back the calculated result to TRANS_ALC.
So a script has been developed based on the requirement and it works perfectly well in testing when the executing volume is low, say 20 entries. But when it comes to full loops for all required items, it took around 13 hours to complete.
I have tried implementing badi RUNLOGIC_PH (https://archive.sap.com/documents/docs/DOC-35152) but failed to import the transport, and I suspect that it is a result of versioning issue. These lead to my questions:
Version:
[BPC 11.1] BPC4HANA 200 SP 4, BW4HANA 200 SP 4 ABAP
Model details:
TRANS_ALC
RATIO_ALC
Script:
PS. User does not expect to select DEPT, BU, or GLACCOUNT information when executing the logic.
*SELECT (%DEPT_CC%, ID, COSTCENTER_DEPT, NATURE = DEPT)
*SELECT (%BU_CC%, ID, COSTCENTER_BU, NATURE = BU)
*SELECT (%COA%, ID, GLACCOUNT, GAE_OAC_AC <>'')
// TRANS_ALC Memberset
*XDIM_MEMBERSET YEAROFPLAN = 2019 //%YEAROFPLAN_SET%
*XDIM_MEMBERSET TIME = 2019.01 //%TIME_SET%
*XDIM_MEMBERSET PROFITCENTER = NA
*XDIM_MEMBERSET MEASURES = PERIODIC
*XDIM_MEMBERSET RPTCURRENCY = HKD
*XDIM_MEMBERSET ACQMAINT = NA
*XDIM_MEMBERSET FLOW_ALC = STEP_B
*XDIM_MEMBERSET CATEGORY = BUDGETV1 //%CATEGORY_SET%
// RATIO_ALC LOOKUP ratio
*LOOKUP RATIO_ALC
*DIM GLACCOUNT = NA
*DIM FLOW_ALC = STEP_C
*DIM DATASOURCE = Input
*FOR %LOOP_DEPT_CC% = %DEPT_CC%
*FOR %LOOP_BU_CC% = %BU_CC%
*DIM R_%LOOP_DEPT_CC%_%LOOP_BU_CC%: COSTCENTER_DEPT = %LOOP_DEPT_CC%
*DIM R_%LOOP_DEPT_CC%_%LOOP_BU_CC%: COSTCENTER_BU = %LOOP_BU_CC%
*NEXT
*NEXT
*ENDLOOKUP
// TRANS_ALC Action
*FOR %LOOP_COA% = %COA%
*WHEN GLACCOUNT
*IS %LOOP_COA%
*FOR %LOOP_DEPT_CC% = %DEPT_CC%
*WHEN COSTCENTER_DEPT
*IS %LOOP_DEPT_CC%
*FOR %LOOP_BU_CC% = %BU_CC%
*REC(EXPRESSION = 0, FLOW_ALC = "STEP_C")
*REC(FACTOR = LOOKUP(R_%LOOP_DEPT_CC%_%LOOP_BU_CC%)*-1,FLOW_ALC = "STEP_C", COSTCENTER_DEPT = %LOOP_DEPT_CC%)
*REC(FACTOR = LOOKUP(R_%LOOP_DEPT_CC%_%LOOP_BU_CC%),FLOW_ALC = "STEP_C", COSTCENTER_BU = %LOOP_BU_CC%)
*NEXT
*ENDWHEN
*NEXT
*ENDWHEN
*NEXT
1. The whole logic will be very slow due to multiple FOR/NEXT loops. There are also some errors in the code.
2. The best way is to first copy ratios from RATIO to TRANS (using dummy account) Then perform required calculations using RUNALLOCATION or WHEN/ENDWHEN without FOR/NEXT.
3. "failed to import the transport, and I suspect that it is a result of versioning issue" - import with ignore version.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Vadim,
Thank you for your reply. I have been trying your suggestions and I have turned the script into 2 scripts: one doing the copy ratio and the other calculates using RUNALLOCATION. And I am able to import the RUNLOGIC_PH badi with ignore version. Many thanks!
So as I now require a parallel run of packages across models, I got quite confused about the syntax when I am trying to create script for RUNLOGIC_PH to do the parallel job. Should I define the Dimensions respectively for the two models as below? Do I still need to CHANGED parameters? Thanks!
//RUNLOGIC_PH
*START_BADI RUNLOGIC_PH
LOGIC = RUNALLOCATIONBC_BADI.LGF
APPSET = GLBPC_STANDARD
// APP = TRANS_ALC
DIMENSION YEAROFPLAN = 2019 //%YEAROFPLAN_SET%
DIMENSION TIME = BAS(2019.TOTAL)
DIMENSION PROFITCENTER = NA
DIMENSION MEASURES = PERIODIC
DIMENSION RPTCURRENCY = HKD
DIMENSION ACQMAINT = NA
DIMENSION FLOW_ALC = STEP_C
DIMENSION CATEGORY = %CATEGORY_SET%
DIMENSION COSTCENTER_DEPT = BAS(GHKCGLHK_DEPT), BAS(GHKCHKBL_DEPT), BAS(GHKCHKBNL_DEPT)
DIMENSION COSTCENTER_BU = BAS(GHKCCCGROUP)
DIMENSION DATASOURCE = Input
DIMENSION GLACCOUNT = NA
DIMENSION ENTITY = 1010
CHANGED = TIME,CATEGORY
*END_BADI
*START_BADI RUNLOGIC_PH
LOGIC = ALCRATIOCOPY_BADI.LGF
APPSET = GLBPC_STANDARD
APP = RATIO_ALC
DIMENSION YEAROFPLAN = 2019 //%YEAROFPLAN_SET%
DIMENSION TIME = BAS(2019.TOTAL)
DIMENSION PROFITCENTER = NA
DIMENSION MEASURES = PERIODIC
DIMENSION RPTCURRENCY = HKD
DIMENSION ACQMAINT = NA
DIMENSION FLOW_ALC = STEP_C
DIMENSION CATEGORY = %CATEGORY_SET%
DIMENSION COSTCENTER_DEPT = %DEPT_CC%
DIMENSION COSTCENTER_BU = %BU_CC%
DIMENSION DATASOURCE = Input
DIMENSION GLACCOUNT = NA
DIMENSION ENTITY = 1010
CHANGED = TIME,CATEGORY
*END_BADI<br>
For Account allocation use:
*DIM_NONAGGR GLACCOUNT WHAT = BAS(TGE); WHERE = <<<; USING = NA
Please read note:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, but why do you need CHANGED at all??? Remove this line from RUNLOGIC.
COPY script is simple and fast
RUNALLOCATION is also fast. But your logic is not 100% clear.
What is the timing if you run both scripts manually?
For the RUNALLOCATION script you need to clearly explain the calculation logic with data samples. If you want some help...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vadim,
Both scripts took less than 10s to complete.
For the RUNALLOCATION script, the purpose of the allocation is to apply the respective ratio per COSTCENTER_DEPT per COSTCENTER_BU in the same FLOW_ALC (say Step C) to each of the GLACCOUNTs under [BAS(TGE)]. User is expected to select the corresponding YEAROFPLAN, TIME and CATEGORY upon execution.
Thank you for your help!
Hi Vadim,
Thank you very much! I will accept your answer!
The >10s execution is performed separately in RATIO_ALC and TRANS_ALC. It would at best to create RUNLOGIC to trigger both logics to run together. I have removed the CHANGED parameter but still failed to run the expected result, can you please comment on the RUNLOGIC script to trigger the parallel run?
Per your previous comment "not 100% clear...For the RUNALLOCATION script you need to clearly explain the calculation logic with data samples. If you want some help...", do you mind sharing some insights based on the business requirement? I just realized that the current script will generate a sum of all GLaccount amount in [BAS(TGE)] and apply the calculated sum to each of the GL accounts, e.g. before allocation = GL1101010 $10000 and GL1101020 $30000; and after allocation = GL1101010 Costcenter 1 $10000+30000*0.5 (Ratio Costcenter 1) and GL1101010 Costcenter 1 $10000+30000*0.5, which is wrong.
Many thanks!
queenielau
Please provide the detailed Excel screenshot of the required allocation sample (use "Insert Image" button). Logic is still not clear from your text. Show multiple accounts.
First you need to create a proper allocation script, test it on full scale without parallel run and only after think about parallel run if necessary.
Thank you Vadim.
Please see if the following example explains in a better way.
At the same time, I have refined the RUNALLOCATION script that is able to generate the result as per the example but as I used *forloop again, it now took 270s to complete the calculation. Any better way to write this script?
//RUNALLOCATION
*XDIM_MEMBERSET YEAROFPLAN = 2019 //%YEAROFPLAN_SET%
*XDIM_MEMBERSET TIME = 2019.01 // %TIME_SET%
*XDIM_MEMBERSET PROFITCENTER = NA
*XDIM_MEMBERSET MEASURES = PERIODIC
*XDIM_MEMBERSET RPTCURRENCY = HKD
*XDIM_MEMBERSET ACQMAINT = NA
*XDIM_MEMBERSET CATEGORY = BUDGETV2 //%CATEGORY_SET%
*XDIM_MEMBERSET GLACCOUNT = NA,BAS(TGE)
*XDIM_MEMBERSET DATASOURCE = Input
*XDIM_MEMBERSET ENTITY = 1010,8010,8020
*XDIM_MEMBERSET COSTCENTER_DEPT = BAS(GHKCCCGROUP)
*XDIM_MEMBERSET COSTCENTER_BU = BAS(GHKCCCGROUP)
*SELECT (%COA%, ID, GLACCOUNT, GAE_OAC_AC <>'')
*FOR %LOOP_COA% = %COA%
*RUNALLOCATION
*FACTOR = USING
*DIM FLOW_ALC WHAT = STEP_B; WHERE = STEP_C; USING = <<<
*DIM GLACCOUNT WHAT = %LOOP_COA% ; WHERE = <<<; USING = NA
*DIM COSTCENTER_DEPT WHAT = BAS(GHKCCCGROUP); WHERE = <<<; USING = <<<
*DIM COSTCENTER_BU WHAT = NA; WHERE = BAS(GHKCCCGROUP); USING = <<<
*ENDALLOCATION
*NEXT
User | Count |
---|---|
15 | |
4 | |
2 | |
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.