cancel
Showing results for 
Search instead for 
Did you mean: 

Scoping in Default Logic

former_member481715
Participant
0 Kudos

Hello,

If I have a simple default logic (see below for code), do I need to scope it? whats the advantage or disadvantage of it?

Thanks.

*WHEN HR_ACCT

*IS AC_611000

*REC(EXPRESSION=%VALUE%)

*ENDHWEN

Accepted Solutions (1)

Accepted Solutions (1)

former_member186338
Active Contributor
0 Kudos

First of all this code do nothing 🙂

In general you have to avoid scoping in default logic - you have to work with the scope passed after writing data to model.

Please read: https://blogs.sap.com/2014/06/09/how-to-write-defaultlgf/

former_member481715
Participant
0 Kudos

Yeah, it was just a sample 🙂 will read through your notes, thanks a lot Vadim.

former_member481715
Participant
0 Kudos

Ok, I went through your article. One quick question: I understood that no XDIM scoping is needed when its default logic. However, what if the users are planning to use default logic run DM package? in a scenario like this, would you recommend using XDIM_Memberset?

Thanks.

former_member186338
Active Contributor
0 Kudos

You may also read my other blog: https://blogs.sap.com/2014/05/05/calculations-in-write-back-badi-defaultlgf-replacement/

to understand the difference between scope of default.lgf and the data records passed to write back badi.

former_member186338
Active Contributor
0 Kudos

"to use default logic run DM package" - sorry, what do you mean?

default.lgf is a script, not a DM package!

former_member481715
Participant
0 Kudos

Yes but you can use a DM package to run Default logic script right? in a scenario like that, do you need to scope it?

Thanks.

former_member186338
Active Contributor
0 Kudos

Yes, you can use DM package to run default.lgf but what is the benefit??

It's better to create another script dedicated to be launched by DM. In this script for sure you will use *XDIM_MEMBERSET scoping!

former_member481715
Participant
0 Kudos

But in that case you will have two scripts to maintain in every model/app. What would be downside of using XDIM_MEMBERSET in that scenario? I understand it doesnt really mean anything when default is triggered by input form, but it doesnt hurt does it?

former_member186338
Active Contributor
0 Kudos

Yes, you have to maintain 2 scripts!

1. If you define scope in default.lgf then calculations will happen for this scope independent of user data entry - will slow down save execution. For example you defined some scope for ACCOUNT. Then even if user is not saving data for this account the default.lgf will perform calculations!

2. Please read about different sign calculation logic in my document!

former_member186338
Active Contributor
0 Kudos

"I understand it doesnt really mean anything when default is triggered by input form" - incorrect understanding, please read again: https://blogs.sap.com/2014/06/09/how-to-write-defaultlgf

Answers (1)

Answers (1)

former_member186338
Active Contributor
0 Kudos

Just some samples:

If ACCOUNT is A1 then multiply value by A2 and write result to A3

default.lgf (for data saved by input form)

*WHEN ACCOUNT
*IS A1
*REC(EXPRESSION=%VALUE%*[ACCOUNT].[A2],ACCOUNT=A3)
*ENDWHEN

DM package script to perform this calculation for user defined scope:

*XDIM_MEMBERSET ACCOUNT=A1 //fixed scope for ACCOUNT
*XDIM_MEMBERSET TIME=%TIME_SET% // user scope for TIME
*XDIM_MEMBERSET ENTITY=%ENTITY_SET%
//...
*WHEN ACCOUNT
*IS * //already scoped
*REC(EXPRESSION=%VALUE%*[ACCOUNT].[A2],ACCOUNT=A3)
*ENDWHEN
former_member186338
Active Contributor
0 Kudos

P.S. sign calculation is different for default.lgf and script launched by DM package (please read my document!)