RPGIV @ Work

A unique site for RPG and System i Lovers

Welcome!

Hi, this site will provide all what you need in System i and RPG developments.

My Name is Chamara Withanachchi, System i Expert and RPG Developer. And in the field for last 11 years.

I hope you will find lot of valuable information from this site

LIKEREC in RPG Print E-mail
User Rating: / 0
PoorBest 
Written by Chamara Withanachchi   

LIKEREC(intrecname{:*ALL|*INPUT|*OUTPUT |*KEY})

Keyword LIKEREC is used to define a data structure, data structure subfield, prototyped return value, or prototyped parameter like a record. The subfields of the data structure will be identical to the fields in the record. LIKEREC can take an optional second parameter which indicates which fields of the record to include in the data structure. These include:

  • *ALL All fields in the external record are extracted.
  • *INPUT All input-capable fields are extracted. (This is the default.)
  • *OUTPUT All output-capable fields are extracted.
  • *KEY The key fields are extracted in the order that the keys are defined on the K specification in the DDS.

The following should be taken into account when using the LIKEREC keyword:

  • The first parameter for keyword LIKEREC is a record name in the program. If the record name has been renamed, it is the internal name for the record.
  • The second parameter for LIKEREC must match the definition of the associated record of the file on the system. *INPUT is only allowed for input and update capable records; *OUTPUT is only allowed for output capable records; *ALL is allowed for any type of record; and *KEY is only allowed for keyed files. If not specified, the parameter defaults to *INPUT.
  • For *INPUT and *OUTPUT, subfields included in the data structure occupy the same start positions as in the external record description.
  • If a prefix was specified for the file, the specified prefix is applied to the names of the subfields.
  • Even if a field in the record is explicitly renamed on an input specification the external name (possibly prefixed) is used, not the internal name.
  • If the file is defined with the ALIAS keyword, the alias names will be used for the subfields of the data structure.
  • A data structure defined with LIKEREC is a QUALIFIED data structure. The names of the subfields will be qualified with the new data structure name, DS1.SUBF1.
  • LIKEREC can be coded for subfields of a qualified data structure. When LIKEREC is coded on a data structure subfield definition, the subfield data structure is automatically defined as QUALIFIED. Subfields in a LIKEREC subfield data structure are referenced in fully qualified form: "ds.subf.subfa". Subfields defined with LIKEREC are themselves data structures, and can be used wherever a data structure is required.
<Previous   Next>