ILE COBOL Language Reference

+-------------------------------IBM Extension--------------------------------+


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.

LIKE Clause - Format
 
        (1)
>>-LIKE-------data-name-1--+-----------+-----------------------><
                           '-(integer)-'
 
 

Notes:

  1. IBM Extension

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:

Note that 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:

For more information about the FORMAT clause, refer to FORMAT Clause.

Related Information:


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]