This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Save a template (so you can use it again), or notSave a template Use a temporary template
Three ways to edit a templateMenu selectionTE (Template Edit) commandThe Template Workbench
File Manager for z/OS training - sections Page 2 of 4
In this section you will learn how to use File Manager templates. You will learn what they are and why you might want to use one. You will also learn how to create them, save them, and make changes to them.
To get the most out of File Manager, you must understand templates:
What is a template?Why you would use one?How do you work with it?
Once you understand template processing, you can easily do most tasks in File Manager
To get the most out of File Manager, you need to understand template processing. You should know what a template is, why you would use one, and how you work with it. Once you understand template processing you can easily do most of the tasks in File Manager edit and utilities.
Templates are used for several reasons. First, you can use templates to lay your records out into individual fields. You can use them to select records to be displayed or processed. Also, you can select only certain fields to be displayed. In addition, you can differentiate between different record types that have different layouts and control the formatting of data displayed in view, edit, or print.
With a template - format fields and select records
EnterTemplate formatting: - Selected City Names that contain a lower case ‘o’
and States that contain ‘TN’ or ‘FL’- Displayed three fields
Template formatting: - Selected City Names that contain a lower case ‘o’
and States that contain ‘TN’ or ‘FL’- Displayed three fields
And here is exactly the same file, but this time a template is being used to format the data. Only certain cities and states have been selected and only three of the fields are selected to be displayed.
Templates are flexible, and can be used in a variety of ways
There are different:Types of templatesWays to use themWays to select recordsWays to edit them
Template processing in File Manager is very flexible and you can use templates in a variety of ways. There are different types of templates, different ways to use them, different ways to perform record selection, and different ways to edit your templates.
Just specify a copybook …Just specify a copybook …
A template can be created in most of the File Manager utilities including edit, and there are even some special utilities just for working with templates. It is really very easy. For example, in edit you just specify a copybook that you want to use. In this case it is a COBOL copybook. Type in the name of the copybook, and in the Copybook/template field under Processing Options, specify 1 (for Above) to use the copybook. Enter.
… and FM automatically compiles it and createsa template
… and FM automatically compiles it and createsa template
File Manager automatically compiled the copybook and created a template. The template is being used by File Manager to format the data in the records. It is that easy; it all happened automatically. Keep in mind that when you use a copybook in File Manager, it creates a template from the copybook, and then you are really using the template, not the copybook.
Consider the similarity between compiling a program, and using a Copybook with FM
ProgramProgram
CompilerCompilerCompiler LinkLinkLink
LoadLoad
“SOURCE”“SOURCE” “EXECUTABLE”“EXECUTABLE”
COBOL or PL/I Copybook
COBOL or PL/I Copybook
FM invokes the compilerFM invokes FM invokes the compilerthe compiler TemplateTemplateTemplate
Can be temporary, or saved in a PDSCan be temporary, or saved in a PDS
What happens in File Manager when you provide a COBOL or PL/I copybook is similar to what happens when you compile one of your application programs. When you compile a program, source code is processed by the COBOL or PL/I compiler. The result of that process is an executable form of a program called a load module. In File Manager, something analogous happens.
The copybook is processed by the COBOL or PL/I compiler. An executable form of the copybook is created called a template. When you provide a copybook, it is compiled by the same compiler that you use to compile your application programs. This all happens automatically, behind the scenes, unless you have a problem with your copybook. If the copybook does not compile successfully, a special menu is displayed, and you have the option of browsing the compiler listing and error messages. So that is how to create a copybook template.
A dynamic template provides similar function to a copybook template
Use a dynamic template if:You do not have a copybookYou want to quickly define selection criteria based on fixed positionsOr if you just do not want to use a copybook
Dynamic templates provide functions similar to copybook templates. You might use a dynamic template if you do not have a copybook, or if you just want to quickly define a few fields that you want to display, or if you just prefer not to use a copybook.
In this example a dynamic template will be created while using the editor. Just give it the name of a file that you want to edit, and most importantly give it the option to create a dynamic template. Specify 4 in the Processing Options Copybook/template field, which tells it to create a new dynamic template. Enter.
Use Help (PF1) to display a list of all valid types.
Use Help (PF1) to display a list of all valid types.
AN (alphanumeric) is the default field type.
AN (alphanumeric) is the default field type.
A dynamic template was created. And a panel is displayed where you can define the fields in your record layout, by specifying the fields’ starting position, length, and type.
In this example a field that starts in position 23 that is 5 bytes long is specified. In the Type field, PD is specified, which will make it a packed decimal field. On the next line, a field starts in position 6 and is 17 bytes long is entered. This time, the Type field is left blank, and by default it is an alphanumeric field. Another field definition is entered on the next line. It starts in position 50, is 14 bytes, and is alphanumeric and so on.
There are several different field types you can specify, and if you hit PF1 you can use the help screens to get a list of the different field data types that are available.
Define the fieldsExamples of Type:(blank) alphanumericAN alphanumericPD packed decimalZD zoned decimalBI binary numericBT bit stringFE floating point
(external)FP floating point
(internal)and many more
Examples of Type:(blank) alphanumericAN alphanumericPD packed decimalZD zoned decimalBI binary numericBT bit stringFE floating point
(external)FP floating point
(internal)and many more
Examples of Start:123 byte 123 of the record (relative to 1)+ the next position after the previous field+0 the next position after the previous field+12 offset 12 bytes from the end of the previous field
Examples of Start:123 byte 123 of the record (relative to 1)+ the next position after the previous field+0 the next position after the previous field+12 offset 12 bytes from the end of the previous field
PF11
Here are some of the more frequently used data types. Specify ‘AN’ for an alphanumeric field, ‘PD’ for packed decimal, ‘ZD’ for zoned decimal (which is also display numeric), and ‘BI’ for a binary numeric field. And there are some shortcuts you can use when you are entering the start position. If you code a plus sign and a number, it is an offset. Code “+0” to begin a field at the next available byte after the end of the previous field. That way, you do not have to make any manual calculations to figure out where fields should start.
And you can do a couple of other things as well. Hit PF11 to scroll out to the right. PF11.
Pf11 (Right) to display Field Names.Field Names are optional.
Pf11 (Right) to display Field Names.Field Names are optional.
PF6 Is "Run Temporary". The template is used but not saved.
Note: SAVEAS will save the template
PF6 Is "Run Temporary". The template is used but not saved.
Note: SAVEAS will save the template PF6
Selection Criteria is optional
Selection Criteria is optional
That shows you some additional items like field name, and an optional comparison operator and value. Field names are optional, but you can type them in in the Field Name column if you want to name your fields. If you do not provide names, File Manager will make up names, which might be OK depending on what you need to do.
You can also provide selection criteria. In this case select only the records that contain either of the values that you entered in the CUST-ID field. Notice the operator, CO. That is the “contains” function. More about coding selection criteria will be discussed later.
At this point, if you want to use the template, you have two choices. You can either save the template or run it as a temporary template. In a minute you will learn how to save templates. Press the PF6 key to run this as a temporary template. PF6.
Template formatting: - Fields were defined- Specific records were selected
Template formatting: - Fields were defined- Specific records were selected
Enter
Now the edit session is displayed, and it is using the new template. Notice that the record is broken down into the different fields that were defined, it is using the field names that were specified in the template, and it is only showing the records that were selected based on the selection criteria. The shadow command turns the dash line display on or off.
Do not define all of the fields, just the ones you need
To display the entire record, switch to “CHAR” format
Consider using dynamic templates with the COPY or COMPARE utilities
To quickly provide position-based selection criteriaCompare ONLY those fields defined
Start with a copybook template – edit the template using the “By Field” technique – and use the MD (Make Dynamic) command to create a new dynamic template with all the fields
Once a copybook template has been made into a dynamic template you can delete any fields you do not need
Here are a few tips for using dynamic templates. First, you do not have to define every single field in your record. You can just define the ones you need. Of course, you can define all of the fields, but that could take you all day. Also, if you are in edit or view, and your dynamic template does not have all the fields in the record, an easy way to display the entire record is to switch to character format.
Here is another good trick. Sometimes when you are using the copy Utility, you only want to copy a few records. For example, only records that contain an X in position 100. You can do that very easily using a dynamic template by going to the copy Utility, creating a dynamic template, specifying a field starting in column 100, specifying selection criteria equal to X, and then running the copy. So that is very fast and easy.
And finally, you can turn a copybook template into a dynamic template by using the MD (for Make Dynamic) command. You might choose to do this because in a dynamic template you can add, remove, and change fields. So if you start off with a copybook, this maneuver allows you to modify the field that you want in File Manager without modifying the copybook.
Edit the copybook template using the “By Field Name” technique
Then use the MD (Make Dynamic) command to quickly convert the copybook template into a dynamic template
Edit the copybook template using the “By Field Name” technique
Then use the MD (Make Dynamic) command to quickly convert the copybook template into a dynamic template
Here is a step by step process to make a copybook template a dynamic template.
First edit the copybook template record selection criteria by field. The CEDIT or DE edit commands can be used to go directly to the Record Selection panel. Once there, type ‘MD(for make dynamic) on the command line to make this copybook template a dynamic template. Enter.
Note: You can adjust the Start Positions – to a contiguous pattern –and use this template to map an output file with only the three fields…then use it in a COPY Utility
Note: You can adjust the Start Positions – to a contiguous pattern –and use this template to map an output file with only the three fields…then use it in a COPY Utility
The start, end, and type information is displayed. PF6 will run temporary or RunTemp the template.
Only three fields are displayed in TABLOnly three fields are displayed in TABL
If you change the format once the data is displayed to format character, you can reveal the entire record – not just the fields currently defined. Enter.
Only three fields are displayed in SNGLOnly three fields are displayed in SNGL
And only the three fields defined are displayed in single record display format.
Just so you know, making a copybook template dynamic then removing unwanted fields is the fastest and easiest method to create the perfect compare template. Only the fields defined are processed by the Compare Utility – eliminating much unnecessary information from the compare and easily controlling what fields are compared.
Save a template (so you can use it again), or notSave a template Use a temporary template
Three ways to edit a templateMenu selectionTE (Template Edit) commandThe Template Workbench
File Manager for z/OS training -sections Page 2 of 4
So far you have learned how to create the two kinds of templates - copybook and dynamic. Next you will learn that you can either save the template, so that you can use it again, or run it as a temporary template.
“Temporary template”Used one-time onlyIs lost after completing the current task
FM will ask if you want to save the template when you:Make changes to a new copybook templateCreate a new dynamic template
When you are using a template you have these two options: you can save the template as a PDS member or you can run it as a temporary template, which means it is used one time only and it is lost after you have completed the current task. It works like this - any time you make a change to a new copybook template or createa new dynamic template, File Manager automatically asks you if you want to save it.
In this next example a new template will be created, a change will be made to it, and it will be saved. You can use templates with many of the File Manager utilities. The editor will be used to demonstrate how this is done, but the way that you handle templates will work the same way when using the other utilities. In this example a copybook is being used. A copybook name is entered, and a 1 (for Above) is specified in the Processing Options Copybook/template field. The important thing to notice is that the Edit template option is selected. Type in a slash next to it to turn it on. This is one way to make a change to a template. Enter.
Because the Edit template option was selected, this panel is displayed, where you can make changes to the template. In this example, a relatively simple thing will be done. You will be shown one way to provide some selection criteria.
In the Sel field, that is, the selection field, #5 > 1000 is typed in. That means that only the records in which field reference number 5 ,ACCT-BALANCE, is greater than 1000 will be selected. In later sections, more about how you can specify selection criteria and make other changes to your template will be discussed. PF3 to exit the template editor.
This panel appears automatically any time you create a new template and make a change to it. When you exit, this panel prompts you to save the template in a file. And you have some choices here. PF12 cancels the process without saving the template. PF6 will run this as a temporary template without saving it, and PF3 will save it.
To save it, specify a data set name. The template can be saved in PDS member of your choosing. The PDS should be defined with 80 byte, fixed length records. You can use either a PDS or a PDSE. And here is an important tip. It is a bad idea to save your template into your copybook library. Very often you will want to give your template the same name as your copybook, so trying to store it in the same library will do nothing but cause problems and confusion. Keep in mind that if you have a separate template library, which is a very good idea, you can share it with your colleagues. PF3 to save the template.
At this point, File Manager saved the template, and automatically plugged the new template name into the Edit Entry panel. All you have to do to continue and use the template is hit Enter.
That started the editor, and the new template is being used. You can tell that the template is active, because it is only displaying records that matched the selection criteria that was in the template - ACCT-BALANCE is greater than 1000.
Save a template (so you can use it again), or notSave a template Use a temporary template
Three ways to edit a templateMenu selectionTE (Template Edit) commandThe Template Workbench
File Manager for z/OS training - sections Page 2 of 4
That was an example of saving a new template. In the next example you will learn about a similar process, but this time the template is not saved. It will be run as a temporary template.
Temporary template – make a change to the template
PF6 is the "Run Temporary" PF KeyPF6 is the "Run Temporary" PF Key
PF6
Now this panel is displayed again. Specify the same record selection criteria…
…where field number 5 (ACCT-BALANCE) is greater than 1000. Last time, the PF3 key was used to exit, and you were prompted to save the file. This time, instead, press the PF6 key. That is a run temporary.
That took you directly into the edit session without saving the template. Use a temporary template if you know that you are never going to need it again. Of course, if you ever need to use it in the future you should save it. Here is a good tip. Consider always saving templates that would typically be temporary in your personal template library in a member called TEMP. That way, you always have the last template that you used, just in case you decide later that you need it again.
The menu selection method, which you have already gone through, will be shown first. For example, if you are using the View or Edit panels, you can turn on the Edit template option by typing a slash next to it. Enter.
Use the TE (Template Edit) command during your View or Edit session to change the template on the fly!
Note:DE edits the template selection criteria “by field”DE ID edits the identification criteria “by field”
Use the TE (Template Edit) command during your View or Edit session to change the template on the fly!
Note:DE edits the template selection criteria “by field”DE ID edits the identification criteria “by field”
If you are already in the editor or viewer, you can enter this command: TE. It lets you make changes to your template on-the-fly, right in the middle of your edit or view session. You have to be in an edit or view session first. Just type in TE on the command line, and Enter.
This panel is displayed again, where you can make changes to the template. It is good to point out that the TE command gives you some powerful options in the edit or view utilities. For example, you can edit a file and use a template to select only certain records. Then you can use the TE command to make changes to the template, and select a completely different set of records. And you can do all that without being forced to save your changes in between.
The Copybook and Template Utility functions menu is displayed. This menu provides several utilities for working with templates. Select option 1 for Workbench.
From the Template Workbench, you can Create, Edit, Map, and Update templates
From the Template Workbench, you can Create, Edit, Map, and Update templates
With "Advanced Copybook Selection", you can specify multiple copybooks
With "Advanced Copybook Selection", you can specify multiple copybooks
Edit a template - Method 3: Template Workbench
That displays the Template Workbench panel. From here, you can create templates by using the commands that are shown. The CC command will create a new template from a copybook, and the CM command will make a copy of a template.
To edit an existing template, type the E command on the command line, and specify the name of the template in the Template Data set name field. When you hit Enter…
… this screen is displayed again. This is exactly the same panel that was displayed by using the Edit template option and by using the TE edit command. From here, of course, you can make changes to the template.
In this section of the tutorial you have learned different ways that templates can be used. Out of all of the methods available, most File Manager users have their favorite ways of working. Now that you have learned the different ways to work with templates, you can choose the methods that you like best.