cancel
Showing results for 
Search instead for 
Did you mean: 

Validations test

Former Member
0 Kudos

Hello Folks,

i just started working with Validations..

when i have gone through the syntax of IF then stattement,

But i am struggling to implement it after i see some examples in Complete reference 7.1 like IF(F1, F2)

F1 is true ->f2

f1 is false ->NULL

Can anyone explain with a practical real time condition

Thanks in Advance.

KR

John

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ,

First thing about validation expression is always return bollean value i.e. either true or false.

So during writing expreesion plz take care of this thing.

Example IF(n1,v2)

n1 - must be a bolean value like (supplier.name="name1").this either true or false

v2 - incase of assignment it can be any value but if you are using with validation then as this is returning value then it must be either "TRUE" or "FALSE"

you can go through this article you will get some knowledge

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/102dc4e5-07c9-2910-93b3-f49c8ed52...

Hope this will help you and if your prob is resolved then please close this thread.

If you need some more info then please get back to us.

Thanks,

Sudhanshu

Former Member
0 Kudos

Hello,

n1 - must be a bolean value like (supplier.name="name1").this either true or false

v2 - incase of assignment it can be any value but if you are using with validation then as this is returning value then it must be either "TRUE" or "FALSE"

Can you substantiate your above statement with an example.

onthe otherhand

when you say validation writes true or false that means it creats a colums and confirms whether that record is success via validation or not. Right!!!!!!

KR

John

Former Member
0 Kudos

Hi John,

Yes in case of validation faliure or succes mdm creates a one new coloumn with coloumn header name the validation name that you run against records.

If validation successful the a right tick in gren color will come into coloumn corresponding to successfull records and a red cross for each failed record.

Example :Like i have a test field in maintable and you want that noone record cotain "xyz" value for this field then in that case we will create a validation like

if(fieldname="XYZ",false) ; //for ifthen case

if(fieldname="XYZ",false,true) ; //for ithenelse case

Hope you understand the case.

Thanks,

Sudhanshu

Former Member
0 Kudos

Hello,

if(fieldname="XYZ",false) ; //for ifthen case

if(fieldname="XYZ",false,true)

I executed both examples and they are working fine. Thanks.

But i have seen a validation in Complete reference 7.1 ''

IF(IS_NULL(FIELD1), "???", FIELD1)

if field 1 is NULL --> "???"

OTHERWISE ---> field1

What does this mean..

Can anyone explain!!!!

KR

John

Former Member
0 Kudos

Hi ,

By just seeing expression i cannot tell that what actually means.

Please share the page number of yr 7.1 and name of guide.

may be

??? -> for any false or true whatever user refers

field1 -> must be a boolean field otherwise may be you seeing a assignment expression

Thanks,

Sudhanshu

former_member283645
Participant
0 Kudos

its on 252 datamanager 71 complete reference

Former Member
0 Kudos

Hi Eva,

What is mentioned on this page 252 is general expression not validation expression.

IF(IS_NULL(Desc), u201C???u201D, Desc)

in that IF THEN ELSE statement they are telling that if value of field Desc has NULL value then assign "???" string to field

Desc otherwise assign same value that Desc value have.

I think this clear your doubts.

Thanks,

Sudhanshu

Former Member
0 Kudos

Hello,

Lets say my table has a field 'DESC'

DESC

-


1001

1002

1004

Four records of which 3 rd record is Empty.

Now if I run the below validation..

IF(IS_NULL(Desc), u201Chellou201D, Desc)

what will be theresult?

will my 3rd record be filled with 'hello' ???

Onthe otherhand,

'If' my Desc field has all four records filled,

and if i run this validation then what happens???

You said 'assign same value that Desc value have.' !!!

What will be the output in this case.

Experts please have a look

KR

John

Former Member
0 Kudos

HI John,

First i want to clear one thing .

With assignment expression only you can assign values to field

with validation expression you only check whether that record is valid against that expression or not.

Now as i already told you that is assignemnt expression not validation expression

If you run this expression in assignemnt then yes it will assign the value"hello" to third record .

This is not a valid validation expresiion because the output of validation expression must be boolean value.

Valid validation expression is

IF(IS_NULL(Desc), false,true)

In this case when you run this validation aginst records then if that record contain value then a green right tick will come otherwise red cross will come and laso it depends upon how you create a validation expression property "automatica execution".

Hope i answered your question.

Thanks,

Sudhanshu

Former Member
0 Kudos

Hi John,

IF(IS_NULL(Desc), u201Chellou201D, Desc)

1stly, you should understand that this is a expression which can be used in Assignment or Validation.

Since Validation always return True or False, so if you are using expression in Validation, it should be like this

IF(IS_NULL(Desc), TRUE, FALSE) or IF(IS_NULL(Desc), FALSE, TRUE)

so whenever your logic passes it goes to then if fails go to Else.

In your case, if you use this expression in your validation, IF(IS_NULL(Desc), u201Chellou201D, Desc)

You will always get FALSE, fail records because as validation returns true or false, its then and else statement should have TRUE or False as suggested above.

But if you use in this Expression in Assignment, IF(IS_NULL(Desc), u201Chellou201D, Desc)

It will populate your 3rd record with hello and values which are already populated(Not Null), it will keep those values of Desc.

Also make sure that during Assignment, your Assignment Field = DESC

Regards,

Mandeep Saini

Former Member
0 Kudos

Hello,

Thanks for taking that extra pain in explaining the issue.

I have a field where there are 4 records

Name

-


1

2

4

*3rd is Null.

Now wen i run a validation expression IF THEN

IF(IS_NULL(NAME),TRUE)

I can see that all the four records have a success symbol.

Where in my condition says If null then Success right!!!

why are the other 3 records which have values in them are also success.

Please answer.

KR

John

Former Member
0 Kudos

Hi John,

Please refer my above post, hope it will clear your doubts.

IF(IS_NULL(NAME),TRUE)

For Validation, you should either write expression as

IS_NULL(NAME)

OR

IF(IS_NULL(NAME),TRUE , FALSE )

Since Validation expression Returns either TRUE or FALSE, you need to tell if your logic passes(PASS/FAIL) then what should return if its PASS mean TRUE/FALSE and what should return if it FAILS mean FALSE/TRUE

Regards,

Mandeep Saini

Former Member
0 Kudos

Fully agree with you.

But my question is ..

i have a field where there are 4 records

Name

-


1

2

4

*3rd is Null.

Now wen i run a validation expression IF THEN

IF(IS_NULL(NAME),TRUE)

I can see that all the four records have a success symbol.

Where in my condition says If null then Success right!!!

why are the other 3 records which have values in them are also success.

John

Former Member
0 Kudos

Hi John,

IF(IS_NULL(NAME),TRUE)

According to this Expression it tells when there is null value for field NAME then returns TRUE which mean Success but you didn't tell what should be done if this field NAME has value, that's why you are getting Success for Every record.

In other words, if you give expression as IF(IS_NULL(NAME),FALSE), it will gives always FALSE as you havent tell what should be happen if it has value.

So you need to tell bth TRUE and FALSE in your Expression to accurately make use of Validations.

IF(IS_NULL(NAME),TRUE, FALSE)

Here, it gives TRUE (Success) for 3 rd record only,

And other 3 records which have values in them should be FALSE as you given in Exprssion if it has no value return TRUE(Success) and if it has Value Return FALSE

Hope you got my point !!

Regards,

Mandeep Saini

Former Member
0 Kudos

Problem solved , thanks guys

Answers (0)