LIKE Clause

The LIKE clause allows you to define the PICTURE, USAGE, SIGN, and FORMAT characteristics of a data item by copying them from a previously defined data item. It also allows you to make the length of the data item you define different from the length of the original item.

Format

Read syntax diagramSkip visual syntax diagramLIKEdata-name-1 (integer)
data-name-1
Can refer to an elementary item, a group item, an index-name, or a type-name. The item referred to by data-name-1 is known as the object of the LIKE clause.
integer
Specifies the difference in length between the new and existing items.

It can be signed.

If a blank or a + precedes the integer, the new item is longer. If a - precedes the integer, the new item is shorter.

You cannot use the integer option to:
  • Change the length of an edited item
  • Change the length of an index, pointer, or procedure-pointer item
  • Change the number of decimal places in a data item
  • Change the length of an internal or external floating-point data item
  • Change the length of a date, time, or timestamp item
Note: An item whose attributes include BLANK WHEN ZERO is treated as an edited item.

The LIKE clause causes the new data item to inherit specific characteristics from the existing data item. These characteristics are the PICTURE, USAGE, SIGN, BLANK WHEN ZERO, and FORMAT attributes of the existing item.

The compiler generates comments to identify the characteristics of the new item. These comments appear after the statement containing the LIKE clause.

Note that the default USAGE IS DISPLAY and SIGN IS TRAILING characteristics do not print as comments.

The FORMAT characteristics that can be inherited include:
  • The category of the item: date, time, or timestamp
  • A FORMAT literal
  • A SIZE phrase and LOCALE phrase.
For more information about the FORMAT clause, refer to FORMAT clause.