Those of us that have been working on PeopleSoft for a while know that we occasionally stumble across undocumented features and functions.
Logical Operators are one of the fundamental building blocks of computer programming languages. Evaluating if a predicate (or expression) is logically false or true determines program flow and results in correct and predictable behaviour. The 3 Logical Operators in PeopleCode (sometimes called logical connectives) are AND, OR and NOT.
In this example the Boolean typed variable &foo must be True and variable &bar must be False in order for this predicate to be True. (In the Truth Table a False and False (i.e. Not False) always returns True).
I've been working on a software project recently and I stumbled upon a new logical operator in PeopleCode.
I found the Maybe operator.
The beauty of this operator is that the evaluation of a Boolean using the Maybe operator might return a False or True but you're never quite sure which. In this example &foo must be True and variable &bar could be False or True. The result of the Maybe operator may result in True or may result in False.
This simple device can save us writing loads of quite complex code and that makes it a very powerful operator indeed.
There are many other useful shorthand functions we can use for evaluating field values and I'm particularly fond of the functions All, None, AllOrNone, OnlyOne and OnlyOneOrNone. You can read all about there here in the PeopleSoft Online Documentation.
To check if a field has a value we could write
or we could simplify this with...
This is particularly useful if you need to evaluate more than one field. So the following...
would become a nice tidy....
And our newly discovered Maybe operator also works as a Function too. We can therefore return True or Maybe False if &foo has a value.
Happy coding. And if you too come across any hidden functions please let me know.
Logical Operators are one of the fundamental building blocks of computer programming languages. Evaluating if a predicate (or expression) is logically false or true determines program flow and results in correct and predictable behaviour. The 3 Logical Operators in PeopleCode (sometimes called logical connectives) are AND, OR and NOT.
In this example the Boolean typed variable &foo must be True and variable &bar must be False in order for this predicate to be True. (In the Truth Table a False and False (i.e. Not False) always returns True).
If &foo And Not &bar Then /* do something... */ End-If;
I've been working on a software project recently and I stumbled upon a new logical operator in PeopleCode.
I found the Maybe operator.
The beauty of this operator is that the evaluation of a Boolean using the Maybe operator might return a False or True but you're never quite sure which. In this example &foo must be True and variable &bar could be False or True. The result of the Maybe operator may result in True or may result in False.
If &foo And Maybe &bar Then /* do something... */ End-If;
This simple device can save us writing loads of quite complex code and that makes it a very powerful operator indeed.
There are many other useful shorthand functions we can use for evaluating field values and I'm particularly fond of the functions All, None, AllOrNone, OnlyOne and OnlyOneOrNone. You can read all about there here in the PeopleSoft Online Documentation.
If &foo <> " " Then End-If;
or we could simplify this with...
If All(&foo) Then End-If;
This is particularly useful if you need to evaluate more than one field. So the following...
If &foo <> " " And &bar <> " " And &dee <> " " Then /* All fields must have a non empty value */ End-If
would become a nice tidy....
If All(&foo, &bar, &dee) Then /* All fields must have a non empty value */ End-If;
And our newly discovered Maybe operator also works as a Function too. We can therefore return True or Maybe False if &foo has a value.
If Maybe(&foo) Then /* do something... */ End-If;
Happy coding. And if you too come across any hidden functions please let me know.
Comments
or the foundation of AI.
Maybe it's 5 o'clock somewhere? ...