Setting the Filter Parameter Value

You can use the following methods to set the value of a filter parameter:

Caution: 
For any given filter, you can only use literal values and one of the other methods. Do not mix the other methods in the same filter.

Method 1: Supply a Literal Value

Supply a literal value—for example, (EMP-EMP-STATUS = 'FT').

This example assumes that a table called FILTER with the prefix FLT is set up with two fields. A is an alpha field of length 3 and S is a signed numeric field.

MOVE "((FLT-A = ?) OR (FLT-A = 'A  ') AND (FLT-S = ?))" TO 
        FILTER-STRING

Method 2: Use the Set Filter Value API Routine

Set a value with 890-SET-<Type>-FILTER-VALUE after calling 890-CREATE-FILTER . In this case, the FILTER-STRING statement includes the "?" parameter marker syntax. For example:

MOVE "(ARO-TRANS-DATE <= ?)"          TO FILTER-STRING
PERFORM 890-CREATE-FILTER.
MOVE AR90F1-SEL-TRANS-DATE-TO   TO DATETIME-FILTER-VALUE.
PERFORM 890-SET-DATETIME-FILTER-VALUE.

Method 3: Set the Parameter Marker with the USEEARLYBINDFILTERS Function

For more information about using USEEARLYBINDFILTERS, see Additional Guidelines for Filters and Sample Filter.

The value of a parameter marker (the ? syntax) can be set before calling 890-CREATE-FILTER if you use the USEEARLYBINDFILTERS function. This function lets the run-time system know that the program will be setting values before the filter is created. This setting remains in effect until you call 890-CREATE-FILTER. 890-CREATE-FILTER changes this setting back to the default behavior.

Call USEEARLYBINDFILTERS and then set a value with 890-SET-<Type>-FILTER-VALUE before calling 890-CREATE-FILTER. For example:

CALL "USEEARLYBINDFILTERS" USING WS-TRUE.
IF (AR90F1-SEL-DUE-DATE-FROM    > ZEROS)
    STRING "(ARO-DUE-DATE >= ?)" DELIMITED BY SIZE
           INTO FILTER-STRING
           POINTER AR90WS-FILTER-LENGTH
    MOVE AR90F1-SEL-DUE-DATE-FROM    TO DATETIME-FILTER-VALUE
    PERFORM 890-SET-DATETIME-FILTER-VALUE.
IF (AR90F1-SEL-DUE-DATE-TO      > ZEROS)
    STRING " AND (ARO-DUE-DATE <= ?)" DELIMITED BY SIZE
           INTO FILTER-STRING
           POINTER AR90WS-FILTER-LENGTH
    MOVE AR90F1-SEL-DUE-DATE-TO      TO DATETIME-FILTER-VALUE
    PERFORM 890-SET-DATETIME-FILTER-VALUE.
PERFORM 890-CREATE-FILTER.

Method 4: Set the Filter Parameter Value with the SETFILTERPARAM Function

Bind the parameter to a working storage field with SETFILTERPARAM. For example:

MOVE "(GAM-COMPANY = ?)" TO FILTER-STRING.
CALL "SETFILTERPARAM" USING GLT-TO-COMPANY.
PERFORM 890-CREATE-FILTER.