CASE

CASE provides multi-choice logic. A variable’s value is compared with a number of alternatives: the first true alternative is selected. After performing this action execution resumes with the statements following END CASE.

 

Example

CASE (EIBAID);

    WHEN (DFHENTER) THEN;

        Custf.Region = 1;

    WHEN (DFHPA1 OR DFHPA2 OR DFHPA3 OR 'x');

        Custf.region = 2;

    ELSE;

        Custf.region = 3;

END CASE;

 

Notes: -

1.                  CASE (field) must name one or more fields. Thus CASE; is invalid. The field name is enclosed in parentheses

2.                  WHEN (field [OR field]…) names a list of fields and/or constants. These must be compatible with the field named in the CASE statement.

3.                  WHEN requires a “;” to show the end of the WHEN statement. You can write THEN if you like, in which case Jazz can insert the “;” for you.

4.                  ELSE means “none of the above” and must be the last condition within the CASE/END CASE;

5.                  The actions may be one or several Jazz statements.

6.                  If CASE names more than one fields, then WHEN clauses may give corresponding values separated by commas, but may not use OR.  Right-hand values may be omitted, in which case any value is valid for the corresponding field.  For example

CASE(C.Country, C.State);

    WHEN('Australia', 'NSW');

        C.A = 1;

    WHEN('Australia', 'Vic');

        C.A = 2;

    WHEN('New Zealand');

        #484 W Anything accepted for omitted values

        C.A = 3;

    ELSE;

        C.A = 4;

END CASE;