How to set-up variables with filters

This example shows how filters can be created on queries with variables.

The example is the following:

Let's imagine we want to create a representation that displays the workflow events history, and we want to be able to filter them on the workflow event code that is triggered on the event type object for the object POC.

So the filter cannot be something such as:

[F:AWS]CODEVT="POCSIG"

This could be used if the corresponding event is always "POCSIG". But as a consultant can rename such an event, it is barely impossible to do it.

It is also impossible to use as a filter the result of a function that would return the code, such as :

[F:AWS]CODEVT=func PURWRK.CODE("POC")

or even
[F:AWS]CODEVT=GACTX.APARAM.AGETVALCHAR([V]CST_ALEVFOLD,"","POCSIG")

In fact, formulas are forbidden when using filters. The only acceptable solution is to use context variables.

So we need to have somewhere in the context the corresponding code. Let's imagine that we create, in the context, a variable POHSIG that contains the real code of the workflow event and that is located in the PUR group (a code to be created in the miscellaneous table 96).

The filter would then become:

[F:AWS]CODEVT=GACTX.PUR.POCSIG

This will be accepted.

So you need to set-up in our context dictionary, a variable POCSIG, in the group PUR (miscellaneous table 96).
This variable can have an initialisation formula such as the first one we wanted to use:

[F:AWS]CODEVT=func PURWRK.CODE("POC")

Of course, we will have to write the CODE function in the PURWRK script. It could be something such as:
Funprog CODE(EVENT)Value Char EVENT()Local Integer IF_FOUNDLocal File AWRKPAR [AWA]# Only the first active workflow on object EVENT will be returnedFilter [AWA] Where ENAFLG=2 and TYPEVT=2 and CODEVT=EVENTFor [AWA]IF_FOUND=1 : BreakNext# Return empty string if not foundIf IF_FOUND=0 : End "" : EndifEnd [AWA]CODE