Financial Management Blogs by Members
Dive into a treasure trove of SAP financial management wisdom shared by a vibrant community of bloggers. Submit a blog post of your own to share knowledge.
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member186338
Active Contributor
Sometimes you need to execute part of your script logic code depending on some member existing in the scope. For example, you need to execute some CALCACCOUNT rule only if you have CATEGORY Budget in scope. Scope can be defined as a result of DM package prompt or can be initial scope for default.lgf.

Somebody may think that the following code will perform the test:
*SELECT(%TEST%,ID,CATEGORY,ID=%CATEGORY_SET% AND ID=Budget)
*FOR %T%=%TEST%
*XDIM_MEMBERSET CATEGORY=%T% //Just for test
//Place your code here
*NEXT

But due to the old bug, if we have two or more "=" conditions for the same property (ID in this case) "AND" is treated as "OR".

The following code will do the job:
//%CATEGORY_SET%=Actual,Budget
*SELECT(%NOTTEST%,ID,CATEGORY,ID=%CATEGORY_SET% AND ID<>Budget) //%NOTTEST%=Actual
*SELECT(%TEST%,ID,CATEGORY,ID=%CATEGORY_SET% AND ID<>%NOTTEST%) //%TEST%=Budget
*FOR %T%=%TEST% //Single execution of the loop
*XDIM_MEMBERSET CATEGORY=%T% //Just for test
//Place your code here
*NEXT

Result in UJKT:
LGX:

*XDIM_MEMBERSET CATEGORY=Budget

If Budget is missing in the scope:
//%CATEGORY_SET%=Actual
*SELECT(%NOTTEST%,ID,CATEGORY,ID=%CATEGORY_SET% AND ID<>Budget) //%NOTTEST%=Actual
*SELECT(%TEST%,ID,CATEGORY,ID=%CATEGORY_SET% AND ID<>%NOTTEST%) //%TEST%=Empty
*FOR %T%=%TEST% //Nothing will be executed
*XDIM_MEMBERSET CATEGORY=%T% //Just for test
//Place your code here
*NEXT

Result:
LGX:



Questions? Comments?
1 Comment
Top kudoed authors