| Q. What does one understand by the phrase – Formatting of Output Records? Why do we need to format them? | |||
| When we generate an Output using DFSORT sometimes, the records are not in a presentable format. For example, in the output records, there might not be a space between two fields. Or you might want to insert a $ sign for the currency field. You might want to re-order the fields, or display only selected fields/columns in the Output. This type of formatting of records can be done using DFSORT. You can format the records to be sorted in a particular way, prior to the sorting. This is also possible. So, for better presentation/easier understanding of the report, we re-format the records produced in Output. For re-formatting of records, there are mainly 3 tools at your disposal - OVERLAY - It allows you to change (edit) the values in specific columns. IFTHEN - Reformats different records in different ways. The above re-formatting tools can be used with INREC, OUTREC and OUTFIL. INREC - Used to reformat the records before applying sort. | |||
| Q. How to generate a Report, which displays only specific(desired) columns in the Output? | |||
|
In the output report, you are asked to display only the name of the Insurance Agent and the Sales Figure. Since, we want reformat records after applying SORT, we will OUTREC FIELDS Control statement.
Note that, we have written SORT FIELDS=COPY, which simply copies the Input Records to the Output, and displays NAME and SALES Columns. Upon submitting the above Batch JOB/JCL, we get the following Output :
A lot more formatting is possible on the above report. Read on to know more... | |||
| Q. What if I wanted the SALES field/column to be displayed before(first) and then the NAME Field/Column? How do you re-order columns in the Output Report? | |||
| If we would like to display the SALES Column first, and then the agent-names, we can simply change the order in OUTREC FIELDS statement. SORT FIELDS=COPY -
| |||
| Q. I’ve understood, how to re-order the columns, but the above output report looks like greek(Cyrilic) – there should be some space between the fields SALES and NAME. How do you insert a SPACE/SPACES? | |||
| SORT FIELDS=COPY -
If you want to fill in blanks in the last field, you use the syntax c:X, where c is the column till where the padding takes place. For example, OUTREC FIELDS=(60,5,2X,10,20,140:X) | |||
| Q. What if I wanted to insert a Character string like ‘IS SALES FOR’ between the two fields? What if I wanted to insert a Date and Timestamp? | |||
| You can insert characters at any position by tying C'<Characters>'.
Upon submitting the above Batch JOB/JCL, we get the following Output Report, with the Date and Time printed :
In the next tutorial, find out how to replace certain characters/fields, eliminate junk characters like LF, changing lower case to upper case and vice versa and much more.. Hope you’ve enjoyed! |
|
|
|
- We are a cosmopolitan community of 400 members, from around the globe. - Working on writing and publishing articles on CICS. - Special article on "How do I learn Mainframe Programming" |
Thursday, July 30, 2009
Formatting Output Records – DFSORT Tutorial
Wednesday, July 29, 2009
Sort, Merge and Copy Files
Tuesday, July 28, 2009
MVS System Catalog – Finding information about VSAM Cluster from the Catalog
| Q. What’s a System Catalog? Why have one? | ||
| A Catalog is like an address book. A real-life address book stores the names of people, and their addresses(where they live/reside, where they work etc..). In a Mainframe System, there are many files(Datasets), that live in different areas of Memory(Storage). Each dataset is found in a different area/location. If you wanted to find a particular dataset, do anything with it, read it, update it etc., you would need to lookup where the dataset is. How do you know, in this vast expanse of storage space consisting several DASD Devices, each having many volumes, where your dataset lies. Its like finding a needle in a haystack. Thanks to the MVS System Catalog. I call it the Address Book of the MVS O/S. You want to access a dataset, but don’t know where it is? Ask the System Catalog. The System Catalog tells you, where in the whole world of storage space, you dataset is.. Storage Devices like DASD are just like Hard-disk Drives. Inside, there are a no. of plates(platters)/circular disks. Each disk is called a volume. Every disk volume records information in tracks. These are just like the tracks on vinyl record/compact disk. The Address Book of the MVS O/S – System Catalog stores the name of the dataset, along with the disk volume on which it resides. Have you ever wondered, on Windows OS, why can't you have 2 files with the same name in a folder? In MVS O/S, on the same lines, you can't create two datasets with the same identical names. Its pretty easy to understand why. The MVS O/S keeps track of all the datasets. It stores information about the name of a dataset, and where this dataset is present on the disk(which volume). In other words, MVS O/S records the name and disk volume of the dataset.The list of all the datasets and their locations are stored in an area called MVS System Catalog. We say, that the dataset is cataloged. If MVS, does not have any information about the whereabouts of a dataset, that is it does not know, where to look for a dataset, we say that the dataset is un-cataloged. | ||
| Q. I would like to see what the MVS System Catalog looks like? How do see what’s in there? | ||
| When you would like to see(peek in) the entries of the MVS System Catalog, you must use the LISTCAT Command of the IDCAMS utility. In case of VSAM Files, the MVS System Catalog also stores information about the Alternate Indexed, no. of records, control interval size, free space etc. So, you can find a lot meta-information(Information about data) for VSAM Files in the MVS System Catalog. You can run LISTCAT from TSO. You must type TSO LISTCAT, and you can see the output. The LISTCAT Command can be used to find the entries of the VSAM Cluster in the Catalog. So, if you want to see the entries of your VSAM file in the Catalog, you can use the LISTCAT AMS Control Statement. The LISTCAT Command has a few options : For example, if you want to see all the catalog entries with the name CAA0176.DEMO.KSDS, you can code the ENTRIES option as ENTRIES(CAA0176.DEMO.KSDS) To code multiple files, you can simply put the continuation character : ENTRIES(CAA0176.DEMO.KSDS1, - You can also make use of a generic name. Suppose, you wanted to list all entries in the catalog having the dataset names starting with CAA0176.DEMO. ENTRIES(CAA0176.DEMO.*) 2) CLUSTER - This is used to specify that only the cluster entry is to be listed. If this is not mentioned, all the index entries would also be printed.
Upon submitting the above Batch JOB/JCL. the JOB Log shows the following information -
As you might notice, the above Catalog Entry gives all information like AIX, ALIAS, CLUSTER, DATA Cluster’s name, INDEX Cluster’s Name. Moreover, it also gives all the SMS-related(where on the disk this dataset resides) information. |
Monday, July 27, 2009
VSAM Tutorial – How to create a ESDS and RRDS Cluster
| Q. How do you create an ESDS Object using JCL/Batch JOB? | |
| An ESDS Cluster is a VSAM Dataset, which is similar to a sequential file. An ESDS Dataset has no Index Structure. Now, you might wonder, how to access the records of an ESDS Cluster. Well, to access a record in an ESDS Cluster, you need to know the exact address/physical location, where record lies on the Disk Volume. It’s like saying, if you had a 1000 page book, and you wanted to access the line having keyword laugh, you must know beforehand on which page no(address) laugh is. Thus, Records in ESDS Cluster are accessed by their Physical Address. This address is called Relative Byte Address(RBA). ESDS works just like a stack/pile of books. If you add records, they always get added to the top of the pile/stack, i.e. the records get appended. Since the pile is too heavy, it is not possible to insert records in between. Here, I’ve shown how to create an empty ESDS Cluster using IDCAMS, DEFINE CLUSTER Control statement.
In the above example, I’ve created a new ESDS Cluster with the name CAA0176.DEMO.ESDS. This ESDS Cluster will be allocated space(extents) in terms of 1 Primary Track and 1 Secondary Track. All records in this ESDS Cluster will be of length 80 bytes. Moreover, since an ESDS Cluster does not have any key, we don’t write KEYS keyword. Also, ESDS Cluster is specified using the option NONINDEXED. Since, it has on DATA Component, only the DATA Sub-parameter has been coded. The ESDS Data component will have the name – CAA0176.DEMO.ESDS.DATA. | |
| Q. How do you create an RRDS Object using a Batch JOB/JCL? | |
| In a Relative Record Dataset, you must recall that each record is identified by a Relative Record Number(RRN), which is nothing but the sequence number relative to the first record. Note : As opposed to KSDS, ESDS and RRDS support only fixed length records. In RRDS, space is divided into fixed length slots. A slot can be either completely vacant(does not contain a record) or completely full(contains a record). Thus, you can add new records to empty slots, and delete existing records from slots which are filled. Let’s see a simple JCL to create an RRDS Cluster :
RRDS is created on the same lines, like how we created an ESDS. The only difference being that since RRDS records are accessed by RRN(Sequence Number), we must code NUMBERED inside the DEFINE CLUSTER AMS Command. |
