Mainframes 360
The one stop destination for System Z professionals

Sunday, March 20, 2011

Segment Search Arguments(SSA)

Q. Is it easy to search for Data in an IMS Database?
image My computer keeps crashing, these days. I make a phone-call to the Computer Technician in my vicinity, and ask him to pay a visit. I have got to search, "What's the Phone number of the Technician guy?" I pull out my Yellow-Pages Directory to find out.

Its remarkably easy to look-up the Yellow-pages, coz’ the business contacts are organized in alphabetical order. I don't need to read the entries from first page, one-by-one sequentially till I reach the desired entry!

Under the Alphabet 'C', I just jump to the "Computer Technician's Section", and voila! I have before me, a List of the phone number's of all computer repair shops. Had it not been for the Yellow-Pages Directory, find the phone-number of the Computer guy would be like finding a needle in a haystack.

Just like the Yellow-Pages directory, an IMS Database also keeps things in a tidy order. The data in an IMS Database is sorted. Searching an IMS Database is a piece of cake! If would like to search in particular for something in the IMS Database, there's no need to run a  scan on the database sequentially...
Q. What is an SSA(Segment Search Argument)? 
An SSA(Segment Search Argument) answers the question, "What are you looking for in the IMS Database?" While performing a search on the Database, IMS-DB System looks at SSA to determine, what data you need? For example in the Inventory Database containing Vendors, Items and Stock-Locations data, you may like to confine your search just to Vendors. Or your supervisor wants to search only for Items. One may decide to search for only those Items whose Price is greater than > 500 rupees. While searching an IMS Database, you may supply extra-parameters to be more precise. 

image

If you supply an SSA on an IMS-DB Call, the SSA will be taken into consideration, during execution and fetching the results. Only those results that satisfy the SSA, and pass through its filter criterion shall be present in the final solution.
Q. How to build(construct) a simple SSA?
First, you must construct or build the COBOL Definition of the SSA. You can then use this SSA on an IMS-DB Call.

The simplest form of an SSA, that you can build is an Unqualified SSA. An Unqualified SSA just contains the segment-name you wish to process. A picture of an unqualified SSA is shown below. Unqualified SSA always contains the segment-name in the first 8-Bytes, followed by one Blank Space.

image
 
First declare all the SSA's you intend to use under the Working-Storage Section of the COBOL Program. This is how, you'd declare an Unqualified SSA in a COBOL-Program.

image

"I want to search for Vendors Data in my IMS Database."
Suppose, you would like to search only for Vendor data in an IMS Database. In the Inventory IMS Database, the Vendors Data is represented by the VENDRSEG Segment-Type. So, I would store the segment-name 'VENDRSEG' in the Unqualified SSA. A picture of it is shown below.

image
Q. Can I supply two SSA's? How does it work?
The Inventory-Database has three Segments : VENDRSEG, ITEMSSEG and STLOCSEG. The root segment type VENDRSEG at Level 01, represents the Vendors Data. Vendors manufacture or produce Items. ITEMSSEG Segment at Level 02, represents the Line-items that are supplied by a Vendor. Each Item may be stocked at different locations like Mumbai, Delhi, Chennai etc. STLOCSEG Segment at Level 03, represents the warehouse-locations at which the stock of an Item is kept.(stored). The Database Structure is shown in the figure below.

image
Now, what if you don’t want to search for Vendors, but rather you'd like to search for the Items Data, under these Vendors. In IMS, you are allowed to supply an SSA, at each hierarchical-level in the IMS Database. This implies, you can specify one SSA at the VENDRSEG Segment-level, and a second SSA at the ITEMSSEG Segment-Level.

imageIn the above picture, I have constructed two SSA's – VENDR-USSA(Vendor Unqualified SSA) and ITEMS-USSA(Items Unqualified SSA). When you supply two SSA's like this, it indicates to IMS – Search only for ITEMS Data, under the VENDOR Data.
image
On the same lines, if you would like to search only for Stock-Data in the IMS Database, you would have supply three SSA's – one at VENDRSEG Level 01, second at ITEMSSEG Level 02 and third at STLOCSEG Level 03. This indicates to IMS – Search only for STOCK Data, under the ITEMS Data which is under the VENDORS Data.

In general, the thumb-rule is that, the last-level SSA determines which segment the IMS-DB System will process.
Q. What is a Qualified SSA?
A Qualified SSA allows you to specify a particular occurrence of a
Segment-Type. The format of the Qualified SSA, is illustrated in the snapshot below.

image
The Qualified SSA is composed of an Eight-Bytes Segment-Name. This is followed by the Field-name, the relational operator, and the search-value. The
Field-name, operator and value are enclosed in round-brackets(parenthesis).



The Database Descriptor DBD for the Inventory Database System is shown above. There are three Segments – VENDRSEG, ITEMSSEG and STLOCSEG. Each segment-type has several fields.

To many people who are thrown to work at a mainframe computer on their first job, they feel lost. Mainframe people seem to speak a completely different language and that doesn't make life easy. What's more, the books and manuals are incredibly hard to comprehend.

"What on earth is a Mainframe?" is an absolute beginner's guide to mainframe computers. We'll introduce you to the hardware and peripherals. We'll talk about the operating system, the software installed on a mainframe. We'll also talk about the different people who work on a mainframe. In a nutshell, we'll de-mystify the mainframe.

Readers based in India, can buy the e-book for Rs. 50 only or the print book. International readers based in the US and other countries can click here to purchase the e-book.