on 2017 Oct 04 8:22 PM
Hello Friends,
Env 10.1
We have a requirement to call a badi from script logic, but depending on the parameters we pass to the DM package the Time memberset get updated.
%TIME_PERIOD_ACTUAL% and %TIME_PERIOD_PLAN% get updated from the flags in the time dimension. Script calls a select statement to populate these variables.
This is one part of the script, we have multiple categories and with additional conditions
eg,
*when category
*is actual
*XDIM_MEMBERSET TIME = %TIME_PERIOD_ACTUAL%
*START_BADI XXXX
QUERY = ON
WRITE = ON
DESTINATION = %RPTCURRENCY_SET%
*END_BADI
*IS PLAN
*XDIM_MEMBERSET TIME = %TIME_PERIOD_PLAN%
*START_BADI XXXX
QUERY = ON
WRITE = ON
DESTINATION = %RPTCURRENCY_SET%
*END_BADI
*ENDWHEN
Question - This script does not validate, I am not sure if we can call a Badi from a *when *endwhen. The name of the badi is same for both the conditions, but I don't want to write outside of *endwhen, as the scoping of time dimension would go off.
If there is any other conditional operator which I can use, that would be great. I dont need any *rec statements in my current script
Thanks for your time
Ed.
Request clarification before answering.
A property to be created in CATEGORY dimension: IDPROP and filled with the member ID. Then:
*SELECT(%PL%,[ID],CATEGORY,ID=%CATEGORY_SET% AND IDPROP=PLAN)
Same for actual with variable %AC%:
*SELECT(%AC%,[ID],CATEGORY,ID=%CATEGORY_SET% AND IDPROP=ACTUAL)
Then you will scope:
*FOR %A%=%AC% // if actual was selected by user
*XDIM_MEMBERSET TIME = %TIME_PERIOD_ACTUAL%
*START_BADI...
*NEXT
*FOR %P%=%PL% // if plan was selected by user
*XDIM_MEMBERSET TIME = %TIME_PERIOD_PLAN%
*START_BADI...
*NEXT
P.S. Code corrected, property creation is required!
Full script:
*SELECT(%TIME_PERIOD_ACTUAL%,"[ID]",TIME,"ACTUAL_PERIOD = 'Y'")
*SELECT(%TIME_PERIOD_PLAN%,"[ID]",TIME,"PLAN_PERIOD = 'Y'")
*SELECT(%PL%,[ID],CATEGORY,ID=%CATEGORY_SET% AND IDPROP=PLAN)
*SELECT(%AC%,[ID],CATEGORY,ID=%CATEGORY_SET% AND IDPROP=ACTUAL)
*FOR %A%=%AC% // if actual was selected by user
*XDIM_MEMBERSET CATEGORY = ACTUAL
*XDIM_MEMBERSET TIME = %TIME_PERIOD_ACTUAL%
*START_BADI XXXXXXXX
QUERY = ON
WRITE = ON
DESTINATION = %RPTCURRENCY_SET%
*END_BADI
*NEXT
*FOR %P%=%PL% // if plan was selected by user
*XDIM_MEMBERSET CATEGORY = PLAN
*XDIM_MEMBERSET TIME = %TIME_PERIOD_PLAN%
*START_BADI XXXXXXXX
QUERY = ON
WRITE = ON
DESTINATION = %RPTCURRENCY_SET%
*END_BADI
*NEXT
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, such approach is possible, but I'd consider it a workaround. SKIPNULLCHECK is designed specifically for that purpose and should improve readability of the script if not performance.
Gersh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In general FOR with empty variable and SKIPNULLCHECK with XDIM_MEMBERSET xxx = empty variable will do exactly same things - skip code. No performance benefits (both will happen during LGX generation). With SKIPNULLCHECK the COMMIT is required resulting in scope reset. And FOR with empty variable method was available before the note 2146749.
Hi Ed,
You can write conditional statements in BPC Script logic by using keyword *XDIM_SKIPPNULLCHECK - OSS Note 2146749.
Regards,
Gersh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Vadim for your reply
//ACTUAL SCRIPT
*SELECT(%TIME_PERIOD_ACTUAL%,"[ID]",TIME,"ACTUAL_PERIOD = 'Y'")
*XDIM_MEMBERSET CATEGORY = ACTUAL //%CATEGORY_SET%
*XDIM_MEMBERSET TIME = %TIME_PERIOD_ACTUAL%
*START_BADI XXXXXXXX
QUERY = ON
WRITE = ON
DESTINATION = %RPTCURRENCY_SET%
*END_BADI
//PLAN SCRIPT
*SELECT(%TIME_PERIOD_PLAN%,"[ID]",TIME,"PLAN_PERIOD = 'Y'")
*XDIM_MEMBERSET CATEGORY = PLAN //%CATEGORY_SET%
*XDIM_MEMBERSET TIME = %TIME_PERIOD_PLAN%
*START_BADI XXXXXXXX
QUERY = ON
WRITE = ON
DESTINATION = %RPTCURRENCY_SET%
*END_BADI
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you post the 2 different scripts for 2 different categories then I will explain you how to combine. I general you need to generate scope for time dimension depending on category.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Vadim for your reply.
My requirement is to pass different time period to the BADI, depending on the category selected in the DM package.
example, if category ACTUAL is passed though the DM package then the script should scope time for the actual period.
if the category PLAN is passed though the DM package then the script should scope time for the plan periods, which would be multiple periods based on the flag.
I could write separate script for each category and hard code that scope for the time dimension(based on the flags in the time dimensions), but it would lead to separate DM packages and separate scripts for each category, which make maintenance difficult.
I understand from your post, that we cannot use *when *endwhen while calling a badi.
what is the best alternative, I am looking for a functionality like using a IF condition to determine the scoping. Not sure if its possible in script logic.
I cannot provide logs as the earlier script does not validate.
Thanks for your time.
Ed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Badi call can't be inside WHEN/ENDWHEN loop, only REC.
Please describe your requirements in line with:
https://blogs.sap.com/2014/01/31/how-to-ask-questions-about-script-logic-issues/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
6 | |
6 | |
5 | |
2 | |
2 | |
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.