CDDLHELP.HLB  —  VARIANTS OF field, Example
  In the following example, RECORD_IDENTIFIER is the tag variable.  The
  value  of  RECORD_IDENTIFIER  at run time determines which VARIANT is
  current according to the translation table in the descriptive text.

  STOCK STRUCTURE.
      /* RECORD_IDENTIFIER determines field type:
           S --> In-stock record.
           B --> Back-order record.
           O --> Out-of-stock record. */
      RECORD_IDENTIFIER          DATATYPE IS TEXT
                                 SIZE IS 1 CHARACTER.
      VARIANTS OF RECORD_IDENTIFIER.
          VARIANT VALUE IS "S".
              IN_STOCK STRUCTURE.
                  PRODUCT_NO     DATATYPE IS TEXT
                                 SIZE IS 8 CHARACTERS.
                  DATE_ORDERED   DATATYPE IS DATE.
                  STATUS_CODE    DATATYPE IS BYTE.
                  QUANTITY       DATATYPE IS LONGWORD
                                 ALIGNED ON LONGWORD.
                  LOCATION       ARRAY 1:4
                                 DATATYPE IS TEXT
                                 SIZE IS 30 CHARACTERS.
                  UNIT_PRICE     DATATYPE IS LONGWORD SCALE -2.
              END IN_STOCK STRUCTURE.
          END VARIANT.
          VARIANT VALUE IS "B".
              BACK_ORDER STRUCTURE.
                  PRODUCT_NO     DATATYPE IS TEXT
                                 SIZE IS 8 CHARACTERS.
                  DATE_ORDERED   DATATYPE IS DATE.
                  STATUS_CODE    DATATYPE IS BYTE.
                  QUANTITY       DATATYPE IS LONGWORD
                                 ALIGNED ON LONGWORD.
                  SUPPLIER       ARRAY 1:4
                                 DATATYPE IS TEXT
                                 SIZE IS 30 CHARACTERS.
                  UNIT_PRICE     DATATYPE IS LONGWORD
                                 SCALE -2.
              END BACK_ORDER STRUCTURE.
          END VARIANT.

          VARIANT VALUE IS "O".
              OUT_OF_STOCK STRUCTURE.
                  PRODUCT_NO         DATATYPE IS TEXT
                                     SIZE IS 8 CHARACTERS.
                  DATE_LAST_SOLD     DATATYPE IS DATE.
              END OUT_OF_STOCK STRUCTURE.
          END VARIANT.
      END VARIANTS.
  END STOCK STRUCTURE.
Close Help