|
expr.compile, l.expr,s.expr , d.expr
Dynamic expressions functions (expr.*) have been one of the best amazing functions of Baan 4GL.It is nicely
documented. However there are certain tricks and techniques related to these functions which are little
known / documented.
Also many senior members have deployed it succcessfully. So no original refeernce to any thread is included.
This post may be more for new members.
This function lets user create dynamic expressions (DE) and use the same repeatedly in the program. When
there is error in compiling and / or evaluating DE , the value of pre-defined variable 'e' is raised along
with BW messages.Programmer can theck the value of 'e' to check if the error occurred in compiling/evaluating
expression.BW messages can be avoided by selecting 'Not action' in 'BW message window option' tab in
option dialog. There is no way to change the same programmatically . The variables to be used in dynamic
expressions must be declared extern.
exp.compile allows lot of functions to be used in the DEs. Though there is no syntax for these function
calls , these functions work perfect and work on the same lines of same function in Baan 4GL (may be with
$ suffix like str$,edit$ , strip$ etc ). These DEs are very useful in letting users control the definition of engineering
parameters (which may change with each product ). Users can key multiple expressions in a text separated
by,zoom to variables in text , do assignments for long repeated expressions, do conditional iterations using ?
and : , format the output using edit , round the value. convert string to numeric and reverse .
The DEs are also very useful in calculated items , query fields lookups in reference table, dynamic formulae,
dynamic dll function calling , dynamic expression creating hierarchies,domain range validation for any data type
in string field . Powerful pattern matching and conditional evaluation in DEs work extra-oridnarily .
e.g.In OLAP , classification / categorization /grouping of data at row level is termed as calculated item. e.g.
if u wish to categorize the sales invoice value (tfacr200.amth ) as per table below
Category Invoice value
A >1000,000
B >500,000
C >100,000
D upto 100,000
Such categorization can be also for alphanumeric data also e.g. All customers beginning with A as LOB 1,
beginning with B to D as LOB 2 and rest LOB 3.
both categorizations can dynamically be created and evaluated runtime easily like .
tfacr200.amth > 500000 ? tfacr200.amth > 1000000 ? "A" : "B" : tfacr200.amth > 100000 ? "C":"D"
OR
tfacr200.amth > 1000000 ? "A" : tfacr200.amth > 500000 ? "B" : tfacr200.amth > 100000 ? "C" : "D"
tfac200.cuno in "A.*"? "LOB 1": tfac200.cuno in "[B-D].*"? "LOB 2" : "LOB 3"
Standard Baan uses these expr.functions extensively in many areas . So the knowledge of these functions can
help user get best in these areas.
1.Input/ref argument for a field to check whether input is allowed on the field or not .
2.Job / user default settings saved in ttaad503 / ttadv990
3.showing the value of an expression and evaluating an expression for stop if condition in program debugger.
4.Range validation for a domain .
The string length for the dynamic expression should be keplt maximum for allowing different variations
and length of data.
Thus DEs are great and are very handy in handling small DEs but It can not do all that baan 4gl functions and
SQL queries can do. This should be kept in mind when deploying it.
|