Using Conditional Statements - trillium_discovery - trillium_quality - 17.1

Trillium Control Center

Product type
Software
Portfolio
Verify
Product family
Trillium
Product
Trillium > Trillium Quality
Trillium > Trillium Discovery
Version
17.1
Language
English
Product name
Trillium Quality and Discovery
Title
Trillium Control Center
Topic type
How Do I
Overview
Configuration
Reference
Administration
Installation
First publish date
2008

A conditional statement can be simple or complex depending on individual requirements. To build a correct statement, follow these rules.

Note: Attributes used in conditional statements cannot contain a parenthesis.

Literal Values

When using literal values such as "New York," enclose the value in double quotation marks. Attribute names and numeric values do not require quotation marks. Any numeric value enclosed in quotation marks, such as "123" will be read as a literal value.

Comments

You can use "/*" as a comment character at the beginning of a line. For multi-line comments, use "/*" at the beginning of each line.

Example

/* Example of comments in the Transformer

/* conditional statements

Multiple Lines

You can extend a conditional statement into multiple lines. Use "\" as a continuation character at the beginning of each additional line.

Example

SET ATTRIBUTE1 = TRIM(ATTRIBUTE2) |: TRIM(ATTRIBUTE3)

\ |: TRIM(ATTRIBUTE4)

\ |: TRIM(ATTRIBUTE5)

Renamed Attributes

If you have changed the name of an attribute in the Schema Editor and you want to use that attribute in the conditional statements, you must use the original name of the attribute instead of the new name. You can find the original name of the attribute in the Schema Editor.

To find the original name of the attribute

  1. From the Navigation or Project View, right-click the special Transformer process and select Edit Process. You can also double-click the process to open it for editing
  2. In the Schema Editor, right-click the attribute and select Edit. The Edit Output Attribute window opens. The original name of the attribute is displayed in the Internal Name field.

    Using SUBROUTINES

    A SUBROUTINE is an independent IF/ELSE statement within a larger conditional statement. A subroutine is often used so that it can be executed several times and/or from several places during a single execution of the process. You must observe the following rules when you use a subroutine in your conditional statement:

    • Subroutines must be specified using the syntax <CONDITION>SUBROUTINE followed by an IF/ELSE/ENDIF statement.
    • Subroutines must be specified as entries in order of entry IDs in the settings file.
    • The RUN command is used to execute the subroutines. Subroutines are identified using their entry IDs. When you call multiple subroutines, use hyphens or commas to run them in sequence. Example: RUN SUBROUTINE(3-5), RUN FIELD_SCANNING(1,6)
    Note: There is a maximum of 100 nested IFs allowed in IF/ELSE conditional statements. The maximum number of actions for each IF statement is 500. Adding multiple IF operators to the top level of a single conditional section is not supported. Include only one top-level IF (head-if) per section.
    Note: It is not recommended to call other subroutines from a subroutine. Judicious use of subroutines will improve clarity and readability of statements but overusing them can create problems with following the logic.

    Example

    ------------------------------------------------------------------------

    <ENTRY>

    <ENTRY_ID>1</ENTRY_ID>

    <FOR_FILES>OUTPUT</FOR_FILES>

    <CONDITION>SUBROUTINE

    IF (ALWAYS)

    SET GA_GOUT_POSTAL_CODE = TQ_GIN_POSTAL_CODE

    ENDIF</CONDITION>

    </ENTRY>

    <ENTRY>

    <ENTRY_ID>2</ENTRY_ID>

    <FOR_FILES>OUTPUT</FOR_FILES>

    <CONDITION>SUBROUTINE

    IF (UCASE(GA_GOUT_POSTAL_CODE) = UCASE(TQ_GIN_POSTAL_CODE))

    SET GA_GOUT_POSTAL_CODE_CHANGED = "N"

    ENDIF</CONDITION>

    </ENTRY>

    <ENTRY>

    <ENTRY_ID>3</ENTRY_ID>

    <FOR_FILES>OUTPUT</FOR_FILES>

    <CONDITION>IF (ALWAYS)

    IF (TQ_GOUT_MATCH_LEVEL =1)

    RUN SUBROUTINE (1)

    ENDIF

    IF (TQ_GOUT_MATCH_LEVEL =2)

    RUN SUBROUTINE (2)

    ENDIF</CONDITION>

    </ENTRY>

    ------------------------------------------------------------------------

    In this example, two subroutines (Entry 1 and Entry 2) are specified. And then the larger conditional statement (Entry 3) is specified using those subroutines so that the program will run the SUBROUTINE (1) if TS_GOUT_MATCH_LEVEL=1, and run the SUBROUTINE (2) if TS_GOUT_MATCH_LEVEL=2.

    Using Escape Characters

    In an IF/ELSE/THEN statement, you must precede nested literal characters with a backslash, referred to as an escape character ( \ ). Adding the backslash ensures the nested literal character is read as part of the string, not the end of the string. Use the following valid escape characters:

    • \\ = \ (backslash)
    • \t = tab
    • \' = ' (single quote)
    • \" = " (double quote)

    Input Record in Output Conditionals

    You can access the value of attributes in the input record in the output conditional statements. The attributes are accessed through the entity name for the input, a "dot" followed by the attribute name.

    Example

    Assume an input has been defined with an entity name e9_us_common_p8.

    ------------------------------------------------------------------------

    IF (e9_us_common_p8.LAST_NAME = LAST_NAME)

    SET FIRST_NAME = e9_us_common_p8.FIRST_NAME

    ELSE

    SET_LAST_NAME = e9_us_common_p8.LAST_NAME

    ENDIF

    ------------------------------------------------------------------------

    In this example, if LAST_NAME has the same value on the input and output records, FIRST_NAME on the output record is updated with the value from the input record; otherwise, LAST_NAME on the output record is updated with the value from the input record.