on 08-21-2015 10:45 PM
Hi Experts.
I have written a below code and its working fine except one case. When the columns has null values in the SQL view, the IS is not checking up such values in the failed results. Though its violating the rule.
Here's my code, may be its wrong or it needs corrected.
BEGIN
IF ($ProcurementMethod = 'PO/SO' And ($Source_Costing_SPK != $Source_MRPController))
RETURN FALSE;
ELSE IF ($ProcurementMethod = 'STO' OR $ProcurementMethod = 'STSA' AND ($Costing_SPK != ' '))
RETURN FALSE;
ELSE IF ($ProcurementMethod = 'STO' OR $ProcurementMethod = 'STSA' AND ($Source_Costing_SPK !=$Source_MRP_SPK))
RETURN FALSE;
ELSE
RETURN TRUE;
END
Appreciate your thoughts.
thanks in advance,
Vinay
if the column value can be null then your rule should explicitly check for IS NULL or IS NOT NULL, you can't use = and != for NULLs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Manoj,
Lets take this as example for the better explanation of my issue:
IF ($ProcurementMethod = 'PO/SO' AND ($Source_Costing_SPK = $Source_MRPController))
this code works absolutely fine as long as there is no NULL values in $Source_Costing_SPK or $Source_MRPController columns.
Ex: When $Source_Costing_SPK = US91 AND $Source_MRPController = NULL
Per the example it should fail right, because those two column values are not same.
I know there is a way but I lack a programming expertise.If you can help me that would be great.
thanks in advance.
Vinay,
This is by design. I raised this with SAP and DI rules assume all fields are populated, and a NULL in any field will produce a failure in this scenario. I raised this idea to hopefully change the current design.
For now, all rules will need to cater for all fields potentially having a NULL or you introduce an NVL to convert from NULL in all parameters.
Feel free to vote for the idea and with any luck SAP will change the functionality at some point.
regards
Adrian
yes, it should fail if one of them is NULL, with the current logic it will also fail if both of them are NULL, I would expect it to pass if both are NULL
for it to pass in case both $Source_Costing_SPK and $Source_MRPController are NULL, change the condition to as below
if ($ProcurementMethod = 'PO/SO' AND (($Source_Costing_SPK = $Source_MRPController) OR ($Source_Costing_SPK IS NULL AND $Source_MRPController IS NULL)))
I think have fixed the issue which I had for the null values. Not sure what was the exact reason, I tried the below code and then ran the rule task. Now the IS failed results have the records that had violated the rule.
BEGIN
IF ($ProcurementMethod = 'PO/SO' AND ($Source_Costing_SPK = $Source_MRPController))
RETURN TRUE;
ELSE IF ($ProcurementMethod = 'STO' AND ($Source_Costing_SPK = $Source_MRP_SPK))
RETURN TRUE;
ELSE IF ($ProcurementMethod = 'STSA' AND ($Source_Costing_SPK = $Source_MRP_SPK))
RETURN TRUE;
ELSE IF ($ProcurementMethod = 'STO' AND ($Costing_SPK = ' '))
RETURN TRUE;
ELSE IF ($ProcurementMethod = 'STSA' AND ($Costing_SPK = ' '))
RETURN TRUE;
ELSE
RETURN FALSE;
END
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.