cancel
Showing results for 
Search instead for 
Did you mean: 

Script Logic: Conditional script with Signed Data values - Above/Below zero

Former Member
0 Kudos

Hi SDN'ers,

I'm currently working through a Profit Share calculation in Script Logic.

To simplify the requirement, we need the following behaviour:

1. If Net Profit is Positive (+0) then multiply by a Profit Share driver

2. If Net Profit is Negative, do nothing (do not multiply by the Profit Share driver)

It is my understanding that Script Logic will not use Signed Data in a *WHEN statement, so cannot say:


*XDIM_MEMBERSET AUDIT_ID = INPUT

*XDIM_MEMBERSET ACCOUNT = BAS(NET_PROFIT)

*WHEN ACCOUNT

*IS NET_PROFIT

  *WHEN SIGNEDDATA

  *IS > 0

  *REC(FACTOR = 1, AUDIT_ID = PROFIT_SHARE)       // Write value to Profit Share Audit ID

  *ENDWHEN

*ENDWHEN

Another option performing this task is obviously creating a BAdI that will handle this scenario, however it seems to be massively over-kill and harder for the business to support than script logic.

Sharing of any experience and/or confirmation that conditional logic on signed data values would be appreciated.

Nick

Accepted Solutions (1)

Accepted Solutions (1)

former_member186338
Active Contributor
0 Kudos

Hi Nick,

Ternary operator is supported in script logic:

(a>b) ? c : d (if true then c, false - d)

*XDIM_MEMBERSET AUDIT_ID = INPUT

*XDIM_MEMBERSET ACCOUNT = BAS(NET_PROFIT)

*WHEN ACCOUNT

*IS *

   *REC(EXPRESSION= (%VALUE%>0) ? %VALUE%*[ACCOUNT].[PROF_SHARE_DRIVER] : %VALUE%, AUDIT_ID = PROFIT_SHARE)

*ENDWHEN

Vadim

Answers (1)

Answers (1)

akos_beres
Contributor
0 Kudos

Nick,

You should try something like this

*XDIM_MEMBERSET AUDIT_ID = INPUT

*XDIM_MEMBERSET ACCOUNT = BAS(NET_PROFIT)

*WHEN ACCOUNT

*IS *

  *REC(EXPRESSION= ((%VALUE%>0)*1), AUDIT_ID = PROFIT_SHARE)       // Write value to Profit Share Audit ID

*ENDWHEN

Please also check out page 25 in this document

Good luck!

Akos