Library /sys$common/syshlp/CDO$HELP.HLB  —  fld-properties  COMPUTED_BY, Examples
    1.CDO>  DEFINE FIELD SUBTOTAL_PRICE
      cont>   COMPUTED BY UNIT_PRICE * QUANTITY.

      In this example, the DEFINE FIELD command includes the COMPUTED
      BY property to calculate a value for the SUBTOTAL_PRICE field
      element. The value is computed by multiplying UNIT_PRICE by
      QUANTITY.

    2.CDO>  DEFINE FIELD TOTAL_PRICE
      cont>   COMPUTED BY UNIT_PRICE (3) * 10.

      In this example, the DEFINE FIELD command includes a COMPUTED
      BY property to calculate a value for the TOTAL_PRICE field
      element. The value is calculated by multiplying the value in
      the third instance of the UNIT_PRICE field element by 10.

    3.CDO>  CHANGE FIELD TOTAL_PRICE
      cont>   NOCOMPUTED BY.

      In this example, the CHANGE FIELD command includes the
      NOCOMPUTED BY keywords to remove the COMPUTED BY property from
      the TOTAL_PRICE field element.

    4.CDO>  DEFINE FIELD C
      cont>   DATATYPE SIGNED WORD.
      CDO>  DEFINE FIELD C_ONE
      cont>   COMPUTED BY IF C EQ 1 THEN 1 ELSE 0.
      CDO>  DEFINE FIELD C_FIVE_TEN
      cont>   NAME FOR COBOL IS C_5_10
      cont>   COMPUTED BY IF C GE 5 AND C LE 10 THEN 1 ELSE 0.
      CDO>  DEFINE FIELD C_OTHER
      cont>   COMPUTED BY
      cont>   IF (C GE 2 AND C LE 4)
      cont>   OR (C GE 11 AND C LE 20)
      cont>   THEN 1 ELSE 0.
      CDO> DEFINE RECORD COB88.
      cont> C.
      cont> C_ONE.
      cont> C_FIVE_TEN.
      cont> C_OTHER.
      cont> END RECORD.

      In this example, the DEFINE FIELD commands include COMPUTED BY
      properties that contain conditional and value expressions.
      These expressions are related to the value of the C field
      element, as follows:

      o  The C_ONE field element takes the value of one (if C
         evaluates to one) or zero.

      o  The C_FIVE_TEN field element takes the value of one (if C
         evaluates to a value between five and ten) or zero.

      o  The C_OTHER field element takes the value of one (if C
         evaluates to a value between two and four or if C evaluates
         to a value between eleven and twenty) or zero.

    5.01  COB88.
          03  C                 USAGE IS COMP PIC 9(4).
             88  C_ONE          VALUE 1.
             88  C_FIVE_TEN     VALUES ARE 5 THRU 10.
             88  C_OTHER        VALUES ARE 2 THRU 4
                                11 THRU 20.

      This example shows COBOL syntax for the record containing level
      88 definitions.
Close Help