Skip to Content
-1

Script Logic calling a badi with conditions

Oct 04, 2017 at 07:22 PM

109

avatar image

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

7 Answers

Best Answer
Vadim Kalinin Oct 05, 2017 at 08:11 PM
0

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
Share
10 |10000 characters needed characters left characters exceeded
Vadim Kalinin Oct 05, 2017 at 07:14 AM
0

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/

Share
10 |10000 characters needed characters left characters exceeded
Vadim Kalinin Oct 05, 2017 at 02:50 PM
0

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.

Share
10 |10000 characters needed characters left characters exceeded
Edward Masarri Oct 05, 2017 at 01:40 PM
0

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.

Share
10 |10000 characters needed characters left characters exceeded
Edward Masarri Oct 05, 2017 at 03:49 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Gersh Voldman
Oct 08, 2017 at 04:00 PM
0

Hi Ed,

You can write conditional statements in BPC Script logic by using keyword *XDIM_SKIPPNULLCHECK - OSS Note 2146749.

Regards,

Gersh

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Gersh,

In my answer I am talking about the same approach but using for with variable that can have some value or nothing. In case of nothing the code inside for next is not executed.

0
Gersh Voldman
Oct 10, 2017 at 02:38 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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.

1