Copying with a copybook or template
When you choose to use templates in your copy action, you can specify a “From” template only or both “From” and “To” templates.
- "From" template only
- Excludes not-selected
records from the output
data set.
You can use the “From” template to exclude not-selected input records from being copied to the output data set. During the copy, the Copy Utility uses the “From” template to provide information about the selected record types, record identification criteria, record selection criteria and record structure. Once selected, the entire contents of the record are copied. Any field selection and field resequencing settings in the “From” template are ignored for copying, as field mapping and field create attributes are taken from the “To” template.
You determine which records are selected or excluded by editing the template and:- selecting record types;
- specifying record identification criteria; and/or
- specifying record selection criteria.
Not-selected records:
- do not match a record type in the template, due to either record identification criteria or record length;
- match a record type, but belong to an unselected record type; or
- do not meet the record selection criteria for the record type.
- "From" and "To" templates (based on the same copybook or dynamic template structure)
- Allows
you to specify how fields in the input
data set are mapped to the output data set: to the same
field (this is the default), to a different field or
unmapped.
You can use the “To” template to specify field mapping to determine which fields in the input data set are copied to the fields in the output data set. Unmapped fields are initialized in the output data set according to “create attributes” in the “To” template. (If no create attributes have been specified, then unmapped numeric fields are initialized to zero and unmapped alphanumeric fields are initialized to blanks.)
File Manager ignores any record type selection, record identification criteria or record selection criteria in the “To” template, as this information is drawn from the “From” template.
The only information in the “To” template that is used for copying is the record structure, field mapping and field create attributes.
If PAD=ON is specified then a field by field copy is done for all fields and the output record length is equal to the layout length of the record type.
If PAD=OFF is specified then the input record copy is copied to the output record and the length of the output record matches the input record length. Only fields that change in value due to scrambling, data create, or code page changes are subsequently processed. For scrambling of fields the performance is improved if you run with PAD=OFF.
- "From" and "To" templates (based on different copybook or dynamic template structures)
- Allows
the input and output data sets to have
different record structures, according to the
differences in the copybook or dynamic template.
The Copy Utility inserts, deletes or moves fields, or changes field lengths or data types, according to the differences between the templates. For example:
- To insert a field, use a “To” template that is identical to the “From” template, except for an inserted field definition.
- Similarly, to delete a field, use a “To” template that is identical to the “From” template, but with the unwanted field removed.
Typically, you create the “To” template by copying the “From” copybook or dynamic template, then you edit the “To” copybook (or dynamic template) so that it describes the record structure that you want in the output data set.
The Copy Utility determines… | Using this information… | In this template… | |
---|---|---|---|
From | To | ||
Which records are copied |
Selected record types | ✓ | |
Which fields are copied, and to where | Field mapping | ✓ | |
How new (or unmapped) fields are initialized | Create attributes | ✓ | |
Whether mapped date and time fields are modified when copied | Date/Time Create/Modify attributes | ✓ |
By default, the Copy Utility maps fields in the “From” template to fields with the same name in the “To” template. You can edit the field mapping in the “To” template, and either delete the mapping for a field (so that its value in the output data set is initialized, rather than copied from the input data set), or specify yourself which field in the “From” template is mapped to a field in the “To” template.
The Copy Utility truncates or pads records appropriately. You can specify the pad character in the PAD field on the Set Processing Options (option 0) panel.
If you are using a copybook or template for your copy, use the Copy Utility panel (see Figure 1) as follows:
- From the Primary Option Menu panel, select
option 3. Utilities and
then option 3. Copy.
The Copy Utility panel is displayed.
- Enter the “From” data set details.
- Enter the “From” copybook or template
details. Use a combination of the Data
set name and Member entry
fields to specify the copybook or template that
describes the data in the “From” data set.
You can select data for copying at either record level or field level:
- For record-level selection, set the record identification and record selection criteria in your “From” template.
- For field-level selection, use a “From” template with a “To” template, and specify the selected fields, field attributes and field mapping in your “To” template.
If you specify both record-level and field-level selection, File Manager first selects data at record level, then at field level.
- Select Copybook/template Processing
Option
1. Above or
3. Create dynamic press Enter.
If you selected option 1, an extended version of the Copy To panel appears. This form of the panel allows you to specify the “To” copybook or template.
If you selected option 3, then you must create the dynamic template. Once you have done so, the extended Copy To panel is displayed.
- Type the “To” data set details.
- Select Copybook/template Processing Option 1. Above, 2. Noneor 3. Create dynamic press Enter.
- If you selected option 1, enter the “To” copybook or template details. Use a combination of the Data set name and Member entry fields to specify the copybook or template that contains field selection and mapping information for your “To” data set.
- If required, select the Edit template mapping option. When the template is displayed, you can specify the mapping of input fields to output fields the data creation patterns for new fields.
- Press Enter. File Manager copies the selected data in the “From” data set to the “To” data set.
Related topics