Let’s discuss a simple case: We have 2 PERIODIC models: SOURCE_MODEL and TARGET_MODEL with identical set of dimensions:
And we want to copy some scope from source to target using script logic launched by DM package.
Looks like the script will be:
*XDIM_MEMBERSET ACCOUNT=A1,A2,A3 *XDIM_MEMBERSET AUDITTRAIL=DS1 *XDIM_MEMBERSET ENTITY=DE *XDIM_MEMBERSET CATEGORY=BUDGET *XDIM_MEMBERSET TIME=2018.11 *XDIM_MEMBERSET CURRENCY=LC *DESTINATION_APP=TARGET_MODEL *WHEN TIME *IS * *REC(EXPRESSION=%VALUE%) *ENDWHEN
But there is an issue in case you perform copy multiple times (due to data changes in SOURCE_MODEL). For example:
- First copy: A1 account has value 10 in SOURCE_MODEL. A1 account in TARGET_MODEL will be also 10.
- Then the user decided to delete A1: 10 Result A1: 0 in SOURCE_MODEL
- Then Lite Optimization with Zero Elimination was performed for SOURCE_MODEL. Result A1: Empty in SOURCE_MODEL
- Second copy: Due to missing record for A1 in SOURCE_MODEL nothing will be copied to TARGET_MODEL. Result A1: 10 in TARGET_MODEL – incorrect!
To get a correct results in TARGET_MODEL we have to clear target scope before copy!
Clearing can be done with simple script (CLEAR.LGF) like:
//CLEAR.LGF *WHEN TIME *IS * *REC(EXPRESSION=0) *ENDWHEN
But this script has to be launched in the TARGET_MODEL. In order to do it in the same script in SOURCE_MODEL we have to implement RUNLOGIC_PH BADI.
Then the script in the SOURCE_MODEL will be:
//Clear scope START_BADI RUNLOGIC_PH QUERY = OFF WRITE = ON DEBUG = OFF LOGIC = CLEAR.LGF //Clear script in TARGET_MODEL //APPSET = Don't specify APPSET - current will be used! APP = TARGET_MODEL DIMENSION ACCOUNT=A1,A2,A3 DIMENSION AUDITTRAIL=DS1 DIMENSION ENTITY=DE DIMENSION CATEGORY=BUDGET DIMENSION TIME=2018.11 DIMENSION CURRENCY=LC END_BADI //this line will reset scope! //Copy data //You have to scope after END_BADI! *XDIM_MEMBERSET ACCOUNT=A1,A2,A3 *XDIM_MEMBERSET AUDITTRAIL=DS1 *XDIM_MEMBERSET ENTITY=DE *XDIM_MEMBERSET CATEGORY=BUDGET *XDIM_MEMBERSET TIME=2018.11 *XDIM_MEMBERSET CURRENCY=LC *DESTINATION_APP=TARGET_MODEL *WHEN TIME *IS * *REC(EXPRESSION=%VALUE%) *ENDWHEN
Using the above script the results will be correct!
P.S. There is a fast method to clear data using RUNALLOCATION:
//CLEAR.LGF *RUNALLOCATION *FACTOR=0 *DIM CATEGORY WHAT=%CATEGORY_SET%; WHERE=%CATEGORY_SET% *ENDALLOCATION