You can use the Format 2 Copy statement only in the Data Division, and you must precede the statement with a group level item that has a level number less than 05.
When the RECORD KEY clause specifies EXTERNALLY-DESCRIBED-KEY, a format can be copied only once under the FD entry for the file.
Format 2 (COPY DDS Translate) ->->---COPY--*-DD-format-name---*--*-------*--*--------------*------> *-DD-ALL-FORMATS---* *- -I---* *- -INDICATOR--* *-DDR-format-name--* *- -O---* *- -INDICATORS-* *-DDR-ALL-FORMATS--* *- -I-O-* *- -INDIC------* *-DDS-format-name--* *-DDS-ALL-FORMATS--* *-DDSR-format-name-* *-DDSR-ALL-FORMATS-* ->----*--------------------------*--file-name--*------------*------> *--OF--*----library-name- -* *--SUPPRESS--* *--IN--* ->--*-----------------------------------------------------------*--><- + *--------------------------------------------* + + V + + *--REPLACING-* ==pseudo-text-1== *-BY-* ==pseudo-text-2== *-* *----identifier-1---* *---identifier-2----* *----literal-1------* *---literal-2-------* *----word-1---------* *---word-2----------*
Each COPY statement must be preceded by a space and ended with a separator period.
A COPY statement may appear in the source program anywhere a character string or a separator may appear. However, a COPY statement must not be specified within a COPY statement. The resulting text must not contain a COPY statement.
Text-name must follow the rules for formation of a program-name. The first 10 characters of text-name are used as the member name; these first 10 characters must, therefore, be unique within one file.
If text-name is not qualified, QLBLSRC is assumed as the file name. If the file name is not qualified by a library name, it is assumed to reside in a library in the library list.
Library-name must follow the rules for formation of a program-name. The first 10 characters of library-name are used as the identifying name; these first 10 characters must be unique within the system.
File-name must follow the rules for formation of a program-name.
The SUPPRESS phrase causes a COPY statement to suppress the listing of copied statements. For its duration, this type of COPY statement overrides any *CONTROL or *CBL statement.
If the copied member contains *CONTROL or *CBL statements, the last one runs once the COPY member has been processed.
In the following discussion, each operand may consist of one of the following:
When you specify REPLACING, the library text is copied, and each properly matched occurrence of the first operand within the library text is replaced by the second operand. For example, identifier-1 is replaced by identifier-2.
Each operand may consist of one of the following:
For purposes of matching, each identifier-1, literal-1, or word-1 is treated, respectively, as pseudo-text containing only identifier-1, literal-1, or word-1.
Use the DD option to reference alias (alternate) names. The specification of an alias name in DDS allows a data name of up to 30 characters to be included in the COBOL program.
When you use the DD option, any alias names present replace the corresponding DDS field names. All underscores in the alias names are translated into hyphens before any replacing occurs.
The format-name is the name of the DDS record format definition that is to be translated into COBOL data description entries. The format-name must follow the rules for formation of any AS/400 name.
If you specify ALL-FORMATS without the indicator attribute, each record format is generated as a redefinition of a 05 elementary item defined as either:
When the indicator attribute is specified, no redefinition takes place. Instead, each of the formats generates a separate data structure.
The DDR option does everything that the DD option does. It also replaces the characters which are not valid for COBOL: @, #, $, and _ in a field name (or alias name, if applicable), with the corresponding valid COBOL characters A, N, D, and - . As well, it removes underscores from the end of a field name.
The DDS option copies in the internal DDS format field names.
The DDSR option does everything the DDS option does. It also copies the internal DDS format field names, replacing the characters which are not valid for COBOL: @, #, $, and _ , with the valid COBOL characters A, N, D, and - , respectively. This option also removes any underscores from the ends of the field names.
I, O, and I-O represent the usage attributes for the data description entries generated by the COPY statement. If you do not specify either -I or -O, I-O is assumed.
If the file is a database file, a single I-O format is generated. Subfile records with only output or input/output fields, and no field indicators specified, generate I-O formats.
For all other file types the description generated varies as follows:
The INDICATOR attribute specifies whether or not data description entries are generated for indicators. If the INDICATOR attribute is specified, data description entries are generated for indicators, but not for data fields. INDICATOR, INDICATORS, and INDIC are equivalent.
The data description entries that are generated are determined by which one of the usage attributes (I, O, I-O) is specified or assumed in the COPY statement.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.