cancel
Showing results for 
Search instead for 
Did you mean: 

Script Logic calling a badi with conditions

sap_user62
Active Participant
0 Kudos
1,287

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.

View Entire Topic
former_member186338
Active Contributor
0 Kudos

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